diff options
author | marha <marha@users.sourceforge.net> | 2010-12-23 07:51:31 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-12-23 07:51:31 +0000 |
commit | 71e1361d0fd4c2d1c6c31f9a28d474fceee7e12e (patch) | |
tree | 4e5cebc3ac6d1c0f5dd765697a7c2ad7be796136 | |
parent | 374f6889ce26ba0a914d07f4946cd113263a6e18 (diff) | |
parent | 8fd06c45853cb2300105db84e4b722f0e2dad8d2 (diff) | |
download | vcxsrv-71e1361d0fd4c2d1c6c31f9a28d474fceee7e12e.tar.gz vcxsrv-71e1361d0fd4c2d1c6c31f9a28d474fceee7e12e.tar.bz2 vcxsrv-71e1361d0fd4c2d1c6c31f9a28d474fceee7e12e.zip |
svn merge ^/branches/released .
50 files changed, 42053 insertions, 44363 deletions
diff --git a/X11/Xlib.h b/X11/Xlib.h index e6cd7471b..b32390894 100644 --- a/X11/Xlib.h +++ b/X11/Xlib.h @@ -1,4023 +1,4023 @@ -/*
-
-Copyright 1985, 1986, 1987, 1991, 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.
-
-*/
-
-
-/*
- * Xlib.h - Header definition and support file for the C subroutine
- * interface library (Xlib) to the X Window System Protocol (V11).
- * Structures and symbols starting with "_" are private to the library.
- */
-#ifndef _X11_XLIB_H_
-#define _X11_XLIB_H_
-
-#define XlibSpecificationRelease 6
-
-#include <sys/types.h>
-
-#if defined(__SCO__) || defined(__UNIXWARE__)
-#include <stdint.h>
-#endif
-
-#include <X11/X.h>
-
-/* applications should not depend on these two headers being included! */
-#include <X11/Xfuncproto.h>
-#include <X11/Xosdefs.h>
-
-#ifndef X_WCHAR
-#include <stddef.h>
-#else
-#ifdef __UNIXOS2__
-#include <stdlib.h>
-#else
-/* replace this with #include or typedef appropriate for your system */
-typedef unsigned long wchar_t;
-#endif
-#endif
-
-#if defined(ISC) && defined(USE_XMBTOWC)
-#define wctomb(a,b) _Xwctomb(a,b)
-#define mblen(a,b) _Xmblen(a,b)
-#ifndef USE_XWCHAR_STRING
-#define mbtowc(a,b,c) _Xmbtowc(a,b,c)
-#endif
-#endif
-
-extern int
-_Xmblen(
-#ifdef ISC
- char const *str,
- size_t len
-#else
- char *str,
- int len
-#endif
- );
-
-/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in
- November 2000. Its presence is indicated through the following macro. */
-#define X_HAVE_UTF8_STRING 1
-
-typedef char *XPointer;
-
-typedef int Bool;
-typedef int Status;
-#define True 1
-#define False 0
-
-#define QueuedAlready 0
-#define QueuedAfterReading 1
-#define QueuedAfterFlush 2
-
-#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd)
-#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root)
-#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen)
-#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root)
-#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual)
-#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc)
-#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel)
-#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel)
-#define AllPlanes ((unsigned long)~0L)
-#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen)
-#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width)
-#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height)
-#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth)
-#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight)
-#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
-#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries)
-#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens)
-#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor)
-#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version)
-#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version)
-#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release)
-#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name)
-#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
-#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap)
-#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit)
-#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order)
-#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad)
-#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order)
-#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */
-#define NextRequest(dpy) XNextRequest(dpy)
-#else
-#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1)
-#endif
-#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read)
-
-/* macros for screen oriented applications (toolkit) */
-#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr])
-#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy))
-#define DisplayOfScreen(s) ((s)->display)
-#define RootWindowOfScreen(s) ((s)->root)
-#define BlackPixelOfScreen(s) ((s)->black_pixel)
-#define WhitePixelOfScreen(s) ((s)->white_pixel)
-#define DefaultColormapOfScreen(s)((s)->cmap)
-#define DefaultDepthOfScreen(s) ((s)->root_depth)
-#define DefaultGCOfScreen(s) ((s)->default_gc)
-#define DefaultVisualOfScreen(s)((s)->root_visual)
-#define WidthOfScreen(s) ((s)->width)
-#define HeightOfScreen(s) ((s)->height)
-#define WidthMMOfScreen(s) ((s)->mwidth)
-#define HeightMMOfScreen(s) ((s)->mheight)
-#define PlanesOfScreen(s) ((s)->root_depth)
-#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries)
-#define MinCmapsOfScreen(s) ((s)->min_maps)
-#define MaxCmapsOfScreen(s) ((s)->max_maps)
-#define DoesSaveUnders(s) ((s)->save_unders)
-#define DoesBackingStore(s) ((s)->backing_store)
-#define EventMaskOfScreen(s) ((s)->root_input_mask)
-
-/*
- * Extensions need a way to hang private data on some structures.
- */
-typedef struct _XExtData {
- int number; /* number returned by XRegisterExtension */
- struct _XExtData *next; /* next item on list of data for structure */
- int (*free_private)( /* called to free private storage */
- struct _XExtData *extension
- );
- XPointer private_data; /* data private to this extension. */
-} XExtData;
-
-/*
- * This file contains structures used by the extension mechanism.
- */
-typedef struct { /* public to extension, cannot be changed */
- int extension; /* extension number */
- int major_opcode; /* major op-code assigned by server */
- int first_event; /* first event number for the extension */
- int first_error; /* first error number for the extension */
-} XExtCodes;
-
-/*
- * Data structure for retrieving info about pixmap formats.
- */
-
-typedef struct {
- int depth;
- int bits_per_pixel;
- int scanline_pad;
-} XPixmapFormatValues;
-
-
-/*
- * Data structure for setting graphics context.
- */
-typedef struct {
- int function; /* logical operation */
- unsigned long plane_mask;/* plane mask */
- unsigned long foreground;/* foreground pixel */
- unsigned long background;/* background pixel */
- int line_width; /* line width */
- int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
- int cap_style; /* CapNotLast, CapButt,
- CapRound, CapProjecting */
- int join_style; /* JoinMiter, JoinRound, JoinBevel */
- int fill_style; /* FillSolid, FillTiled,
- FillStippled, FillOpaeueStippled */
- int fill_rule; /* EvenOddRule, WindingRule */
- int arc_mode; /* ArcChord, ArcPieSlice */
- Pixmap tile; /* tile pixmap for tiling operations */
- Pixmap stipple; /* stipple 1 plane pixmap for stipping */
- int ts_x_origin; /* offset for tile or stipple operations */
- int ts_y_origin;
- Font font; /* default text font for text operations */
- int subwindow_mode; /* ClipByChildren, IncludeInferiors */
- Bool graphics_exposures;/* boolean, should exposures be generated */
- int clip_x_origin; /* origin for clipping */
- int clip_y_origin;
- Pixmap clip_mask; /* bitmap clipping; other calls for rects */
- int dash_offset; /* patterned/dashed line information */
- char dashes;
-} XGCValues;
-
-/*
- * Graphics context. The contents of this structure are implementation
- * dependent. A GC should be treated as opaque by application code.
- */
-
-typedef struct _XGC
-#ifdef XLIB_ILLEGAL_ACCESS
-{
- XExtData *ext_data; /* hook for extension to hang data */
- GContext gid; /* protocol ID for graphics context */
- /* there is more to this structure, but it is private to Xlib */
-}
-#endif
-*GC;
-
-/*
- * Visual structure; contains information about colormapping possible.
- */
-typedef struct {
- XExtData *ext_data; /* hook for extension to hang data */
- VisualID visualid; /* visual id of this visual */
-#if defined(__cplusplus) || defined(c_plusplus)
- int c_class; /* C++ class of screen (monochrome, etc.) */
-#else
- int class; /* class of screen (monochrome, etc.) */
-#endif
- unsigned long red_mask, green_mask, blue_mask; /* mask values */
- int bits_per_rgb; /* log base 2 of distinct color values */
- int map_entries; /* color map entries */
-} Visual;
-
-/*
- * Depth structure; contains information for each possible depth.
- */
-typedef struct {
- int depth; /* this depth (Z) of the depth */
- int nvisuals; /* number of Visual types at this depth */
- Visual *visuals; /* list of visuals possible at this depth */
-} Depth;
-
-/*
- * Information about the screen. The contents of this structure are
- * implementation dependent. A Screen should be treated as opaque
- * by application code.
- */
-
-struct _XDisplay; /* Forward declare before use for C++ */
-
-typedef struct {
- XExtData *ext_data; /* hook for extension to hang data */
- struct _XDisplay *display;/* back pointer to display structure */
- Window root; /* Root window id. */
- int width, height; /* width and height of screen */
- int mwidth, mheight; /* width and height of in millimeters */
- int ndepths; /* number of depths possible */
- Depth *depths; /* list of allowable depths on the screen */
- int root_depth; /* bits per pixel */
- Visual *root_visual; /* root visual */
- GC default_gc; /* GC for the root root visual */
- Colormap cmap; /* default color map */
- unsigned long white_pixel;
- unsigned long black_pixel; /* White and Black pixel values */
- int max_maps, min_maps; /* max and min color maps */
- int backing_store; /* Never, WhenMapped, Always */
- Bool save_unders;
- long root_input_mask; /* initial root input mask */
-} Screen;
-
-/*
- * Format structure; describes ZFormat data the screen will understand.
- */
-typedef struct {
- XExtData *ext_data; /* hook for extension to hang data */
- int depth; /* depth of this image format */
- int bits_per_pixel; /* bits/pixel at this depth */
- int scanline_pad; /* scanline must padded to this multiple */
-} ScreenFormat;
-
-/*
- * Data structure for setting window attributes.
- */
-typedef struct {
- Pixmap background_pixmap; /* background or None or ParentRelative */
- unsigned long background_pixel; /* background pixel */
- Pixmap border_pixmap; /* border of the window */
- unsigned long border_pixel; /* border pixel value */
- int bit_gravity; /* one of bit gravity values */
- int win_gravity; /* one of the window gravity values */
- int backing_store; /* NotUseful, WhenMapped, Always */
- unsigned long backing_planes;/* planes to be preseved if possible */
- unsigned long backing_pixel;/* value to use in restoring planes */
- Bool save_under; /* should bits under be saved? (popups) */
- long event_mask; /* set of events that should be saved */
- long do_not_propagate_mask; /* set of events that should not propagate */
- Bool override_redirect; /* boolean value for override-redirect */
- Colormap colormap; /* color map to be associated with window */
- Cursor cursor; /* cursor to be displayed (or None) */
-} XSetWindowAttributes;
-
-typedef struct {
- int x, y; /* location of window */
- int width, height; /* width and height of window */
- int border_width; /* border width of window */
- int depth; /* depth of window */
- Visual *visual; /* the associated visual structure */
- Window root; /* root of screen containing window */
-#if defined(__cplusplus) || defined(c_plusplus)
- int c_class; /* C++ InputOutput, InputOnly*/
-#else
- int class; /* InputOutput, InputOnly*/
-#endif
- int bit_gravity; /* one of bit gravity values */
- int win_gravity; /* one of the window gravity values */
- int backing_store; /* NotUseful, WhenMapped, Always */
- unsigned long backing_planes;/* planes to be preserved if possible */
- unsigned long backing_pixel;/* value to be used when restoring planes */
- Bool save_under; /* boolean, should bits under be saved? */
- Colormap colormap; /* color map to be associated with window */
- Bool map_installed; /* boolean, is color map currently installed*/
- int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
- long all_event_masks; /* set of events all people have interest in*/
- long your_event_mask; /* my event mask */
- long do_not_propagate_mask; /* set of events that should not propagate */
- Bool override_redirect; /* boolean value for override-redirect */
- Screen *screen; /* back pointer to correct screen */
-} XWindowAttributes;
-
-/*
- * Data structure for host setting; getting routines.
- *
- */
-
-typedef struct {
- int family; /* for example FamilyInternet */
- int length; /* length of address, in bytes */
- char *address; /* pointer to where to find the bytes */
-} XHostAddress;
-
-/*
- * Data structure for ServerFamilyInterpreted addresses in host routines
- */
-typedef struct {
- int typelength; /* length of type string, in bytes */
- int valuelength; /* length of value string, in bytes */
- char *type; /* pointer to where to find the type string */
- char *value; /* pointer to where to find the address */
-} XServerInterpretedAddress;
-
-/*
- * Data structure for "image" data, used by image manipulation routines.
- */
-typedef struct _XImage {
- int width, height; /* size of image */
- int xoffset; /* number of pixels offset in X direction */
- int format; /* XYBitmap, XYPixmap, ZPixmap */
- char *data; /* pointer to image data */
- int byte_order; /* data byte order, LSBFirst, MSBFirst */
- int bitmap_unit; /* quant. of scanline 8, 16, 32 */
- int bitmap_bit_order; /* LSBFirst, MSBFirst */
- int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */
- int depth; /* depth of image */
- int bytes_per_line; /* accelarator to next line */
- int bits_per_pixel; /* bits per pixel (ZPixmap) */
- unsigned long red_mask; /* bits in z arrangment */
- unsigned long green_mask;
- unsigned long blue_mask;
- XPointer obdata; /* hook for the object routines to hang on */
- struct funcs { /* image manipulation routines */
- struct _XImage *(*create_image)(
- struct _XDisplay* /* display */,
- Visual* /* visual */,
- unsigned int /* depth */,
- int /* format */,
- int /* offset */,
- char* /* data */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* bitmap_pad */,
- int /* bytes_per_line */);
- int (*destroy_image) (struct _XImage *);
- unsigned long (*get_pixel) (struct _XImage *, int, int);
- int (*put_pixel) (struct _XImage *, int, int, unsigned long);
- struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int);
- int (*add_pixel) (struct _XImage *, long);
- } f;
-} XImage;
-
-/*
- * Data structure for XReconfigureWindow
- */
-typedef struct {
- int x, y;
- int width, height;
- int border_width;
- Window sibling;
- int stack_mode;
-} XWindowChanges;
-
-/*
- * Data structure used by color operations
- */
-typedef struct {
- unsigned long pixel;
- unsigned short red, green, blue;
- char flags; /* do_red, do_green, do_blue */
- char pad;
-} XColor;
-
-/*
- * Data structures for graphics operations. On most machines, these are
- * congruent with the wire protocol structures, so reformatting the data
- * can be avoided on these architectures.
- */
-typedef struct {
- short x1, y1, x2, y2;
-} XSegment;
-
-typedef struct {
- short x, y;
-} XPoint;
-
-typedef struct {
- short x, y;
- unsigned short width, height;
-} XRectangle;
-
-typedef struct {
- short x, y;
- unsigned short width, height;
- short angle1, angle2;
-} XArc;
-
-
-/* Data structure for XChangeKeyboardControl */
-
-typedef struct {
- int key_click_percent;
- int bell_percent;
- int bell_pitch;
- int bell_duration;
- int led;
- int led_mode;
- int key;
- int auto_repeat_mode; /* On, Off, Default */
-} XKeyboardControl;
-
-/* Data structure for XGetKeyboardControl */
-
-typedef struct {
- int key_click_percent;
- int bell_percent;
- unsigned int bell_pitch, bell_duration;
- unsigned long led_mask;
- int global_auto_repeat;
- char auto_repeats[32];
-} XKeyboardState;
-
-/* Data structure for XGetMotionEvents. */
-
-typedef struct {
- Time time;
- short x, y;
-} XTimeCoord;
-
-/* Data structure for X{Set,Get}ModifierMapping */
-
-typedef struct {
- int max_keypermod; /* The server's max # of keys per modifier */
- KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */
-} XModifierKeymap;
-
-
-/*
- * Display datatype maintaining display specific data.
- * The contents of this structure are implementation dependent.
- * A Display should be treated as opaque by application code.
- */
-#ifndef XLIB_ILLEGAL_ACCESS
-typedef struct _XDisplay Display;
-#endif
-
-struct _XPrivate; /* Forward declare before use for C++ */
-struct _XrmHashBucketRec;
-
-typedef struct
-#ifdef XLIB_ILLEGAL_ACCESS
-_XDisplay
-#endif
-{
- XExtData *ext_data; /* hook for extension to hang data */
- struct _XPrivate *private1;
- int fd; /* Network socket. */
- int private2;
- int proto_major_version;/* major version of server's X protocol */
- int proto_minor_version;/* minor version of servers X protocol */
- char *vendor; /* vendor of the server hardware */
- XID private3;
- XID private4;
- XID private5;
- int private6;
- XID (*resource_alloc)( /* allocator function */
- struct _XDisplay*
- );
- int byte_order; /* screen byte order, LSBFirst, MSBFirst */
- int bitmap_unit; /* padding and data requirements */
- int bitmap_pad; /* padding requirements on bitmaps */
- int bitmap_bit_order; /* LeastSignificant or MostSignificant */
- int nformats; /* number of pixmap formats in list */
- ScreenFormat *pixmap_format; /* pixmap format list */
- int private8;
- int release; /* release of the server */
- struct _XPrivate *private9, *private10;
- int qlen; /* Length of input event queue */
- unsigned long last_request_read; /* seq number of last event read */
- unsigned long request; /* sequence number of last request. */
- XPointer private11;
- XPointer private12;
- XPointer private13;
- XPointer private14;
- unsigned max_request_size; /* maximum number 32 bit words in request*/
- struct _XrmHashBucketRec *db;
- int (*private15)(
- struct _XDisplay*
- );
- char *display_name; /* "host:display" string used on this connect*/
- int default_screen; /* default screen for operations */
- int nscreens; /* number of screens on this server*/
- Screen *screens; /* pointer to list of screens */
- unsigned long motion_buffer; /* size of motion buffer */
- unsigned long private16;
- int min_keycode; /* minimum defined keycode */
- int max_keycode; /* maximum defined keycode */
- XPointer private17;
- XPointer private18;
- int private19;
- char *xdefaults; /* contents of defaults from server */
- /* there is more to this structure, but it is private to Xlib */
-}
-#ifdef XLIB_ILLEGAL_ACCESS
-Display,
-#endif
-*_XPrivDisplay;
-
-#undef _XEVENT_
-#ifndef _XEVENT_
-/*
- * Definitions of specific events.
- */
-typedef struct {
- int type; /* of event */
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* "event" window it is reported relative to */
- Window root; /* root window that the event occurred on */
- Window subwindow; /* child window */
- Time time; /* milliseconds */
- int x, y; /* pointer x, y coordinates in event window */
- int x_root, y_root; /* coordinates relative to root */
- unsigned int state; /* key or button mask */
- unsigned int keycode; /* detail */
- Bool same_screen; /* same screen flag */
-} XKeyEvent;
-typedef XKeyEvent XKeyPressedEvent;
-typedef XKeyEvent XKeyReleasedEvent;
-
-typedef struct {
- int type; /* of event */
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* "event" window it is reported relative to */
- Window root; /* root window that the event occurred on */
- Window subwindow; /* child window */
- Time time; /* milliseconds */
- int x, y; /* pointer x, y coordinates in event window */
- int x_root, y_root; /* coordinates relative to root */
- unsigned int state; /* key or button mask */
- unsigned int button; /* detail */
- Bool same_screen; /* same screen flag */
-} XButtonEvent;
-typedef XButtonEvent XButtonPressedEvent;
-typedef XButtonEvent XButtonReleasedEvent;
-
-typedef struct {
- int type; /* of event */
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* "event" window reported relative to */
- Window root; /* root window that the event occurred on */
- Window subwindow; /* child window */
- Time time; /* milliseconds */
- int x, y; /* pointer x, y coordinates in event window */
- int x_root, y_root; /* coordinates relative to root */
- unsigned int state; /* key or button mask */
- char is_hint; /* detail */
- Bool same_screen; /* same screen flag */
-} XMotionEvent;
-typedef XMotionEvent XPointerMovedEvent;
-
-typedef struct {
- int type; /* of event */
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* "event" window reported relative to */
- Window root; /* root window that the event occurred on */
- Window subwindow; /* child window */
- Time time; /* milliseconds */
- int x, y; /* pointer x, y coordinates in event window */
- int x_root, y_root; /* coordinates relative to root */
- int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
- int detail;
- /*
- * NotifyAncestor, NotifyVirtual, NotifyInferior,
- * NotifyNonlinear,NotifyNonlinearVirtual
- */
- Bool same_screen; /* same screen flag */
- Bool focus; /* boolean focus */
- unsigned int state; /* key or button mask */
-} XCrossingEvent;
-typedef XCrossingEvent XEnterWindowEvent;
-typedef XCrossingEvent XLeaveWindowEvent;
-
-typedef struct {
- int type; /* FocusIn or FocusOut */
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* window of event */
- int mode; /* NotifyNormal, NotifyWhileGrabbed,
- NotifyGrab, NotifyUngrab */
- int detail;
- /*
- * NotifyAncestor, NotifyVirtual, NotifyInferior,
- * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
- * NotifyPointerRoot, NotifyDetailNone
- */
-} XFocusChangeEvent;
-typedef XFocusChangeEvent XFocusInEvent;
-typedef XFocusChangeEvent XFocusOutEvent;
-
-/* generated on EnterWindow and FocusIn when KeyMapState selected */
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- char key_vector[32];
-} XKeymapEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- int x, y;
- int width, height;
- int count; /* if non-zero, at least this many more */
-} XExposeEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Drawable drawable;
- int x, y;
- int width, height;
- int count; /* if non-zero, at least this many more */
- int major_code; /* core is CopyArea or CopyPlane */
- int minor_code; /* not defined in the core */
-} XGraphicsExposeEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Drawable drawable;
- int major_code; /* core is CopyArea or CopyPlane */
- int minor_code; /* not defined in the core */
-} XNoExposeEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- int state; /* Visibility state */
-} XVisibilityEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window parent; /* parent of the window */
- Window window; /* window id of window created */
- int x, y; /* window location */
- int width, height; /* size of window */
- int border_width; /* border width */
- Bool override_redirect; /* creation should be overridden */
-} XCreateWindowEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
-} XDestroyWindowEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- Bool from_configure;
-} XUnmapEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- Bool override_redirect; /* boolean, is override set... */
-} XMapEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window parent;
- Window window;
-} XMapRequestEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- Window parent;
- int x, y;
- Bool override_redirect;
-} XReparentEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- int x, y;
- int width, height;
- int border_width;
- Window above;
- Bool override_redirect;
-} XConfigureEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- int x, y;
-} XGravityEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- int width, height;
-} XResizeRequestEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window parent;
- Window window;
- int x, y;
- int width, height;
- int border_width;
- Window above;
- int detail; /* Above, Below, TopIf, BottomIf, Opposite */
- unsigned long value_mask;
-} XConfigureRequestEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- int place; /* PlaceOnTop, PlaceOnBottom */
-} XCirculateEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window parent;
- Window window;
- int place; /* PlaceOnTop, PlaceOnBottom */
-} XCirculateRequestEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- Atom atom;
- Time time;
- int state; /* NewValue, Deleted */
-} XPropertyEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- Atom selection;
- Time time;
-} XSelectionClearEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window owner;
- Window requestor;
- Atom selection;
- Atom target;
- Atom property;
- Time time;
-} XSelectionRequestEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window requestor;
- Atom selection;
- Atom target;
- Atom property; /* ATOM or None */
- Time time;
-} XSelectionEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- Colormap colormap; /* COLORMAP or None */
-#if defined(__cplusplus) || defined(c_plusplus)
- Bool c_new; /* C++ */
-#else
- Bool new;
-#endif
- int state; /* ColormapInstalled, ColormapUninstalled */
-} XColormapEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- Atom message_type;
- int format;
- union {
- char b[20];
- short s[10];
- long l[5];
- } data;
-} XClientMessageEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* unused */
- int request; /* one of MappingModifier, MappingKeyboard,
- MappingPointer */
- int first_keycode; /* first keycode */
- int count; /* defines range of change w. first_keycode*/
-} XMappingEvent;
-
-typedef struct {
- int type;
- Display *display; /* Display the event was read from */
- XID resourceid; /* resource id */
- unsigned long serial; /* serial number of failed request */
- unsigned char error_code; /* error code of failed request */
- unsigned char request_code; /* Major op-code of failed request */
- unsigned char minor_code; /* Minor op-code of failed request */
-} XErrorEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display;/* Display the event was read from */
- Window window; /* window on which event was requested in event mask */
-} XAnyEvent;
-
-
-/***************************************************************
- *
- * GenericEvent. This event is the standard event for all newer extensions.
- */
-
-typedef struct
- {
- int type; /* of event. Always GenericEvent */
- unsigned long serial; /* # of last request processed */
- Bool send_event; /* true if from SendEvent request */
- Display *display; /* Display the event was read from */
- int extension; /* major opcode of extension that caused the event */
- int evtype; /* actual event type. */
- } XGenericEvent;
-
-typedef struct {
- int type; /* of event. Always GenericEvent */
- unsigned long serial; /* # of last request processed */
- Bool send_event; /* true if from SendEvent request */
- Display *display; /* Display the event was read from */
- int extension; /* major opcode of extension that caused the event */
- int evtype; /* actual event type. */
- unsigned int cookie;
- void *data;
-} XGenericEventCookie;
-
-/*
- * this union is defined so Xlib can always use the same sized
- * event structure internally, to avoid memory fragmentation.
- */
-typedef union _XEvent {
- int type; /* must not be changed; first element */
- XAnyEvent xany;
- XKeyEvent xkey;
- XButtonEvent xbutton;
- XMotionEvent xmotion;
- XCrossingEvent xcrossing;
- XFocusChangeEvent xfocus;
- XExposeEvent xexpose;
- XGraphicsExposeEvent xgraphicsexpose;
- XNoExposeEvent xnoexpose;
- XVisibilityEvent xvisibility;
- XCreateWindowEvent xcreatewindow;
- XDestroyWindowEvent xdestroywindow;
- XUnmapEvent xunmap;
- XMapEvent xmap;
- XMapRequestEvent xmaprequest;
- XReparentEvent xreparent;
- XConfigureEvent xconfigure;
- XGravityEvent xgravity;
- XResizeRequestEvent xresizerequest;
- XConfigureRequestEvent xconfigurerequest;
- XCirculateEvent xcirculate;
- XCirculateRequestEvent xcirculaterequest;
- XPropertyEvent xproperty;
- XSelectionClearEvent xselectionclear;
- XSelectionRequestEvent xselectionrequest;
- XSelectionEvent xselection;
- XColormapEvent xcolormap;
- XClientMessageEvent xclient;
- XMappingEvent xmapping;
- XErrorEvent xerror;
- XKeymapEvent xkeymap;
- XGenericEvent xgeneric;
- XGenericEventCookie xcookie;
- long pad[24];
-} XEvent;
-#endif
-
-#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy)))
-
-/*
- * per character font metric information.
- */
-typedef struct {
- short lbearing; /* origin to left edge of raster */
- short rbearing; /* origin to right edge of raster */
- short width; /* advance to next char's origin */
- short ascent; /* baseline to top edge of raster */
- short descent; /* baseline to bottom edge of raster */
- unsigned short attributes; /* per char flags (not predefined) */
-} XCharStruct;
-
-/*
- * To allow arbitrary information with fonts, there are additional properties
- * returned.
- */
-typedef struct {
- Atom name;
- unsigned long card32;
-} XFontProp;
-
-typedef struct {
- XExtData *ext_data; /* hook for extension to hang data */
- Font fid; /* Font id for this font */
- unsigned direction; /* hint about direction the font is painted */
- unsigned min_char_or_byte2;/* first character */
- unsigned max_char_or_byte2;/* last character */
- unsigned min_byte1; /* first row that exists */
- unsigned max_byte1; /* last row that exists */
- Bool all_chars_exist;/* flag if all characters have non-zero size*/
- unsigned default_char; /* char to print for undefined character */
- int n_properties; /* how many properties there are */
- XFontProp *properties; /* pointer to array of additional properties*/
- XCharStruct min_bounds; /* minimum bounds over all existing char*/
- XCharStruct max_bounds; /* maximum bounds over all existing char*/
- XCharStruct *per_char; /* first_char to last_char information */
- int ascent; /* log. extent above baseline for spacing */
- int descent; /* log. descent below baseline for spacing */
-} XFontStruct;
-
-/*
- * PolyText routines take these as arguments.
- */
-typedef struct {
- char *chars; /* pointer to string */
- int nchars; /* number of characters */
- int delta; /* delta between strings */
- Font font; /* font to print it in, None don't change */
-} XTextItem;
-
-typedef struct { /* normal 16 bit characters are two bytes */
- unsigned char byte1;
- unsigned char byte2;
-} XChar2b;
-
-typedef struct {
- XChar2b *chars; /* two byte characters */
- int nchars; /* number of characters */
- int delta; /* delta between strings */
- Font font; /* font to print it in, None don't change */
-} XTextItem16;
-
-
-typedef union { Display *display;
- GC gc;
- Visual *visual;
- Screen *screen;
- ScreenFormat *pixmap_format;
- XFontStruct *font; } XEDataObject;
-
-typedef struct {
- XRectangle max_ink_extent;
- XRectangle max_logical_extent;
-} XFontSetExtents;
-
-/* unused:
-typedef void (*XOMProc)();
- */
-
-typedef struct _XOM *XOM;
-typedef struct _XOC *XOC, *XFontSet;
-
-typedef struct {
- char *chars;
- int nchars;
- int delta;
- XFontSet font_set;
-} XmbTextItem;
-
-typedef struct {
- wchar_t *chars;
- int nchars;
- int delta;
- XFontSet font_set;
-} XwcTextItem;
-
-#define XNRequiredCharSet "requiredCharSet"
-#define XNQueryOrientation "queryOrientation"
-#define XNBaseFontName "baseFontName"
-#define XNOMAutomatic "omAutomatic"
-#define XNMissingCharSet "missingCharSet"
-#define XNDefaultString "defaultString"
-#define XNOrientation "orientation"
-#define XNDirectionalDependentDrawing "directionalDependentDrawing"
-#define XNContextualDrawing "contextualDrawing"
-#define XNFontInfo "fontInfo"
-
-typedef struct {
- int charset_count;
- char **charset_list;
-} XOMCharSetList;
-
-typedef enum {
- XOMOrientation_LTR_TTB,
- XOMOrientation_RTL_TTB,
- XOMOrientation_TTB_LTR,
- XOMOrientation_TTB_RTL,
- XOMOrientation_Context
-} XOrientation;
-
-typedef struct {
- int num_orientation;
- XOrientation *orientation; /* Input Text description */
-} XOMOrientation;
-
-typedef struct {
- int num_font;
- XFontStruct **font_struct_list;
- char **font_name_list;
-} XOMFontInfo;
-
-typedef struct _XIM *XIM;
-typedef struct _XIC *XIC;
-
-typedef void (*XIMProc)(
- XIM,
- XPointer,
- XPointer
-);
-
-typedef Bool (*XICProc)(
- XIC,
- XPointer,
- XPointer
-);
-
-typedef void (*XIDProc)(
- Display*,
- XPointer,
- XPointer
-);
-
-typedef unsigned long XIMStyle;
-
-typedef struct {
- unsigned short count_styles;
- XIMStyle *supported_styles;
-} XIMStyles;
-
-#define XIMPreeditArea 0x0001L
-#define XIMPreeditCallbacks 0x0002L
-#define XIMPreeditPosition 0x0004L
-#define XIMPreeditNothing 0x0008L
-#define XIMPreeditNone 0x0010L
-#define XIMStatusArea 0x0100L
-#define XIMStatusCallbacks 0x0200L
-#define XIMStatusNothing 0x0400L
-#define XIMStatusNone 0x0800L
-
-#define XNVaNestedList "XNVaNestedList"
-#define XNQueryInputStyle "queryInputStyle"
-#define XNClientWindow "clientWindow"
-#define XNInputStyle "inputStyle"
-#define XNFocusWindow "focusWindow"
-#define XNResourceName "resourceName"
-#define XNResourceClass "resourceClass"
-#define XNGeometryCallback "geometryCallback"
-#define XNDestroyCallback "destroyCallback"
-#define XNFilterEvents "filterEvents"
-#define XNPreeditStartCallback "preeditStartCallback"
-#define XNPreeditDoneCallback "preeditDoneCallback"
-#define XNPreeditDrawCallback "preeditDrawCallback"
-#define XNPreeditCaretCallback "preeditCaretCallback"
-#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback"
-#define XNPreeditAttributes "preeditAttributes"
-#define XNStatusStartCallback "statusStartCallback"
-#define XNStatusDoneCallback "statusDoneCallback"
-#define XNStatusDrawCallback "statusDrawCallback"
-#define XNStatusAttributes "statusAttributes"
-#define XNArea "area"
-#define XNAreaNeeded "areaNeeded"
-#define XNSpotLocation "spotLocation"
-#define XNColormap "colorMap"
-#define XNStdColormap "stdColorMap"
-#define XNForeground "foreground"
-#define XNBackground "background"
-#define XNBackgroundPixmap "backgroundPixmap"
-#define XNFontSet "fontSet"
-#define XNLineSpace "lineSpace"
-#define XNCursor "cursor"
-
-#define XNQueryIMValuesList "queryIMValuesList"
-#define XNQueryICValuesList "queryICValuesList"
-#define XNVisiblePosition "visiblePosition"
-#define XNR6PreeditCallback "r6PreeditCallback"
-#define XNStringConversionCallback "stringConversionCallback"
-#define XNStringConversion "stringConversion"
-#define XNResetState "resetState"
-#define XNHotKey "hotKey"
-#define XNHotKeyState "hotKeyState"
-#define XNPreeditState "preeditState"
-#define XNSeparatorofNestedList "separatorofNestedList"
-
-#define XBufferOverflow -1
-#define XLookupNone 1
-#define XLookupChars 2
-#define XLookupKeySym 3
-#define XLookupBoth 4
-
-typedef void *XVaNestedList;
-
-typedef struct {
- XPointer client_data;
- XIMProc callback;
-} XIMCallback;
-
-typedef struct {
- XPointer client_data;
- XICProc callback;
-} XICCallback;
-
-typedef unsigned long XIMFeedback;
-
-#define XIMReverse 1L
-#define XIMUnderline (1L<<1)
-#define XIMHighlight (1L<<2)
-#define XIMPrimary (1L<<5)
-#define XIMSecondary (1L<<6)
-#define XIMTertiary (1L<<7)
-#define XIMVisibleToForward (1L<<8)
-#define XIMVisibleToBackword (1L<<9)
-#define XIMVisibleToCenter (1L<<10)
-
-typedef struct _XIMText {
- unsigned short length;
- XIMFeedback *feedback;
- Bool encoding_is_wchar;
- union {
- char *multi_byte;
- wchar_t *wide_char;
- } string;
-} XIMText;
-
-typedef unsigned long XIMPreeditState;
-
-#define XIMPreeditUnKnown 0L
-#define XIMPreeditEnable 1L
-#define XIMPreeditDisable (1L<<1)
-
-typedef struct _XIMPreeditStateNotifyCallbackStruct {
- XIMPreeditState state;
-} XIMPreeditStateNotifyCallbackStruct;
-
-typedef unsigned long XIMResetState;
-
-#define XIMInitialState 1L
-#define XIMPreserveState (1L<<1)
-
-typedef unsigned long XIMStringConversionFeedback;
-
-#define XIMStringConversionLeftEdge (0x00000001)
-#define XIMStringConversionRightEdge (0x00000002)
-#define XIMStringConversionTopEdge (0x00000004)
-#define XIMStringConversionBottomEdge (0x00000008)
-#define XIMStringConversionConcealed (0x00000010)
-#define XIMStringConversionWrapped (0x00000020)
-
-typedef struct _XIMStringConversionText {
- unsigned short length;
- XIMStringConversionFeedback *feedback;
- Bool encoding_is_wchar;
- union {
- char *mbs;
- wchar_t *wcs;
- } string;
-} XIMStringConversionText;
-
-typedef unsigned short XIMStringConversionPosition;
-
-typedef unsigned short XIMStringConversionType;
-
-#define XIMStringConversionBuffer (0x0001)
-#define XIMStringConversionLine (0x0002)
-#define XIMStringConversionWord (0x0003)
-#define XIMStringConversionChar (0x0004)
-
-typedef unsigned short XIMStringConversionOperation;
-
-#define XIMStringConversionSubstitution (0x0001)
-#define XIMStringConversionRetrieval (0x0002)
-
-typedef enum {
- XIMForwardChar, XIMBackwardChar,
- XIMForwardWord, XIMBackwardWord,
- XIMCaretUp, XIMCaretDown,
- XIMNextLine, XIMPreviousLine,
- XIMLineStart, XIMLineEnd,
- XIMAbsolutePosition,
- XIMDontChange
-} XIMCaretDirection;
-
-typedef struct _XIMStringConversionCallbackStruct {
- XIMStringConversionPosition position;
- XIMCaretDirection direction;
- XIMStringConversionOperation operation;
- unsigned short factor;
- XIMStringConversionText *text;
-} XIMStringConversionCallbackStruct;
-
-typedef struct _XIMPreeditDrawCallbackStruct {
- int caret; /* Cursor offset within pre-edit string */
- int chg_first; /* Starting change position */
- int chg_length; /* Length of the change in character count */
- XIMText *text;
-} XIMPreeditDrawCallbackStruct;
-
-typedef enum {
- XIMIsInvisible, /* Disable caret feedback */
- XIMIsPrimary, /* UI defined caret feedback */
- XIMIsSecondary /* UI defined caret feedback */
-} XIMCaretStyle;
-
-typedef struct _XIMPreeditCaretCallbackStruct {
- int position; /* Caret offset within pre-edit string */
- XIMCaretDirection direction; /* Caret moves direction */
- XIMCaretStyle style; /* Feedback of the caret */
-} XIMPreeditCaretCallbackStruct;
-
-typedef enum {
- XIMTextType,
- XIMBitmapType
-} XIMStatusDataType;
-
-typedef struct _XIMStatusDrawCallbackStruct {
- XIMStatusDataType type;
- union {
- XIMText *text;
- Pixmap bitmap;
- } data;
-} XIMStatusDrawCallbackStruct;
-
-typedef struct _XIMHotKeyTrigger {
- KeySym keysym;
- int modifier;
- int modifier_mask;
-} XIMHotKeyTrigger;
-
-typedef struct _XIMHotKeyTriggers {
- int num_hot_key;
- XIMHotKeyTrigger *key;
-} XIMHotKeyTriggers;
-
-typedef unsigned long XIMHotKeyState;
-
-#define XIMHotKeyStateON (0x0001L)
-#define XIMHotKeyStateOFF (0x0002L)
-
-typedef struct {
- unsigned short count_values;
- char **supported_values;
-} XIMValuesList;
-
-_XFUNCPROTOBEGIN
-
-#if defined(WIN32) && !defined(_XLIBINT_)
-#define _Xdebug (*_Xdebug_p)
-#endif
-
-extern int _Xdebug;
-
-extern XFontStruct *XLoadQueryFont(
- Display* /* display */,
- _Xconst char* /* name */
-);
-
-extern XFontStruct *XQueryFont(
- Display* /* display */,
- XID /* font_ID */
-);
-
-
-extern XTimeCoord *XGetMotionEvents(
- Display* /* display */,
- Window /* w */,
- Time /* start */,
- Time /* stop */,
- int* /* nevents_return */
-);
-
-extern XModifierKeymap *XDeleteModifiermapEntry(
- XModifierKeymap* /* modmap */,
-#if NeedWidePrototypes
- unsigned int /* keycode_entry */,
-#else
- KeyCode /* keycode_entry */,
-#endif
- int /* modifier */
-);
-
-extern XModifierKeymap *XGetModifierMapping(
- Display* /* display */
-);
-
-extern XModifierKeymap *XInsertModifiermapEntry(
- XModifierKeymap* /* modmap */,
-#if NeedWidePrototypes
- unsigned int /* keycode_entry */,
-#else
- KeyCode /* keycode_entry */,
-#endif
- int /* modifier */
-);
-
-extern XModifierKeymap *XNewModifiermap(
- int /* max_keys_per_mod */
-);
-
-extern XImage *XCreateImage(
- Display* /* display */,
- Visual* /* visual */,
- unsigned int /* depth */,
- int /* format */,
- int /* offset */,
- char* /* data */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* bitmap_pad */,
- int /* bytes_per_line */
-);
-extern Status XInitImage(
- XImage* /* image */
-);
-extern XImage *XGetImage(
- Display* /* display */,
- Drawable /* d */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned long /* plane_mask */,
- int /* format */
-);
-extern XImage *XGetSubImage(
- Display* /* display */,
- Drawable /* d */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned long /* plane_mask */,
- int /* format */,
- XImage* /* dest_image */,
- int /* dest_x */,
- int /* dest_y */
-);
-
-/*
- * X function declarations.
- */
-extern Display *XOpenDisplay(
- _Xconst char* /* display_name */
-);
-
-extern void XrmInitialize(
- void
-);
-
-extern char *XFetchBytes(
- Display* /* display */,
- int* /* nbytes_return */
-);
-extern char *XFetchBuffer(
- Display* /* display */,
- int* /* nbytes_return */,
- int /* buffer */
-);
-extern char *XGetAtomName(
- Display* /* display */,
- Atom /* atom */
-);
-extern Status XGetAtomNames(
- Display* /* dpy */,
- Atom* /* atoms */,
- int /* count */,
- char** /* names_return */
-);
-extern char *XGetDefault(
- Display* /* display */,
- _Xconst char* /* program */,
- _Xconst char* /* option */
-);
-extern char *XDisplayName(
- _Xconst char* /* string */
-);
-extern char *XKeysymToString(
- KeySym /* keysym */
-);
-
-extern int (*XSynchronize(
- Display* /* display */,
- Bool /* onoff */
-))(
- Display* /* display */
-);
-extern int (*XSetAfterFunction(
- Display* /* display */,
- int (*) (
- Display* /* display */
- ) /* procedure */
-))(
- Display* /* display */
-);
-extern Atom XInternAtom(
- Display* /* display */,
- _Xconst char* /* atom_name */,
- Bool /* only_if_exists */
-);
-extern Status XInternAtoms(
- Display* /* dpy */,
- _Xconst char** /* names */,
- int /* count */,
- Bool /* onlyIfExists */,
- Atom* /* atoms_return */
-);
-extern Colormap XCopyColormapAndFree(
- Display* /* display */,
- Colormap /* colormap */
-);
-extern Colormap XCreateColormap(
- Display* /* display */,
- Window /* w */,
- Visual* /* visual */,
- int /* alloc */
-);
-extern Cursor XCreatePixmapCursor(
- Display* /* display */,
- Pixmap /* source */,
- Pixmap /* mask */,
- XColor* /* foreground_color */,
- XColor* /* background_color */,
- unsigned int /* x */,
- unsigned int /* y */
-);
-extern Cursor XCreateGlyphCursor(
- Display* /* display */,
- Font /* source_font */,
- Font /* mask_font */,
- unsigned int /* source_char */,
- unsigned int /* mask_char */,
- XColor _Xconst * /* foreground_color */,
- XColor _Xconst * /* background_color */
-);
-extern Cursor XCreateFontCursor(
- Display* /* display */,
- unsigned int /* shape */
-);
-extern Font XLoadFont(
- Display* /* display */,
- _Xconst char* /* name */
-);
-extern GC XCreateGC(
- Display* /* display */,
- Drawable /* d */,
- unsigned long /* valuemask */,
- XGCValues* /* values */
-);
-extern GContext XGContextFromGC(
- GC /* gc */
-);
-extern void XFlushGC(
- Display* /* display */,
- GC /* gc */
-);
-extern Pixmap XCreatePixmap(
- Display* /* display */,
- Drawable /* d */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int /* depth */
-);
-extern Pixmap XCreateBitmapFromData(
- Display* /* display */,
- Drawable /* d */,
- _Xconst char* /* data */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-extern Pixmap XCreatePixmapFromBitmapData(
- Display* /* display */,
- Drawable /* d */,
- char* /* data */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned long /* fg */,
- unsigned long /* bg */,
- unsigned int /* depth */
-);
-extern Window XCreateSimpleWindow(
- Display* /* display */,
- Window /* parent */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int /* border_width */,
- unsigned long /* border */,
- unsigned long /* background */
-);
-extern Window XGetSelectionOwner(
- Display* /* display */,
- Atom /* selection */
-);
-extern Window XCreateWindow(
- Display* /* display */,
- Window /* parent */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int /* border_width */,
- int /* depth */,
- unsigned int /* class */,
- Visual* /* visual */,
- unsigned long /* valuemask */,
- XSetWindowAttributes* /* attributes */
-);
-extern Colormap *XListInstalledColormaps(
- Display* /* display */,
- Window /* w */,
- int* /* num_return */
-);
-extern char **XListFonts(
- Display* /* display */,
- _Xconst char* /* pattern */,
- int /* maxnames */,
- int* /* actual_count_return */
-);
-extern char **XListFontsWithInfo(
- Display* /* display */,
- _Xconst char* /* pattern */,
- int /* maxnames */,
- int* /* count_return */,
- XFontStruct** /* info_return */
-);
-extern char **XGetFontPath(
- Display* /* display */,
- int* /* npaths_return */
-);
-extern char **XListExtensions(
- Display* /* display */,
- int* /* nextensions_return */
-);
-extern Atom *XListProperties(
- Display* /* display */,
- Window /* w */,
- int* /* num_prop_return */
-);
-extern XHostAddress *XListHosts(
- Display* /* display */,
- int* /* nhosts_return */,
- Bool* /* state_return */
-);
-extern KeySym XKeycodeToKeysym(
- Display* /* display */,
-#if NeedWidePrototypes
- unsigned int /* keycode */,
-#else
- KeyCode /* keycode */,
-#endif
- int /* index */
-);
-extern KeySym XLookupKeysym(
- XKeyEvent* /* key_event */,
- int /* index */
-);
-extern KeySym *XGetKeyboardMapping(
- Display* /* display */,
-#if NeedWidePrototypes
- unsigned int /* first_keycode */,
-#else
- KeyCode /* first_keycode */,
-#endif
- int /* keycode_count */,
- int* /* keysyms_per_keycode_return */
-);
-extern KeySym XStringToKeysym(
- _Xconst char* /* string */
-);
-extern long XMaxRequestSize(
- Display* /* display */
-);
-extern long XExtendedMaxRequestSize(
- Display* /* display */
-);
-extern char *XResourceManagerString(
- Display* /* display */
-);
-extern char *XScreenResourceString(
- Screen* /* screen */
-);
-extern unsigned long XDisplayMotionBufferSize(
- Display* /* display */
-);
-extern VisualID XVisualIDFromVisual(
- Visual* /* visual */
-);
-
-/* multithread routines */
-
-extern Status XInitThreads(
- void
-);
-
-extern void XLockDisplay(
- Display* /* display */
-);
-
-extern void XUnlockDisplay(
- Display* /* display */
-);
-
-/* routines for dealing with extensions */
-
-extern XExtCodes *XInitExtension(
- Display* /* display */,
- _Xconst char* /* name */
-);
-
-extern XExtCodes *XAddExtension(
- Display* /* display */
-);
-extern XExtData *XFindOnExtensionList(
- XExtData** /* structure */,
- int /* number */
-);
-extern XExtData **XEHeadOfExtensionList(
- XEDataObject /* object */
-);
-
-/* these are routines for which there are also macros */
-extern Window XRootWindow(
- Display* /* display */,
- int /* screen_number */
-);
-extern Window XDefaultRootWindow(
- Display* /* display */
-);
-extern Window XRootWindowOfScreen(
- Screen* /* screen */
-);
-extern Visual *XDefaultVisual(
- Display* /* display */,
- int /* screen_number */
-);
-extern Visual *XDefaultVisualOfScreen(
- Screen* /* screen */
-);
-extern GC XDefaultGC(
- Display* /* display */,
- int /* screen_number */
-);
-extern GC XDefaultGCOfScreen(
- Screen* /* screen */
-);
-extern unsigned long XBlackPixel(
- Display* /* display */,
- int /* screen_number */
-);
-extern unsigned long XWhitePixel(
- Display* /* display */,
- int /* screen_number */
-);
-extern unsigned long XAllPlanes(
- void
-);
-extern unsigned long XBlackPixelOfScreen(
- Screen* /* screen */
-);
-extern unsigned long XWhitePixelOfScreen(
- Screen* /* screen */
-);
-extern unsigned long XNextRequest(
- Display* /* display */
-);
-extern unsigned long XLastKnownRequestProcessed(
- Display* /* display */
-);
-extern char *XServerVendor(
- Display* /* display */
-);
-extern char *XDisplayString(
- Display* /* display */
-);
-extern Colormap XDefaultColormap(
- Display* /* display */,
- int /* screen_number */
-);
-extern Colormap XDefaultColormapOfScreen(
- Screen* /* screen */
-);
-extern Display *XDisplayOfScreen(
- Screen* /* screen */
-);
-extern Screen *XScreenOfDisplay(
- Display* /* display */,
- int /* screen_number */
-);
-extern Screen *XDefaultScreenOfDisplay(
- Display* /* display */
-);
-extern long XEventMaskOfScreen(
- Screen* /* screen */
-);
-
-extern int XScreenNumberOfScreen(
- Screen* /* screen */
-);
-
-typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */
- Display* /* display */,
- XErrorEvent* /* error_event */
-);
-
-extern XErrorHandler XSetErrorHandler (
- XErrorHandler /* handler */
-);
-
-
-typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */
- Display* /* display */
-);
-
-extern XIOErrorHandler XSetIOErrorHandler (
- XIOErrorHandler /* handler */
-);
-
-
-extern XPixmapFormatValues *XListPixmapFormats(
- Display* /* display */,
- int* /* count_return */
-);
-extern int *XListDepths(
- Display* /* display */,
- int /* screen_number */,
- int* /* count_return */
-);
-
-/* ICCCM routines for things that don't require special include files; */
-/* other declarations are given in Xutil.h */
-extern Status XReconfigureWMWindow(
- Display* /* display */,
- Window /* w */,
- int /* screen_number */,
- unsigned int /* mask */,
- XWindowChanges* /* changes */
-);
-
-extern Status XGetWMProtocols(
- Display* /* display */,
- Window /* w */,
- Atom** /* protocols_return */,
- int* /* count_return */
-);
-extern Status XSetWMProtocols(
- Display* /* display */,
- Window /* w */,
- Atom* /* protocols */,
- int /* count */
-);
-extern Status XIconifyWindow(
- Display* /* display */,
- Window /* w */,
- int /* screen_number */
-);
-extern Status XWithdrawWindow(
- Display* /* display */,
- Window /* w */,
- int /* screen_number */
-);
-extern Status XGetCommand(
- Display* /* display */,
- Window /* w */,
- char*** /* argv_return */,
- int* /* argc_return */
-);
-extern Status XGetWMColormapWindows(
- Display* /* display */,
- Window /* w */,
- Window** /* windows_return */,
- int* /* count_return */
-);
-extern Status XSetWMColormapWindows(
- Display* /* display */,
- Window /* w */,
- Window* /* colormap_windows */,
- int /* count */
-);
-extern void XFreeStringList(
- char** /* list */
-);
-extern int XSetTransientForHint(
- Display* /* display */,
- Window /* w */,
- Window /* prop_window */
-);
-
-/* The following are given in alphabetical order */
-
-extern int XActivateScreenSaver(
- Display* /* display */
-);
-
-extern int XAddHost(
- Display* /* display */,
- XHostAddress* /* host */
-);
-
-extern int XAddHosts(
- Display* /* display */,
- XHostAddress* /* hosts */,
- int /* num_hosts */
-);
-
-extern int XAddToExtensionList(
- struct _XExtData** /* structure */,
- XExtData* /* ext_data */
-);
-
-extern int XAddToSaveSet(
- Display* /* display */,
- Window /* w */
-);
-
-extern Status XAllocColor(
- Display* /* display */,
- Colormap /* colormap */,
- XColor* /* screen_in_out */
-);
-
-extern Status XAllocColorCells(
- Display* /* display */,
- Colormap /* colormap */,
- Bool /* contig */,
- unsigned long* /* plane_masks_return */,
- unsigned int /* nplanes */,
- unsigned long* /* pixels_return */,
- unsigned int /* npixels */
-);
-
-extern Status XAllocColorPlanes(
- Display* /* display */,
- Colormap /* colormap */,
- Bool /* contig */,
- unsigned long* /* pixels_return */,
- int /* ncolors */,
- int /* nreds */,
- int /* ngreens */,
- int /* nblues */,
- unsigned long* /* rmask_return */,
- unsigned long* /* gmask_return */,
- unsigned long* /* bmask_return */
-);
-
-extern Status XAllocNamedColor(
- Display* /* display */,
- Colormap /* colormap */,
- _Xconst char* /* color_name */,
- XColor* /* screen_def_return */,
- XColor* /* exact_def_return */
-);
-
-extern int XAllowEvents(
- Display* /* display */,
- int /* event_mode */,
- Time /* time */
-);
-
-extern int XAutoRepeatOff(
- Display* /* display */
-);
-
-extern int XAutoRepeatOn(
- Display* /* display */
-);
-
-extern int XBell(
- Display* /* display */,
- int /* percent */
-);
-
-extern int XBitmapBitOrder(
- Display* /* display */
-);
-
-extern int XBitmapPad(
- Display* /* display */
-);
-
-extern int XBitmapUnit(
- Display* /* display */
-);
-
-extern int XCellsOfScreen(
- Screen* /* screen */
-);
-
-extern int XChangeActivePointerGrab(
- Display* /* display */,
- unsigned int /* event_mask */,
- Cursor /* cursor */,
- Time /* time */
-);
-
-extern int XChangeGC(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* valuemask */,
- XGCValues* /* values */
-);
-
-extern int XChangeKeyboardControl(
- Display* /* display */,
- unsigned long /* value_mask */,
- XKeyboardControl* /* values */
-);
-
-extern int XChangeKeyboardMapping(
- Display* /* display */,
- int /* first_keycode */,
- int /* keysyms_per_keycode */,
- KeySym* /* keysyms */,
- int /* num_codes */
-);
-
-extern int XChangePointerControl(
- Display* /* display */,
- Bool /* do_accel */,
- Bool /* do_threshold */,
- int /* accel_numerator */,
- int /* accel_denominator */,
- int /* threshold */
-);
-
-extern int XChangeProperty(
- Display* /* display */,
- Window /* w */,
- Atom /* property */,
- Atom /* type */,
- int /* format */,
- int /* mode */,
- _Xconst unsigned char* /* data */,
- int /* nelements */
-);
-
-extern int XChangeSaveSet(
- Display* /* display */,
- Window /* w */,
- int /* change_mode */
-);
-
-extern int XChangeWindowAttributes(
- Display* /* display */,
- Window /* w */,
- unsigned long /* valuemask */,
- XSetWindowAttributes* /* attributes */
-);
-
-extern Bool XCheckIfEvent(
- Display* /* display */,
- XEvent* /* event_return */,
- Bool (*) (
- Display* /* display */,
- XEvent* /* event */,
- XPointer /* arg */
- ) /* predicate */,
- XPointer /* arg */
-);
-
-extern Bool XCheckMaskEvent(
- Display* /* display */,
- long /* event_mask */,
- XEvent* /* event_return */
-);
-
-extern Bool XCheckTypedEvent(
- Display* /* display */,
- int /* event_type */,
- XEvent* /* event_return */
-);
-
-extern Bool XCheckTypedWindowEvent(
- Display* /* display */,
- Window /* w */,
- int /* event_type */,
- XEvent* /* event_return */
-);
-
-extern Bool XCheckWindowEvent(
- Display* /* display */,
- Window /* w */,
- long /* event_mask */,
- XEvent* /* event_return */
-);
-
-extern int XCirculateSubwindows(
- Display* /* display */,
- Window /* w */,
- int /* direction */
-);
-
-extern int XCirculateSubwindowsDown(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XCirculateSubwindowsUp(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XClearArea(
- Display* /* display */,
- Window /* w */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- Bool /* exposures */
-);
-
-extern int XClearWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XCloseDisplay(
- Display* /* display */
-);
-
-extern int XConfigureWindow(
- Display* /* display */,
- Window /* w */,
- unsigned int /* value_mask */,
- XWindowChanges* /* values */
-);
-
-extern int XConnectionNumber(
- Display* /* display */
-);
-
-extern int XConvertSelection(
- Display* /* display */,
- Atom /* selection */,
- Atom /* target */,
- Atom /* property */,
- Window /* requestor */,
- Time /* time */
-);
-
-extern int XCopyArea(
- Display* /* display */,
- Drawable /* src */,
- Drawable /* dest */,
- GC /* gc */,
- int /* src_x */,
- int /* src_y */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* dest_x */,
- int /* dest_y */
-);
-
-extern int XCopyGC(
- Display* /* display */,
- GC /* src */,
- unsigned long /* valuemask */,
- GC /* dest */
-);
-
-extern int XCopyPlane(
- Display* /* display */,
- Drawable /* src */,
- Drawable /* dest */,
- GC /* gc */,
- int /* src_x */,
- int /* src_y */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* dest_x */,
- int /* dest_y */,
- unsigned long /* plane */
-);
-
-extern int XDefaultDepth(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDefaultDepthOfScreen(
- Screen* /* screen */
-);
-
-extern int XDefaultScreen(
- Display* /* display */
-);
-
-extern int XDefineCursor(
- Display* /* display */,
- Window /* w */,
- Cursor /* cursor */
-);
-
-extern int XDeleteProperty(
- Display* /* display */,
- Window /* w */,
- Atom /* property */
-);
-
-extern int XDestroyWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XDestroySubwindows(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XDoesBackingStore(
- Screen* /* screen */
-);
-
-extern Bool XDoesSaveUnders(
- Screen* /* screen */
-);
-
-extern int XDisableAccessControl(
- Display* /* display */
-);
-
-
-extern int XDisplayCells(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDisplayHeight(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDisplayHeightMM(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDisplayKeycodes(
- Display* /* display */,
- int* /* min_keycodes_return */,
- int* /* max_keycodes_return */
-);
-
-extern int XDisplayPlanes(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDisplayWidth(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDisplayWidthMM(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDrawArc(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* angle1 */,
- int /* angle2 */
-);
-
-extern int XDrawArcs(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XArc* /* arcs */,
- int /* narcs */
-);
-
-extern int XDrawImageString(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* string */,
- int /* length */
-);
-
-extern int XDrawImageString16(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst XChar2b* /* string */,
- int /* length */
-);
-
-extern int XDrawLine(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x1 */,
- int /* y1 */,
- int /* x2 */,
- int /* y2 */
-);
-
-extern int XDrawLines(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XPoint* /* points */,
- int /* npoints */,
- int /* mode */
-);
-
-extern int XDrawPoint(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */
-);
-
-extern int XDrawPoints(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XPoint* /* points */,
- int /* npoints */,
- int /* mode */
-);
-
-extern int XDrawRectangle(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-
-extern int XDrawRectangles(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XRectangle* /* rectangles */,
- int /* nrectangles */
-);
-
-extern int XDrawSegments(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XSegment* /* segments */,
- int /* nsegments */
-);
-
-extern int XDrawString(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* string */,
- int /* length */
-);
-
-extern int XDrawString16(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst XChar2b* /* string */,
- int /* length */
-);
-
-extern int XDrawText(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- XTextItem* /* items */,
- int /* nitems */
-);
-
-extern int XDrawText16(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- XTextItem16* /* items */,
- int /* nitems */
-);
-
-extern int XEnableAccessControl(
- Display* /* display */
-);
-
-extern int XEventsQueued(
- Display* /* display */,
- int /* mode */
-);
-
-extern Status XFetchName(
- Display* /* display */,
- Window /* w */,
- char** /* window_name_return */
-);
-
-extern int XFillArc(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* angle1 */,
- int /* angle2 */
-);
-
-extern int XFillArcs(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XArc* /* arcs */,
- int /* narcs */
-);
-
-extern int XFillPolygon(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XPoint* /* points */,
- int /* npoints */,
- int /* shape */,
- int /* mode */
-);
-
-extern int XFillRectangle(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-
-extern int XFillRectangles(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XRectangle* /* rectangles */,
- int /* nrectangles */
-);
-
-extern int XFlush(
- Display* /* display */
-);
-
-extern int XForceScreenSaver(
- Display* /* display */,
- int /* mode */
-);
-
-extern int XFree(
- void* /* data */
-);
-
-extern int XFreeColormap(
- Display* /* display */,
- Colormap /* colormap */
-);
-
-extern int XFreeColors(
- Display* /* display */,
- Colormap /* colormap */,
- unsigned long* /* pixels */,
- int /* npixels */,
- unsigned long /* planes */
-);
-
-extern int XFreeCursor(
- Display* /* display */,
- Cursor /* cursor */
-);
-
-extern int XFreeExtensionList(
- char** /* list */
-);
-
-extern int XFreeFont(
- Display* /* display */,
- XFontStruct* /* font_struct */
-);
-
-extern int XFreeFontInfo(
- char** /* names */,
- XFontStruct* /* free_info */,
- int /* actual_count */
-);
-
-extern int XFreeFontNames(
- char** /* list */
-);
-
-extern int XFreeFontPath(
- char** /* list */
-);
-
-extern int XFreeGC(
- Display* /* display */,
- GC /* gc */
-);
-
-extern int XFreeModifiermap(
- XModifierKeymap* /* modmap */
-);
-
-extern int XFreePixmap(
- Display* /* display */,
- Pixmap /* pixmap */
-);
-
-extern int XGeometry(
- Display* /* display */,
- int /* screen */,
- _Xconst char* /* position */,
- _Xconst char* /* default_position */,
- unsigned int /* bwidth */,
- unsigned int /* fwidth */,
- unsigned int /* fheight */,
- int /* xadder */,
- int /* yadder */,
- int* /* x_return */,
- int* /* y_return */,
- int* /* width_return */,
- int* /* height_return */
-);
-
-extern int XGetErrorDatabaseText(
- Display* /* display */,
- _Xconst char* /* name */,
- _Xconst char* /* message */,
- _Xconst char* /* default_string */,
- char* /* buffer_return */,
- int /* length */
-);
-
-extern int XGetErrorText(
- Display* /* display */,
- int /* code */,
- char* /* buffer_return */,
- int /* length */
-);
-
-extern Bool XGetFontProperty(
- XFontStruct* /* font_struct */,
- Atom /* atom */,
- unsigned long* /* value_return */
-);
-
-extern Status XGetGCValues(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* valuemask */,
- XGCValues* /* values_return */
-);
-
-extern Status XGetGeometry(
- Display* /* display */,
- Drawable /* d */,
- Window* /* root_return */,
- int* /* x_return */,
- int* /* y_return */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */,
- unsigned int* /* border_width_return */,
- unsigned int* /* depth_return */
-);
-
-extern Status XGetIconName(
- Display* /* display */,
- Window /* w */,
- char** /* icon_name_return */
-);
-
-extern int XGetInputFocus(
- Display* /* display */,
- Window* /* focus_return */,
- int* /* revert_to_return */
-);
-
-extern int XGetKeyboardControl(
- Display* /* display */,
- XKeyboardState* /* values_return */
-);
-
-extern int XGetPointerControl(
- Display* /* display */,
- int* /* accel_numerator_return */,
- int* /* accel_denominator_return */,
- int* /* threshold_return */
-);
-
-extern int XGetPointerMapping(
- Display* /* display */,
- unsigned char* /* map_return */,
- int /* nmap */
-);
-
-extern int XGetScreenSaver(
- Display* /* display */,
- int* /* timeout_return */,
- int* /* interval_return */,
- int* /* prefer_blanking_return */,
- int* /* allow_exposures_return */
-);
-
-extern Status XGetTransientForHint(
- Display* /* display */,
- Window /* w */,
- Window* /* prop_window_return */
-);
-
-extern int XGetWindowProperty(
- Display* /* display */,
- Window /* w */,
- Atom /* property */,
- long /* long_offset */,
- long /* long_length */,
- Bool /* delete */,
- Atom /* req_type */,
- Atom* /* actual_type_return */,
- int* /* actual_format_return */,
- unsigned long* /* nitems_return */,
- unsigned long* /* bytes_after_return */,
- unsigned char** /* prop_return */
-);
-
-extern Status XGetWindowAttributes(
- Display* /* display */,
- Window /* w */,
- XWindowAttributes* /* window_attributes_return */
-);
-
-extern int XGrabButton(
- Display* /* display */,
- unsigned int /* button */,
- unsigned int /* modifiers */,
- Window /* grab_window */,
- Bool /* owner_events */,
- unsigned int /* event_mask */,
- int /* pointer_mode */,
- int /* keyboard_mode */,
- Window /* confine_to */,
- Cursor /* cursor */
-);
-
-extern int XGrabKey(
- Display* /* display */,
- int /* keycode */,
- unsigned int /* modifiers */,
- Window /* grab_window */,
- Bool /* owner_events */,
- int /* pointer_mode */,
- int /* keyboard_mode */
-);
-
-extern int XGrabKeyboard(
- Display* /* display */,
- Window /* grab_window */,
- Bool /* owner_events */,
- int /* pointer_mode */,
- int /* keyboard_mode */,
- Time /* time */
-);
-
-extern int XGrabPointer(
- Display* /* display */,
- Window /* grab_window */,
- Bool /* owner_events */,
- unsigned int /* event_mask */,
- int /* pointer_mode */,
- int /* keyboard_mode */,
- Window /* confine_to */,
- Cursor /* cursor */,
- Time /* time */
-);
-
-extern int XGrabServer(
- Display* /* display */
-);
-
-extern int XHeightMMOfScreen(
- Screen* /* screen */
-);
-
-extern int XHeightOfScreen(
- Screen* /* screen */
-);
-
-extern int XIfEvent(
- Display* /* display */,
- XEvent* /* event_return */,
- Bool (*) (
- Display* /* display */,
- XEvent* /* event */,
- XPointer /* arg */
- ) /* predicate */,
- XPointer /* arg */
-);
-
-extern int XImageByteOrder(
- Display* /* display */
-);
-
-extern int XInstallColormap(
- Display* /* display */,
- Colormap /* colormap */
-);
-
-extern KeyCode XKeysymToKeycode(
- Display* /* display */,
- KeySym /* keysym */
-);
-
-extern int XKillClient(
- Display* /* display */,
- XID /* resource */
-);
-
-extern Status XLookupColor(
- Display* /* display */,
- Colormap /* colormap */,
- _Xconst char* /* color_name */,
- XColor* /* exact_def_return */,
- XColor* /* screen_def_return */
-);
-
-extern int XLowerWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XMapRaised(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XMapSubwindows(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XMapWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XMaskEvent(
- Display* /* display */,
- long /* event_mask */,
- XEvent* /* event_return */
-);
-
-extern int XMaxCmapsOfScreen(
- Screen* /* screen */
-);
-
-extern int XMinCmapsOfScreen(
- Screen* /* screen */
-);
-
-extern int XMoveResizeWindow(
- Display* /* display */,
- Window /* w */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-
-extern int XMoveWindow(
- Display* /* display */,
- Window /* w */,
- int /* x */,
- int /* y */
-);
-
-extern int XNextEvent(
- Display* /* display */,
- XEvent* /* event_return */
-);
-
-extern int XNoOp(
- Display* /* display */
-);
-
-extern Status XParseColor(
- Display* /* display */,
- Colormap /* colormap */,
- _Xconst char* /* spec */,
- XColor* /* exact_def_return */
-);
-
-extern int XParseGeometry(
- _Xconst char* /* parsestring */,
- int* /* x_return */,
- int* /* y_return */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */
-);
-
-extern int XPeekEvent(
- Display* /* display */,
- XEvent* /* event_return */
-);
-
-extern int XPeekIfEvent(
- Display* /* display */,
- XEvent* /* event_return */,
- Bool (*) (
- Display* /* display */,
- XEvent* /* event */,
- XPointer /* arg */
- ) /* predicate */,
- XPointer /* arg */
-);
-
-extern int XPending(
- Display* /* display */
-);
-
-extern int XPlanesOfScreen(
- Screen* /* screen */
-);
-
-extern int XProtocolRevision(
- Display* /* display */
-);
-
-extern int XProtocolVersion(
- Display* /* display */
-);
-
-
-extern int XPutBackEvent(
- Display* /* display */,
- XEvent* /* event */
-);
-
-extern int XPutImage(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XImage* /* image */,
- int /* src_x */,
- int /* src_y */,
- int /* dest_x */,
- int /* dest_y */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-
-extern int XQLength(
- Display* /* display */
-);
-
-extern Status XQueryBestCursor(
- Display* /* display */,
- Drawable /* d */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */
-);
-
-extern Status XQueryBestSize(
- Display* /* display */,
- int /* class */,
- Drawable /* which_screen */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */
-);
-
-extern Status XQueryBestStipple(
- Display* /* display */,
- Drawable /* which_screen */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */
-);
-
-extern Status XQueryBestTile(
- Display* /* display */,
- Drawable /* which_screen */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */
-);
-
-extern int XQueryColor(
- Display* /* display */,
- Colormap /* colormap */,
- XColor* /* def_in_out */
-);
-
-extern int XQueryColors(
- Display* /* display */,
- Colormap /* colormap */,
- XColor* /* defs_in_out */,
- int /* ncolors */
-);
-
-extern Bool XQueryExtension(
- Display* /* display */,
- _Xconst char* /* name */,
- int* /* major_opcode_return */,
- int* /* first_event_return */,
- int* /* first_error_return */
-);
-
-extern int XQueryKeymap(
- Display* /* display */,
- char [32] /* keys_return */
-);
-
-extern Bool XQueryPointer(
- Display* /* display */,
- Window /* w */,
- Window* /* root_return */,
- Window* /* child_return */,
- int* /* root_x_return */,
- int* /* root_y_return */,
- int* /* win_x_return */,
- int* /* win_y_return */,
- unsigned int* /* mask_return */
-);
-
-extern int XQueryTextExtents(
- Display* /* display */,
- XID /* font_ID */,
- _Xconst char* /* string */,
- int /* nchars */,
- int* /* direction_return */,
- int* /* font_ascent_return */,
- int* /* font_descent_return */,
- XCharStruct* /* overall_return */
-);
-
-extern int XQueryTextExtents16(
- Display* /* display */,
- XID /* font_ID */,
- _Xconst XChar2b* /* string */,
- int /* nchars */,
- int* /* direction_return */,
- int* /* font_ascent_return */,
- int* /* font_descent_return */,
- XCharStruct* /* overall_return */
-);
-
-extern Status XQueryTree(
- Display* /* display */,
- Window /* w */,
- Window* /* root_return */,
- Window* /* parent_return */,
- Window** /* children_return */,
- unsigned int* /* nchildren_return */
-);
-
-extern int XRaiseWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XReadBitmapFile(
- Display* /* display */,
- Drawable /* d */,
- _Xconst char* /* filename */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */,
- Pixmap* /* bitmap_return */,
- int* /* x_hot_return */,
- int* /* y_hot_return */
-);
-
-extern int XReadBitmapFileData(
- _Xconst char* /* filename */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */,
- unsigned char** /* data_return */,
- int* /* x_hot_return */,
- int* /* y_hot_return */
-);
-
-extern int XRebindKeysym(
- Display* /* display */,
- KeySym /* keysym */,
- KeySym* /* list */,
- int /* mod_count */,
- _Xconst unsigned char* /* string */,
- int /* bytes_string */
-);
-
-extern int XRecolorCursor(
- Display* /* display */,
- Cursor /* cursor */,
- XColor* /* foreground_color */,
- XColor* /* background_color */
-);
-
-extern int XRefreshKeyboardMapping(
- XMappingEvent* /* event_map */
-);
-
-extern int XRemoveFromSaveSet(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XRemoveHost(
- Display* /* display */,
- XHostAddress* /* host */
-);
-
-extern int XRemoveHosts(
- Display* /* display */,
- XHostAddress* /* hosts */,
- int /* num_hosts */
-);
-
-extern int XReparentWindow(
- Display* /* display */,
- Window /* w */,
- Window /* parent */,
- int /* x */,
- int /* y */
-);
-
-extern int XResetScreenSaver(
- Display* /* display */
-);
-
-extern int XResizeWindow(
- Display* /* display */,
- Window /* w */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-
-extern int XRestackWindows(
- Display* /* display */,
- Window* /* windows */,
- int /* nwindows */
-);
-
-extern int XRotateBuffers(
- Display* /* display */,
- int /* rotate */
-);
-
-extern int XRotateWindowProperties(
- Display* /* display */,
- Window /* w */,
- Atom* /* properties */,
- int /* num_prop */,
- int /* npositions */
-);
-
-extern int XScreenCount(
- Display* /* display */
-);
-
-extern int XSelectInput(
- Display* /* display */,
- Window /* w */,
- long /* event_mask */
-);
-
-extern Status XSendEvent(
- Display* /* display */,
- Window /* w */,
- Bool /* propagate */,
- long /* event_mask */,
- XEvent* /* event_send */
-);
-
-extern int XSetAccessControl(
- Display* /* display */,
- int /* mode */
-);
-
-extern int XSetArcMode(
- Display* /* display */,
- GC /* gc */,
- int /* arc_mode */
-);
-
-extern int XSetBackground(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* background */
-);
-
-extern int XSetClipMask(
- Display* /* display */,
- GC /* gc */,
- Pixmap /* pixmap */
-);
-
-extern int XSetClipOrigin(
- Display* /* display */,
- GC /* gc */,
- int /* clip_x_origin */,
- int /* clip_y_origin */
-);
-
-extern int XSetClipRectangles(
- Display* /* display */,
- GC /* gc */,
- int /* clip_x_origin */,
- int /* clip_y_origin */,
- XRectangle* /* rectangles */,
- int /* n */,
- int /* ordering */
-);
-
-extern int XSetCloseDownMode(
- Display* /* display */,
- int /* close_mode */
-);
-
-extern int XSetCommand(
- Display* /* display */,
- Window /* w */,
- char** /* argv */,
- int /* argc */
-);
-
-extern int XSetDashes(
- Display* /* display */,
- GC /* gc */,
- int /* dash_offset */,
- _Xconst char* /* dash_list */,
- int /* n */
-);
-
-extern int XSetFillRule(
- Display* /* display */,
- GC /* gc */,
- int /* fill_rule */
-);
-
-extern int XSetFillStyle(
- Display* /* display */,
- GC /* gc */,
- int /* fill_style */
-);
-
-extern int XSetFont(
- Display* /* display */,
- GC /* gc */,
- Font /* font */
-);
-
-extern int XSetFontPath(
- Display* /* display */,
- char** /* directories */,
- int /* ndirs */
-);
-
-extern int XSetForeground(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* foreground */
-);
-
-extern int XSetFunction(
- Display* /* display */,
- GC /* gc */,
- int /* function */
-);
-
-extern int XSetGraphicsExposures(
- Display* /* display */,
- GC /* gc */,
- Bool /* graphics_exposures */
-);
-
-extern int XSetIconName(
- Display* /* display */,
- Window /* w */,
- _Xconst char* /* icon_name */
-);
-
-extern int XSetInputFocus(
- Display* /* display */,
- Window /* focus */,
- int /* revert_to */,
- Time /* time */
-);
-
-extern int XSetLineAttributes(
- Display* /* display */,
- GC /* gc */,
- unsigned int /* line_width */,
- int /* line_style */,
- int /* cap_style */,
- int /* join_style */
-);
-
-extern int XSetModifierMapping(
- Display* /* display */,
- XModifierKeymap* /* modmap */
-);
-
-extern int XSetPlaneMask(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* plane_mask */
-);
-
-extern int XSetPointerMapping(
- Display* /* display */,
- _Xconst unsigned char* /* map */,
- int /* nmap */
-);
-
-extern int XSetScreenSaver(
- Display* /* display */,
- int /* timeout */,
- int /* interval */,
- int /* prefer_blanking */,
- int /* allow_exposures */
-);
-
-extern int XSetSelectionOwner(
- Display* /* display */,
- Atom /* selection */,
- Window /* owner */,
- Time /* time */
-);
-
-extern int XSetState(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* foreground */,
- unsigned long /* background */,
- int /* function */,
- unsigned long /* plane_mask */
-);
-
-extern int XSetStipple(
- Display* /* display */,
- GC /* gc */,
- Pixmap /* stipple */
-);
-
-extern int XSetSubwindowMode(
- Display* /* display */,
- GC /* gc */,
- int /* subwindow_mode */
-);
-
-extern int XSetTSOrigin(
- Display* /* display */,
- GC /* gc */,
- int /* ts_x_origin */,
- int /* ts_y_origin */
-);
-
-extern int XSetTile(
- Display* /* display */,
- GC /* gc */,
- Pixmap /* tile */
-);
-
-extern int XSetWindowBackground(
- Display* /* display */,
- Window /* w */,
- unsigned long /* background_pixel */
-);
-
-extern int XSetWindowBackgroundPixmap(
- Display* /* display */,
- Window /* w */,
- Pixmap /* background_pixmap */
-);
-
-extern int XSetWindowBorder(
- Display* /* display */,
- Window /* w */,
- unsigned long /* border_pixel */
-);
-
-extern int XSetWindowBorderPixmap(
- Display* /* display */,
- Window /* w */,
- Pixmap /* border_pixmap */
-);
-
-extern int XSetWindowBorderWidth(
- Display* /* display */,
- Window /* w */,
- unsigned int /* width */
-);
-
-extern int XSetWindowColormap(
- Display* /* display */,
- Window /* w */,
- Colormap /* colormap */
-);
-
-extern int XStoreBuffer(
- Display* /* display */,
- _Xconst char* /* bytes */,
- int /* nbytes */,
- int /* buffer */
-);
-
-extern int XStoreBytes(
- Display* /* display */,
- _Xconst char* /* bytes */,
- int /* nbytes */
-);
-
-extern int XStoreColor(
- Display* /* display */,
- Colormap /* colormap */,
- XColor* /* color */
-);
-
-extern int XStoreColors(
- Display* /* display */,
- Colormap /* colormap */,
- XColor* /* color */,
- int /* ncolors */
-);
-
-extern int XStoreName(
- Display* /* display */,
- Window /* w */,
- _Xconst char* /* window_name */
-);
-
-extern int XStoreNamedColor(
- Display* /* display */,
- Colormap /* colormap */,
- _Xconst char* /* color */,
- unsigned long /* pixel */,
- int /* flags */
-);
-
-extern int XSync(
- Display* /* display */,
- Bool /* discard */
-);
-
-extern int XTextExtents(
- XFontStruct* /* font_struct */,
- _Xconst char* /* string */,
- int /* nchars */,
- int* /* direction_return */,
- int* /* font_ascent_return */,
- int* /* font_descent_return */,
- XCharStruct* /* overall_return */
-);
-
-extern int XTextExtents16(
- XFontStruct* /* font_struct */,
- _Xconst XChar2b* /* string */,
- int /* nchars */,
- int* /* direction_return */,
- int* /* font_ascent_return */,
- int* /* font_descent_return */,
- XCharStruct* /* overall_return */
-);
-
-extern int XTextWidth(
- XFontStruct* /* font_struct */,
- _Xconst char* /* string */,
- int /* count */
-);
-
-extern int XTextWidth16(
- XFontStruct* /* font_struct */,
- _Xconst XChar2b* /* string */,
- int /* count */
-);
-
-extern Bool XTranslateCoordinates(
- Display* /* display */,
- Window /* src_w */,
- Window /* dest_w */,
- int /* src_x */,
- int /* src_y */,
- int* /* dest_x_return */,
- int* /* dest_y_return */,
- Window* /* child_return */
-);
-
-extern int XUndefineCursor(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XUngrabButton(
- Display* /* display */,
- unsigned int /* button */,
- unsigned int /* modifiers */,
- Window /* grab_window */
-);
-
-extern int XUngrabKey(
- Display* /* display */,
- int /* keycode */,
- unsigned int /* modifiers */,
- Window /* grab_window */
-);
-
-extern int XUngrabKeyboard(
- Display* /* display */,
- Time /* time */
-);
-
-extern int XUngrabPointer(
- Display* /* display */,
- Time /* time */
-);
-
-extern int XUngrabServer(
- Display* /* display */
-);
-
-extern int XUninstallColormap(
- Display* /* display */,
- Colormap /* colormap */
-);
-
-extern int XUnloadFont(
- Display* /* display */,
- Font /* font */
-);
-
-extern int XUnmapSubwindows(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XUnmapWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XVendorRelease(
- Display* /* display */
-);
-
-extern int XWarpPointer(
- Display* /* display */,
- Window /* src_w */,
- Window /* dest_w */,
- int /* src_x */,
- int /* src_y */,
- unsigned int /* src_width */,
- unsigned int /* src_height */,
- int /* dest_x */,
- int /* dest_y */
-);
-
-extern int XWidthMMOfScreen(
- Screen* /* screen */
-);
-
-extern int XWidthOfScreen(
- Screen* /* screen */
-);
-
-extern int XWindowEvent(
- Display* /* display */,
- Window /* w */,
- long /* event_mask */,
- XEvent* /* event_return */
-);
-
-extern int XWriteBitmapFile(
- Display* /* display */,
- _Xconst char* /* filename */,
- Pixmap /* bitmap */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* x_hot */,
- int /* y_hot */
-);
-
-extern Bool XSupportsLocale (void);
-
-extern char *XSetLocaleModifiers(
- const char* /* modifier_list */
-);
-
-extern XOM XOpenOM(
- Display* /* display */,
- struct _XrmHashBucketRec* /* rdb */,
- _Xconst char* /* res_name */,
- _Xconst char* /* res_class */
-);
-
-extern Status XCloseOM(
- XOM /* om */
-);
-
-extern char *XSetOMValues(
- XOM /* om */,
- ...
-) _X_SENTINEL(0);
-
-extern char *XGetOMValues(
- XOM /* om */,
- ...
-) _X_SENTINEL(0);
-
-extern Display *XDisplayOfOM(
- XOM /* om */
-);
-
-extern char *XLocaleOfOM(
- XOM /* om */
-);
-
-extern XOC XCreateOC(
- XOM /* om */,
- ...
-) _X_SENTINEL(0);
-
-extern void XDestroyOC(
- XOC /* oc */
-);
-
-extern XOM XOMOfOC(
- XOC /* oc */
-);
-
-extern char *XSetOCValues(
- XOC /* oc */,
- ...
-) _X_SENTINEL(0);
-
-extern char *XGetOCValues(
- XOC /* oc */,
- ...
-) _X_SENTINEL(0);
-
-extern XFontSet XCreateFontSet(
- Display* /* display */,
- _Xconst char* /* base_font_name_list */,
- char*** /* missing_charset_list */,
- int* /* missing_charset_count */,
- char** /* def_string */
-);
-
-extern void XFreeFontSet(
- Display* /* display */,
- XFontSet /* font_set */
-);
-
-extern int XFontsOfFontSet(
- XFontSet /* font_set */,
- XFontStruct*** /* font_struct_list */,
- char*** /* font_name_list */
-);
-
-extern char *XBaseFontNameListOfFontSet(
- XFontSet /* font_set */
-);
-
-extern char *XLocaleOfFontSet(
- XFontSet /* font_set */
-);
-
-extern Bool XContextDependentDrawing(
- XFontSet /* font_set */
-);
-
-extern Bool XDirectionalDependentDrawing(
- XFontSet /* font_set */
-);
-
-extern Bool XContextualDrawing(
- XFontSet /* font_set */
-);
-
-extern XFontSetExtents *XExtentsOfFontSet(
- XFontSet /* font_set */
-);
-
-extern int XmbTextEscapement(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern int XwcTextEscapement(
- XFontSet /* font_set */,
- _Xconst wchar_t* /* text */,
- int /* num_wchars */
-);
-
-extern int Xutf8TextEscapement(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern int XmbTextExtents(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern int XwcTextExtents(
- XFontSet /* font_set */,
- _Xconst wchar_t* /* text */,
- int /* num_wchars */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern int Xutf8TextExtents(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern Status XmbTextPerCharExtents(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */,
- XRectangle* /* ink_extents_buffer */,
- XRectangle* /* logical_extents_buffer */,
- int /* buffer_size */,
- int* /* num_chars */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern Status XwcTextPerCharExtents(
- XFontSet /* font_set */,
- _Xconst wchar_t* /* text */,
- int /* num_wchars */,
- XRectangle* /* ink_extents_buffer */,
- XRectangle* /* logical_extents_buffer */,
- int /* buffer_size */,
- int* /* num_chars */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern Status Xutf8TextPerCharExtents(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */,
- XRectangle* /* ink_extents_buffer */,
- XRectangle* /* logical_extents_buffer */,
- int /* buffer_size */,
- int* /* num_chars */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern void XmbDrawText(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- XmbTextItem* /* text_items */,
- int /* nitems */
-);
-
-extern void XwcDrawText(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- XwcTextItem* /* text_items */,
- int /* nitems */
-);
-
-extern void Xutf8DrawText(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- XmbTextItem* /* text_items */,
- int /* nitems */
-);
-
-extern void XmbDrawString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern void XwcDrawString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst wchar_t* /* text */,
- int /* num_wchars */
-);
-
-extern void Xutf8DrawString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern void XmbDrawImageString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern void XwcDrawImageString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst wchar_t* /* text */,
- int /* num_wchars */
-);
-
-extern void Xutf8DrawImageString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern XIM XOpenIM(
- Display* /* dpy */,
- struct _XrmHashBucketRec* /* rdb */,
- char* /* res_name */,
- char* /* res_class */
-);
-
-extern Status XCloseIM(
- XIM /* im */
-);
-
-extern char *XGetIMValues(
- XIM /* im */, ...
-) _X_SENTINEL(0);
-
-extern char *XSetIMValues(
- XIM /* im */, ...
-) _X_SENTINEL(0);
-
-extern Display *XDisplayOfIM(
- XIM /* im */
-);
-
-extern char *XLocaleOfIM(
- XIM /* im*/
-);
-
-extern XIC XCreateIC(
- XIM /* im */, ...
-) _X_SENTINEL(0);
-
-extern void XDestroyIC(
- XIC /* ic */
-);
-
-extern void XSetICFocus(
- XIC /* ic */
-);
-
-extern void XUnsetICFocus(
- XIC /* ic */
-);
-
-extern wchar_t *XwcResetIC(
- XIC /* ic */
-);
-
-extern char *XmbResetIC(
- XIC /* ic */
-);
-
-extern char *Xutf8ResetIC(
- XIC /* ic */
-);
-
-extern char *XSetICValues(
- XIC /* ic */, ...
-) _X_SENTINEL(0);
-
-extern char *XGetICValues(
- XIC /* ic */, ...
-) _X_SENTINEL(0);
-
-extern XIM XIMOfIC(
- XIC /* ic */
-);
-
-extern Bool XFilterEvent(
- XEvent* /* event */,
- Window /* window */
-);
-
-extern int XmbLookupString(
- XIC /* ic */,
- XKeyPressedEvent* /* event */,
- char* /* buffer_return */,
- int /* bytes_buffer */,
- KeySym* /* keysym_return */,
- Status* /* status_return */
-);
-
-extern int XwcLookupString(
- XIC /* ic */,
- XKeyPressedEvent* /* event */,
- wchar_t* /* buffer_return */,
- int /* wchars_buffer */,
- KeySym* /* keysym_return */,
- Status* /* status_return */
-);
-
-extern int Xutf8LookupString(
- XIC /* ic */,
- XKeyPressedEvent* /* event */,
- char* /* buffer_return */,
- int /* bytes_buffer */,
- KeySym* /* keysym_return */,
- Status* /* status_return */
-);
-
-extern XVaNestedList XVaCreateNestedList(
- int /*unused*/, ...
-) _X_SENTINEL(0);
-
-/* internal connections for IMs */
-
-extern Bool XRegisterIMInstantiateCallback(
- Display* /* dpy */,
- struct _XrmHashBucketRec* /* rdb */,
- char* /* res_name */,
- char* /* res_class */,
- XIDProc /* callback */,
- XPointer /* client_data */
-);
-
-extern Bool XUnregisterIMInstantiateCallback(
- Display* /* dpy */,
- struct _XrmHashBucketRec* /* rdb */,
- char* /* res_name */,
- char* /* res_class */,
- XIDProc /* callback */,
- XPointer /* client_data */
-);
-
-typedef void (*XConnectionWatchProc)(
- Display* /* dpy */,
- XPointer /* client_data */,
- int /* fd */,
- Bool /* opening */, /* open or close flag */
- XPointer* /* watch_data */ /* open sets, close uses */
-);
-
-
-extern Status XInternalConnectionNumbers(
- Display* /* dpy */,
- int** /* fd_return */,
- int* /* count_return */
-);
-
-extern void XProcessInternalConnection(
- Display* /* dpy */,
- int /* fd */
-);
-
-extern Status XAddConnectionWatch(
- Display* /* dpy */,
- XConnectionWatchProc /* callback */,
- XPointer /* client_data */
-);
-
-extern void XRemoveConnectionWatch(
- Display* /* dpy */,
- XConnectionWatchProc /* callback */,
- XPointer /* client_data */
-);
-
-extern void XSetAuthorization(
- char * /* name */,
- int /* namelen */,
- char * /* data */,
- int /* datalen */
-);
-
-extern int _Xmbtowc(
- wchar_t * /* wstr */,
-#ifdef ISC
- char const * /* str */,
- size_t /* len */
-#else
- char * /* str */,
- int /* len */
-#endif
-);
-
-extern int _Xwctomb(
- char * /* str */,
- wchar_t /* wc */
-);
-
-extern Bool XGetEventData(
- Display* /* dpy */,
- XGenericEventCookie* /* cookie*/
-);
-
-extern void XFreeEventData(
- Display* /* dpy */,
- XGenericEventCookie* /* cookie*/
-);
-
-_XFUNCPROTOEND
-
-#endif /* _X11_XLIB_H_ */
+/* + +Copyright 1985, 1986, 1987, 1991, 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. + +*/ + + +/* + * Xlib.h - Header definition and support file for the C subroutine + * interface library (Xlib) to the X Window System Protocol (V11). + * Structures and symbols starting with "_" are private to the library. + */ +#ifndef _X11_XLIB_H_ +#define _X11_XLIB_H_ + +#define XlibSpecificationRelease 6 + +#include <sys/types.h> + +#if defined(__SCO__) || defined(__UNIXWARE__) +#include <stdint.h> +#endif + +#include <X11/X.h> + +/* applications should not depend on these two headers being included! */ +#include <X11/Xfuncproto.h> +#include <X11/Xosdefs.h> + +#ifndef X_WCHAR +#include <stddef.h> +#else +#ifdef __UNIXOS2__ +#include <stdlib.h> +#else +/* replace this with #include or typedef appropriate for your system */ +typedef unsigned long wchar_t; +#endif +#endif + +#if defined(ISC) && defined(USE_XMBTOWC) +#define wctomb(a,b) _Xwctomb(a,b) +#define mblen(a,b) _Xmblen(a,b) +#ifndef USE_XWCHAR_STRING +#define mbtowc(a,b,c) _Xmbtowc(a,b,c) +#endif +#endif + +extern int +_Xmblen( +#ifdef ISC + char const *str, + size_t len +#else + char *str, + int len +#endif + ); + +/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in + November 2000. Its presence is indicated through the following macro. */ +#define X_HAVE_UTF8_STRING 1 + +typedef char *XPointer; + +typedef int Bool; +typedef int Status; +#define True 1 +#define False 0 + +#define QueuedAlready 0 +#define QueuedAfterReading 1 +#define QueuedAfterFlush 2 + +#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd) +#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root) +#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen) +#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root) +#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual) +#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc) +#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel) +#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel) +#define AllPlanes ((unsigned long)~0L) +#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen) +#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width) +#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height) +#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth) +#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight) +#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) +#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries) +#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens) +#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor) +#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version) +#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version) +#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release) +#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name) +#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) +#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap) +#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit) +#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order) +#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad) +#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order) +#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */ +#define NextRequest(dpy) XNextRequest(dpy) +#else +#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1) +#endif +#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read) + +/* macros for screen oriented applications (toolkit) */ +#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr]) +#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy)) +#define DisplayOfScreen(s) ((s)->display) +#define RootWindowOfScreen(s) ((s)->root) +#define BlackPixelOfScreen(s) ((s)->black_pixel) +#define WhitePixelOfScreen(s) ((s)->white_pixel) +#define DefaultColormapOfScreen(s)((s)->cmap) +#define DefaultDepthOfScreen(s) ((s)->root_depth) +#define DefaultGCOfScreen(s) ((s)->default_gc) +#define DefaultVisualOfScreen(s)((s)->root_visual) +#define WidthOfScreen(s) ((s)->width) +#define HeightOfScreen(s) ((s)->height) +#define WidthMMOfScreen(s) ((s)->mwidth) +#define HeightMMOfScreen(s) ((s)->mheight) +#define PlanesOfScreen(s) ((s)->root_depth) +#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries) +#define MinCmapsOfScreen(s) ((s)->min_maps) +#define MaxCmapsOfScreen(s) ((s)->max_maps) +#define DoesSaveUnders(s) ((s)->save_unders) +#define DoesBackingStore(s) ((s)->backing_store) +#define EventMaskOfScreen(s) ((s)->root_input_mask) + +/* + * Extensions need a way to hang private data on some structures. + */ +typedef struct _XExtData { + int number; /* number returned by XRegisterExtension */ + struct _XExtData *next; /* next item on list of data for structure */ + int (*free_private)( /* called to free private storage */ + struct _XExtData *extension + ); + XPointer private_data; /* data private to this extension. */ +} XExtData; + +/* + * This file contains structures used by the extension mechanism. + */ +typedef struct { /* public to extension, cannot be changed */ + int extension; /* extension number */ + int major_opcode; /* major op-code assigned by server */ + int first_event; /* first event number for the extension */ + int first_error; /* first error number for the extension */ +} XExtCodes; + +/* + * Data structure for retrieving info about pixmap formats. + */ + +typedef struct { + int depth; + int bits_per_pixel; + int scanline_pad; +} XPixmapFormatValues; + + +/* + * Data structure for setting graphics context. + */ +typedef struct { + int function; /* logical operation */ + unsigned long plane_mask;/* plane mask */ + unsigned long foreground;/* foreground pixel */ + unsigned long background;/* background pixel */ + int line_width; /* line width */ + int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */ + int cap_style; /* CapNotLast, CapButt, + CapRound, CapProjecting */ + int join_style; /* JoinMiter, JoinRound, JoinBevel */ + int fill_style; /* FillSolid, FillTiled, + FillStippled, FillOpaeueStippled */ + int fill_rule; /* EvenOddRule, WindingRule */ + int arc_mode; /* ArcChord, ArcPieSlice */ + Pixmap tile; /* tile pixmap for tiling operations */ + Pixmap stipple; /* stipple 1 plane pixmap for stipping */ + int ts_x_origin; /* offset for tile or stipple operations */ + int ts_y_origin; + Font font; /* default text font for text operations */ + int subwindow_mode; /* ClipByChildren, IncludeInferiors */ + Bool graphics_exposures;/* boolean, should exposures be generated */ + int clip_x_origin; /* origin for clipping */ + int clip_y_origin; + Pixmap clip_mask; /* bitmap clipping; other calls for rects */ + int dash_offset; /* patterned/dashed line information */ + char dashes; +} XGCValues; + +/* + * Graphics context. The contents of this structure are implementation + * dependent. A GC should be treated as opaque by application code. + */ + +typedef struct _XGC +#ifdef XLIB_ILLEGAL_ACCESS +{ + XExtData *ext_data; /* hook for extension to hang data */ + GContext gid; /* protocol ID for graphics context */ + /* there is more to this structure, but it is private to Xlib */ +} +#endif +*GC; + +/* + * Visual structure; contains information about colormapping possible. + */ +typedef struct { + XExtData *ext_data; /* hook for extension to hang data */ + VisualID visualid; /* visual id of this visual */ +#if defined(__cplusplus) || defined(c_plusplus) + int c_class; /* C++ class of screen (monochrome, etc.) */ +#else + int class; /* class of screen (monochrome, etc.) */ +#endif + unsigned long red_mask, green_mask, blue_mask; /* mask values */ + int bits_per_rgb; /* log base 2 of distinct color values */ + int map_entries; /* color map entries */ +} Visual; + +/* + * Depth structure; contains information for each possible depth. + */ +typedef struct { + int depth; /* this depth (Z) of the depth */ + int nvisuals; /* number of Visual types at this depth */ + Visual *visuals; /* list of visuals possible at this depth */ +} Depth; + +/* + * Information about the screen. The contents of this structure are + * implementation dependent. A Screen should be treated as opaque + * by application code. + */ + +struct _XDisplay; /* Forward declare before use for C++ */ + +typedef struct { + XExtData *ext_data; /* hook for extension to hang data */ + struct _XDisplay *display;/* back pointer to display structure */ + Window root; /* Root window id. */ + int width, height; /* width and height of screen */ + int mwidth, mheight; /* width and height of in millimeters */ + int ndepths; /* number of depths possible */ + Depth *depths; /* list of allowable depths on the screen */ + int root_depth; /* bits per pixel */ + Visual *root_visual; /* root visual */ + GC default_gc; /* GC for the root root visual */ + Colormap cmap; /* default color map */ + unsigned long white_pixel; + unsigned long black_pixel; /* White and Black pixel values */ + int max_maps, min_maps; /* max and min color maps */ + int backing_store; /* Never, WhenMapped, Always */ + Bool save_unders; + long root_input_mask; /* initial root input mask */ +} Screen; + +/* + * Format structure; describes ZFormat data the screen will understand. + */ +typedef struct { + XExtData *ext_data; /* hook for extension to hang data */ + int depth; /* depth of this image format */ + int bits_per_pixel; /* bits/pixel at this depth */ + int scanline_pad; /* scanline must padded to this multiple */ +} ScreenFormat; + +/* + * Data structure for setting window attributes. + */ +typedef struct { + Pixmap background_pixmap; /* background or None or ParentRelative */ + unsigned long background_pixel; /* background pixel */ + Pixmap border_pixmap; /* border of the window */ + unsigned long border_pixel; /* border pixel value */ + int bit_gravity; /* one of bit gravity values */ + int win_gravity; /* one of the window gravity values */ + int backing_store; /* NotUseful, WhenMapped, Always */ + unsigned long backing_planes;/* planes to be preseved if possible */ + unsigned long backing_pixel;/* value to use in restoring planes */ + Bool save_under; /* should bits under be saved? (popups) */ + long event_mask; /* set of events that should be saved */ + long do_not_propagate_mask; /* set of events that should not propagate */ + Bool override_redirect; /* boolean value for override-redirect */ + Colormap colormap; /* color map to be associated with window */ + Cursor cursor; /* cursor to be displayed (or None) */ +} XSetWindowAttributes; + +typedef struct { + int x, y; /* location of window */ + int width, height; /* width and height of window */ + int border_width; /* border width of window */ + int depth; /* depth of window */ + Visual *visual; /* the associated visual structure */ + Window root; /* root of screen containing window */ +#if defined(__cplusplus) || defined(c_plusplus) + int c_class; /* C++ InputOutput, InputOnly*/ +#else + int class; /* InputOutput, InputOnly*/ +#endif + int bit_gravity; /* one of bit gravity values */ + int win_gravity; /* one of the window gravity values */ + int backing_store; /* NotUseful, WhenMapped, Always */ + unsigned long backing_planes;/* planes to be preserved if possible */ + unsigned long backing_pixel;/* value to be used when restoring planes */ + Bool save_under; /* boolean, should bits under be saved? */ + Colormap colormap; /* color map to be associated with window */ + Bool map_installed; /* boolean, is color map currently installed*/ + int map_state; /* IsUnmapped, IsUnviewable, IsViewable */ + long all_event_masks; /* set of events all people have interest in*/ + long your_event_mask; /* my event mask */ + long do_not_propagate_mask; /* set of events that should not propagate */ + Bool override_redirect; /* boolean value for override-redirect */ + Screen *screen; /* back pointer to correct screen */ +} XWindowAttributes; + +/* + * Data structure for host setting; getting routines. + * + */ + +typedef struct { + int family; /* for example FamilyInternet */ + int length; /* length of address, in bytes */ + char *address; /* pointer to where to find the bytes */ +} XHostAddress; + +/* + * Data structure for ServerFamilyInterpreted addresses in host routines + */ +typedef struct { + int typelength; /* length of type string, in bytes */ + int valuelength; /* length of value string, in bytes */ + char *type; /* pointer to where to find the type string */ + char *value; /* pointer to where to find the address */ +} XServerInterpretedAddress; + +/* + * Data structure for "image" data, used by image manipulation routines. + */ +typedef struct _XImage { + int width, height; /* size of image */ + int xoffset; /* number of pixels offset in X direction */ + int format; /* XYBitmap, XYPixmap, ZPixmap */ + char *data; /* pointer to image data */ + int byte_order; /* data byte order, LSBFirst, MSBFirst */ + int bitmap_unit; /* quant. of scanline 8, 16, 32 */ + int bitmap_bit_order; /* LSBFirst, MSBFirst */ + int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */ + int depth; /* depth of image */ + int bytes_per_line; /* accelarator to next line */ + int bits_per_pixel; /* bits per pixel (ZPixmap) */ + unsigned long red_mask; /* bits in z arrangment */ + unsigned long green_mask; + unsigned long blue_mask; + XPointer obdata; /* hook for the object routines to hang on */ + struct funcs { /* image manipulation routines */ + struct _XImage *(*create_image)( + struct _XDisplay* /* display */, + Visual* /* visual */, + unsigned int /* depth */, + int /* format */, + int /* offset */, + char* /* data */, + unsigned int /* width */, + unsigned int /* height */, + int /* bitmap_pad */, + int /* bytes_per_line */); + int (*destroy_image) (struct _XImage *); + unsigned long (*get_pixel) (struct _XImage *, int, int); + int (*put_pixel) (struct _XImage *, int, int, unsigned long); + struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int); + int (*add_pixel) (struct _XImage *, long); + } f; +} XImage; + +/* + * Data structure for XReconfigureWindow + */ +typedef struct { + int x, y; + int width, height; + int border_width; + Window sibling; + int stack_mode; +} XWindowChanges; + +/* + * Data structure used by color operations + */ +typedef struct { + unsigned long pixel; + unsigned short red, green, blue; + char flags; /* do_red, do_green, do_blue */ + char pad; +} XColor; + +/* + * Data structures for graphics operations. On most machines, these are + * congruent with the wire protocol structures, so reformatting the data + * can be avoided on these architectures. + */ +typedef struct { + short x1, y1, x2, y2; +} XSegment; + +typedef struct { + short x, y; +} XPoint; + +typedef struct { + short x, y; + unsigned short width, height; +} XRectangle; + +typedef struct { + short x, y; + unsigned short width, height; + short angle1, angle2; +} XArc; + + +/* Data structure for XChangeKeyboardControl */ + +typedef struct { + int key_click_percent; + int bell_percent; + int bell_pitch; + int bell_duration; + int led; + int led_mode; + int key; + int auto_repeat_mode; /* On, Off, Default */ +} XKeyboardControl; + +/* Data structure for XGetKeyboardControl */ + +typedef struct { + int key_click_percent; + int bell_percent; + unsigned int bell_pitch, bell_duration; + unsigned long led_mask; + int global_auto_repeat; + char auto_repeats[32]; +} XKeyboardState; + +/* Data structure for XGetMotionEvents. */ + +typedef struct { + Time time; + short x, y; +} XTimeCoord; + +/* Data structure for X{Set,Get}ModifierMapping */ + +typedef struct { + int max_keypermod; /* The server's max # of keys per modifier */ + KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */ +} XModifierKeymap; + + +/* + * Display datatype maintaining display specific data. + * The contents of this structure are implementation dependent. + * A Display should be treated as opaque by application code. + */ +#ifndef XLIB_ILLEGAL_ACCESS +typedef struct _XDisplay Display; +#endif + +struct _XPrivate; /* Forward declare before use for C++ */ +struct _XrmHashBucketRec; + +typedef struct +#ifdef XLIB_ILLEGAL_ACCESS +_XDisplay +#endif +{ + XExtData *ext_data; /* hook for extension to hang data */ + struct _XPrivate *private1; + int fd; /* Network socket. */ + int private2; + int proto_major_version;/* major version of server's X protocol */ + int proto_minor_version;/* minor version of servers X protocol */ + char *vendor; /* vendor of the server hardware */ + XID private3; + XID private4; + XID private5; + int private6; + XID (*resource_alloc)( /* allocator function */ + struct _XDisplay* + ); + int byte_order; /* screen byte order, LSBFirst, MSBFirst */ + int bitmap_unit; /* padding and data requirements */ + int bitmap_pad; /* padding requirements on bitmaps */ + int bitmap_bit_order; /* LeastSignificant or MostSignificant */ + int nformats; /* number of pixmap formats in list */ + ScreenFormat *pixmap_format; /* pixmap format list */ + int private8; + int release; /* release of the server */ + struct _XPrivate *private9, *private10; + int qlen; /* Length of input event queue */ + unsigned long last_request_read; /* seq number of last event read */ + unsigned long request; /* sequence number of last request. */ + XPointer private11; + XPointer private12; + XPointer private13; + XPointer private14; + unsigned max_request_size; /* maximum number 32 bit words in request*/ + struct _XrmHashBucketRec *db; + int (*private15)( + struct _XDisplay* + ); + char *display_name; /* "host:display" string used on this connect*/ + int default_screen; /* default screen for operations */ + int nscreens; /* number of screens on this server*/ + Screen *screens; /* pointer to list of screens */ + unsigned long motion_buffer; /* size of motion buffer */ + unsigned long private16; + int min_keycode; /* minimum defined keycode */ + int max_keycode; /* maximum defined keycode */ + XPointer private17; + XPointer private18; + int private19; + char *xdefaults; /* contents of defaults from server */ + /* there is more to this structure, but it is private to Xlib */ +} +#ifdef XLIB_ILLEGAL_ACCESS +Display, +#endif +*_XPrivDisplay; + +#undef _XEVENT_ +#ifndef _XEVENT_ +/* + * Definitions of specific events. + */ +typedef struct { + int type; /* of event */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* "event" window it is reported relative to */ + Window root; /* root window that the event occurred on */ + Window subwindow; /* child window */ + Time time; /* milliseconds */ + int x, y; /* pointer x, y coordinates in event window */ + int x_root, y_root; /* coordinates relative to root */ + unsigned int state; /* key or button mask */ + unsigned int keycode; /* detail */ + Bool same_screen; /* same screen flag */ +} XKeyEvent; +typedef XKeyEvent XKeyPressedEvent; +typedef XKeyEvent XKeyReleasedEvent; + +typedef struct { + int type; /* of event */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* "event" window it is reported relative to */ + Window root; /* root window that the event occurred on */ + Window subwindow; /* child window */ + Time time; /* milliseconds */ + int x, y; /* pointer x, y coordinates in event window */ + int x_root, y_root; /* coordinates relative to root */ + unsigned int state; /* key or button mask */ + unsigned int button; /* detail */ + Bool same_screen; /* same screen flag */ +} XButtonEvent; +typedef XButtonEvent XButtonPressedEvent; +typedef XButtonEvent XButtonReleasedEvent; + +typedef struct { + int type; /* of event */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* "event" window reported relative to */ + Window root; /* root window that the event occurred on */ + Window subwindow; /* child window */ + Time time; /* milliseconds */ + int x, y; /* pointer x, y coordinates in event window */ + int x_root, y_root; /* coordinates relative to root */ + unsigned int state; /* key or button mask */ + char is_hint; /* detail */ + Bool same_screen; /* same screen flag */ +} XMotionEvent; +typedef XMotionEvent XPointerMovedEvent; + +typedef struct { + int type; /* of event */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* "event" window reported relative to */ + Window root; /* root window that the event occurred on */ + Window subwindow; /* child window */ + Time time; /* milliseconds */ + int x, y; /* pointer x, y coordinates in event window */ + int x_root, y_root; /* coordinates relative to root */ + int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */ + int detail; + /* + * NotifyAncestor, NotifyVirtual, NotifyInferior, + * NotifyNonlinear,NotifyNonlinearVirtual + */ + Bool same_screen; /* same screen flag */ + Bool focus; /* boolean focus */ + unsigned int state; /* key or button mask */ +} XCrossingEvent; +typedef XCrossingEvent XEnterWindowEvent; +typedef XCrossingEvent XLeaveWindowEvent; + +typedef struct { + int type; /* FocusIn or FocusOut */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* window of event */ + int mode; /* NotifyNormal, NotifyWhileGrabbed, + NotifyGrab, NotifyUngrab */ + int detail; + /* + * NotifyAncestor, NotifyVirtual, NotifyInferior, + * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer, + * NotifyPointerRoot, NotifyDetailNone + */ +} XFocusChangeEvent; +typedef XFocusChangeEvent XFocusInEvent; +typedef XFocusChangeEvent XFocusOutEvent; + +/* generated on EnterWindow and FocusIn when KeyMapState selected */ +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + char key_vector[32]; +} XKeymapEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + int x, y; + int width, height; + int count; /* if non-zero, at least this many more */ +} XExposeEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Drawable drawable; + int x, y; + int width, height; + int count; /* if non-zero, at least this many more */ + int major_code; /* core is CopyArea or CopyPlane */ + int minor_code; /* not defined in the core */ +} XGraphicsExposeEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Drawable drawable; + int major_code; /* core is CopyArea or CopyPlane */ + int minor_code; /* not defined in the core */ +} XNoExposeEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + int state; /* Visibility state */ +} XVisibilityEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window parent; /* parent of the window */ + Window window; /* window id of window created */ + int x, y; /* window location */ + int width, height; /* size of window */ + int border_width; /* border width */ + Bool override_redirect; /* creation should be overridden */ +} XCreateWindowEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; +} XDestroyWindowEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + Bool from_configure; +} XUnmapEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + Bool override_redirect; /* boolean, is override set... */ +} XMapEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window parent; + Window window; +} XMapRequestEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + Window parent; + int x, y; + Bool override_redirect; +} XReparentEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + int x, y; + int width, height; + int border_width; + Window above; + Bool override_redirect; +} XConfigureEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + int x, y; +} XGravityEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + int width, height; +} XResizeRequestEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window parent; + Window window; + int x, y; + int width, height; + int border_width; + Window above; + int detail; /* Above, Below, TopIf, BottomIf, Opposite */ + unsigned long value_mask; +} XConfigureRequestEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + int place; /* PlaceOnTop, PlaceOnBottom */ +} XCirculateEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window parent; + Window window; + int place; /* PlaceOnTop, PlaceOnBottom */ +} XCirculateRequestEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + Atom atom; + Time time; + int state; /* NewValue, Deleted */ +} XPropertyEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + Atom selection; + Time time; +} XSelectionClearEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window owner; + Window requestor; + Atom selection; + Atom target; + Atom property; + Time time; +} XSelectionRequestEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window requestor; + Atom selection; + Atom target; + Atom property; /* ATOM or None */ + Time time; +} XSelectionEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + Colormap colormap; /* COLORMAP or None */ +#if defined(__cplusplus) || defined(c_plusplus) + Bool c_new; /* C++ */ +#else + Bool new; +#endif + int state; /* ColormapInstalled, ColormapUninstalled */ +} XColormapEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + Atom message_type; + int format; + union { + char b[20]; + short s[10]; + long l[5]; + } data; +} XClientMessageEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* unused */ + int request; /* one of MappingModifier, MappingKeyboard, + MappingPointer */ + int first_keycode; /* first keycode */ + int count; /* defines range of change w. first_keycode*/ +} XMappingEvent; + +typedef struct { + int type; + Display *display; /* Display the event was read from */ + XID resourceid; /* resource id */ + unsigned long serial; /* serial number of failed request */ + unsigned char error_code; /* error code of failed request */ + unsigned char request_code; /* Major op-code of failed request */ + unsigned char minor_code; /* Minor op-code of failed request */ +} XErrorEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display;/* Display the event was read from */ + Window window; /* window on which event was requested in event mask */ +} XAnyEvent; + + +/*************************************************************** + * + * GenericEvent. This event is the standard event for all newer extensions. + */ + +typedef struct + { + int type; /* of event. Always GenericEvent */ + unsigned long serial; /* # of last request processed */ + Bool send_event; /* true if from SendEvent request */ + Display *display; /* Display the event was read from */ + int extension; /* major opcode of extension that caused the event */ + int evtype; /* actual event type. */ + } XGenericEvent; + +typedef struct { + int type; /* of event. Always GenericEvent */ + unsigned long serial; /* # of last request processed */ + Bool send_event; /* true if from SendEvent request */ + Display *display; /* Display the event was read from */ + int extension; /* major opcode of extension that caused the event */ + int evtype; /* actual event type. */ + unsigned int cookie; + void *data; +} XGenericEventCookie; + +/* + * this union is defined so Xlib can always use the same sized + * event structure internally, to avoid memory fragmentation. + */ +typedef union _XEvent { + int type; /* must not be changed; first element */ + XAnyEvent xany; + XKeyEvent xkey; + XButtonEvent xbutton; + XMotionEvent xmotion; + XCrossingEvent xcrossing; + XFocusChangeEvent xfocus; + XExposeEvent xexpose; + XGraphicsExposeEvent xgraphicsexpose; + XNoExposeEvent xnoexpose; + XVisibilityEvent xvisibility; + XCreateWindowEvent xcreatewindow; + XDestroyWindowEvent xdestroywindow; + XUnmapEvent xunmap; + XMapEvent xmap; + XMapRequestEvent xmaprequest; + XReparentEvent xreparent; + XConfigureEvent xconfigure; + XGravityEvent xgravity; + XResizeRequestEvent xresizerequest; + XConfigureRequestEvent xconfigurerequest; + XCirculateEvent xcirculate; + XCirculateRequestEvent xcirculaterequest; + XPropertyEvent xproperty; + XSelectionClearEvent xselectionclear; + XSelectionRequestEvent xselectionrequest; + XSelectionEvent xselection; + XColormapEvent xcolormap; + XClientMessageEvent xclient; + XMappingEvent xmapping; + XErrorEvent xerror; + XKeymapEvent xkeymap; + XGenericEvent xgeneric; + XGenericEventCookie xcookie; + long pad[24]; +} XEvent; +#endif + +#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy))) + +/* + * per character font metric information. + */ +typedef struct { + short lbearing; /* origin to left edge of raster */ + short rbearing; /* origin to right edge of raster */ + short width; /* advance to next char's origin */ + short ascent; /* baseline to top edge of raster */ + short descent; /* baseline to bottom edge of raster */ + unsigned short attributes; /* per char flags (not predefined) */ +} XCharStruct; + +/* + * To allow arbitrary information with fonts, there are additional properties + * returned. + */ +typedef struct { + Atom name; + unsigned long card32; +} XFontProp; + +typedef struct { + XExtData *ext_data; /* hook for extension to hang data */ + Font fid; /* Font id for this font */ + unsigned direction; /* hint about direction the font is painted */ + unsigned min_char_or_byte2;/* first character */ + unsigned max_char_or_byte2;/* last character */ + unsigned min_byte1; /* first row that exists */ + unsigned max_byte1; /* last row that exists */ + Bool all_chars_exist;/* flag if all characters have non-zero size*/ + unsigned default_char; /* char to print for undefined character */ + int n_properties; /* how many properties there are */ + XFontProp *properties; /* pointer to array of additional properties*/ + XCharStruct min_bounds; /* minimum bounds over all existing char*/ + XCharStruct max_bounds; /* maximum bounds over all existing char*/ + XCharStruct *per_char; /* first_char to last_char information */ + int ascent; /* log. extent above baseline for spacing */ + int descent; /* log. descent below baseline for spacing */ +} XFontStruct; + +/* + * PolyText routines take these as arguments. + */ +typedef struct { + char *chars; /* pointer to string */ + int nchars; /* number of characters */ + int delta; /* delta between strings */ + Font font; /* font to print it in, None don't change */ +} XTextItem; + +typedef struct { /* normal 16 bit characters are two bytes */ + unsigned char byte1; + unsigned char byte2; +} XChar2b; + +typedef struct { + XChar2b *chars; /* two byte characters */ + int nchars; /* number of characters */ + int delta; /* delta between strings */ + Font font; /* font to print it in, None don't change */ +} XTextItem16; + + +typedef union { Display *display; + GC gc; + Visual *visual; + Screen *screen; + ScreenFormat *pixmap_format; + XFontStruct *font; } XEDataObject; + +typedef struct { + XRectangle max_ink_extent; + XRectangle max_logical_extent; +} XFontSetExtents; + +/* unused: +typedef void (*XOMProc)(); + */ + +typedef struct _XOM *XOM; +typedef struct _XOC *XOC, *XFontSet; + +typedef struct { + char *chars; + int nchars; + int delta; + XFontSet font_set; +} XmbTextItem; + +typedef struct { + wchar_t *chars; + int nchars; + int delta; + XFontSet font_set; +} XwcTextItem; + +#define XNRequiredCharSet "requiredCharSet" +#define XNQueryOrientation "queryOrientation" +#define XNBaseFontName "baseFontName" +#define XNOMAutomatic "omAutomatic" +#define XNMissingCharSet "missingCharSet" +#define XNDefaultString "defaultString" +#define XNOrientation "orientation" +#define XNDirectionalDependentDrawing "directionalDependentDrawing" +#define XNContextualDrawing "contextualDrawing" +#define XNFontInfo "fontInfo" + +typedef struct { + int charset_count; + char **charset_list; +} XOMCharSetList; + +typedef enum { + XOMOrientation_LTR_TTB, + XOMOrientation_RTL_TTB, + XOMOrientation_TTB_LTR, + XOMOrientation_TTB_RTL, + XOMOrientation_Context +} XOrientation; + +typedef struct { + int num_orientation; + XOrientation *orientation; /* Input Text description */ +} XOMOrientation; + +typedef struct { + int num_font; + XFontStruct **font_struct_list; + char **font_name_list; +} XOMFontInfo; + +typedef struct _XIM *XIM; +typedef struct _XIC *XIC; + +typedef void (*XIMProc)( + XIM, + XPointer, + XPointer +); + +typedef Bool (*XICProc)( + XIC, + XPointer, + XPointer +); + +typedef void (*XIDProc)( + Display*, + XPointer, + XPointer +); + +typedef unsigned long XIMStyle; + +typedef struct { + unsigned short count_styles; + XIMStyle *supported_styles; +} XIMStyles; + +#define XIMPreeditArea 0x0001L +#define XIMPreeditCallbacks 0x0002L +#define XIMPreeditPosition 0x0004L +#define XIMPreeditNothing 0x0008L +#define XIMPreeditNone 0x0010L +#define XIMStatusArea 0x0100L +#define XIMStatusCallbacks 0x0200L +#define XIMStatusNothing 0x0400L +#define XIMStatusNone 0x0800L + +#define XNVaNestedList "XNVaNestedList" +#define XNQueryInputStyle "queryInputStyle" +#define XNClientWindow "clientWindow" +#define XNInputStyle "inputStyle" +#define XNFocusWindow "focusWindow" +#define XNResourceName "resourceName" +#define XNResourceClass "resourceClass" +#define XNGeometryCallback "geometryCallback" +#define XNDestroyCallback "destroyCallback" +#define XNFilterEvents "filterEvents" +#define XNPreeditStartCallback "preeditStartCallback" +#define XNPreeditDoneCallback "preeditDoneCallback" +#define XNPreeditDrawCallback "preeditDrawCallback" +#define XNPreeditCaretCallback "preeditCaretCallback" +#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback" +#define XNPreeditAttributes "preeditAttributes" +#define XNStatusStartCallback "statusStartCallback" +#define XNStatusDoneCallback "statusDoneCallback" +#define XNStatusDrawCallback "statusDrawCallback" +#define XNStatusAttributes "statusAttributes" +#define XNArea "area" +#define XNAreaNeeded "areaNeeded" +#define XNSpotLocation "spotLocation" +#define XNColormap "colorMap" +#define XNStdColormap "stdColorMap" +#define XNForeground "foreground" +#define XNBackground "background" +#define XNBackgroundPixmap "backgroundPixmap" +#define XNFontSet "fontSet" +#define XNLineSpace "lineSpace" +#define XNCursor "cursor" + +#define XNQueryIMValuesList "queryIMValuesList" +#define XNQueryICValuesList "queryICValuesList" +#define XNVisiblePosition "visiblePosition" +#define XNR6PreeditCallback "r6PreeditCallback" +#define XNStringConversionCallback "stringConversionCallback" +#define XNStringConversion "stringConversion" +#define XNResetState "resetState" +#define XNHotKey "hotKey" +#define XNHotKeyState "hotKeyState" +#define XNPreeditState "preeditState" +#define XNSeparatorofNestedList "separatorofNestedList" + +#define XBufferOverflow -1 +#define XLookupNone 1 +#define XLookupChars 2 +#define XLookupKeySym 3 +#define XLookupBoth 4 + +typedef void *XVaNestedList; + +typedef struct { + XPointer client_data; + XIMProc callback; +} XIMCallback; + +typedef struct { + XPointer client_data; + XICProc callback; +} XICCallback; + +typedef unsigned long XIMFeedback; + +#define XIMReverse 1L +#define XIMUnderline (1L<<1) +#define XIMHighlight (1L<<2) +#define XIMPrimary (1L<<5) +#define XIMSecondary (1L<<6) +#define XIMTertiary (1L<<7) +#define XIMVisibleToForward (1L<<8) +#define XIMVisibleToBackword (1L<<9) +#define XIMVisibleToCenter (1L<<10) + +typedef struct _XIMText { + unsigned short length; + XIMFeedback *feedback; + Bool encoding_is_wchar; + union { + char *multi_byte; + wchar_t *wide_char; + } string; +} XIMText; + +typedef unsigned long XIMPreeditState; + +#define XIMPreeditUnKnown 0L +#define XIMPreeditEnable 1L +#define XIMPreeditDisable (1L<<1) + +typedef struct _XIMPreeditStateNotifyCallbackStruct { + XIMPreeditState state; +} XIMPreeditStateNotifyCallbackStruct; + +typedef unsigned long XIMResetState; + +#define XIMInitialState 1L +#define XIMPreserveState (1L<<1) + +typedef unsigned long XIMStringConversionFeedback; + +#define XIMStringConversionLeftEdge (0x00000001) +#define XIMStringConversionRightEdge (0x00000002) +#define XIMStringConversionTopEdge (0x00000004) +#define XIMStringConversionBottomEdge (0x00000008) +#define XIMStringConversionConcealed (0x00000010) +#define XIMStringConversionWrapped (0x00000020) + +typedef struct _XIMStringConversionText { + unsigned short length; + XIMStringConversionFeedback *feedback; + Bool encoding_is_wchar; + union { + char *mbs; + wchar_t *wcs; + } string; +} XIMStringConversionText; + +typedef unsigned short XIMStringConversionPosition; + +typedef unsigned short XIMStringConversionType; + +#define XIMStringConversionBuffer (0x0001) +#define XIMStringConversionLine (0x0002) +#define XIMStringConversionWord (0x0003) +#define XIMStringConversionChar (0x0004) + +typedef unsigned short XIMStringConversionOperation; + +#define XIMStringConversionSubstitution (0x0001) +#define XIMStringConversionRetrieval (0x0002) + +typedef enum { + XIMForwardChar, XIMBackwardChar, + XIMForwardWord, XIMBackwardWord, + XIMCaretUp, XIMCaretDown, + XIMNextLine, XIMPreviousLine, + XIMLineStart, XIMLineEnd, + XIMAbsolutePosition, + XIMDontChange +} XIMCaretDirection; + +typedef struct _XIMStringConversionCallbackStruct { + XIMStringConversionPosition position; + XIMCaretDirection direction; + XIMStringConversionOperation operation; + unsigned short factor; + XIMStringConversionText *text; +} XIMStringConversionCallbackStruct; + +typedef struct _XIMPreeditDrawCallbackStruct { + int caret; /* Cursor offset within pre-edit string */ + int chg_first; /* Starting change position */ + int chg_length; /* Length of the change in character count */ + XIMText *text; +} XIMPreeditDrawCallbackStruct; + +typedef enum { + XIMIsInvisible, /* Disable caret feedback */ + XIMIsPrimary, /* UI defined caret feedback */ + XIMIsSecondary /* UI defined caret feedback */ +} XIMCaretStyle; + +typedef struct _XIMPreeditCaretCallbackStruct { + int position; /* Caret offset within pre-edit string */ + XIMCaretDirection direction; /* Caret moves direction */ + XIMCaretStyle style; /* Feedback of the caret */ +} XIMPreeditCaretCallbackStruct; + +typedef enum { + XIMTextType, + XIMBitmapType +} XIMStatusDataType; + +typedef struct _XIMStatusDrawCallbackStruct { + XIMStatusDataType type; + union { + XIMText *text; + Pixmap bitmap; + } data; +} XIMStatusDrawCallbackStruct; + +typedef struct _XIMHotKeyTrigger { + KeySym keysym; + int modifier; + int modifier_mask; +} XIMHotKeyTrigger; + +typedef struct _XIMHotKeyTriggers { + int num_hot_key; + XIMHotKeyTrigger *key; +} XIMHotKeyTriggers; + +typedef unsigned long XIMHotKeyState; + +#define XIMHotKeyStateON (0x0001L) +#define XIMHotKeyStateOFF (0x0002L) + +typedef struct { + unsigned short count_values; + char **supported_values; +} XIMValuesList; + +_XFUNCPROTOBEGIN + +#if defined(WIN32) && !defined(_XLIBINT_) +#define _Xdebug (*_Xdebug_p) +#endif + +extern int _Xdebug; + +extern XFontStruct *XLoadQueryFont( + Display* /* display */, + _Xconst char* /* name */ +); + +extern XFontStruct *XQueryFont( + Display* /* display */, + XID /* font_ID */ +); + + +extern XTimeCoord *XGetMotionEvents( + Display* /* display */, + Window /* w */, + Time /* start */, + Time /* stop */, + int* /* nevents_return */ +); + +extern XModifierKeymap *XDeleteModifiermapEntry( + XModifierKeymap* /* modmap */, +#if NeedWidePrototypes + unsigned int /* keycode_entry */, +#else + KeyCode /* keycode_entry */, +#endif + int /* modifier */ +); + +extern XModifierKeymap *XGetModifierMapping( + Display* /* display */ +); + +extern XModifierKeymap *XInsertModifiermapEntry( + XModifierKeymap* /* modmap */, +#if NeedWidePrototypes + unsigned int /* keycode_entry */, +#else + KeyCode /* keycode_entry */, +#endif + int /* modifier */ +); + +extern XModifierKeymap *XNewModifiermap( + int /* max_keys_per_mod */ +); + +extern XImage *XCreateImage( + Display* /* display */, + Visual* /* visual */, + unsigned int /* depth */, + int /* format */, + int /* offset */, + char* /* data */, + unsigned int /* width */, + unsigned int /* height */, + int /* bitmap_pad */, + int /* bytes_per_line */ +); +extern Status XInitImage( + XImage* /* image */ +); +extern XImage *XGetImage( + Display* /* display */, + Drawable /* d */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + unsigned long /* plane_mask */, + int /* format */ +); +extern XImage *XGetSubImage( + Display* /* display */, + Drawable /* d */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + unsigned long /* plane_mask */, + int /* format */, + XImage* /* dest_image */, + int /* dest_x */, + int /* dest_y */ +); + +/* + * X function declarations. + */ +extern Display *XOpenDisplay( + _Xconst char* /* display_name */ +); + +extern void XrmInitialize( + void +); + +extern char *XFetchBytes( + Display* /* display */, + int* /* nbytes_return */ +); +extern char *XFetchBuffer( + Display* /* display */, + int* /* nbytes_return */, + int /* buffer */ +); +extern char *XGetAtomName( + Display* /* display */, + Atom /* atom */ +); +extern Status XGetAtomNames( + Display* /* dpy */, + Atom* /* atoms */, + int /* count */, + char** /* names_return */ +); +extern char *XGetDefault( + Display* /* display */, + _Xconst char* /* program */, + _Xconst char* /* option */ +); +extern char *XDisplayName( + _Xconst char* /* string */ +); +extern char *XKeysymToString( + KeySym /* keysym */ +); + +extern int (*XSynchronize( + Display* /* display */, + Bool /* onoff */ +))( + Display* /* display */ +); +extern int (*XSetAfterFunction( + Display* /* display */, + int (*) ( + Display* /* display */ + ) /* procedure */ +))( + Display* /* display */ +); +extern Atom XInternAtom( + Display* /* display */, + _Xconst char* /* atom_name */, + Bool /* only_if_exists */ +); +extern Status XInternAtoms( + Display* /* dpy */, + char** /* names */, + int /* count */, + Bool /* onlyIfExists */, + Atom* /* atoms_return */ +); +extern Colormap XCopyColormapAndFree( + Display* /* display */, + Colormap /* colormap */ +); +extern Colormap XCreateColormap( + Display* /* display */, + Window /* w */, + Visual* /* visual */, + int /* alloc */ +); +extern Cursor XCreatePixmapCursor( + Display* /* display */, + Pixmap /* source */, + Pixmap /* mask */, + XColor* /* foreground_color */, + XColor* /* background_color */, + unsigned int /* x */, + unsigned int /* y */ +); +extern Cursor XCreateGlyphCursor( + Display* /* display */, + Font /* source_font */, + Font /* mask_font */, + unsigned int /* source_char */, + unsigned int /* mask_char */, + XColor _Xconst * /* foreground_color */, + XColor _Xconst * /* background_color */ +); +extern Cursor XCreateFontCursor( + Display* /* display */, + unsigned int /* shape */ +); +extern Font XLoadFont( + Display* /* display */, + _Xconst char* /* name */ +); +extern GC XCreateGC( + Display* /* display */, + Drawable /* d */, + unsigned long /* valuemask */, + XGCValues* /* values */ +); +extern GContext XGContextFromGC( + GC /* gc */ +); +extern void XFlushGC( + Display* /* display */, + GC /* gc */ +); +extern Pixmap XCreatePixmap( + Display* /* display */, + Drawable /* d */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int /* depth */ +); +extern Pixmap XCreateBitmapFromData( + Display* /* display */, + Drawable /* d */, + _Xconst char* /* data */, + unsigned int /* width */, + unsigned int /* height */ +); +extern Pixmap XCreatePixmapFromBitmapData( + Display* /* display */, + Drawable /* d */, + char* /* data */, + unsigned int /* width */, + unsigned int /* height */, + unsigned long /* fg */, + unsigned long /* bg */, + unsigned int /* depth */ +); +extern Window XCreateSimpleWindow( + Display* /* display */, + Window /* parent */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int /* border_width */, + unsigned long /* border */, + unsigned long /* background */ +); +extern Window XGetSelectionOwner( + Display* /* display */, + Atom /* selection */ +); +extern Window XCreateWindow( + Display* /* display */, + Window /* parent */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int /* border_width */, + int /* depth */, + unsigned int /* class */, + Visual* /* visual */, + unsigned long /* valuemask */, + XSetWindowAttributes* /* attributes */ +); +extern Colormap *XListInstalledColormaps( + Display* /* display */, + Window /* w */, + int* /* num_return */ +); +extern char **XListFonts( + Display* /* display */, + _Xconst char* /* pattern */, + int /* maxnames */, + int* /* actual_count_return */ +); +extern char **XListFontsWithInfo( + Display* /* display */, + _Xconst char* /* pattern */, + int /* maxnames */, + int* /* count_return */, + XFontStruct** /* info_return */ +); +extern char **XGetFontPath( + Display* /* display */, + int* /* npaths_return */ +); +extern char **XListExtensions( + Display* /* display */, + int* /* nextensions_return */ +); +extern Atom *XListProperties( + Display* /* display */, + Window /* w */, + int* /* num_prop_return */ +); +extern XHostAddress *XListHosts( + Display* /* display */, + int* /* nhosts_return */, + Bool* /* state_return */ +); +extern KeySym XKeycodeToKeysym( + Display* /* display */, +#if NeedWidePrototypes + unsigned int /* keycode */, +#else + KeyCode /* keycode */, +#endif + int /* index */ +); +extern KeySym XLookupKeysym( + XKeyEvent* /* key_event */, + int /* index */ +); +extern KeySym *XGetKeyboardMapping( + Display* /* display */, +#if NeedWidePrototypes + unsigned int /* first_keycode */, +#else + KeyCode /* first_keycode */, +#endif + int /* keycode_count */, + int* /* keysyms_per_keycode_return */ +); +extern KeySym XStringToKeysym( + _Xconst char* /* string */ +); +extern long XMaxRequestSize( + Display* /* display */ +); +extern long XExtendedMaxRequestSize( + Display* /* display */ +); +extern char *XResourceManagerString( + Display* /* display */ +); +extern char *XScreenResourceString( + Screen* /* screen */ +); +extern unsigned long XDisplayMotionBufferSize( + Display* /* display */ +); +extern VisualID XVisualIDFromVisual( + Visual* /* visual */ +); + +/* multithread routines */ + +extern Status XInitThreads( + void +); + +extern void XLockDisplay( + Display* /* display */ +); + +extern void XUnlockDisplay( + Display* /* display */ +); + +/* routines for dealing with extensions */ + +extern XExtCodes *XInitExtension( + Display* /* display */, + _Xconst char* /* name */ +); + +extern XExtCodes *XAddExtension( + Display* /* display */ +); +extern XExtData *XFindOnExtensionList( + XExtData** /* structure */, + int /* number */ +); +extern XExtData **XEHeadOfExtensionList( + XEDataObject /* object */ +); + +/* these are routines for which there are also macros */ +extern Window XRootWindow( + Display* /* display */, + int /* screen_number */ +); +extern Window XDefaultRootWindow( + Display* /* display */ +); +extern Window XRootWindowOfScreen( + Screen* /* screen */ +); +extern Visual *XDefaultVisual( + Display* /* display */, + int /* screen_number */ +); +extern Visual *XDefaultVisualOfScreen( + Screen* /* screen */ +); +extern GC XDefaultGC( + Display* /* display */, + int /* screen_number */ +); +extern GC XDefaultGCOfScreen( + Screen* /* screen */ +); +extern unsigned long XBlackPixel( + Display* /* display */, + int /* screen_number */ +); +extern unsigned long XWhitePixel( + Display* /* display */, + int /* screen_number */ +); +extern unsigned long XAllPlanes( + void +); +extern unsigned long XBlackPixelOfScreen( + Screen* /* screen */ +); +extern unsigned long XWhitePixelOfScreen( + Screen* /* screen */ +); +extern unsigned long XNextRequest( + Display* /* display */ +); +extern unsigned long XLastKnownRequestProcessed( + Display* /* display */ +); +extern char *XServerVendor( + Display* /* display */ +); +extern char *XDisplayString( + Display* /* display */ +); +extern Colormap XDefaultColormap( + Display* /* display */, + int /* screen_number */ +); +extern Colormap XDefaultColormapOfScreen( + Screen* /* screen */ +); +extern Display *XDisplayOfScreen( + Screen* /* screen */ +); +extern Screen *XScreenOfDisplay( + Display* /* display */, + int /* screen_number */ +); +extern Screen *XDefaultScreenOfDisplay( + Display* /* display */ +); +extern long XEventMaskOfScreen( + Screen* /* screen */ +); + +extern int XScreenNumberOfScreen( + Screen* /* screen */ +); + +typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */ + Display* /* display */, + XErrorEvent* /* error_event */ +); + +extern XErrorHandler XSetErrorHandler ( + XErrorHandler /* handler */ +); + + +typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */ + Display* /* display */ +); + +extern XIOErrorHandler XSetIOErrorHandler ( + XIOErrorHandler /* handler */ +); + + +extern XPixmapFormatValues *XListPixmapFormats( + Display* /* display */, + int* /* count_return */ +); +extern int *XListDepths( + Display* /* display */, + int /* screen_number */, + int* /* count_return */ +); + +/* ICCCM routines for things that don't require special include files; */ +/* other declarations are given in Xutil.h */ +extern Status XReconfigureWMWindow( + Display* /* display */, + Window /* w */, + int /* screen_number */, + unsigned int /* mask */, + XWindowChanges* /* changes */ +); + +extern Status XGetWMProtocols( + Display* /* display */, + Window /* w */, + Atom** /* protocols_return */, + int* /* count_return */ +); +extern Status XSetWMProtocols( + Display* /* display */, + Window /* w */, + Atom* /* protocols */, + int /* count */ +); +extern Status XIconifyWindow( + Display* /* display */, + Window /* w */, + int /* screen_number */ +); +extern Status XWithdrawWindow( + Display* /* display */, + Window /* w */, + int /* screen_number */ +); +extern Status XGetCommand( + Display* /* display */, + Window /* w */, + char*** /* argv_return */, + int* /* argc_return */ +); +extern Status XGetWMColormapWindows( + Display* /* display */, + Window /* w */, + Window** /* windows_return */, + int* /* count_return */ +); +extern Status XSetWMColormapWindows( + Display* /* display */, + Window /* w */, + Window* /* colormap_windows */, + int /* count */ +); +extern void XFreeStringList( + char** /* list */ +); +extern int XSetTransientForHint( + Display* /* display */, + Window /* w */, + Window /* prop_window */ +); + +/* The following are given in alphabetical order */ + +extern int XActivateScreenSaver( + Display* /* display */ +); + +extern int XAddHost( + Display* /* display */, + XHostAddress* /* host */ +); + +extern int XAddHosts( + Display* /* display */, + XHostAddress* /* hosts */, + int /* num_hosts */ +); + +extern int XAddToExtensionList( + struct _XExtData** /* structure */, + XExtData* /* ext_data */ +); + +extern int XAddToSaveSet( + Display* /* display */, + Window /* w */ +); + +extern Status XAllocColor( + Display* /* display */, + Colormap /* colormap */, + XColor* /* screen_in_out */ +); + +extern Status XAllocColorCells( + Display* /* display */, + Colormap /* colormap */, + Bool /* contig */, + unsigned long* /* plane_masks_return */, + unsigned int /* nplanes */, + unsigned long* /* pixels_return */, + unsigned int /* npixels */ +); + +extern Status XAllocColorPlanes( + Display* /* display */, + Colormap /* colormap */, + Bool /* contig */, + unsigned long* /* pixels_return */, + int /* ncolors */, + int /* nreds */, + int /* ngreens */, + int /* nblues */, + unsigned long* /* rmask_return */, + unsigned long* /* gmask_return */, + unsigned long* /* bmask_return */ +); + +extern Status XAllocNamedColor( + Display* /* display */, + Colormap /* colormap */, + _Xconst char* /* color_name */, + XColor* /* screen_def_return */, + XColor* /* exact_def_return */ +); + +extern int XAllowEvents( + Display* /* display */, + int /* event_mode */, + Time /* time */ +); + +extern int XAutoRepeatOff( + Display* /* display */ +); + +extern int XAutoRepeatOn( + Display* /* display */ +); + +extern int XBell( + Display* /* display */, + int /* percent */ +); + +extern int XBitmapBitOrder( + Display* /* display */ +); + +extern int XBitmapPad( + Display* /* display */ +); + +extern int XBitmapUnit( + Display* /* display */ +); + +extern int XCellsOfScreen( + Screen* /* screen */ +); + +extern int XChangeActivePointerGrab( + Display* /* display */, + unsigned int /* event_mask */, + Cursor /* cursor */, + Time /* time */ +); + +extern int XChangeGC( + Display* /* display */, + GC /* gc */, + unsigned long /* valuemask */, + XGCValues* /* values */ +); + +extern int XChangeKeyboardControl( + Display* /* display */, + unsigned long /* value_mask */, + XKeyboardControl* /* values */ +); + +extern int XChangeKeyboardMapping( + Display* /* display */, + int /* first_keycode */, + int /* keysyms_per_keycode */, + KeySym* /* keysyms */, + int /* num_codes */ +); + +extern int XChangePointerControl( + Display* /* display */, + Bool /* do_accel */, + Bool /* do_threshold */, + int /* accel_numerator */, + int /* accel_denominator */, + int /* threshold */ +); + +extern int XChangeProperty( + Display* /* display */, + Window /* w */, + Atom /* property */, + Atom /* type */, + int /* format */, + int /* mode */, + _Xconst unsigned char* /* data */, + int /* nelements */ +); + +extern int XChangeSaveSet( + Display* /* display */, + Window /* w */, + int /* change_mode */ +); + +extern int XChangeWindowAttributes( + Display* /* display */, + Window /* w */, + unsigned long /* valuemask */, + XSetWindowAttributes* /* attributes */ +); + +extern Bool XCheckIfEvent( + Display* /* display */, + XEvent* /* event_return */, + Bool (*) ( + Display* /* display */, + XEvent* /* event */, + XPointer /* arg */ + ) /* predicate */, + XPointer /* arg */ +); + +extern Bool XCheckMaskEvent( + Display* /* display */, + long /* event_mask */, + XEvent* /* event_return */ +); + +extern Bool XCheckTypedEvent( + Display* /* display */, + int /* event_type */, + XEvent* /* event_return */ +); + +extern Bool XCheckTypedWindowEvent( + Display* /* display */, + Window /* w */, + int /* event_type */, + XEvent* /* event_return */ +); + +extern Bool XCheckWindowEvent( + Display* /* display */, + Window /* w */, + long /* event_mask */, + XEvent* /* event_return */ +); + +extern int XCirculateSubwindows( + Display* /* display */, + Window /* w */, + int /* direction */ +); + +extern int XCirculateSubwindowsDown( + Display* /* display */, + Window /* w */ +); + +extern int XCirculateSubwindowsUp( + Display* /* display */, + Window /* w */ +); + +extern int XClearArea( + Display* /* display */, + Window /* w */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + Bool /* exposures */ +); + +extern int XClearWindow( + Display* /* display */, + Window /* w */ +); + +extern int XCloseDisplay( + Display* /* display */ +); + +extern int XConfigureWindow( + Display* /* display */, + Window /* w */, + unsigned int /* value_mask */, + XWindowChanges* /* values */ +); + +extern int XConnectionNumber( + Display* /* display */ +); + +extern int XConvertSelection( + Display* /* display */, + Atom /* selection */, + Atom /* target */, + Atom /* property */, + Window /* requestor */, + Time /* time */ +); + +extern int XCopyArea( + Display* /* display */, + Drawable /* src */, + Drawable /* dest */, + GC /* gc */, + int /* src_x */, + int /* src_y */, + unsigned int /* width */, + unsigned int /* height */, + int /* dest_x */, + int /* dest_y */ +); + +extern int XCopyGC( + Display* /* display */, + GC /* src */, + unsigned long /* valuemask */, + GC /* dest */ +); + +extern int XCopyPlane( + Display* /* display */, + Drawable /* src */, + Drawable /* dest */, + GC /* gc */, + int /* src_x */, + int /* src_y */, + unsigned int /* width */, + unsigned int /* height */, + int /* dest_x */, + int /* dest_y */, + unsigned long /* plane */ +); + +extern int XDefaultDepth( + Display* /* display */, + int /* screen_number */ +); + +extern int XDefaultDepthOfScreen( + Screen* /* screen */ +); + +extern int XDefaultScreen( + Display* /* display */ +); + +extern int XDefineCursor( + Display* /* display */, + Window /* w */, + Cursor /* cursor */ +); + +extern int XDeleteProperty( + Display* /* display */, + Window /* w */, + Atom /* property */ +); + +extern int XDestroyWindow( + Display* /* display */, + Window /* w */ +); + +extern int XDestroySubwindows( + Display* /* display */, + Window /* w */ +); + +extern int XDoesBackingStore( + Screen* /* screen */ +); + +extern Bool XDoesSaveUnders( + Screen* /* screen */ +); + +extern int XDisableAccessControl( + Display* /* display */ +); + + +extern int XDisplayCells( + Display* /* display */, + int /* screen_number */ +); + +extern int XDisplayHeight( + Display* /* display */, + int /* screen_number */ +); + +extern int XDisplayHeightMM( + Display* /* display */, + int /* screen_number */ +); + +extern int XDisplayKeycodes( + Display* /* display */, + int* /* min_keycodes_return */, + int* /* max_keycodes_return */ +); + +extern int XDisplayPlanes( + Display* /* display */, + int /* screen_number */ +); + +extern int XDisplayWidth( + Display* /* display */, + int /* screen_number */ +); + +extern int XDisplayWidthMM( + Display* /* display */, + int /* screen_number */ +); + +extern int XDrawArc( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + int /* angle1 */, + int /* angle2 */ +); + +extern int XDrawArcs( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XArc* /* arcs */, + int /* narcs */ +); + +extern int XDrawImageString( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* string */, + int /* length */ +); + +extern int XDrawImageString16( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst XChar2b* /* string */, + int /* length */ +); + +extern int XDrawLine( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x1 */, + int /* y1 */, + int /* x2 */, + int /* y2 */ +); + +extern int XDrawLines( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XPoint* /* points */, + int /* npoints */, + int /* mode */ +); + +extern int XDrawPoint( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */ +); + +extern int XDrawPoints( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XPoint* /* points */, + int /* npoints */, + int /* mode */ +); + +extern int XDrawRectangle( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XDrawRectangles( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XRectangle* /* rectangles */, + int /* nrectangles */ +); + +extern int XDrawSegments( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XSegment* /* segments */, + int /* nsegments */ +); + +extern int XDrawString( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* string */, + int /* length */ +); + +extern int XDrawString16( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst XChar2b* /* string */, + int /* length */ +); + +extern int XDrawText( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + XTextItem* /* items */, + int /* nitems */ +); + +extern int XDrawText16( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + XTextItem16* /* items */, + int /* nitems */ +); + +extern int XEnableAccessControl( + Display* /* display */ +); + +extern int XEventsQueued( + Display* /* display */, + int /* mode */ +); + +extern Status XFetchName( + Display* /* display */, + Window /* w */, + char** /* window_name_return */ +); + +extern int XFillArc( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + int /* angle1 */, + int /* angle2 */ +); + +extern int XFillArcs( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XArc* /* arcs */, + int /* narcs */ +); + +extern int XFillPolygon( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XPoint* /* points */, + int /* npoints */, + int /* shape */, + int /* mode */ +); + +extern int XFillRectangle( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XFillRectangles( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XRectangle* /* rectangles */, + int /* nrectangles */ +); + +extern int XFlush( + Display* /* display */ +); + +extern int XForceScreenSaver( + Display* /* display */, + int /* mode */ +); + +extern int XFree( + void* /* data */ +); + +extern int XFreeColormap( + Display* /* display */, + Colormap /* colormap */ +); + +extern int XFreeColors( + Display* /* display */, + Colormap /* colormap */, + unsigned long* /* pixels */, + int /* npixels */, + unsigned long /* planes */ +); + +extern int XFreeCursor( + Display* /* display */, + Cursor /* cursor */ +); + +extern int XFreeExtensionList( + char** /* list */ +); + +extern int XFreeFont( + Display* /* display */, + XFontStruct* /* font_struct */ +); + +extern int XFreeFontInfo( + char** /* names */, + XFontStruct* /* free_info */, + int /* actual_count */ +); + +extern int XFreeFontNames( + char** /* list */ +); + +extern int XFreeFontPath( + char** /* list */ +); + +extern int XFreeGC( + Display* /* display */, + GC /* gc */ +); + +extern int XFreeModifiermap( + XModifierKeymap* /* modmap */ +); + +extern int XFreePixmap( + Display* /* display */, + Pixmap /* pixmap */ +); + +extern int XGeometry( + Display* /* display */, + int /* screen */, + _Xconst char* /* position */, + _Xconst char* /* default_position */, + unsigned int /* bwidth */, + unsigned int /* fwidth */, + unsigned int /* fheight */, + int /* xadder */, + int /* yadder */, + int* /* x_return */, + int* /* y_return */, + int* /* width_return */, + int* /* height_return */ +); + +extern int XGetErrorDatabaseText( + Display* /* display */, + _Xconst char* /* name */, + _Xconst char* /* message */, + _Xconst char* /* default_string */, + char* /* buffer_return */, + int /* length */ +); + +extern int XGetErrorText( + Display* /* display */, + int /* code */, + char* /* buffer_return */, + int /* length */ +); + +extern Bool XGetFontProperty( + XFontStruct* /* font_struct */, + Atom /* atom */, + unsigned long* /* value_return */ +); + +extern Status XGetGCValues( + Display* /* display */, + GC /* gc */, + unsigned long /* valuemask */, + XGCValues* /* values_return */ +); + +extern Status XGetGeometry( + Display* /* display */, + Drawable /* d */, + Window* /* root_return */, + int* /* x_return */, + int* /* y_return */, + unsigned int* /* width_return */, + unsigned int* /* height_return */, + unsigned int* /* border_width_return */, + unsigned int* /* depth_return */ +); + +extern Status XGetIconName( + Display* /* display */, + Window /* w */, + char** /* icon_name_return */ +); + +extern int XGetInputFocus( + Display* /* display */, + Window* /* focus_return */, + int* /* revert_to_return */ +); + +extern int XGetKeyboardControl( + Display* /* display */, + XKeyboardState* /* values_return */ +); + +extern int XGetPointerControl( + Display* /* display */, + int* /* accel_numerator_return */, + int* /* accel_denominator_return */, + int* /* threshold_return */ +); + +extern int XGetPointerMapping( + Display* /* display */, + unsigned char* /* map_return */, + int /* nmap */ +); + +extern int XGetScreenSaver( + Display* /* display */, + int* /* timeout_return */, + int* /* interval_return */, + int* /* prefer_blanking_return */, + int* /* allow_exposures_return */ +); + +extern Status XGetTransientForHint( + Display* /* display */, + Window /* w */, + Window* /* prop_window_return */ +); + +extern int XGetWindowProperty( + Display* /* display */, + Window /* w */, + Atom /* property */, + long /* long_offset */, + long /* long_length */, + Bool /* delete */, + Atom /* req_type */, + Atom* /* actual_type_return */, + int* /* actual_format_return */, + unsigned long* /* nitems_return */, + unsigned long* /* bytes_after_return */, + unsigned char** /* prop_return */ +); + +extern Status XGetWindowAttributes( + Display* /* display */, + Window /* w */, + XWindowAttributes* /* window_attributes_return */ +); + +extern int XGrabButton( + Display* /* display */, + unsigned int /* button */, + unsigned int /* modifiers */, + Window /* grab_window */, + Bool /* owner_events */, + unsigned int /* event_mask */, + int /* pointer_mode */, + int /* keyboard_mode */, + Window /* confine_to */, + Cursor /* cursor */ +); + +extern int XGrabKey( + Display* /* display */, + int /* keycode */, + unsigned int /* modifiers */, + Window /* grab_window */, + Bool /* owner_events */, + int /* pointer_mode */, + int /* keyboard_mode */ +); + +extern int XGrabKeyboard( + Display* /* display */, + Window /* grab_window */, + Bool /* owner_events */, + int /* pointer_mode */, + int /* keyboard_mode */, + Time /* time */ +); + +extern int XGrabPointer( + Display* /* display */, + Window /* grab_window */, + Bool /* owner_events */, + unsigned int /* event_mask */, + int /* pointer_mode */, + int /* keyboard_mode */, + Window /* confine_to */, + Cursor /* cursor */, + Time /* time */ +); + +extern int XGrabServer( + Display* /* display */ +); + +extern int XHeightMMOfScreen( + Screen* /* screen */ +); + +extern int XHeightOfScreen( + Screen* /* screen */ +); + +extern int XIfEvent( + Display* /* display */, + XEvent* /* event_return */, + Bool (*) ( + Display* /* display */, + XEvent* /* event */, + XPointer /* arg */ + ) /* predicate */, + XPointer /* arg */ +); + +extern int XImageByteOrder( + Display* /* display */ +); + +extern int XInstallColormap( + Display* /* display */, + Colormap /* colormap */ +); + +extern KeyCode XKeysymToKeycode( + Display* /* display */, + KeySym /* keysym */ +); + +extern int XKillClient( + Display* /* display */, + XID /* resource */ +); + +extern Status XLookupColor( + Display* /* display */, + Colormap /* colormap */, + _Xconst char* /* color_name */, + XColor* /* exact_def_return */, + XColor* /* screen_def_return */ +); + +extern int XLowerWindow( + Display* /* display */, + Window /* w */ +); + +extern int XMapRaised( + Display* /* display */, + Window /* w */ +); + +extern int XMapSubwindows( + Display* /* display */, + Window /* w */ +); + +extern int XMapWindow( + Display* /* display */, + Window /* w */ +); + +extern int XMaskEvent( + Display* /* display */, + long /* event_mask */, + XEvent* /* event_return */ +); + +extern int XMaxCmapsOfScreen( + Screen* /* screen */ +); + +extern int XMinCmapsOfScreen( + Screen* /* screen */ +); + +extern int XMoveResizeWindow( + Display* /* display */, + Window /* w */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XMoveWindow( + Display* /* display */, + Window /* w */, + int /* x */, + int /* y */ +); + +extern int XNextEvent( + Display* /* display */, + XEvent* /* event_return */ +); + +extern int XNoOp( + Display* /* display */ +); + +extern Status XParseColor( + Display* /* display */, + Colormap /* colormap */, + _Xconst char* /* spec */, + XColor* /* exact_def_return */ +); + +extern int XParseGeometry( + _Xconst char* /* parsestring */, + int* /* x_return */, + int* /* y_return */, + unsigned int* /* width_return */, + unsigned int* /* height_return */ +); + +extern int XPeekEvent( + Display* /* display */, + XEvent* /* event_return */ +); + +extern int XPeekIfEvent( + Display* /* display */, + XEvent* /* event_return */, + Bool (*) ( + Display* /* display */, + XEvent* /* event */, + XPointer /* arg */ + ) /* predicate */, + XPointer /* arg */ +); + +extern int XPending( + Display* /* display */ +); + +extern int XPlanesOfScreen( + Screen* /* screen */ +); + +extern int XProtocolRevision( + Display* /* display */ +); + +extern int XProtocolVersion( + Display* /* display */ +); + + +extern int XPutBackEvent( + Display* /* display */, + XEvent* /* event */ +); + +extern int XPutImage( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XImage* /* image */, + int /* src_x */, + int /* src_y */, + int /* dest_x */, + int /* dest_y */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XQLength( + Display* /* display */ +); + +extern Status XQueryBestCursor( + Display* /* display */, + Drawable /* d */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int* /* width_return */, + unsigned int* /* height_return */ +); + +extern Status XQueryBestSize( + Display* /* display */, + int /* class */, + Drawable /* which_screen */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int* /* width_return */, + unsigned int* /* height_return */ +); + +extern Status XQueryBestStipple( + Display* /* display */, + Drawable /* which_screen */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int* /* width_return */, + unsigned int* /* height_return */ +); + +extern Status XQueryBestTile( + Display* /* display */, + Drawable /* which_screen */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int* /* width_return */, + unsigned int* /* height_return */ +); + +extern int XQueryColor( + Display* /* display */, + Colormap /* colormap */, + XColor* /* def_in_out */ +); + +extern int XQueryColors( + Display* /* display */, + Colormap /* colormap */, + XColor* /* defs_in_out */, + int /* ncolors */ +); + +extern Bool XQueryExtension( + Display* /* display */, + _Xconst char* /* name */, + int* /* major_opcode_return */, + int* /* first_event_return */, + int* /* first_error_return */ +); + +extern int XQueryKeymap( + Display* /* display */, + char [32] /* keys_return */ +); + +extern Bool XQueryPointer( + Display* /* display */, + Window /* w */, + Window* /* root_return */, + Window* /* child_return */, + int* /* root_x_return */, + int* /* root_y_return */, + int* /* win_x_return */, + int* /* win_y_return */, + unsigned int* /* mask_return */ +); + +extern int XQueryTextExtents( + Display* /* display */, + XID /* font_ID */, + _Xconst char* /* string */, + int /* nchars */, + int* /* direction_return */, + int* /* font_ascent_return */, + int* /* font_descent_return */, + XCharStruct* /* overall_return */ +); + +extern int XQueryTextExtents16( + Display* /* display */, + XID /* font_ID */, + _Xconst XChar2b* /* string */, + int /* nchars */, + int* /* direction_return */, + int* /* font_ascent_return */, + int* /* font_descent_return */, + XCharStruct* /* overall_return */ +); + +extern Status XQueryTree( + Display* /* display */, + Window /* w */, + Window* /* root_return */, + Window* /* parent_return */, + Window** /* children_return */, + unsigned int* /* nchildren_return */ +); + +extern int XRaiseWindow( + Display* /* display */, + Window /* w */ +); + +extern int XReadBitmapFile( + Display* /* display */, + Drawable /* d */, + _Xconst char* /* filename */, + unsigned int* /* width_return */, + unsigned int* /* height_return */, + Pixmap* /* bitmap_return */, + int* /* x_hot_return */, + int* /* y_hot_return */ +); + +extern int XReadBitmapFileData( + _Xconst char* /* filename */, + unsigned int* /* width_return */, + unsigned int* /* height_return */, + unsigned char** /* data_return */, + int* /* x_hot_return */, + int* /* y_hot_return */ +); + +extern int XRebindKeysym( + Display* /* display */, + KeySym /* keysym */, + KeySym* /* list */, + int /* mod_count */, + _Xconst unsigned char* /* string */, + int /* bytes_string */ +); + +extern int XRecolorCursor( + Display* /* display */, + Cursor /* cursor */, + XColor* /* foreground_color */, + XColor* /* background_color */ +); + +extern int XRefreshKeyboardMapping( + XMappingEvent* /* event_map */ +); + +extern int XRemoveFromSaveSet( + Display* /* display */, + Window /* w */ +); + +extern int XRemoveHost( + Display* /* display */, + XHostAddress* /* host */ +); + +extern int XRemoveHosts( + Display* /* display */, + XHostAddress* /* hosts */, + int /* num_hosts */ +); + +extern int XReparentWindow( + Display* /* display */, + Window /* w */, + Window /* parent */, + int /* x */, + int /* y */ +); + +extern int XResetScreenSaver( + Display* /* display */ +); + +extern int XResizeWindow( + Display* /* display */, + Window /* w */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XRestackWindows( + Display* /* display */, + Window* /* windows */, + int /* nwindows */ +); + +extern int XRotateBuffers( + Display* /* display */, + int /* rotate */ +); + +extern int XRotateWindowProperties( + Display* /* display */, + Window /* w */, + Atom* /* properties */, + int /* num_prop */, + int /* npositions */ +); + +extern int XScreenCount( + Display* /* display */ +); + +extern int XSelectInput( + Display* /* display */, + Window /* w */, + long /* event_mask */ +); + +extern Status XSendEvent( + Display* /* display */, + Window /* w */, + Bool /* propagate */, + long /* event_mask */, + XEvent* /* event_send */ +); + +extern int XSetAccessControl( + Display* /* display */, + int /* mode */ +); + +extern int XSetArcMode( + Display* /* display */, + GC /* gc */, + int /* arc_mode */ +); + +extern int XSetBackground( + Display* /* display */, + GC /* gc */, + unsigned long /* background */ +); + +extern int XSetClipMask( + Display* /* display */, + GC /* gc */, + Pixmap /* pixmap */ +); + +extern int XSetClipOrigin( + Display* /* display */, + GC /* gc */, + int /* clip_x_origin */, + int /* clip_y_origin */ +); + +extern int XSetClipRectangles( + Display* /* display */, + GC /* gc */, + int /* clip_x_origin */, + int /* clip_y_origin */, + XRectangle* /* rectangles */, + int /* n */, + int /* ordering */ +); + +extern int XSetCloseDownMode( + Display* /* display */, + int /* close_mode */ +); + +extern int XSetCommand( + Display* /* display */, + Window /* w */, + char** /* argv */, + int /* argc */ +); + +extern int XSetDashes( + Display* /* display */, + GC /* gc */, + int /* dash_offset */, + _Xconst char* /* dash_list */, + int /* n */ +); + +extern int XSetFillRule( + Display* /* display */, + GC /* gc */, + int /* fill_rule */ +); + +extern int XSetFillStyle( + Display* /* display */, + GC /* gc */, + int /* fill_style */ +); + +extern int XSetFont( + Display* /* display */, + GC /* gc */, + Font /* font */ +); + +extern int XSetFontPath( + Display* /* display */, + char** /* directories */, + int /* ndirs */ +); + +extern int XSetForeground( + Display* /* display */, + GC /* gc */, + unsigned long /* foreground */ +); + +extern int XSetFunction( + Display* /* display */, + GC /* gc */, + int /* function */ +); + +extern int XSetGraphicsExposures( + Display* /* display */, + GC /* gc */, + Bool /* graphics_exposures */ +); + +extern int XSetIconName( + Display* /* display */, + Window /* w */, + _Xconst char* /* icon_name */ +); + +extern int XSetInputFocus( + Display* /* display */, + Window /* focus */, + int /* revert_to */, + Time /* time */ +); + +extern int XSetLineAttributes( + Display* /* display */, + GC /* gc */, + unsigned int /* line_width */, + int /* line_style */, + int /* cap_style */, + int /* join_style */ +); + +extern int XSetModifierMapping( + Display* /* display */, + XModifierKeymap* /* modmap */ +); + +extern int XSetPlaneMask( + Display* /* display */, + GC /* gc */, + unsigned long /* plane_mask */ +); + +extern int XSetPointerMapping( + Display* /* display */, + _Xconst unsigned char* /* map */, + int /* nmap */ +); + +extern int XSetScreenSaver( + Display* /* display */, + int /* timeout */, + int /* interval */, + int /* prefer_blanking */, + int /* allow_exposures */ +); + +extern int XSetSelectionOwner( + Display* /* display */, + Atom /* selection */, + Window /* owner */, + Time /* time */ +); + +extern int XSetState( + Display* /* display */, + GC /* gc */, + unsigned long /* foreground */, + unsigned long /* background */, + int /* function */, + unsigned long /* plane_mask */ +); + +extern int XSetStipple( + Display* /* display */, + GC /* gc */, + Pixmap /* stipple */ +); + +extern int XSetSubwindowMode( + Display* /* display */, + GC /* gc */, + int /* subwindow_mode */ +); + +extern int XSetTSOrigin( + Display* /* display */, + GC /* gc */, + int /* ts_x_origin */, + int /* ts_y_origin */ +); + +extern int XSetTile( + Display* /* display */, + GC /* gc */, + Pixmap /* tile */ +); + +extern int XSetWindowBackground( + Display* /* display */, + Window /* w */, + unsigned long /* background_pixel */ +); + +extern int XSetWindowBackgroundPixmap( + Display* /* display */, + Window /* w */, + Pixmap /* background_pixmap */ +); + +extern int XSetWindowBorder( + Display* /* display */, + Window /* w */, + unsigned long /* border_pixel */ +); + +extern int XSetWindowBorderPixmap( + Display* /* display */, + Window /* w */, + Pixmap /* border_pixmap */ +); + +extern int XSetWindowBorderWidth( + Display* /* display */, + Window /* w */, + unsigned int /* width */ +); + +extern int XSetWindowColormap( + Display* /* display */, + Window /* w */, + Colormap /* colormap */ +); + +extern int XStoreBuffer( + Display* /* display */, + _Xconst char* /* bytes */, + int /* nbytes */, + int /* buffer */ +); + +extern int XStoreBytes( + Display* /* display */, + _Xconst char* /* bytes */, + int /* nbytes */ +); + +extern int XStoreColor( + Display* /* display */, + Colormap /* colormap */, + XColor* /* color */ +); + +extern int XStoreColors( + Display* /* display */, + Colormap /* colormap */, + XColor* /* color */, + int /* ncolors */ +); + +extern int XStoreName( + Display* /* display */, + Window /* w */, + _Xconst char* /* window_name */ +); + +extern int XStoreNamedColor( + Display* /* display */, + Colormap /* colormap */, + _Xconst char* /* color */, + unsigned long /* pixel */, + int /* flags */ +); + +extern int XSync( + Display* /* display */, + Bool /* discard */ +); + +extern int XTextExtents( + XFontStruct* /* font_struct */, + _Xconst char* /* string */, + int /* nchars */, + int* /* direction_return */, + int* /* font_ascent_return */, + int* /* font_descent_return */, + XCharStruct* /* overall_return */ +); + +extern int XTextExtents16( + XFontStruct* /* font_struct */, + _Xconst XChar2b* /* string */, + int /* nchars */, + int* /* direction_return */, + int* /* font_ascent_return */, + int* /* font_descent_return */, + XCharStruct* /* overall_return */ +); + +extern int XTextWidth( + XFontStruct* /* font_struct */, + _Xconst char* /* string */, + int /* count */ +); + +extern int XTextWidth16( + XFontStruct* /* font_struct */, + _Xconst XChar2b* /* string */, + int /* count */ +); + +extern Bool XTranslateCoordinates( + Display* /* display */, + Window /* src_w */, + Window /* dest_w */, + int /* src_x */, + int /* src_y */, + int* /* dest_x_return */, + int* /* dest_y_return */, + Window* /* child_return */ +); + +extern int XUndefineCursor( + Display* /* display */, + Window /* w */ +); + +extern int XUngrabButton( + Display* /* display */, + unsigned int /* button */, + unsigned int /* modifiers */, + Window /* grab_window */ +); + +extern int XUngrabKey( + Display* /* display */, + int /* keycode */, + unsigned int /* modifiers */, + Window /* grab_window */ +); + +extern int XUngrabKeyboard( + Display* /* display */, + Time /* time */ +); + +extern int XUngrabPointer( + Display* /* display */, + Time /* time */ +); + +extern int XUngrabServer( + Display* /* display */ +); + +extern int XUninstallColormap( + Display* /* display */, + Colormap /* colormap */ +); + +extern int XUnloadFont( + Display* /* display */, + Font /* font */ +); + +extern int XUnmapSubwindows( + Display* /* display */, + Window /* w */ +); + +extern int XUnmapWindow( + Display* /* display */, + Window /* w */ +); + +extern int XVendorRelease( + Display* /* display */ +); + +extern int XWarpPointer( + Display* /* display */, + Window /* src_w */, + Window /* dest_w */, + int /* src_x */, + int /* src_y */, + unsigned int /* src_width */, + unsigned int /* src_height */, + int /* dest_x */, + int /* dest_y */ +); + +extern int XWidthMMOfScreen( + Screen* /* screen */ +); + +extern int XWidthOfScreen( + Screen* /* screen */ +); + +extern int XWindowEvent( + Display* /* display */, + Window /* w */, + long /* event_mask */, + XEvent* /* event_return */ +); + +extern int XWriteBitmapFile( + Display* /* display */, + _Xconst char* /* filename */, + Pixmap /* bitmap */, + unsigned int /* width */, + unsigned int /* height */, + int /* x_hot */, + int /* y_hot */ +); + +extern Bool XSupportsLocale (void); + +extern char *XSetLocaleModifiers( + const char* /* modifier_list */ +); + +extern XOM XOpenOM( + Display* /* display */, + struct _XrmHashBucketRec* /* rdb */, + _Xconst char* /* res_name */, + _Xconst char* /* res_class */ +); + +extern Status XCloseOM( + XOM /* om */ +); + +extern char *XSetOMValues( + XOM /* om */, + ... +) _X_SENTINEL(0); + +extern char *XGetOMValues( + XOM /* om */, + ... +) _X_SENTINEL(0); + +extern Display *XDisplayOfOM( + XOM /* om */ +); + +extern char *XLocaleOfOM( + XOM /* om */ +); + +extern XOC XCreateOC( + XOM /* om */, + ... +) _X_SENTINEL(0); + +extern void XDestroyOC( + XOC /* oc */ +); + +extern XOM XOMOfOC( + XOC /* oc */ +); + +extern char *XSetOCValues( + XOC /* oc */, + ... +) _X_SENTINEL(0); + +extern char *XGetOCValues( + XOC /* oc */, + ... +) _X_SENTINEL(0); + +extern XFontSet XCreateFontSet( + Display* /* display */, + _Xconst char* /* base_font_name_list */, + char*** /* missing_charset_list */, + int* /* missing_charset_count */, + char** /* def_string */ +); + +extern void XFreeFontSet( + Display* /* display */, + XFontSet /* font_set */ +); + +extern int XFontsOfFontSet( + XFontSet /* font_set */, + XFontStruct*** /* font_struct_list */, + char*** /* font_name_list */ +); + +extern char *XBaseFontNameListOfFontSet( + XFontSet /* font_set */ +); + +extern char *XLocaleOfFontSet( + XFontSet /* font_set */ +); + +extern Bool XContextDependentDrawing( + XFontSet /* font_set */ +); + +extern Bool XDirectionalDependentDrawing( + XFontSet /* font_set */ +); + +extern Bool XContextualDrawing( + XFontSet /* font_set */ +); + +extern XFontSetExtents *XExtentsOfFontSet( + XFontSet /* font_set */ +); + +extern int XmbTextEscapement( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern int XwcTextEscapement( + XFontSet /* font_set */, + _Xconst wchar_t* /* text */, + int /* num_wchars */ +); + +extern int Xutf8TextEscapement( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern int XmbTextExtents( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern int XwcTextExtents( + XFontSet /* font_set */, + _Xconst wchar_t* /* text */, + int /* num_wchars */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern int Xutf8TextExtents( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern Status XmbTextPerCharExtents( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */, + XRectangle* /* ink_extents_buffer */, + XRectangle* /* logical_extents_buffer */, + int /* buffer_size */, + int* /* num_chars */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern Status XwcTextPerCharExtents( + XFontSet /* font_set */, + _Xconst wchar_t* /* text */, + int /* num_wchars */, + XRectangle* /* ink_extents_buffer */, + XRectangle* /* logical_extents_buffer */, + int /* buffer_size */, + int* /* num_chars */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern Status Xutf8TextPerCharExtents( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */, + XRectangle* /* ink_extents_buffer */, + XRectangle* /* logical_extents_buffer */, + int /* buffer_size */, + int* /* num_chars */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern void XmbDrawText( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + XmbTextItem* /* text_items */, + int /* nitems */ +); + +extern void XwcDrawText( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + XwcTextItem* /* text_items */, + int /* nitems */ +); + +extern void Xutf8DrawText( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + XmbTextItem* /* text_items */, + int /* nitems */ +); + +extern void XmbDrawString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern void XwcDrawString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst wchar_t* /* text */, + int /* num_wchars */ +); + +extern void Xutf8DrawString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern void XmbDrawImageString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern void XwcDrawImageString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst wchar_t* /* text */, + int /* num_wchars */ +); + +extern void Xutf8DrawImageString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern XIM XOpenIM( + Display* /* dpy */, + struct _XrmHashBucketRec* /* rdb */, + char* /* res_name */, + char* /* res_class */ +); + +extern Status XCloseIM( + XIM /* im */ +); + +extern char *XGetIMValues( + XIM /* im */, ... +) _X_SENTINEL(0); + +extern char *XSetIMValues( + XIM /* im */, ... +) _X_SENTINEL(0); + +extern Display *XDisplayOfIM( + XIM /* im */ +); + +extern char *XLocaleOfIM( + XIM /* im*/ +); + +extern XIC XCreateIC( + XIM /* im */, ... +) _X_SENTINEL(0); + +extern void XDestroyIC( + XIC /* ic */ +); + +extern void XSetICFocus( + XIC /* ic */ +); + +extern void XUnsetICFocus( + XIC /* ic */ +); + +extern wchar_t *XwcResetIC( + XIC /* ic */ +); + +extern char *XmbResetIC( + XIC /* ic */ +); + +extern char *Xutf8ResetIC( + XIC /* ic */ +); + +extern char *XSetICValues( + XIC /* ic */, ... +) _X_SENTINEL(0); + +extern char *XGetICValues( + XIC /* ic */, ... +) _X_SENTINEL(0); + +extern XIM XIMOfIC( + XIC /* ic */ +); + +extern Bool XFilterEvent( + XEvent* /* event */, + Window /* window */ +); + +extern int XmbLookupString( + XIC /* ic */, + XKeyPressedEvent* /* event */, + char* /* buffer_return */, + int /* bytes_buffer */, + KeySym* /* keysym_return */, + Status* /* status_return */ +); + +extern int XwcLookupString( + XIC /* ic */, + XKeyPressedEvent* /* event */, + wchar_t* /* buffer_return */, + int /* wchars_buffer */, + KeySym* /* keysym_return */, + Status* /* status_return */ +); + +extern int Xutf8LookupString( + XIC /* ic */, + XKeyPressedEvent* /* event */, + char* /* buffer_return */, + int /* bytes_buffer */, + KeySym* /* keysym_return */, + Status* /* status_return */ +); + +extern XVaNestedList XVaCreateNestedList( + int /*unused*/, ... +) _X_SENTINEL(0); + +/* internal connections for IMs */ + +extern Bool XRegisterIMInstantiateCallback( + Display* /* dpy */, + struct _XrmHashBucketRec* /* rdb */, + char* /* res_name */, + char* /* res_class */, + XIDProc /* callback */, + XPointer /* client_data */ +); + +extern Bool XUnregisterIMInstantiateCallback( + Display* /* dpy */, + struct _XrmHashBucketRec* /* rdb */, + char* /* res_name */, + char* /* res_class */, + XIDProc /* callback */, + XPointer /* client_data */ +); + +typedef void (*XConnectionWatchProc)( + Display* /* dpy */, + XPointer /* client_data */, + int /* fd */, + Bool /* opening */, /* open or close flag */ + XPointer* /* watch_data */ /* open sets, close uses */ +); + + +extern Status XInternalConnectionNumbers( + Display* /* dpy */, + int** /* fd_return */, + int* /* count_return */ +); + +extern void XProcessInternalConnection( + Display* /* dpy */, + int /* fd */ +); + +extern Status XAddConnectionWatch( + Display* /* dpy */, + XConnectionWatchProc /* callback */, + XPointer /* client_data */ +); + +extern void XRemoveConnectionWatch( + Display* /* dpy */, + XConnectionWatchProc /* callback */, + XPointer /* client_data */ +); + +extern void XSetAuthorization( + char * /* name */, + int /* namelen */, + char * /* data */, + int /* datalen */ +); + +extern int _Xmbtowc( + wchar_t * /* wstr */, +#ifdef ISC + char const * /* str */, + size_t /* len */ +#else + char * /* str */, + int /* len */ +#endif +); + +extern int _Xwctomb( + char * /* str */, + wchar_t /* wc */ +); + +extern Bool XGetEventData( + Display* /* dpy */, + XGenericEventCookie* /* cookie*/ +); + +extern void XFreeEventData( + Display* /* dpy */, + XGenericEventCookie* /* cookie*/ +); + +_XFUNCPROTOEND + +#endif /* _X11_XLIB_H_ */ diff --git a/libX11/include/X11/Xlib.h b/libX11/include/X11/Xlib.h index e6cd7471b..b32390894 100644 --- a/libX11/include/X11/Xlib.h +++ b/libX11/include/X11/Xlib.h @@ -1,4023 +1,4023 @@ -/*
-
-Copyright 1985, 1986, 1987, 1991, 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.
-
-*/
-
-
-/*
- * Xlib.h - Header definition and support file for the C subroutine
- * interface library (Xlib) to the X Window System Protocol (V11).
- * Structures and symbols starting with "_" are private to the library.
- */
-#ifndef _X11_XLIB_H_
-#define _X11_XLIB_H_
-
-#define XlibSpecificationRelease 6
-
-#include <sys/types.h>
-
-#if defined(__SCO__) || defined(__UNIXWARE__)
-#include <stdint.h>
-#endif
-
-#include <X11/X.h>
-
-/* applications should not depend on these two headers being included! */
-#include <X11/Xfuncproto.h>
-#include <X11/Xosdefs.h>
-
-#ifndef X_WCHAR
-#include <stddef.h>
-#else
-#ifdef __UNIXOS2__
-#include <stdlib.h>
-#else
-/* replace this with #include or typedef appropriate for your system */
-typedef unsigned long wchar_t;
-#endif
-#endif
-
-#if defined(ISC) && defined(USE_XMBTOWC)
-#define wctomb(a,b) _Xwctomb(a,b)
-#define mblen(a,b) _Xmblen(a,b)
-#ifndef USE_XWCHAR_STRING
-#define mbtowc(a,b,c) _Xmbtowc(a,b,c)
-#endif
-#endif
-
-extern int
-_Xmblen(
-#ifdef ISC
- char const *str,
- size_t len
-#else
- char *str,
- int len
-#endif
- );
-
-/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in
- November 2000. Its presence is indicated through the following macro. */
-#define X_HAVE_UTF8_STRING 1
-
-typedef char *XPointer;
-
-typedef int Bool;
-typedef int Status;
-#define True 1
-#define False 0
-
-#define QueuedAlready 0
-#define QueuedAfterReading 1
-#define QueuedAfterFlush 2
-
-#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd)
-#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root)
-#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen)
-#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root)
-#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual)
-#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc)
-#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel)
-#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel)
-#define AllPlanes ((unsigned long)~0L)
-#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen)
-#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width)
-#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height)
-#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth)
-#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight)
-#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
-#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries)
-#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens)
-#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor)
-#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version)
-#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version)
-#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release)
-#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name)
-#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
-#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap)
-#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit)
-#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order)
-#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad)
-#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order)
-#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */
-#define NextRequest(dpy) XNextRequest(dpy)
-#else
-#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1)
-#endif
-#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read)
-
-/* macros for screen oriented applications (toolkit) */
-#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr])
-#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy))
-#define DisplayOfScreen(s) ((s)->display)
-#define RootWindowOfScreen(s) ((s)->root)
-#define BlackPixelOfScreen(s) ((s)->black_pixel)
-#define WhitePixelOfScreen(s) ((s)->white_pixel)
-#define DefaultColormapOfScreen(s)((s)->cmap)
-#define DefaultDepthOfScreen(s) ((s)->root_depth)
-#define DefaultGCOfScreen(s) ((s)->default_gc)
-#define DefaultVisualOfScreen(s)((s)->root_visual)
-#define WidthOfScreen(s) ((s)->width)
-#define HeightOfScreen(s) ((s)->height)
-#define WidthMMOfScreen(s) ((s)->mwidth)
-#define HeightMMOfScreen(s) ((s)->mheight)
-#define PlanesOfScreen(s) ((s)->root_depth)
-#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries)
-#define MinCmapsOfScreen(s) ((s)->min_maps)
-#define MaxCmapsOfScreen(s) ((s)->max_maps)
-#define DoesSaveUnders(s) ((s)->save_unders)
-#define DoesBackingStore(s) ((s)->backing_store)
-#define EventMaskOfScreen(s) ((s)->root_input_mask)
-
-/*
- * Extensions need a way to hang private data on some structures.
- */
-typedef struct _XExtData {
- int number; /* number returned by XRegisterExtension */
- struct _XExtData *next; /* next item on list of data for structure */
- int (*free_private)( /* called to free private storage */
- struct _XExtData *extension
- );
- XPointer private_data; /* data private to this extension. */
-} XExtData;
-
-/*
- * This file contains structures used by the extension mechanism.
- */
-typedef struct { /* public to extension, cannot be changed */
- int extension; /* extension number */
- int major_opcode; /* major op-code assigned by server */
- int first_event; /* first event number for the extension */
- int first_error; /* first error number for the extension */
-} XExtCodes;
-
-/*
- * Data structure for retrieving info about pixmap formats.
- */
-
-typedef struct {
- int depth;
- int bits_per_pixel;
- int scanline_pad;
-} XPixmapFormatValues;
-
-
-/*
- * Data structure for setting graphics context.
- */
-typedef struct {
- int function; /* logical operation */
- unsigned long plane_mask;/* plane mask */
- unsigned long foreground;/* foreground pixel */
- unsigned long background;/* background pixel */
- int line_width; /* line width */
- int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
- int cap_style; /* CapNotLast, CapButt,
- CapRound, CapProjecting */
- int join_style; /* JoinMiter, JoinRound, JoinBevel */
- int fill_style; /* FillSolid, FillTiled,
- FillStippled, FillOpaeueStippled */
- int fill_rule; /* EvenOddRule, WindingRule */
- int arc_mode; /* ArcChord, ArcPieSlice */
- Pixmap tile; /* tile pixmap for tiling operations */
- Pixmap stipple; /* stipple 1 plane pixmap for stipping */
- int ts_x_origin; /* offset for tile or stipple operations */
- int ts_y_origin;
- Font font; /* default text font for text operations */
- int subwindow_mode; /* ClipByChildren, IncludeInferiors */
- Bool graphics_exposures;/* boolean, should exposures be generated */
- int clip_x_origin; /* origin for clipping */
- int clip_y_origin;
- Pixmap clip_mask; /* bitmap clipping; other calls for rects */
- int dash_offset; /* patterned/dashed line information */
- char dashes;
-} XGCValues;
-
-/*
- * Graphics context. The contents of this structure are implementation
- * dependent. A GC should be treated as opaque by application code.
- */
-
-typedef struct _XGC
-#ifdef XLIB_ILLEGAL_ACCESS
-{
- XExtData *ext_data; /* hook for extension to hang data */
- GContext gid; /* protocol ID for graphics context */
- /* there is more to this structure, but it is private to Xlib */
-}
-#endif
-*GC;
-
-/*
- * Visual structure; contains information about colormapping possible.
- */
-typedef struct {
- XExtData *ext_data; /* hook for extension to hang data */
- VisualID visualid; /* visual id of this visual */
-#if defined(__cplusplus) || defined(c_plusplus)
- int c_class; /* C++ class of screen (monochrome, etc.) */
-#else
- int class; /* class of screen (monochrome, etc.) */
-#endif
- unsigned long red_mask, green_mask, blue_mask; /* mask values */
- int bits_per_rgb; /* log base 2 of distinct color values */
- int map_entries; /* color map entries */
-} Visual;
-
-/*
- * Depth structure; contains information for each possible depth.
- */
-typedef struct {
- int depth; /* this depth (Z) of the depth */
- int nvisuals; /* number of Visual types at this depth */
- Visual *visuals; /* list of visuals possible at this depth */
-} Depth;
-
-/*
- * Information about the screen. The contents of this structure are
- * implementation dependent. A Screen should be treated as opaque
- * by application code.
- */
-
-struct _XDisplay; /* Forward declare before use for C++ */
-
-typedef struct {
- XExtData *ext_data; /* hook for extension to hang data */
- struct _XDisplay *display;/* back pointer to display structure */
- Window root; /* Root window id. */
- int width, height; /* width and height of screen */
- int mwidth, mheight; /* width and height of in millimeters */
- int ndepths; /* number of depths possible */
- Depth *depths; /* list of allowable depths on the screen */
- int root_depth; /* bits per pixel */
- Visual *root_visual; /* root visual */
- GC default_gc; /* GC for the root root visual */
- Colormap cmap; /* default color map */
- unsigned long white_pixel;
- unsigned long black_pixel; /* White and Black pixel values */
- int max_maps, min_maps; /* max and min color maps */
- int backing_store; /* Never, WhenMapped, Always */
- Bool save_unders;
- long root_input_mask; /* initial root input mask */
-} Screen;
-
-/*
- * Format structure; describes ZFormat data the screen will understand.
- */
-typedef struct {
- XExtData *ext_data; /* hook for extension to hang data */
- int depth; /* depth of this image format */
- int bits_per_pixel; /* bits/pixel at this depth */
- int scanline_pad; /* scanline must padded to this multiple */
-} ScreenFormat;
-
-/*
- * Data structure for setting window attributes.
- */
-typedef struct {
- Pixmap background_pixmap; /* background or None or ParentRelative */
- unsigned long background_pixel; /* background pixel */
- Pixmap border_pixmap; /* border of the window */
- unsigned long border_pixel; /* border pixel value */
- int bit_gravity; /* one of bit gravity values */
- int win_gravity; /* one of the window gravity values */
- int backing_store; /* NotUseful, WhenMapped, Always */
- unsigned long backing_planes;/* planes to be preseved if possible */
- unsigned long backing_pixel;/* value to use in restoring planes */
- Bool save_under; /* should bits under be saved? (popups) */
- long event_mask; /* set of events that should be saved */
- long do_not_propagate_mask; /* set of events that should not propagate */
- Bool override_redirect; /* boolean value for override-redirect */
- Colormap colormap; /* color map to be associated with window */
- Cursor cursor; /* cursor to be displayed (or None) */
-} XSetWindowAttributes;
-
-typedef struct {
- int x, y; /* location of window */
- int width, height; /* width and height of window */
- int border_width; /* border width of window */
- int depth; /* depth of window */
- Visual *visual; /* the associated visual structure */
- Window root; /* root of screen containing window */
-#if defined(__cplusplus) || defined(c_plusplus)
- int c_class; /* C++ InputOutput, InputOnly*/
-#else
- int class; /* InputOutput, InputOnly*/
-#endif
- int bit_gravity; /* one of bit gravity values */
- int win_gravity; /* one of the window gravity values */
- int backing_store; /* NotUseful, WhenMapped, Always */
- unsigned long backing_planes;/* planes to be preserved if possible */
- unsigned long backing_pixel;/* value to be used when restoring planes */
- Bool save_under; /* boolean, should bits under be saved? */
- Colormap colormap; /* color map to be associated with window */
- Bool map_installed; /* boolean, is color map currently installed*/
- int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
- long all_event_masks; /* set of events all people have interest in*/
- long your_event_mask; /* my event mask */
- long do_not_propagate_mask; /* set of events that should not propagate */
- Bool override_redirect; /* boolean value for override-redirect */
- Screen *screen; /* back pointer to correct screen */
-} XWindowAttributes;
-
-/*
- * Data structure for host setting; getting routines.
- *
- */
-
-typedef struct {
- int family; /* for example FamilyInternet */
- int length; /* length of address, in bytes */
- char *address; /* pointer to where to find the bytes */
-} XHostAddress;
-
-/*
- * Data structure for ServerFamilyInterpreted addresses in host routines
- */
-typedef struct {
- int typelength; /* length of type string, in bytes */
- int valuelength; /* length of value string, in bytes */
- char *type; /* pointer to where to find the type string */
- char *value; /* pointer to where to find the address */
-} XServerInterpretedAddress;
-
-/*
- * Data structure for "image" data, used by image manipulation routines.
- */
-typedef struct _XImage {
- int width, height; /* size of image */
- int xoffset; /* number of pixels offset in X direction */
- int format; /* XYBitmap, XYPixmap, ZPixmap */
- char *data; /* pointer to image data */
- int byte_order; /* data byte order, LSBFirst, MSBFirst */
- int bitmap_unit; /* quant. of scanline 8, 16, 32 */
- int bitmap_bit_order; /* LSBFirst, MSBFirst */
- int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */
- int depth; /* depth of image */
- int bytes_per_line; /* accelarator to next line */
- int bits_per_pixel; /* bits per pixel (ZPixmap) */
- unsigned long red_mask; /* bits in z arrangment */
- unsigned long green_mask;
- unsigned long blue_mask;
- XPointer obdata; /* hook for the object routines to hang on */
- struct funcs { /* image manipulation routines */
- struct _XImage *(*create_image)(
- struct _XDisplay* /* display */,
- Visual* /* visual */,
- unsigned int /* depth */,
- int /* format */,
- int /* offset */,
- char* /* data */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* bitmap_pad */,
- int /* bytes_per_line */);
- int (*destroy_image) (struct _XImage *);
- unsigned long (*get_pixel) (struct _XImage *, int, int);
- int (*put_pixel) (struct _XImage *, int, int, unsigned long);
- struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int);
- int (*add_pixel) (struct _XImage *, long);
- } f;
-} XImage;
-
-/*
- * Data structure for XReconfigureWindow
- */
-typedef struct {
- int x, y;
- int width, height;
- int border_width;
- Window sibling;
- int stack_mode;
-} XWindowChanges;
-
-/*
- * Data structure used by color operations
- */
-typedef struct {
- unsigned long pixel;
- unsigned short red, green, blue;
- char flags; /* do_red, do_green, do_blue */
- char pad;
-} XColor;
-
-/*
- * Data structures for graphics operations. On most machines, these are
- * congruent with the wire protocol structures, so reformatting the data
- * can be avoided on these architectures.
- */
-typedef struct {
- short x1, y1, x2, y2;
-} XSegment;
-
-typedef struct {
- short x, y;
-} XPoint;
-
-typedef struct {
- short x, y;
- unsigned short width, height;
-} XRectangle;
-
-typedef struct {
- short x, y;
- unsigned short width, height;
- short angle1, angle2;
-} XArc;
-
-
-/* Data structure for XChangeKeyboardControl */
-
-typedef struct {
- int key_click_percent;
- int bell_percent;
- int bell_pitch;
- int bell_duration;
- int led;
- int led_mode;
- int key;
- int auto_repeat_mode; /* On, Off, Default */
-} XKeyboardControl;
-
-/* Data structure for XGetKeyboardControl */
-
-typedef struct {
- int key_click_percent;
- int bell_percent;
- unsigned int bell_pitch, bell_duration;
- unsigned long led_mask;
- int global_auto_repeat;
- char auto_repeats[32];
-} XKeyboardState;
-
-/* Data structure for XGetMotionEvents. */
-
-typedef struct {
- Time time;
- short x, y;
-} XTimeCoord;
-
-/* Data structure for X{Set,Get}ModifierMapping */
-
-typedef struct {
- int max_keypermod; /* The server's max # of keys per modifier */
- KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */
-} XModifierKeymap;
-
-
-/*
- * Display datatype maintaining display specific data.
- * The contents of this structure are implementation dependent.
- * A Display should be treated as opaque by application code.
- */
-#ifndef XLIB_ILLEGAL_ACCESS
-typedef struct _XDisplay Display;
-#endif
-
-struct _XPrivate; /* Forward declare before use for C++ */
-struct _XrmHashBucketRec;
-
-typedef struct
-#ifdef XLIB_ILLEGAL_ACCESS
-_XDisplay
-#endif
-{
- XExtData *ext_data; /* hook for extension to hang data */
- struct _XPrivate *private1;
- int fd; /* Network socket. */
- int private2;
- int proto_major_version;/* major version of server's X protocol */
- int proto_minor_version;/* minor version of servers X protocol */
- char *vendor; /* vendor of the server hardware */
- XID private3;
- XID private4;
- XID private5;
- int private6;
- XID (*resource_alloc)( /* allocator function */
- struct _XDisplay*
- );
- int byte_order; /* screen byte order, LSBFirst, MSBFirst */
- int bitmap_unit; /* padding and data requirements */
- int bitmap_pad; /* padding requirements on bitmaps */
- int bitmap_bit_order; /* LeastSignificant or MostSignificant */
- int nformats; /* number of pixmap formats in list */
- ScreenFormat *pixmap_format; /* pixmap format list */
- int private8;
- int release; /* release of the server */
- struct _XPrivate *private9, *private10;
- int qlen; /* Length of input event queue */
- unsigned long last_request_read; /* seq number of last event read */
- unsigned long request; /* sequence number of last request. */
- XPointer private11;
- XPointer private12;
- XPointer private13;
- XPointer private14;
- unsigned max_request_size; /* maximum number 32 bit words in request*/
- struct _XrmHashBucketRec *db;
- int (*private15)(
- struct _XDisplay*
- );
- char *display_name; /* "host:display" string used on this connect*/
- int default_screen; /* default screen for operations */
- int nscreens; /* number of screens on this server*/
- Screen *screens; /* pointer to list of screens */
- unsigned long motion_buffer; /* size of motion buffer */
- unsigned long private16;
- int min_keycode; /* minimum defined keycode */
- int max_keycode; /* maximum defined keycode */
- XPointer private17;
- XPointer private18;
- int private19;
- char *xdefaults; /* contents of defaults from server */
- /* there is more to this structure, but it is private to Xlib */
-}
-#ifdef XLIB_ILLEGAL_ACCESS
-Display,
-#endif
-*_XPrivDisplay;
-
-#undef _XEVENT_
-#ifndef _XEVENT_
-/*
- * Definitions of specific events.
- */
-typedef struct {
- int type; /* of event */
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* "event" window it is reported relative to */
- Window root; /* root window that the event occurred on */
- Window subwindow; /* child window */
- Time time; /* milliseconds */
- int x, y; /* pointer x, y coordinates in event window */
- int x_root, y_root; /* coordinates relative to root */
- unsigned int state; /* key or button mask */
- unsigned int keycode; /* detail */
- Bool same_screen; /* same screen flag */
-} XKeyEvent;
-typedef XKeyEvent XKeyPressedEvent;
-typedef XKeyEvent XKeyReleasedEvent;
-
-typedef struct {
- int type; /* of event */
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* "event" window it is reported relative to */
- Window root; /* root window that the event occurred on */
- Window subwindow; /* child window */
- Time time; /* milliseconds */
- int x, y; /* pointer x, y coordinates in event window */
- int x_root, y_root; /* coordinates relative to root */
- unsigned int state; /* key or button mask */
- unsigned int button; /* detail */
- Bool same_screen; /* same screen flag */
-} XButtonEvent;
-typedef XButtonEvent XButtonPressedEvent;
-typedef XButtonEvent XButtonReleasedEvent;
-
-typedef struct {
- int type; /* of event */
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* "event" window reported relative to */
- Window root; /* root window that the event occurred on */
- Window subwindow; /* child window */
- Time time; /* milliseconds */
- int x, y; /* pointer x, y coordinates in event window */
- int x_root, y_root; /* coordinates relative to root */
- unsigned int state; /* key or button mask */
- char is_hint; /* detail */
- Bool same_screen; /* same screen flag */
-} XMotionEvent;
-typedef XMotionEvent XPointerMovedEvent;
-
-typedef struct {
- int type; /* of event */
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* "event" window reported relative to */
- Window root; /* root window that the event occurred on */
- Window subwindow; /* child window */
- Time time; /* milliseconds */
- int x, y; /* pointer x, y coordinates in event window */
- int x_root, y_root; /* coordinates relative to root */
- int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
- int detail;
- /*
- * NotifyAncestor, NotifyVirtual, NotifyInferior,
- * NotifyNonlinear,NotifyNonlinearVirtual
- */
- Bool same_screen; /* same screen flag */
- Bool focus; /* boolean focus */
- unsigned int state; /* key or button mask */
-} XCrossingEvent;
-typedef XCrossingEvent XEnterWindowEvent;
-typedef XCrossingEvent XLeaveWindowEvent;
-
-typedef struct {
- int type; /* FocusIn or FocusOut */
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* window of event */
- int mode; /* NotifyNormal, NotifyWhileGrabbed,
- NotifyGrab, NotifyUngrab */
- int detail;
- /*
- * NotifyAncestor, NotifyVirtual, NotifyInferior,
- * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
- * NotifyPointerRoot, NotifyDetailNone
- */
-} XFocusChangeEvent;
-typedef XFocusChangeEvent XFocusInEvent;
-typedef XFocusChangeEvent XFocusOutEvent;
-
-/* generated on EnterWindow and FocusIn when KeyMapState selected */
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- char key_vector[32];
-} XKeymapEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- int x, y;
- int width, height;
- int count; /* if non-zero, at least this many more */
-} XExposeEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Drawable drawable;
- int x, y;
- int width, height;
- int count; /* if non-zero, at least this many more */
- int major_code; /* core is CopyArea or CopyPlane */
- int minor_code; /* not defined in the core */
-} XGraphicsExposeEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Drawable drawable;
- int major_code; /* core is CopyArea or CopyPlane */
- int minor_code; /* not defined in the core */
-} XNoExposeEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- int state; /* Visibility state */
-} XVisibilityEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window parent; /* parent of the window */
- Window window; /* window id of window created */
- int x, y; /* window location */
- int width, height; /* size of window */
- int border_width; /* border width */
- Bool override_redirect; /* creation should be overridden */
-} XCreateWindowEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
-} XDestroyWindowEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- Bool from_configure;
-} XUnmapEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- Bool override_redirect; /* boolean, is override set... */
-} XMapEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window parent;
- Window window;
-} XMapRequestEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- Window parent;
- int x, y;
- Bool override_redirect;
-} XReparentEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- int x, y;
- int width, height;
- int border_width;
- Window above;
- Bool override_redirect;
-} XConfigureEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- int x, y;
-} XGravityEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- int width, height;
-} XResizeRequestEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window parent;
- Window window;
- int x, y;
- int width, height;
- int border_width;
- Window above;
- int detail; /* Above, Below, TopIf, BottomIf, Opposite */
- unsigned long value_mask;
-} XConfigureRequestEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event;
- Window window;
- int place; /* PlaceOnTop, PlaceOnBottom */
-} XCirculateEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window parent;
- Window window;
- int place; /* PlaceOnTop, PlaceOnBottom */
-} XCirculateRequestEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- Atom atom;
- Time time;
- int state; /* NewValue, Deleted */
-} XPropertyEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- Atom selection;
- Time time;
-} XSelectionClearEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window owner;
- Window requestor;
- Atom selection;
- Atom target;
- Atom property;
- Time time;
-} XSelectionRequestEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window requestor;
- Atom selection;
- Atom target;
- Atom property; /* ATOM or None */
- Time time;
-} XSelectionEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- Colormap colormap; /* COLORMAP or None */
-#if defined(__cplusplus) || defined(c_plusplus)
- Bool c_new; /* C++ */
-#else
- Bool new;
-#endif
- int state; /* ColormapInstalled, ColormapUninstalled */
-} XColormapEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window;
- Atom message_type;
- int format;
- union {
- char b[20];
- short s[10];
- long l[5];
- } data;
-} XClientMessageEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* unused */
- int request; /* one of MappingModifier, MappingKeyboard,
- MappingPointer */
- int first_keycode; /* first keycode */
- int count; /* defines range of change w. first_keycode*/
-} XMappingEvent;
-
-typedef struct {
- int type;
- Display *display; /* Display the event was read from */
- XID resourceid; /* resource id */
- unsigned long serial; /* serial number of failed request */
- unsigned char error_code; /* error code of failed request */
- unsigned char request_code; /* Major op-code of failed request */
- unsigned char minor_code; /* Minor op-code of failed request */
-} XErrorEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* true if this came from a SendEvent request */
- Display *display;/* Display the event was read from */
- Window window; /* window on which event was requested in event mask */
-} XAnyEvent;
-
-
-/***************************************************************
- *
- * GenericEvent. This event is the standard event for all newer extensions.
- */
-
-typedef struct
- {
- int type; /* of event. Always GenericEvent */
- unsigned long serial; /* # of last request processed */
- Bool send_event; /* true if from SendEvent request */
- Display *display; /* Display the event was read from */
- int extension; /* major opcode of extension that caused the event */
- int evtype; /* actual event type. */
- } XGenericEvent;
-
-typedef struct {
- int type; /* of event. Always GenericEvent */
- unsigned long serial; /* # of last request processed */
- Bool send_event; /* true if from SendEvent request */
- Display *display; /* Display the event was read from */
- int extension; /* major opcode of extension that caused the event */
- int evtype; /* actual event type. */
- unsigned int cookie;
- void *data;
-} XGenericEventCookie;
-
-/*
- * this union is defined so Xlib can always use the same sized
- * event structure internally, to avoid memory fragmentation.
- */
-typedef union _XEvent {
- int type; /* must not be changed; first element */
- XAnyEvent xany;
- XKeyEvent xkey;
- XButtonEvent xbutton;
- XMotionEvent xmotion;
- XCrossingEvent xcrossing;
- XFocusChangeEvent xfocus;
- XExposeEvent xexpose;
- XGraphicsExposeEvent xgraphicsexpose;
- XNoExposeEvent xnoexpose;
- XVisibilityEvent xvisibility;
- XCreateWindowEvent xcreatewindow;
- XDestroyWindowEvent xdestroywindow;
- XUnmapEvent xunmap;
- XMapEvent xmap;
- XMapRequestEvent xmaprequest;
- XReparentEvent xreparent;
- XConfigureEvent xconfigure;
- XGravityEvent xgravity;
- XResizeRequestEvent xresizerequest;
- XConfigureRequestEvent xconfigurerequest;
- XCirculateEvent xcirculate;
- XCirculateRequestEvent xcirculaterequest;
- XPropertyEvent xproperty;
- XSelectionClearEvent xselectionclear;
- XSelectionRequestEvent xselectionrequest;
- XSelectionEvent xselection;
- XColormapEvent xcolormap;
- XClientMessageEvent xclient;
- XMappingEvent xmapping;
- XErrorEvent xerror;
- XKeymapEvent xkeymap;
- XGenericEvent xgeneric;
- XGenericEventCookie xcookie;
- long pad[24];
-} XEvent;
-#endif
-
-#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy)))
-
-/*
- * per character font metric information.
- */
-typedef struct {
- short lbearing; /* origin to left edge of raster */
- short rbearing; /* origin to right edge of raster */
- short width; /* advance to next char's origin */
- short ascent; /* baseline to top edge of raster */
- short descent; /* baseline to bottom edge of raster */
- unsigned short attributes; /* per char flags (not predefined) */
-} XCharStruct;
-
-/*
- * To allow arbitrary information with fonts, there are additional properties
- * returned.
- */
-typedef struct {
- Atom name;
- unsigned long card32;
-} XFontProp;
-
-typedef struct {
- XExtData *ext_data; /* hook for extension to hang data */
- Font fid; /* Font id for this font */
- unsigned direction; /* hint about direction the font is painted */
- unsigned min_char_or_byte2;/* first character */
- unsigned max_char_or_byte2;/* last character */
- unsigned min_byte1; /* first row that exists */
- unsigned max_byte1; /* last row that exists */
- Bool all_chars_exist;/* flag if all characters have non-zero size*/
- unsigned default_char; /* char to print for undefined character */
- int n_properties; /* how many properties there are */
- XFontProp *properties; /* pointer to array of additional properties*/
- XCharStruct min_bounds; /* minimum bounds over all existing char*/
- XCharStruct max_bounds; /* maximum bounds over all existing char*/
- XCharStruct *per_char; /* first_char to last_char information */
- int ascent; /* log. extent above baseline for spacing */
- int descent; /* log. descent below baseline for spacing */
-} XFontStruct;
-
-/*
- * PolyText routines take these as arguments.
- */
-typedef struct {
- char *chars; /* pointer to string */
- int nchars; /* number of characters */
- int delta; /* delta between strings */
- Font font; /* font to print it in, None don't change */
-} XTextItem;
-
-typedef struct { /* normal 16 bit characters are two bytes */
- unsigned char byte1;
- unsigned char byte2;
-} XChar2b;
-
-typedef struct {
- XChar2b *chars; /* two byte characters */
- int nchars; /* number of characters */
- int delta; /* delta between strings */
- Font font; /* font to print it in, None don't change */
-} XTextItem16;
-
-
-typedef union { Display *display;
- GC gc;
- Visual *visual;
- Screen *screen;
- ScreenFormat *pixmap_format;
- XFontStruct *font; } XEDataObject;
-
-typedef struct {
- XRectangle max_ink_extent;
- XRectangle max_logical_extent;
-} XFontSetExtents;
-
-/* unused:
-typedef void (*XOMProc)();
- */
-
-typedef struct _XOM *XOM;
-typedef struct _XOC *XOC, *XFontSet;
-
-typedef struct {
- char *chars;
- int nchars;
- int delta;
- XFontSet font_set;
-} XmbTextItem;
-
-typedef struct {
- wchar_t *chars;
- int nchars;
- int delta;
- XFontSet font_set;
-} XwcTextItem;
-
-#define XNRequiredCharSet "requiredCharSet"
-#define XNQueryOrientation "queryOrientation"
-#define XNBaseFontName "baseFontName"
-#define XNOMAutomatic "omAutomatic"
-#define XNMissingCharSet "missingCharSet"
-#define XNDefaultString "defaultString"
-#define XNOrientation "orientation"
-#define XNDirectionalDependentDrawing "directionalDependentDrawing"
-#define XNContextualDrawing "contextualDrawing"
-#define XNFontInfo "fontInfo"
-
-typedef struct {
- int charset_count;
- char **charset_list;
-} XOMCharSetList;
-
-typedef enum {
- XOMOrientation_LTR_TTB,
- XOMOrientation_RTL_TTB,
- XOMOrientation_TTB_LTR,
- XOMOrientation_TTB_RTL,
- XOMOrientation_Context
-} XOrientation;
-
-typedef struct {
- int num_orientation;
- XOrientation *orientation; /* Input Text description */
-} XOMOrientation;
-
-typedef struct {
- int num_font;
- XFontStruct **font_struct_list;
- char **font_name_list;
-} XOMFontInfo;
-
-typedef struct _XIM *XIM;
-typedef struct _XIC *XIC;
-
-typedef void (*XIMProc)(
- XIM,
- XPointer,
- XPointer
-);
-
-typedef Bool (*XICProc)(
- XIC,
- XPointer,
- XPointer
-);
-
-typedef void (*XIDProc)(
- Display*,
- XPointer,
- XPointer
-);
-
-typedef unsigned long XIMStyle;
-
-typedef struct {
- unsigned short count_styles;
- XIMStyle *supported_styles;
-} XIMStyles;
-
-#define XIMPreeditArea 0x0001L
-#define XIMPreeditCallbacks 0x0002L
-#define XIMPreeditPosition 0x0004L
-#define XIMPreeditNothing 0x0008L
-#define XIMPreeditNone 0x0010L
-#define XIMStatusArea 0x0100L
-#define XIMStatusCallbacks 0x0200L
-#define XIMStatusNothing 0x0400L
-#define XIMStatusNone 0x0800L
-
-#define XNVaNestedList "XNVaNestedList"
-#define XNQueryInputStyle "queryInputStyle"
-#define XNClientWindow "clientWindow"
-#define XNInputStyle "inputStyle"
-#define XNFocusWindow "focusWindow"
-#define XNResourceName "resourceName"
-#define XNResourceClass "resourceClass"
-#define XNGeometryCallback "geometryCallback"
-#define XNDestroyCallback "destroyCallback"
-#define XNFilterEvents "filterEvents"
-#define XNPreeditStartCallback "preeditStartCallback"
-#define XNPreeditDoneCallback "preeditDoneCallback"
-#define XNPreeditDrawCallback "preeditDrawCallback"
-#define XNPreeditCaretCallback "preeditCaretCallback"
-#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback"
-#define XNPreeditAttributes "preeditAttributes"
-#define XNStatusStartCallback "statusStartCallback"
-#define XNStatusDoneCallback "statusDoneCallback"
-#define XNStatusDrawCallback "statusDrawCallback"
-#define XNStatusAttributes "statusAttributes"
-#define XNArea "area"
-#define XNAreaNeeded "areaNeeded"
-#define XNSpotLocation "spotLocation"
-#define XNColormap "colorMap"
-#define XNStdColormap "stdColorMap"
-#define XNForeground "foreground"
-#define XNBackground "background"
-#define XNBackgroundPixmap "backgroundPixmap"
-#define XNFontSet "fontSet"
-#define XNLineSpace "lineSpace"
-#define XNCursor "cursor"
-
-#define XNQueryIMValuesList "queryIMValuesList"
-#define XNQueryICValuesList "queryICValuesList"
-#define XNVisiblePosition "visiblePosition"
-#define XNR6PreeditCallback "r6PreeditCallback"
-#define XNStringConversionCallback "stringConversionCallback"
-#define XNStringConversion "stringConversion"
-#define XNResetState "resetState"
-#define XNHotKey "hotKey"
-#define XNHotKeyState "hotKeyState"
-#define XNPreeditState "preeditState"
-#define XNSeparatorofNestedList "separatorofNestedList"
-
-#define XBufferOverflow -1
-#define XLookupNone 1
-#define XLookupChars 2
-#define XLookupKeySym 3
-#define XLookupBoth 4
-
-typedef void *XVaNestedList;
-
-typedef struct {
- XPointer client_data;
- XIMProc callback;
-} XIMCallback;
-
-typedef struct {
- XPointer client_data;
- XICProc callback;
-} XICCallback;
-
-typedef unsigned long XIMFeedback;
-
-#define XIMReverse 1L
-#define XIMUnderline (1L<<1)
-#define XIMHighlight (1L<<2)
-#define XIMPrimary (1L<<5)
-#define XIMSecondary (1L<<6)
-#define XIMTertiary (1L<<7)
-#define XIMVisibleToForward (1L<<8)
-#define XIMVisibleToBackword (1L<<9)
-#define XIMVisibleToCenter (1L<<10)
-
-typedef struct _XIMText {
- unsigned short length;
- XIMFeedback *feedback;
- Bool encoding_is_wchar;
- union {
- char *multi_byte;
- wchar_t *wide_char;
- } string;
-} XIMText;
-
-typedef unsigned long XIMPreeditState;
-
-#define XIMPreeditUnKnown 0L
-#define XIMPreeditEnable 1L
-#define XIMPreeditDisable (1L<<1)
-
-typedef struct _XIMPreeditStateNotifyCallbackStruct {
- XIMPreeditState state;
-} XIMPreeditStateNotifyCallbackStruct;
-
-typedef unsigned long XIMResetState;
-
-#define XIMInitialState 1L
-#define XIMPreserveState (1L<<1)
-
-typedef unsigned long XIMStringConversionFeedback;
-
-#define XIMStringConversionLeftEdge (0x00000001)
-#define XIMStringConversionRightEdge (0x00000002)
-#define XIMStringConversionTopEdge (0x00000004)
-#define XIMStringConversionBottomEdge (0x00000008)
-#define XIMStringConversionConcealed (0x00000010)
-#define XIMStringConversionWrapped (0x00000020)
-
-typedef struct _XIMStringConversionText {
- unsigned short length;
- XIMStringConversionFeedback *feedback;
- Bool encoding_is_wchar;
- union {
- char *mbs;
- wchar_t *wcs;
- } string;
-} XIMStringConversionText;
-
-typedef unsigned short XIMStringConversionPosition;
-
-typedef unsigned short XIMStringConversionType;
-
-#define XIMStringConversionBuffer (0x0001)
-#define XIMStringConversionLine (0x0002)
-#define XIMStringConversionWord (0x0003)
-#define XIMStringConversionChar (0x0004)
-
-typedef unsigned short XIMStringConversionOperation;
-
-#define XIMStringConversionSubstitution (0x0001)
-#define XIMStringConversionRetrieval (0x0002)
-
-typedef enum {
- XIMForwardChar, XIMBackwardChar,
- XIMForwardWord, XIMBackwardWord,
- XIMCaretUp, XIMCaretDown,
- XIMNextLine, XIMPreviousLine,
- XIMLineStart, XIMLineEnd,
- XIMAbsolutePosition,
- XIMDontChange
-} XIMCaretDirection;
-
-typedef struct _XIMStringConversionCallbackStruct {
- XIMStringConversionPosition position;
- XIMCaretDirection direction;
- XIMStringConversionOperation operation;
- unsigned short factor;
- XIMStringConversionText *text;
-} XIMStringConversionCallbackStruct;
-
-typedef struct _XIMPreeditDrawCallbackStruct {
- int caret; /* Cursor offset within pre-edit string */
- int chg_first; /* Starting change position */
- int chg_length; /* Length of the change in character count */
- XIMText *text;
-} XIMPreeditDrawCallbackStruct;
-
-typedef enum {
- XIMIsInvisible, /* Disable caret feedback */
- XIMIsPrimary, /* UI defined caret feedback */
- XIMIsSecondary /* UI defined caret feedback */
-} XIMCaretStyle;
-
-typedef struct _XIMPreeditCaretCallbackStruct {
- int position; /* Caret offset within pre-edit string */
- XIMCaretDirection direction; /* Caret moves direction */
- XIMCaretStyle style; /* Feedback of the caret */
-} XIMPreeditCaretCallbackStruct;
-
-typedef enum {
- XIMTextType,
- XIMBitmapType
-} XIMStatusDataType;
-
-typedef struct _XIMStatusDrawCallbackStruct {
- XIMStatusDataType type;
- union {
- XIMText *text;
- Pixmap bitmap;
- } data;
-} XIMStatusDrawCallbackStruct;
-
-typedef struct _XIMHotKeyTrigger {
- KeySym keysym;
- int modifier;
- int modifier_mask;
-} XIMHotKeyTrigger;
-
-typedef struct _XIMHotKeyTriggers {
- int num_hot_key;
- XIMHotKeyTrigger *key;
-} XIMHotKeyTriggers;
-
-typedef unsigned long XIMHotKeyState;
-
-#define XIMHotKeyStateON (0x0001L)
-#define XIMHotKeyStateOFF (0x0002L)
-
-typedef struct {
- unsigned short count_values;
- char **supported_values;
-} XIMValuesList;
-
-_XFUNCPROTOBEGIN
-
-#if defined(WIN32) && !defined(_XLIBINT_)
-#define _Xdebug (*_Xdebug_p)
-#endif
-
-extern int _Xdebug;
-
-extern XFontStruct *XLoadQueryFont(
- Display* /* display */,
- _Xconst char* /* name */
-);
-
-extern XFontStruct *XQueryFont(
- Display* /* display */,
- XID /* font_ID */
-);
-
-
-extern XTimeCoord *XGetMotionEvents(
- Display* /* display */,
- Window /* w */,
- Time /* start */,
- Time /* stop */,
- int* /* nevents_return */
-);
-
-extern XModifierKeymap *XDeleteModifiermapEntry(
- XModifierKeymap* /* modmap */,
-#if NeedWidePrototypes
- unsigned int /* keycode_entry */,
-#else
- KeyCode /* keycode_entry */,
-#endif
- int /* modifier */
-);
-
-extern XModifierKeymap *XGetModifierMapping(
- Display* /* display */
-);
-
-extern XModifierKeymap *XInsertModifiermapEntry(
- XModifierKeymap* /* modmap */,
-#if NeedWidePrototypes
- unsigned int /* keycode_entry */,
-#else
- KeyCode /* keycode_entry */,
-#endif
- int /* modifier */
-);
-
-extern XModifierKeymap *XNewModifiermap(
- int /* max_keys_per_mod */
-);
-
-extern XImage *XCreateImage(
- Display* /* display */,
- Visual* /* visual */,
- unsigned int /* depth */,
- int /* format */,
- int /* offset */,
- char* /* data */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* bitmap_pad */,
- int /* bytes_per_line */
-);
-extern Status XInitImage(
- XImage* /* image */
-);
-extern XImage *XGetImage(
- Display* /* display */,
- Drawable /* d */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned long /* plane_mask */,
- int /* format */
-);
-extern XImage *XGetSubImage(
- Display* /* display */,
- Drawable /* d */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned long /* plane_mask */,
- int /* format */,
- XImage* /* dest_image */,
- int /* dest_x */,
- int /* dest_y */
-);
-
-/*
- * X function declarations.
- */
-extern Display *XOpenDisplay(
- _Xconst char* /* display_name */
-);
-
-extern void XrmInitialize(
- void
-);
-
-extern char *XFetchBytes(
- Display* /* display */,
- int* /* nbytes_return */
-);
-extern char *XFetchBuffer(
- Display* /* display */,
- int* /* nbytes_return */,
- int /* buffer */
-);
-extern char *XGetAtomName(
- Display* /* display */,
- Atom /* atom */
-);
-extern Status XGetAtomNames(
- Display* /* dpy */,
- Atom* /* atoms */,
- int /* count */,
- char** /* names_return */
-);
-extern char *XGetDefault(
- Display* /* display */,
- _Xconst char* /* program */,
- _Xconst char* /* option */
-);
-extern char *XDisplayName(
- _Xconst char* /* string */
-);
-extern char *XKeysymToString(
- KeySym /* keysym */
-);
-
-extern int (*XSynchronize(
- Display* /* display */,
- Bool /* onoff */
-))(
- Display* /* display */
-);
-extern int (*XSetAfterFunction(
- Display* /* display */,
- int (*) (
- Display* /* display */
- ) /* procedure */
-))(
- Display* /* display */
-);
-extern Atom XInternAtom(
- Display* /* display */,
- _Xconst char* /* atom_name */,
- Bool /* only_if_exists */
-);
-extern Status XInternAtoms(
- Display* /* dpy */,
- _Xconst char** /* names */,
- int /* count */,
- Bool /* onlyIfExists */,
- Atom* /* atoms_return */
-);
-extern Colormap XCopyColormapAndFree(
- Display* /* display */,
- Colormap /* colormap */
-);
-extern Colormap XCreateColormap(
- Display* /* display */,
- Window /* w */,
- Visual* /* visual */,
- int /* alloc */
-);
-extern Cursor XCreatePixmapCursor(
- Display* /* display */,
- Pixmap /* source */,
- Pixmap /* mask */,
- XColor* /* foreground_color */,
- XColor* /* background_color */,
- unsigned int /* x */,
- unsigned int /* y */
-);
-extern Cursor XCreateGlyphCursor(
- Display* /* display */,
- Font /* source_font */,
- Font /* mask_font */,
- unsigned int /* source_char */,
- unsigned int /* mask_char */,
- XColor _Xconst * /* foreground_color */,
- XColor _Xconst * /* background_color */
-);
-extern Cursor XCreateFontCursor(
- Display* /* display */,
- unsigned int /* shape */
-);
-extern Font XLoadFont(
- Display* /* display */,
- _Xconst char* /* name */
-);
-extern GC XCreateGC(
- Display* /* display */,
- Drawable /* d */,
- unsigned long /* valuemask */,
- XGCValues* /* values */
-);
-extern GContext XGContextFromGC(
- GC /* gc */
-);
-extern void XFlushGC(
- Display* /* display */,
- GC /* gc */
-);
-extern Pixmap XCreatePixmap(
- Display* /* display */,
- Drawable /* d */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int /* depth */
-);
-extern Pixmap XCreateBitmapFromData(
- Display* /* display */,
- Drawable /* d */,
- _Xconst char* /* data */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-extern Pixmap XCreatePixmapFromBitmapData(
- Display* /* display */,
- Drawable /* d */,
- char* /* data */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned long /* fg */,
- unsigned long /* bg */,
- unsigned int /* depth */
-);
-extern Window XCreateSimpleWindow(
- Display* /* display */,
- Window /* parent */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int /* border_width */,
- unsigned long /* border */,
- unsigned long /* background */
-);
-extern Window XGetSelectionOwner(
- Display* /* display */,
- Atom /* selection */
-);
-extern Window XCreateWindow(
- Display* /* display */,
- Window /* parent */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int /* border_width */,
- int /* depth */,
- unsigned int /* class */,
- Visual* /* visual */,
- unsigned long /* valuemask */,
- XSetWindowAttributes* /* attributes */
-);
-extern Colormap *XListInstalledColormaps(
- Display* /* display */,
- Window /* w */,
- int* /* num_return */
-);
-extern char **XListFonts(
- Display* /* display */,
- _Xconst char* /* pattern */,
- int /* maxnames */,
- int* /* actual_count_return */
-);
-extern char **XListFontsWithInfo(
- Display* /* display */,
- _Xconst char* /* pattern */,
- int /* maxnames */,
- int* /* count_return */,
- XFontStruct** /* info_return */
-);
-extern char **XGetFontPath(
- Display* /* display */,
- int* /* npaths_return */
-);
-extern char **XListExtensions(
- Display* /* display */,
- int* /* nextensions_return */
-);
-extern Atom *XListProperties(
- Display* /* display */,
- Window /* w */,
- int* /* num_prop_return */
-);
-extern XHostAddress *XListHosts(
- Display* /* display */,
- int* /* nhosts_return */,
- Bool* /* state_return */
-);
-extern KeySym XKeycodeToKeysym(
- Display* /* display */,
-#if NeedWidePrototypes
- unsigned int /* keycode */,
-#else
- KeyCode /* keycode */,
-#endif
- int /* index */
-);
-extern KeySym XLookupKeysym(
- XKeyEvent* /* key_event */,
- int /* index */
-);
-extern KeySym *XGetKeyboardMapping(
- Display* /* display */,
-#if NeedWidePrototypes
- unsigned int /* first_keycode */,
-#else
- KeyCode /* first_keycode */,
-#endif
- int /* keycode_count */,
- int* /* keysyms_per_keycode_return */
-);
-extern KeySym XStringToKeysym(
- _Xconst char* /* string */
-);
-extern long XMaxRequestSize(
- Display* /* display */
-);
-extern long XExtendedMaxRequestSize(
- Display* /* display */
-);
-extern char *XResourceManagerString(
- Display* /* display */
-);
-extern char *XScreenResourceString(
- Screen* /* screen */
-);
-extern unsigned long XDisplayMotionBufferSize(
- Display* /* display */
-);
-extern VisualID XVisualIDFromVisual(
- Visual* /* visual */
-);
-
-/* multithread routines */
-
-extern Status XInitThreads(
- void
-);
-
-extern void XLockDisplay(
- Display* /* display */
-);
-
-extern void XUnlockDisplay(
- Display* /* display */
-);
-
-/* routines for dealing with extensions */
-
-extern XExtCodes *XInitExtension(
- Display* /* display */,
- _Xconst char* /* name */
-);
-
-extern XExtCodes *XAddExtension(
- Display* /* display */
-);
-extern XExtData *XFindOnExtensionList(
- XExtData** /* structure */,
- int /* number */
-);
-extern XExtData **XEHeadOfExtensionList(
- XEDataObject /* object */
-);
-
-/* these are routines for which there are also macros */
-extern Window XRootWindow(
- Display* /* display */,
- int /* screen_number */
-);
-extern Window XDefaultRootWindow(
- Display* /* display */
-);
-extern Window XRootWindowOfScreen(
- Screen* /* screen */
-);
-extern Visual *XDefaultVisual(
- Display* /* display */,
- int /* screen_number */
-);
-extern Visual *XDefaultVisualOfScreen(
- Screen* /* screen */
-);
-extern GC XDefaultGC(
- Display* /* display */,
- int /* screen_number */
-);
-extern GC XDefaultGCOfScreen(
- Screen* /* screen */
-);
-extern unsigned long XBlackPixel(
- Display* /* display */,
- int /* screen_number */
-);
-extern unsigned long XWhitePixel(
- Display* /* display */,
- int /* screen_number */
-);
-extern unsigned long XAllPlanes(
- void
-);
-extern unsigned long XBlackPixelOfScreen(
- Screen* /* screen */
-);
-extern unsigned long XWhitePixelOfScreen(
- Screen* /* screen */
-);
-extern unsigned long XNextRequest(
- Display* /* display */
-);
-extern unsigned long XLastKnownRequestProcessed(
- Display* /* display */
-);
-extern char *XServerVendor(
- Display* /* display */
-);
-extern char *XDisplayString(
- Display* /* display */
-);
-extern Colormap XDefaultColormap(
- Display* /* display */,
- int /* screen_number */
-);
-extern Colormap XDefaultColormapOfScreen(
- Screen* /* screen */
-);
-extern Display *XDisplayOfScreen(
- Screen* /* screen */
-);
-extern Screen *XScreenOfDisplay(
- Display* /* display */,
- int /* screen_number */
-);
-extern Screen *XDefaultScreenOfDisplay(
- Display* /* display */
-);
-extern long XEventMaskOfScreen(
- Screen* /* screen */
-);
-
-extern int XScreenNumberOfScreen(
- Screen* /* screen */
-);
-
-typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */
- Display* /* display */,
- XErrorEvent* /* error_event */
-);
-
-extern XErrorHandler XSetErrorHandler (
- XErrorHandler /* handler */
-);
-
-
-typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */
- Display* /* display */
-);
-
-extern XIOErrorHandler XSetIOErrorHandler (
- XIOErrorHandler /* handler */
-);
-
-
-extern XPixmapFormatValues *XListPixmapFormats(
- Display* /* display */,
- int* /* count_return */
-);
-extern int *XListDepths(
- Display* /* display */,
- int /* screen_number */,
- int* /* count_return */
-);
-
-/* ICCCM routines for things that don't require special include files; */
-/* other declarations are given in Xutil.h */
-extern Status XReconfigureWMWindow(
- Display* /* display */,
- Window /* w */,
- int /* screen_number */,
- unsigned int /* mask */,
- XWindowChanges* /* changes */
-);
-
-extern Status XGetWMProtocols(
- Display* /* display */,
- Window /* w */,
- Atom** /* protocols_return */,
- int* /* count_return */
-);
-extern Status XSetWMProtocols(
- Display* /* display */,
- Window /* w */,
- Atom* /* protocols */,
- int /* count */
-);
-extern Status XIconifyWindow(
- Display* /* display */,
- Window /* w */,
- int /* screen_number */
-);
-extern Status XWithdrawWindow(
- Display* /* display */,
- Window /* w */,
- int /* screen_number */
-);
-extern Status XGetCommand(
- Display* /* display */,
- Window /* w */,
- char*** /* argv_return */,
- int* /* argc_return */
-);
-extern Status XGetWMColormapWindows(
- Display* /* display */,
- Window /* w */,
- Window** /* windows_return */,
- int* /* count_return */
-);
-extern Status XSetWMColormapWindows(
- Display* /* display */,
- Window /* w */,
- Window* /* colormap_windows */,
- int /* count */
-);
-extern void XFreeStringList(
- char** /* list */
-);
-extern int XSetTransientForHint(
- Display* /* display */,
- Window /* w */,
- Window /* prop_window */
-);
-
-/* The following are given in alphabetical order */
-
-extern int XActivateScreenSaver(
- Display* /* display */
-);
-
-extern int XAddHost(
- Display* /* display */,
- XHostAddress* /* host */
-);
-
-extern int XAddHosts(
- Display* /* display */,
- XHostAddress* /* hosts */,
- int /* num_hosts */
-);
-
-extern int XAddToExtensionList(
- struct _XExtData** /* structure */,
- XExtData* /* ext_data */
-);
-
-extern int XAddToSaveSet(
- Display* /* display */,
- Window /* w */
-);
-
-extern Status XAllocColor(
- Display* /* display */,
- Colormap /* colormap */,
- XColor* /* screen_in_out */
-);
-
-extern Status XAllocColorCells(
- Display* /* display */,
- Colormap /* colormap */,
- Bool /* contig */,
- unsigned long* /* plane_masks_return */,
- unsigned int /* nplanes */,
- unsigned long* /* pixels_return */,
- unsigned int /* npixels */
-);
-
-extern Status XAllocColorPlanes(
- Display* /* display */,
- Colormap /* colormap */,
- Bool /* contig */,
- unsigned long* /* pixels_return */,
- int /* ncolors */,
- int /* nreds */,
- int /* ngreens */,
- int /* nblues */,
- unsigned long* /* rmask_return */,
- unsigned long* /* gmask_return */,
- unsigned long* /* bmask_return */
-);
-
-extern Status XAllocNamedColor(
- Display* /* display */,
- Colormap /* colormap */,
- _Xconst char* /* color_name */,
- XColor* /* screen_def_return */,
- XColor* /* exact_def_return */
-);
-
-extern int XAllowEvents(
- Display* /* display */,
- int /* event_mode */,
- Time /* time */
-);
-
-extern int XAutoRepeatOff(
- Display* /* display */
-);
-
-extern int XAutoRepeatOn(
- Display* /* display */
-);
-
-extern int XBell(
- Display* /* display */,
- int /* percent */
-);
-
-extern int XBitmapBitOrder(
- Display* /* display */
-);
-
-extern int XBitmapPad(
- Display* /* display */
-);
-
-extern int XBitmapUnit(
- Display* /* display */
-);
-
-extern int XCellsOfScreen(
- Screen* /* screen */
-);
-
-extern int XChangeActivePointerGrab(
- Display* /* display */,
- unsigned int /* event_mask */,
- Cursor /* cursor */,
- Time /* time */
-);
-
-extern int XChangeGC(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* valuemask */,
- XGCValues* /* values */
-);
-
-extern int XChangeKeyboardControl(
- Display* /* display */,
- unsigned long /* value_mask */,
- XKeyboardControl* /* values */
-);
-
-extern int XChangeKeyboardMapping(
- Display* /* display */,
- int /* first_keycode */,
- int /* keysyms_per_keycode */,
- KeySym* /* keysyms */,
- int /* num_codes */
-);
-
-extern int XChangePointerControl(
- Display* /* display */,
- Bool /* do_accel */,
- Bool /* do_threshold */,
- int /* accel_numerator */,
- int /* accel_denominator */,
- int /* threshold */
-);
-
-extern int XChangeProperty(
- Display* /* display */,
- Window /* w */,
- Atom /* property */,
- Atom /* type */,
- int /* format */,
- int /* mode */,
- _Xconst unsigned char* /* data */,
- int /* nelements */
-);
-
-extern int XChangeSaveSet(
- Display* /* display */,
- Window /* w */,
- int /* change_mode */
-);
-
-extern int XChangeWindowAttributes(
- Display* /* display */,
- Window /* w */,
- unsigned long /* valuemask */,
- XSetWindowAttributes* /* attributes */
-);
-
-extern Bool XCheckIfEvent(
- Display* /* display */,
- XEvent* /* event_return */,
- Bool (*) (
- Display* /* display */,
- XEvent* /* event */,
- XPointer /* arg */
- ) /* predicate */,
- XPointer /* arg */
-);
-
-extern Bool XCheckMaskEvent(
- Display* /* display */,
- long /* event_mask */,
- XEvent* /* event_return */
-);
-
-extern Bool XCheckTypedEvent(
- Display* /* display */,
- int /* event_type */,
- XEvent* /* event_return */
-);
-
-extern Bool XCheckTypedWindowEvent(
- Display* /* display */,
- Window /* w */,
- int /* event_type */,
- XEvent* /* event_return */
-);
-
-extern Bool XCheckWindowEvent(
- Display* /* display */,
- Window /* w */,
- long /* event_mask */,
- XEvent* /* event_return */
-);
-
-extern int XCirculateSubwindows(
- Display* /* display */,
- Window /* w */,
- int /* direction */
-);
-
-extern int XCirculateSubwindowsDown(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XCirculateSubwindowsUp(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XClearArea(
- Display* /* display */,
- Window /* w */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- Bool /* exposures */
-);
-
-extern int XClearWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XCloseDisplay(
- Display* /* display */
-);
-
-extern int XConfigureWindow(
- Display* /* display */,
- Window /* w */,
- unsigned int /* value_mask */,
- XWindowChanges* /* values */
-);
-
-extern int XConnectionNumber(
- Display* /* display */
-);
-
-extern int XConvertSelection(
- Display* /* display */,
- Atom /* selection */,
- Atom /* target */,
- Atom /* property */,
- Window /* requestor */,
- Time /* time */
-);
-
-extern int XCopyArea(
- Display* /* display */,
- Drawable /* src */,
- Drawable /* dest */,
- GC /* gc */,
- int /* src_x */,
- int /* src_y */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* dest_x */,
- int /* dest_y */
-);
-
-extern int XCopyGC(
- Display* /* display */,
- GC /* src */,
- unsigned long /* valuemask */,
- GC /* dest */
-);
-
-extern int XCopyPlane(
- Display* /* display */,
- Drawable /* src */,
- Drawable /* dest */,
- GC /* gc */,
- int /* src_x */,
- int /* src_y */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* dest_x */,
- int /* dest_y */,
- unsigned long /* plane */
-);
-
-extern int XDefaultDepth(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDefaultDepthOfScreen(
- Screen* /* screen */
-);
-
-extern int XDefaultScreen(
- Display* /* display */
-);
-
-extern int XDefineCursor(
- Display* /* display */,
- Window /* w */,
- Cursor /* cursor */
-);
-
-extern int XDeleteProperty(
- Display* /* display */,
- Window /* w */,
- Atom /* property */
-);
-
-extern int XDestroyWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XDestroySubwindows(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XDoesBackingStore(
- Screen* /* screen */
-);
-
-extern Bool XDoesSaveUnders(
- Screen* /* screen */
-);
-
-extern int XDisableAccessControl(
- Display* /* display */
-);
-
-
-extern int XDisplayCells(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDisplayHeight(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDisplayHeightMM(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDisplayKeycodes(
- Display* /* display */,
- int* /* min_keycodes_return */,
- int* /* max_keycodes_return */
-);
-
-extern int XDisplayPlanes(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDisplayWidth(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDisplayWidthMM(
- Display* /* display */,
- int /* screen_number */
-);
-
-extern int XDrawArc(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* angle1 */,
- int /* angle2 */
-);
-
-extern int XDrawArcs(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XArc* /* arcs */,
- int /* narcs */
-);
-
-extern int XDrawImageString(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* string */,
- int /* length */
-);
-
-extern int XDrawImageString16(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst XChar2b* /* string */,
- int /* length */
-);
-
-extern int XDrawLine(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x1 */,
- int /* y1 */,
- int /* x2 */,
- int /* y2 */
-);
-
-extern int XDrawLines(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XPoint* /* points */,
- int /* npoints */,
- int /* mode */
-);
-
-extern int XDrawPoint(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */
-);
-
-extern int XDrawPoints(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XPoint* /* points */,
- int /* npoints */,
- int /* mode */
-);
-
-extern int XDrawRectangle(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-
-extern int XDrawRectangles(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XRectangle* /* rectangles */,
- int /* nrectangles */
-);
-
-extern int XDrawSegments(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XSegment* /* segments */,
- int /* nsegments */
-);
-
-extern int XDrawString(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* string */,
- int /* length */
-);
-
-extern int XDrawString16(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst XChar2b* /* string */,
- int /* length */
-);
-
-extern int XDrawText(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- XTextItem* /* items */,
- int /* nitems */
-);
-
-extern int XDrawText16(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- XTextItem16* /* items */,
- int /* nitems */
-);
-
-extern int XEnableAccessControl(
- Display* /* display */
-);
-
-extern int XEventsQueued(
- Display* /* display */,
- int /* mode */
-);
-
-extern Status XFetchName(
- Display* /* display */,
- Window /* w */,
- char** /* window_name_return */
-);
-
-extern int XFillArc(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* angle1 */,
- int /* angle2 */
-);
-
-extern int XFillArcs(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XArc* /* arcs */,
- int /* narcs */
-);
-
-extern int XFillPolygon(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XPoint* /* points */,
- int /* npoints */,
- int /* shape */,
- int /* mode */
-);
-
-extern int XFillRectangle(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-
-extern int XFillRectangles(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XRectangle* /* rectangles */,
- int /* nrectangles */
-);
-
-extern int XFlush(
- Display* /* display */
-);
-
-extern int XForceScreenSaver(
- Display* /* display */,
- int /* mode */
-);
-
-extern int XFree(
- void* /* data */
-);
-
-extern int XFreeColormap(
- Display* /* display */,
- Colormap /* colormap */
-);
-
-extern int XFreeColors(
- Display* /* display */,
- Colormap /* colormap */,
- unsigned long* /* pixels */,
- int /* npixels */,
- unsigned long /* planes */
-);
-
-extern int XFreeCursor(
- Display* /* display */,
- Cursor /* cursor */
-);
-
-extern int XFreeExtensionList(
- char** /* list */
-);
-
-extern int XFreeFont(
- Display* /* display */,
- XFontStruct* /* font_struct */
-);
-
-extern int XFreeFontInfo(
- char** /* names */,
- XFontStruct* /* free_info */,
- int /* actual_count */
-);
-
-extern int XFreeFontNames(
- char** /* list */
-);
-
-extern int XFreeFontPath(
- char** /* list */
-);
-
-extern int XFreeGC(
- Display* /* display */,
- GC /* gc */
-);
-
-extern int XFreeModifiermap(
- XModifierKeymap* /* modmap */
-);
-
-extern int XFreePixmap(
- Display* /* display */,
- Pixmap /* pixmap */
-);
-
-extern int XGeometry(
- Display* /* display */,
- int /* screen */,
- _Xconst char* /* position */,
- _Xconst char* /* default_position */,
- unsigned int /* bwidth */,
- unsigned int /* fwidth */,
- unsigned int /* fheight */,
- int /* xadder */,
- int /* yadder */,
- int* /* x_return */,
- int* /* y_return */,
- int* /* width_return */,
- int* /* height_return */
-);
-
-extern int XGetErrorDatabaseText(
- Display* /* display */,
- _Xconst char* /* name */,
- _Xconst char* /* message */,
- _Xconst char* /* default_string */,
- char* /* buffer_return */,
- int /* length */
-);
-
-extern int XGetErrorText(
- Display* /* display */,
- int /* code */,
- char* /* buffer_return */,
- int /* length */
-);
-
-extern Bool XGetFontProperty(
- XFontStruct* /* font_struct */,
- Atom /* atom */,
- unsigned long* /* value_return */
-);
-
-extern Status XGetGCValues(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* valuemask */,
- XGCValues* /* values_return */
-);
-
-extern Status XGetGeometry(
- Display* /* display */,
- Drawable /* d */,
- Window* /* root_return */,
- int* /* x_return */,
- int* /* y_return */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */,
- unsigned int* /* border_width_return */,
- unsigned int* /* depth_return */
-);
-
-extern Status XGetIconName(
- Display* /* display */,
- Window /* w */,
- char** /* icon_name_return */
-);
-
-extern int XGetInputFocus(
- Display* /* display */,
- Window* /* focus_return */,
- int* /* revert_to_return */
-);
-
-extern int XGetKeyboardControl(
- Display* /* display */,
- XKeyboardState* /* values_return */
-);
-
-extern int XGetPointerControl(
- Display* /* display */,
- int* /* accel_numerator_return */,
- int* /* accel_denominator_return */,
- int* /* threshold_return */
-);
-
-extern int XGetPointerMapping(
- Display* /* display */,
- unsigned char* /* map_return */,
- int /* nmap */
-);
-
-extern int XGetScreenSaver(
- Display* /* display */,
- int* /* timeout_return */,
- int* /* interval_return */,
- int* /* prefer_blanking_return */,
- int* /* allow_exposures_return */
-);
-
-extern Status XGetTransientForHint(
- Display* /* display */,
- Window /* w */,
- Window* /* prop_window_return */
-);
-
-extern int XGetWindowProperty(
- Display* /* display */,
- Window /* w */,
- Atom /* property */,
- long /* long_offset */,
- long /* long_length */,
- Bool /* delete */,
- Atom /* req_type */,
- Atom* /* actual_type_return */,
- int* /* actual_format_return */,
- unsigned long* /* nitems_return */,
- unsigned long* /* bytes_after_return */,
- unsigned char** /* prop_return */
-);
-
-extern Status XGetWindowAttributes(
- Display* /* display */,
- Window /* w */,
- XWindowAttributes* /* window_attributes_return */
-);
-
-extern int XGrabButton(
- Display* /* display */,
- unsigned int /* button */,
- unsigned int /* modifiers */,
- Window /* grab_window */,
- Bool /* owner_events */,
- unsigned int /* event_mask */,
- int /* pointer_mode */,
- int /* keyboard_mode */,
- Window /* confine_to */,
- Cursor /* cursor */
-);
-
-extern int XGrabKey(
- Display* /* display */,
- int /* keycode */,
- unsigned int /* modifiers */,
- Window /* grab_window */,
- Bool /* owner_events */,
- int /* pointer_mode */,
- int /* keyboard_mode */
-);
-
-extern int XGrabKeyboard(
- Display* /* display */,
- Window /* grab_window */,
- Bool /* owner_events */,
- int /* pointer_mode */,
- int /* keyboard_mode */,
- Time /* time */
-);
-
-extern int XGrabPointer(
- Display* /* display */,
- Window /* grab_window */,
- Bool /* owner_events */,
- unsigned int /* event_mask */,
- int /* pointer_mode */,
- int /* keyboard_mode */,
- Window /* confine_to */,
- Cursor /* cursor */,
- Time /* time */
-);
-
-extern int XGrabServer(
- Display* /* display */
-);
-
-extern int XHeightMMOfScreen(
- Screen* /* screen */
-);
-
-extern int XHeightOfScreen(
- Screen* /* screen */
-);
-
-extern int XIfEvent(
- Display* /* display */,
- XEvent* /* event_return */,
- Bool (*) (
- Display* /* display */,
- XEvent* /* event */,
- XPointer /* arg */
- ) /* predicate */,
- XPointer /* arg */
-);
-
-extern int XImageByteOrder(
- Display* /* display */
-);
-
-extern int XInstallColormap(
- Display* /* display */,
- Colormap /* colormap */
-);
-
-extern KeyCode XKeysymToKeycode(
- Display* /* display */,
- KeySym /* keysym */
-);
-
-extern int XKillClient(
- Display* /* display */,
- XID /* resource */
-);
-
-extern Status XLookupColor(
- Display* /* display */,
- Colormap /* colormap */,
- _Xconst char* /* color_name */,
- XColor* /* exact_def_return */,
- XColor* /* screen_def_return */
-);
-
-extern int XLowerWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XMapRaised(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XMapSubwindows(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XMapWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XMaskEvent(
- Display* /* display */,
- long /* event_mask */,
- XEvent* /* event_return */
-);
-
-extern int XMaxCmapsOfScreen(
- Screen* /* screen */
-);
-
-extern int XMinCmapsOfScreen(
- Screen* /* screen */
-);
-
-extern int XMoveResizeWindow(
- Display* /* display */,
- Window /* w */,
- int /* x */,
- int /* y */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-
-extern int XMoveWindow(
- Display* /* display */,
- Window /* w */,
- int /* x */,
- int /* y */
-);
-
-extern int XNextEvent(
- Display* /* display */,
- XEvent* /* event_return */
-);
-
-extern int XNoOp(
- Display* /* display */
-);
-
-extern Status XParseColor(
- Display* /* display */,
- Colormap /* colormap */,
- _Xconst char* /* spec */,
- XColor* /* exact_def_return */
-);
-
-extern int XParseGeometry(
- _Xconst char* /* parsestring */,
- int* /* x_return */,
- int* /* y_return */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */
-);
-
-extern int XPeekEvent(
- Display* /* display */,
- XEvent* /* event_return */
-);
-
-extern int XPeekIfEvent(
- Display* /* display */,
- XEvent* /* event_return */,
- Bool (*) (
- Display* /* display */,
- XEvent* /* event */,
- XPointer /* arg */
- ) /* predicate */,
- XPointer /* arg */
-);
-
-extern int XPending(
- Display* /* display */
-);
-
-extern int XPlanesOfScreen(
- Screen* /* screen */
-);
-
-extern int XProtocolRevision(
- Display* /* display */
-);
-
-extern int XProtocolVersion(
- Display* /* display */
-);
-
-
-extern int XPutBackEvent(
- Display* /* display */,
- XEvent* /* event */
-);
-
-extern int XPutImage(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- XImage* /* image */,
- int /* src_x */,
- int /* src_y */,
- int /* dest_x */,
- int /* dest_y */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-
-extern int XQLength(
- Display* /* display */
-);
-
-extern Status XQueryBestCursor(
- Display* /* display */,
- Drawable /* d */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */
-);
-
-extern Status XQueryBestSize(
- Display* /* display */,
- int /* class */,
- Drawable /* which_screen */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */
-);
-
-extern Status XQueryBestStipple(
- Display* /* display */,
- Drawable /* which_screen */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */
-);
-
-extern Status XQueryBestTile(
- Display* /* display */,
- Drawable /* which_screen */,
- unsigned int /* width */,
- unsigned int /* height */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */
-);
-
-extern int XQueryColor(
- Display* /* display */,
- Colormap /* colormap */,
- XColor* /* def_in_out */
-);
-
-extern int XQueryColors(
- Display* /* display */,
- Colormap /* colormap */,
- XColor* /* defs_in_out */,
- int /* ncolors */
-);
-
-extern Bool XQueryExtension(
- Display* /* display */,
- _Xconst char* /* name */,
- int* /* major_opcode_return */,
- int* /* first_event_return */,
- int* /* first_error_return */
-);
-
-extern int XQueryKeymap(
- Display* /* display */,
- char [32] /* keys_return */
-);
-
-extern Bool XQueryPointer(
- Display* /* display */,
- Window /* w */,
- Window* /* root_return */,
- Window* /* child_return */,
- int* /* root_x_return */,
- int* /* root_y_return */,
- int* /* win_x_return */,
- int* /* win_y_return */,
- unsigned int* /* mask_return */
-);
-
-extern int XQueryTextExtents(
- Display* /* display */,
- XID /* font_ID */,
- _Xconst char* /* string */,
- int /* nchars */,
- int* /* direction_return */,
- int* /* font_ascent_return */,
- int* /* font_descent_return */,
- XCharStruct* /* overall_return */
-);
-
-extern int XQueryTextExtents16(
- Display* /* display */,
- XID /* font_ID */,
- _Xconst XChar2b* /* string */,
- int /* nchars */,
- int* /* direction_return */,
- int* /* font_ascent_return */,
- int* /* font_descent_return */,
- XCharStruct* /* overall_return */
-);
-
-extern Status XQueryTree(
- Display* /* display */,
- Window /* w */,
- Window* /* root_return */,
- Window* /* parent_return */,
- Window** /* children_return */,
- unsigned int* /* nchildren_return */
-);
-
-extern int XRaiseWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XReadBitmapFile(
- Display* /* display */,
- Drawable /* d */,
- _Xconst char* /* filename */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */,
- Pixmap* /* bitmap_return */,
- int* /* x_hot_return */,
- int* /* y_hot_return */
-);
-
-extern int XReadBitmapFileData(
- _Xconst char* /* filename */,
- unsigned int* /* width_return */,
- unsigned int* /* height_return */,
- unsigned char** /* data_return */,
- int* /* x_hot_return */,
- int* /* y_hot_return */
-);
-
-extern int XRebindKeysym(
- Display* /* display */,
- KeySym /* keysym */,
- KeySym* /* list */,
- int /* mod_count */,
- _Xconst unsigned char* /* string */,
- int /* bytes_string */
-);
-
-extern int XRecolorCursor(
- Display* /* display */,
- Cursor /* cursor */,
- XColor* /* foreground_color */,
- XColor* /* background_color */
-);
-
-extern int XRefreshKeyboardMapping(
- XMappingEvent* /* event_map */
-);
-
-extern int XRemoveFromSaveSet(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XRemoveHost(
- Display* /* display */,
- XHostAddress* /* host */
-);
-
-extern int XRemoveHosts(
- Display* /* display */,
- XHostAddress* /* hosts */,
- int /* num_hosts */
-);
-
-extern int XReparentWindow(
- Display* /* display */,
- Window /* w */,
- Window /* parent */,
- int /* x */,
- int /* y */
-);
-
-extern int XResetScreenSaver(
- Display* /* display */
-);
-
-extern int XResizeWindow(
- Display* /* display */,
- Window /* w */,
- unsigned int /* width */,
- unsigned int /* height */
-);
-
-extern int XRestackWindows(
- Display* /* display */,
- Window* /* windows */,
- int /* nwindows */
-);
-
-extern int XRotateBuffers(
- Display* /* display */,
- int /* rotate */
-);
-
-extern int XRotateWindowProperties(
- Display* /* display */,
- Window /* w */,
- Atom* /* properties */,
- int /* num_prop */,
- int /* npositions */
-);
-
-extern int XScreenCount(
- Display* /* display */
-);
-
-extern int XSelectInput(
- Display* /* display */,
- Window /* w */,
- long /* event_mask */
-);
-
-extern Status XSendEvent(
- Display* /* display */,
- Window /* w */,
- Bool /* propagate */,
- long /* event_mask */,
- XEvent* /* event_send */
-);
-
-extern int XSetAccessControl(
- Display* /* display */,
- int /* mode */
-);
-
-extern int XSetArcMode(
- Display* /* display */,
- GC /* gc */,
- int /* arc_mode */
-);
-
-extern int XSetBackground(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* background */
-);
-
-extern int XSetClipMask(
- Display* /* display */,
- GC /* gc */,
- Pixmap /* pixmap */
-);
-
-extern int XSetClipOrigin(
- Display* /* display */,
- GC /* gc */,
- int /* clip_x_origin */,
- int /* clip_y_origin */
-);
-
-extern int XSetClipRectangles(
- Display* /* display */,
- GC /* gc */,
- int /* clip_x_origin */,
- int /* clip_y_origin */,
- XRectangle* /* rectangles */,
- int /* n */,
- int /* ordering */
-);
-
-extern int XSetCloseDownMode(
- Display* /* display */,
- int /* close_mode */
-);
-
-extern int XSetCommand(
- Display* /* display */,
- Window /* w */,
- char** /* argv */,
- int /* argc */
-);
-
-extern int XSetDashes(
- Display* /* display */,
- GC /* gc */,
- int /* dash_offset */,
- _Xconst char* /* dash_list */,
- int /* n */
-);
-
-extern int XSetFillRule(
- Display* /* display */,
- GC /* gc */,
- int /* fill_rule */
-);
-
-extern int XSetFillStyle(
- Display* /* display */,
- GC /* gc */,
- int /* fill_style */
-);
-
-extern int XSetFont(
- Display* /* display */,
- GC /* gc */,
- Font /* font */
-);
-
-extern int XSetFontPath(
- Display* /* display */,
- char** /* directories */,
- int /* ndirs */
-);
-
-extern int XSetForeground(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* foreground */
-);
-
-extern int XSetFunction(
- Display* /* display */,
- GC /* gc */,
- int /* function */
-);
-
-extern int XSetGraphicsExposures(
- Display* /* display */,
- GC /* gc */,
- Bool /* graphics_exposures */
-);
-
-extern int XSetIconName(
- Display* /* display */,
- Window /* w */,
- _Xconst char* /* icon_name */
-);
-
-extern int XSetInputFocus(
- Display* /* display */,
- Window /* focus */,
- int /* revert_to */,
- Time /* time */
-);
-
-extern int XSetLineAttributes(
- Display* /* display */,
- GC /* gc */,
- unsigned int /* line_width */,
- int /* line_style */,
- int /* cap_style */,
- int /* join_style */
-);
-
-extern int XSetModifierMapping(
- Display* /* display */,
- XModifierKeymap* /* modmap */
-);
-
-extern int XSetPlaneMask(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* plane_mask */
-);
-
-extern int XSetPointerMapping(
- Display* /* display */,
- _Xconst unsigned char* /* map */,
- int /* nmap */
-);
-
-extern int XSetScreenSaver(
- Display* /* display */,
- int /* timeout */,
- int /* interval */,
- int /* prefer_blanking */,
- int /* allow_exposures */
-);
-
-extern int XSetSelectionOwner(
- Display* /* display */,
- Atom /* selection */,
- Window /* owner */,
- Time /* time */
-);
-
-extern int XSetState(
- Display* /* display */,
- GC /* gc */,
- unsigned long /* foreground */,
- unsigned long /* background */,
- int /* function */,
- unsigned long /* plane_mask */
-);
-
-extern int XSetStipple(
- Display* /* display */,
- GC /* gc */,
- Pixmap /* stipple */
-);
-
-extern int XSetSubwindowMode(
- Display* /* display */,
- GC /* gc */,
- int /* subwindow_mode */
-);
-
-extern int XSetTSOrigin(
- Display* /* display */,
- GC /* gc */,
- int /* ts_x_origin */,
- int /* ts_y_origin */
-);
-
-extern int XSetTile(
- Display* /* display */,
- GC /* gc */,
- Pixmap /* tile */
-);
-
-extern int XSetWindowBackground(
- Display* /* display */,
- Window /* w */,
- unsigned long /* background_pixel */
-);
-
-extern int XSetWindowBackgroundPixmap(
- Display* /* display */,
- Window /* w */,
- Pixmap /* background_pixmap */
-);
-
-extern int XSetWindowBorder(
- Display* /* display */,
- Window /* w */,
- unsigned long /* border_pixel */
-);
-
-extern int XSetWindowBorderPixmap(
- Display* /* display */,
- Window /* w */,
- Pixmap /* border_pixmap */
-);
-
-extern int XSetWindowBorderWidth(
- Display* /* display */,
- Window /* w */,
- unsigned int /* width */
-);
-
-extern int XSetWindowColormap(
- Display* /* display */,
- Window /* w */,
- Colormap /* colormap */
-);
-
-extern int XStoreBuffer(
- Display* /* display */,
- _Xconst char* /* bytes */,
- int /* nbytes */,
- int /* buffer */
-);
-
-extern int XStoreBytes(
- Display* /* display */,
- _Xconst char* /* bytes */,
- int /* nbytes */
-);
-
-extern int XStoreColor(
- Display* /* display */,
- Colormap /* colormap */,
- XColor* /* color */
-);
-
-extern int XStoreColors(
- Display* /* display */,
- Colormap /* colormap */,
- XColor* /* color */,
- int /* ncolors */
-);
-
-extern int XStoreName(
- Display* /* display */,
- Window /* w */,
- _Xconst char* /* window_name */
-);
-
-extern int XStoreNamedColor(
- Display* /* display */,
- Colormap /* colormap */,
- _Xconst char* /* color */,
- unsigned long /* pixel */,
- int /* flags */
-);
-
-extern int XSync(
- Display* /* display */,
- Bool /* discard */
-);
-
-extern int XTextExtents(
- XFontStruct* /* font_struct */,
- _Xconst char* /* string */,
- int /* nchars */,
- int* /* direction_return */,
- int* /* font_ascent_return */,
- int* /* font_descent_return */,
- XCharStruct* /* overall_return */
-);
-
-extern int XTextExtents16(
- XFontStruct* /* font_struct */,
- _Xconst XChar2b* /* string */,
- int /* nchars */,
- int* /* direction_return */,
- int* /* font_ascent_return */,
- int* /* font_descent_return */,
- XCharStruct* /* overall_return */
-);
-
-extern int XTextWidth(
- XFontStruct* /* font_struct */,
- _Xconst char* /* string */,
- int /* count */
-);
-
-extern int XTextWidth16(
- XFontStruct* /* font_struct */,
- _Xconst XChar2b* /* string */,
- int /* count */
-);
-
-extern Bool XTranslateCoordinates(
- Display* /* display */,
- Window /* src_w */,
- Window /* dest_w */,
- int /* src_x */,
- int /* src_y */,
- int* /* dest_x_return */,
- int* /* dest_y_return */,
- Window* /* child_return */
-);
-
-extern int XUndefineCursor(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XUngrabButton(
- Display* /* display */,
- unsigned int /* button */,
- unsigned int /* modifiers */,
- Window /* grab_window */
-);
-
-extern int XUngrabKey(
- Display* /* display */,
- int /* keycode */,
- unsigned int /* modifiers */,
- Window /* grab_window */
-);
-
-extern int XUngrabKeyboard(
- Display* /* display */,
- Time /* time */
-);
-
-extern int XUngrabPointer(
- Display* /* display */,
- Time /* time */
-);
-
-extern int XUngrabServer(
- Display* /* display */
-);
-
-extern int XUninstallColormap(
- Display* /* display */,
- Colormap /* colormap */
-);
-
-extern int XUnloadFont(
- Display* /* display */,
- Font /* font */
-);
-
-extern int XUnmapSubwindows(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XUnmapWindow(
- Display* /* display */,
- Window /* w */
-);
-
-extern int XVendorRelease(
- Display* /* display */
-);
-
-extern int XWarpPointer(
- Display* /* display */,
- Window /* src_w */,
- Window /* dest_w */,
- int /* src_x */,
- int /* src_y */,
- unsigned int /* src_width */,
- unsigned int /* src_height */,
- int /* dest_x */,
- int /* dest_y */
-);
-
-extern int XWidthMMOfScreen(
- Screen* /* screen */
-);
-
-extern int XWidthOfScreen(
- Screen* /* screen */
-);
-
-extern int XWindowEvent(
- Display* /* display */,
- Window /* w */,
- long /* event_mask */,
- XEvent* /* event_return */
-);
-
-extern int XWriteBitmapFile(
- Display* /* display */,
- _Xconst char* /* filename */,
- Pixmap /* bitmap */,
- unsigned int /* width */,
- unsigned int /* height */,
- int /* x_hot */,
- int /* y_hot */
-);
-
-extern Bool XSupportsLocale (void);
-
-extern char *XSetLocaleModifiers(
- const char* /* modifier_list */
-);
-
-extern XOM XOpenOM(
- Display* /* display */,
- struct _XrmHashBucketRec* /* rdb */,
- _Xconst char* /* res_name */,
- _Xconst char* /* res_class */
-);
-
-extern Status XCloseOM(
- XOM /* om */
-);
-
-extern char *XSetOMValues(
- XOM /* om */,
- ...
-) _X_SENTINEL(0);
-
-extern char *XGetOMValues(
- XOM /* om */,
- ...
-) _X_SENTINEL(0);
-
-extern Display *XDisplayOfOM(
- XOM /* om */
-);
-
-extern char *XLocaleOfOM(
- XOM /* om */
-);
-
-extern XOC XCreateOC(
- XOM /* om */,
- ...
-) _X_SENTINEL(0);
-
-extern void XDestroyOC(
- XOC /* oc */
-);
-
-extern XOM XOMOfOC(
- XOC /* oc */
-);
-
-extern char *XSetOCValues(
- XOC /* oc */,
- ...
-) _X_SENTINEL(0);
-
-extern char *XGetOCValues(
- XOC /* oc */,
- ...
-) _X_SENTINEL(0);
-
-extern XFontSet XCreateFontSet(
- Display* /* display */,
- _Xconst char* /* base_font_name_list */,
- char*** /* missing_charset_list */,
- int* /* missing_charset_count */,
- char** /* def_string */
-);
-
-extern void XFreeFontSet(
- Display* /* display */,
- XFontSet /* font_set */
-);
-
-extern int XFontsOfFontSet(
- XFontSet /* font_set */,
- XFontStruct*** /* font_struct_list */,
- char*** /* font_name_list */
-);
-
-extern char *XBaseFontNameListOfFontSet(
- XFontSet /* font_set */
-);
-
-extern char *XLocaleOfFontSet(
- XFontSet /* font_set */
-);
-
-extern Bool XContextDependentDrawing(
- XFontSet /* font_set */
-);
-
-extern Bool XDirectionalDependentDrawing(
- XFontSet /* font_set */
-);
-
-extern Bool XContextualDrawing(
- XFontSet /* font_set */
-);
-
-extern XFontSetExtents *XExtentsOfFontSet(
- XFontSet /* font_set */
-);
-
-extern int XmbTextEscapement(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern int XwcTextEscapement(
- XFontSet /* font_set */,
- _Xconst wchar_t* /* text */,
- int /* num_wchars */
-);
-
-extern int Xutf8TextEscapement(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern int XmbTextExtents(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern int XwcTextExtents(
- XFontSet /* font_set */,
- _Xconst wchar_t* /* text */,
- int /* num_wchars */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern int Xutf8TextExtents(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern Status XmbTextPerCharExtents(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */,
- XRectangle* /* ink_extents_buffer */,
- XRectangle* /* logical_extents_buffer */,
- int /* buffer_size */,
- int* /* num_chars */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern Status XwcTextPerCharExtents(
- XFontSet /* font_set */,
- _Xconst wchar_t* /* text */,
- int /* num_wchars */,
- XRectangle* /* ink_extents_buffer */,
- XRectangle* /* logical_extents_buffer */,
- int /* buffer_size */,
- int* /* num_chars */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern Status Xutf8TextPerCharExtents(
- XFontSet /* font_set */,
- _Xconst char* /* text */,
- int /* bytes_text */,
- XRectangle* /* ink_extents_buffer */,
- XRectangle* /* logical_extents_buffer */,
- int /* buffer_size */,
- int* /* num_chars */,
- XRectangle* /* overall_ink_return */,
- XRectangle* /* overall_logical_return */
-);
-
-extern void XmbDrawText(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- XmbTextItem* /* text_items */,
- int /* nitems */
-);
-
-extern void XwcDrawText(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- XwcTextItem* /* text_items */,
- int /* nitems */
-);
-
-extern void Xutf8DrawText(
- Display* /* display */,
- Drawable /* d */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- XmbTextItem* /* text_items */,
- int /* nitems */
-);
-
-extern void XmbDrawString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern void XwcDrawString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst wchar_t* /* text */,
- int /* num_wchars */
-);
-
-extern void Xutf8DrawString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern void XmbDrawImageString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern void XwcDrawImageString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst wchar_t* /* text */,
- int /* num_wchars */
-);
-
-extern void Xutf8DrawImageString(
- Display* /* display */,
- Drawable /* d */,
- XFontSet /* font_set */,
- GC /* gc */,
- int /* x */,
- int /* y */,
- _Xconst char* /* text */,
- int /* bytes_text */
-);
-
-extern XIM XOpenIM(
- Display* /* dpy */,
- struct _XrmHashBucketRec* /* rdb */,
- char* /* res_name */,
- char* /* res_class */
-);
-
-extern Status XCloseIM(
- XIM /* im */
-);
-
-extern char *XGetIMValues(
- XIM /* im */, ...
-) _X_SENTINEL(0);
-
-extern char *XSetIMValues(
- XIM /* im */, ...
-) _X_SENTINEL(0);
-
-extern Display *XDisplayOfIM(
- XIM /* im */
-);
-
-extern char *XLocaleOfIM(
- XIM /* im*/
-);
-
-extern XIC XCreateIC(
- XIM /* im */, ...
-) _X_SENTINEL(0);
-
-extern void XDestroyIC(
- XIC /* ic */
-);
-
-extern void XSetICFocus(
- XIC /* ic */
-);
-
-extern void XUnsetICFocus(
- XIC /* ic */
-);
-
-extern wchar_t *XwcResetIC(
- XIC /* ic */
-);
-
-extern char *XmbResetIC(
- XIC /* ic */
-);
-
-extern char *Xutf8ResetIC(
- XIC /* ic */
-);
-
-extern char *XSetICValues(
- XIC /* ic */, ...
-) _X_SENTINEL(0);
-
-extern char *XGetICValues(
- XIC /* ic */, ...
-) _X_SENTINEL(0);
-
-extern XIM XIMOfIC(
- XIC /* ic */
-);
-
-extern Bool XFilterEvent(
- XEvent* /* event */,
- Window /* window */
-);
-
-extern int XmbLookupString(
- XIC /* ic */,
- XKeyPressedEvent* /* event */,
- char* /* buffer_return */,
- int /* bytes_buffer */,
- KeySym* /* keysym_return */,
- Status* /* status_return */
-);
-
-extern int XwcLookupString(
- XIC /* ic */,
- XKeyPressedEvent* /* event */,
- wchar_t* /* buffer_return */,
- int /* wchars_buffer */,
- KeySym* /* keysym_return */,
- Status* /* status_return */
-);
-
-extern int Xutf8LookupString(
- XIC /* ic */,
- XKeyPressedEvent* /* event */,
- char* /* buffer_return */,
- int /* bytes_buffer */,
- KeySym* /* keysym_return */,
- Status* /* status_return */
-);
-
-extern XVaNestedList XVaCreateNestedList(
- int /*unused*/, ...
-) _X_SENTINEL(0);
-
-/* internal connections for IMs */
-
-extern Bool XRegisterIMInstantiateCallback(
- Display* /* dpy */,
- struct _XrmHashBucketRec* /* rdb */,
- char* /* res_name */,
- char* /* res_class */,
- XIDProc /* callback */,
- XPointer /* client_data */
-);
-
-extern Bool XUnregisterIMInstantiateCallback(
- Display* /* dpy */,
- struct _XrmHashBucketRec* /* rdb */,
- char* /* res_name */,
- char* /* res_class */,
- XIDProc /* callback */,
- XPointer /* client_data */
-);
-
-typedef void (*XConnectionWatchProc)(
- Display* /* dpy */,
- XPointer /* client_data */,
- int /* fd */,
- Bool /* opening */, /* open or close flag */
- XPointer* /* watch_data */ /* open sets, close uses */
-);
-
-
-extern Status XInternalConnectionNumbers(
- Display* /* dpy */,
- int** /* fd_return */,
- int* /* count_return */
-);
-
-extern void XProcessInternalConnection(
- Display* /* dpy */,
- int /* fd */
-);
-
-extern Status XAddConnectionWatch(
- Display* /* dpy */,
- XConnectionWatchProc /* callback */,
- XPointer /* client_data */
-);
-
-extern void XRemoveConnectionWatch(
- Display* /* dpy */,
- XConnectionWatchProc /* callback */,
- XPointer /* client_data */
-);
-
-extern void XSetAuthorization(
- char * /* name */,
- int /* namelen */,
- char * /* data */,
- int /* datalen */
-);
-
-extern int _Xmbtowc(
- wchar_t * /* wstr */,
-#ifdef ISC
- char const * /* str */,
- size_t /* len */
-#else
- char * /* str */,
- int /* len */
-#endif
-);
-
-extern int _Xwctomb(
- char * /* str */,
- wchar_t /* wc */
-);
-
-extern Bool XGetEventData(
- Display* /* dpy */,
- XGenericEventCookie* /* cookie*/
-);
-
-extern void XFreeEventData(
- Display* /* dpy */,
- XGenericEventCookie* /* cookie*/
-);
-
-_XFUNCPROTOEND
-
-#endif /* _X11_XLIB_H_ */
+/* + +Copyright 1985, 1986, 1987, 1991, 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. + +*/ + + +/* + * Xlib.h - Header definition and support file for the C subroutine + * interface library (Xlib) to the X Window System Protocol (V11). + * Structures and symbols starting with "_" are private to the library. + */ +#ifndef _X11_XLIB_H_ +#define _X11_XLIB_H_ + +#define XlibSpecificationRelease 6 + +#include <sys/types.h> + +#if defined(__SCO__) || defined(__UNIXWARE__) +#include <stdint.h> +#endif + +#include <X11/X.h> + +/* applications should not depend on these two headers being included! */ +#include <X11/Xfuncproto.h> +#include <X11/Xosdefs.h> + +#ifndef X_WCHAR +#include <stddef.h> +#else +#ifdef __UNIXOS2__ +#include <stdlib.h> +#else +/* replace this with #include or typedef appropriate for your system */ +typedef unsigned long wchar_t; +#endif +#endif + +#if defined(ISC) && defined(USE_XMBTOWC) +#define wctomb(a,b) _Xwctomb(a,b) +#define mblen(a,b) _Xmblen(a,b) +#ifndef USE_XWCHAR_STRING +#define mbtowc(a,b,c) _Xmbtowc(a,b,c) +#endif +#endif + +extern int +_Xmblen( +#ifdef ISC + char const *str, + size_t len +#else + char *str, + int len +#endif + ); + +/* API mentioning "UTF8" or "utf8" is an XFree86 extension, introduced in + November 2000. Its presence is indicated through the following macro. */ +#define X_HAVE_UTF8_STRING 1 + +typedef char *XPointer; + +typedef int Bool; +typedef int Status; +#define True 1 +#define False 0 + +#define QueuedAlready 0 +#define QueuedAfterReading 1 +#define QueuedAfterFlush 2 + +#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd) +#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root) +#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen) +#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root) +#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual) +#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc) +#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel) +#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel) +#define AllPlanes ((unsigned long)~0L) +#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen) +#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width) +#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height) +#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth) +#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight) +#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) +#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries) +#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens) +#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor) +#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version) +#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version) +#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release) +#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name) +#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth) +#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap) +#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit) +#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order) +#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad) +#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order) +#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */ +#define NextRequest(dpy) XNextRequest(dpy) +#else +#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1) +#endif +#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read) + +/* macros for screen oriented applications (toolkit) */ +#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr]) +#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy)) +#define DisplayOfScreen(s) ((s)->display) +#define RootWindowOfScreen(s) ((s)->root) +#define BlackPixelOfScreen(s) ((s)->black_pixel) +#define WhitePixelOfScreen(s) ((s)->white_pixel) +#define DefaultColormapOfScreen(s)((s)->cmap) +#define DefaultDepthOfScreen(s) ((s)->root_depth) +#define DefaultGCOfScreen(s) ((s)->default_gc) +#define DefaultVisualOfScreen(s)((s)->root_visual) +#define WidthOfScreen(s) ((s)->width) +#define HeightOfScreen(s) ((s)->height) +#define WidthMMOfScreen(s) ((s)->mwidth) +#define HeightMMOfScreen(s) ((s)->mheight) +#define PlanesOfScreen(s) ((s)->root_depth) +#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries) +#define MinCmapsOfScreen(s) ((s)->min_maps) +#define MaxCmapsOfScreen(s) ((s)->max_maps) +#define DoesSaveUnders(s) ((s)->save_unders) +#define DoesBackingStore(s) ((s)->backing_store) +#define EventMaskOfScreen(s) ((s)->root_input_mask) + +/* + * Extensions need a way to hang private data on some structures. + */ +typedef struct _XExtData { + int number; /* number returned by XRegisterExtension */ + struct _XExtData *next; /* next item on list of data for structure */ + int (*free_private)( /* called to free private storage */ + struct _XExtData *extension + ); + XPointer private_data; /* data private to this extension. */ +} XExtData; + +/* + * This file contains structures used by the extension mechanism. + */ +typedef struct { /* public to extension, cannot be changed */ + int extension; /* extension number */ + int major_opcode; /* major op-code assigned by server */ + int first_event; /* first event number for the extension */ + int first_error; /* first error number for the extension */ +} XExtCodes; + +/* + * Data structure for retrieving info about pixmap formats. + */ + +typedef struct { + int depth; + int bits_per_pixel; + int scanline_pad; +} XPixmapFormatValues; + + +/* + * Data structure for setting graphics context. + */ +typedef struct { + int function; /* logical operation */ + unsigned long plane_mask;/* plane mask */ + unsigned long foreground;/* foreground pixel */ + unsigned long background;/* background pixel */ + int line_width; /* line width */ + int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */ + int cap_style; /* CapNotLast, CapButt, + CapRound, CapProjecting */ + int join_style; /* JoinMiter, JoinRound, JoinBevel */ + int fill_style; /* FillSolid, FillTiled, + FillStippled, FillOpaeueStippled */ + int fill_rule; /* EvenOddRule, WindingRule */ + int arc_mode; /* ArcChord, ArcPieSlice */ + Pixmap tile; /* tile pixmap for tiling operations */ + Pixmap stipple; /* stipple 1 plane pixmap for stipping */ + int ts_x_origin; /* offset for tile or stipple operations */ + int ts_y_origin; + Font font; /* default text font for text operations */ + int subwindow_mode; /* ClipByChildren, IncludeInferiors */ + Bool graphics_exposures;/* boolean, should exposures be generated */ + int clip_x_origin; /* origin for clipping */ + int clip_y_origin; + Pixmap clip_mask; /* bitmap clipping; other calls for rects */ + int dash_offset; /* patterned/dashed line information */ + char dashes; +} XGCValues; + +/* + * Graphics context. The contents of this structure are implementation + * dependent. A GC should be treated as opaque by application code. + */ + +typedef struct _XGC +#ifdef XLIB_ILLEGAL_ACCESS +{ + XExtData *ext_data; /* hook for extension to hang data */ + GContext gid; /* protocol ID for graphics context */ + /* there is more to this structure, but it is private to Xlib */ +} +#endif +*GC; + +/* + * Visual structure; contains information about colormapping possible. + */ +typedef struct { + XExtData *ext_data; /* hook for extension to hang data */ + VisualID visualid; /* visual id of this visual */ +#if defined(__cplusplus) || defined(c_plusplus) + int c_class; /* C++ class of screen (monochrome, etc.) */ +#else + int class; /* class of screen (monochrome, etc.) */ +#endif + unsigned long red_mask, green_mask, blue_mask; /* mask values */ + int bits_per_rgb; /* log base 2 of distinct color values */ + int map_entries; /* color map entries */ +} Visual; + +/* + * Depth structure; contains information for each possible depth. + */ +typedef struct { + int depth; /* this depth (Z) of the depth */ + int nvisuals; /* number of Visual types at this depth */ + Visual *visuals; /* list of visuals possible at this depth */ +} Depth; + +/* + * Information about the screen. The contents of this structure are + * implementation dependent. A Screen should be treated as opaque + * by application code. + */ + +struct _XDisplay; /* Forward declare before use for C++ */ + +typedef struct { + XExtData *ext_data; /* hook for extension to hang data */ + struct _XDisplay *display;/* back pointer to display structure */ + Window root; /* Root window id. */ + int width, height; /* width and height of screen */ + int mwidth, mheight; /* width and height of in millimeters */ + int ndepths; /* number of depths possible */ + Depth *depths; /* list of allowable depths on the screen */ + int root_depth; /* bits per pixel */ + Visual *root_visual; /* root visual */ + GC default_gc; /* GC for the root root visual */ + Colormap cmap; /* default color map */ + unsigned long white_pixel; + unsigned long black_pixel; /* White and Black pixel values */ + int max_maps, min_maps; /* max and min color maps */ + int backing_store; /* Never, WhenMapped, Always */ + Bool save_unders; + long root_input_mask; /* initial root input mask */ +} Screen; + +/* + * Format structure; describes ZFormat data the screen will understand. + */ +typedef struct { + XExtData *ext_data; /* hook for extension to hang data */ + int depth; /* depth of this image format */ + int bits_per_pixel; /* bits/pixel at this depth */ + int scanline_pad; /* scanline must padded to this multiple */ +} ScreenFormat; + +/* + * Data structure for setting window attributes. + */ +typedef struct { + Pixmap background_pixmap; /* background or None or ParentRelative */ + unsigned long background_pixel; /* background pixel */ + Pixmap border_pixmap; /* border of the window */ + unsigned long border_pixel; /* border pixel value */ + int bit_gravity; /* one of bit gravity values */ + int win_gravity; /* one of the window gravity values */ + int backing_store; /* NotUseful, WhenMapped, Always */ + unsigned long backing_planes;/* planes to be preseved if possible */ + unsigned long backing_pixel;/* value to use in restoring planes */ + Bool save_under; /* should bits under be saved? (popups) */ + long event_mask; /* set of events that should be saved */ + long do_not_propagate_mask; /* set of events that should not propagate */ + Bool override_redirect; /* boolean value for override-redirect */ + Colormap colormap; /* color map to be associated with window */ + Cursor cursor; /* cursor to be displayed (or None) */ +} XSetWindowAttributes; + +typedef struct { + int x, y; /* location of window */ + int width, height; /* width and height of window */ + int border_width; /* border width of window */ + int depth; /* depth of window */ + Visual *visual; /* the associated visual structure */ + Window root; /* root of screen containing window */ +#if defined(__cplusplus) || defined(c_plusplus) + int c_class; /* C++ InputOutput, InputOnly*/ +#else + int class; /* InputOutput, InputOnly*/ +#endif + int bit_gravity; /* one of bit gravity values */ + int win_gravity; /* one of the window gravity values */ + int backing_store; /* NotUseful, WhenMapped, Always */ + unsigned long backing_planes;/* planes to be preserved if possible */ + unsigned long backing_pixel;/* value to be used when restoring planes */ + Bool save_under; /* boolean, should bits under be saved? */ + Colormap colormap; /* color map to be associated with window */ + Bool map_installed; /* boolean, is color map currently installed*/ + int map_state; /* IsUnmapped, IsUnviewable, IsViewable */ + long all_event_masks; /* set of events all people have interest in*/ + long your_event_mask; /* my event mask */ + long do_not_propagate_mask; /* set of events that should not propagate */ + Bool override_redirect; /* boolean value for override-redirect */ + Screen *screen; /* back pointer to correct screen */ +} XWindowAttributes; + +/* + * Data structure for host setting; getting routines. + * + */ + +typedef struct { + int family; /* for example FamilyInternet */ + int length; /* length of address, in bytes */ + char *address; /* pointer to where to find the bytes */ +} XHostAddress; + +/* + * Data structure for ServerFamilyInterpreted addresses in host routines + */ +typedef struct { + int typelength; /* length of type string, in bytes */ + int valuelength; /* length of value string, in bytes */ + char *type; /* pointer to where to find the type string */ + char *value; /* pointer to where to find the address */ +} XServerInterpretedAddress; + +/* + * Data structure for "image" data, used by image manipulation routines. + */ +typedef struct _XImage { + int width, height; /* size of image */ + int xoffset; /* number of pixels offset in X direction */ + int format; /* XYBitmap, XYPixmap, ZPixmap */ + char *data; /* pointer to image data */ + int byte_order; /* data byte order, LSBFirst, MSBFirst */ + int bitmap_unit; /* quant. of scanline 8, 16, 32 */ + int bitmap_bit_order; /* LSBFirst, MSBFirst */ + int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */ + int depth; /* depth of image */ + int bytes_per_line; /* accelarator to next line */ + int bits_per_pixel; /* bits per pixel (ZPixmap) */ + unsigned long red_mask; /* bits in z arrangment */ + unsigned long green_mask; + unsigned long blue_mask; + XPointer obdata; /* hook for the object routines to hang on */ + struct funcs { /* image manipulation routines */ + struct _XImage *(*create_image)( + struct _XDisplay* /* display */, + Visual* /* visual */, + unsigned int /* depth */, + int /* format */, + int /* offset */, + char* /* data */, + unsigned int /* width */, + unsigned int /* height */, + int /* bitmap_pad */, + int /* bytes_per_line */); + int (*destroy_image) (struct _XImage *); + unsigned long (*get_pixel) (struct _XImage *, int, int); + int (*put_pixel) (struct _XImage *, int, int, unsigned long); + struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int); + int (*add_pixel) (struct _XImage *, long); + } f; +} XImage; + +/* + * Data structure for XReconfigureWindow + */ +typedef struct { + int x, y; + int width, height; + int border_width; + Window sibling; + int stack_mode; +} XWindowChanges; + +/* + * Data structure used by color operations + */ +typedef struct { + unsigned long pixel; + unsigned short red, green, blue; + char flags; /* do_red, do_green, do_blue */ + char pad; +} XColor; + +/* + * Data structures for graphics operations. On most machines, these are + * congruent with the wire protocol structures, so reformatting the data + * can be avoided on these architectures. + */ +typedef struct { + short x1, y1, x2, y2; +} XSegment; + +typedef struct { + short x, y; +} XPoint; + +typedef struct { + short x, y; + unsigned short width, height; +} XRectangle; + +typedef struct { + short x, y; + unsigned short width, height; + short angle1, angle2; +} XArc; + + +/* Data structure for XChangeKeyboardControl */ + +typedef struct { + int key_click_percent; + int bell_percent; + int bell_pitch; + int bell_duration; + int led; + int led_mode; + int key; + int auto_repeat_mode; /* On, Off, Default */ +} XKeyboardControl; + +/* Data structure for XGetKeyboardControl */ + +typedef struct { + int key_click_percent; + int bell_percent; + unsigned int bell_pitch, bell_duration; + unsigned long led_mask; + int global_auto_repeat; + char auto_repeats[32]; +} XKeyboardState; + +/* Data structure for XGetMotionEvents. */ + +typedef struct { + Time time; + short x, y; +} XTimeCoord; + +/* Data structure for X{Set,Get}ModifierMapping */ + +typedef struct { + int max_keypermod; /* The server's max # of keys per modifier */ + KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */ +} XModifierKeymap; + + +/* + * Display datatype maintaining display specific data. + * The contents of this structure are implementation dependent. + * A Display should be treated as opaque by application code. + */ +#ifndef XLIB_ILLEGAL_ACCESS +typedef struct _XDisplay Display; +#endif + +struct _XPrivate; /* Forward declare before use for C++ */ +struct _XrmHashBucketRec; + +typedef struct +#ifdef XLIB_ILLEGAL_ACCESS +_XDisplay +#endif +{ + XExtData *ext_data; /* hook for extension to hang data */ + struct _XPrivate *private1; + int fd; /* Network socket. */ + int private2; + int proto_major_version;/* major version of server's X protocol */ + int proto_minor_version;/* minor version of servers X protocol */ + char *vendor; /* vendor of the server hardware */ + XID private3; + XID private4; + XID private5; + int private6; + XID (*resource_alloc)( /* allocator function */ + struct _XDisplay* + ); + int byte_order; /* screen byte order, LSBFirst, MSBFirst */ + int bitmap_unit; /* padding and data requirements */ + int bitmap_pad; /* padding requirements on bitmaps */ + int bitmap_bit_order; /* LeastSignificant or MostSignificant */ + int nformats; /* number of pixmap formats in list */ + ScreenFormat *pixmap_format; /* pixmap format list */ + int private8; + int release; /* release of the server */ + struct _XPrivate *private9, *private10; + int qlen; /* Length of input event queue */ + unsigned long last_request_read; /* seq number of last event read */ + unsigned long request; /* sequence number of last request. */ + XPointer private11; + XPointer private12; + XPointer private13; + XPointer private14; + unsigned max_request_size; /* maximum number 32 bit words in request*/ + struct _XrmHashBucketRec *db; + int (*private15)( + struct _XDisplay* + ); + char *display_name; /* "host:display" string used on this connect*/ + int default_screen; /* default screen for operations */ + int nscreens; /* number of screens on this server*/ + Screen *screens; /* pointer to list of screens */ + unsigned long motion_buffer; /* size of motion buffer */ + unsigned long private16; + int min_keycode; /* minimum defined keycode */ + int max_keycode; /* maximum defined keycode */ + XPointer private17; + XPointer private18; + int private19; + char *xdefaults; /* contents of defaults from server */ + /* there is more to this structure, but it is private to Xlib */ +} +#ifdef XLIB_ILLEGAL_ACCESS +Display, +#endif +*_XPrivDisplay; + +#undef _XEVENT_ +#ifndef _XEVENT_ +/* + * Definitions of specific events. + */ +typedef struct { + int type; /* of event */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* "event" window it is reported relative to */ + Window root; /* root window that the event occurred on */ + Window subwindow; /* child window */ + Time time; /* milliseconds */ + int x, y; /* pointer x, y coordinates in event window */ + int x_root, y_root; /* coordinates relative to root */ + unsigned int state; /* key or button mask */ + unsigned int keycode; /* detail */ + Bool same_screen; /* same screen flag */ +} XKeyEvent; +typedef XKeyEvent XKeyPressedEvent; +typedef XKeyEvent XKeyReleasedEvent; + +typedef struct { + int type; /* of event */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* "event" window it is reported relative to */ + Window root; /* root window that the event occurred on */ + Window subwindow; /* child window */ + Time time; /* milliseconds */ + int x, y; /* pointer x, y coordinates in event window */ + int x_root, y_root; /* coordinates relative to root */ + unsigned int state; /* key or button mask */ + unsigned int button; /* detail */ + Bool same_screen; /* same screen flag */ +} XButtonEvent; +typedef XButtonEvent XButtonPressedEvent; +typedef XButtonEvent XButtonReleasedEvent; + +typedef struct { + int type; /* of event */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* "event" window reported relative to */ + Window root; /* root window that the event occurred on */ + Window subwindow; /* child window */ + Time time; /* milliseconds */ + int x, y; /* pointer x, y coordinates in event window */ + int x_root, y_root; /* coordinates relative to root */ + unsigned int state; /* key or button mask */ + char is_hint; /* detail */ + Bool same_screen; /* same screen flag */ +} XMotionEvent; +typedef XMotionEvent XPointerMovedEvent; + +typedef struct { + int type; /* of event */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* "event" window reported relative to */ + Window root; /* root window that the event occurred on */ + Window subwindow; /* child window */ + Time time; /* milliseconds */ + int x, y; /* pointer x, y coordinates in event window */ + int x_root, y_root; /* coordinates relative to root */ + int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */ + int detail; + /* + * NotifyAncestor, NotifyVirtual, NotifyInferior, + * NotifyNonlinear,NotifyNonlinearVirtual + */ + Bool same_screen; /* same screen flag */ + Bool focus; /* boolean focus */ + unsigned int state; /* key or button mask */ +} XCrossingEvent; +typedef XCrossingEvent XEnterWindowEvent; +typedef XCrossingEvent XLeaveWindowEvent; + +typedef struct { + int type; /* FocusIn or FocusOut */ + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* window of event */ + int mode; /* NotifyNormal, NotifyWhileGrabbed, + NotifyGrab, NotifyUngrab */ + int detail; + /* + * NotifyAncestor, NotifyVirtual, NotifyInferior, + * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer, + * NotifyPointerRoot, NotifyDetailNone + */ +} XFocusChangeEvent; +typedef XFocusChangeEvent XFocusInEvent; +typedef XFocusChangeEvent XFocusOutEvent; + +/* generated on EnterWindow and FocusIn when KeyMapState selected */ +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + char key_vector[32]; +} XKeymapEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + int x, y; + int width, height; + int count; /* if non-zero, at least this many more */ +} XExposeEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Drawable drawable; + int x, y; + int width, height; + int count; /* if non-zero, at least this many more */ + int major_code; /* core is CopyArea or CopyPlane */ + int minor_code; /* not defined in the core */ +} XGraphicsExposeEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Drawable drawable; + int major_code; /* core is CopyArea or CopyPlane */ + int minor_code; /* not defined in the core */ +} XNoExposeEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + int state; /* Visibility state */ +} XVisibilityEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window parent; /* parent of the window */ + Window window; /* window id of window created */ + int x, y; /* window location */ + int width, height; /* size of window */ + int border_width; /* border width */ + Bool override_redirect; /* creation should be overridden */ +} XCreateWindowEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; +} XDestroyWindowEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + Bool from_configure; +} XUnmapEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + Bool override_redirect; /* boolean, is override set... */ +} XMapEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window parent; + Window window; +} XMapRequestEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + Window parent; + int x, y; + Bool override_redirect; +} XReparentEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + int x, y; + int width, height; + int border_width; + Window above; + Bool override_redirect; +} XConfigureEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + int x, y; +} XGravityEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + int width, height; +} XResizeRequestEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window parent; + Window window; + int x, y; + int width, height; + int border_width; + Window above; + int detail; /* Above, Below, TopIf, BottomIf, Opposite */ + unsigned long value_mask; +} XConfigureRequestEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window event; + Window window; + int place; /* PlaceOnTop, PlaceOnBottom */ +} XCirculateEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window parent; + Window window; + int place; /* PlaceOnTop, PlaceOnBottom */ +} XCirculateRequestEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + Atom atom; + Time time; + int state; /* NewValue, Deleted */ +} XPropertyEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + Atom selection; + Time time; +} XSelectionClearEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window owner; + Window requestor; + Atom selection; + Atom target; + Atom property; + Time time; +} XSelectionRequestEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window requestor; + Atom selection; + Atom target; + Atom property; /* ATOM or None */ + Time time; +} XSelectionEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + Colormap colormap; /* COLORMAP or None */ +#if defined(__cplusplus) || defined(c_plusplus) + Bool c_new; /* C++ */ +#else + Bool new; +#endif + int state; /* ColormapInstalled, ColormapUninstalled */ +} XColormapEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; + Atom message_type; + int format; + union { + char b[20]; + short s[10]; + long l[5]; + } data; +} XClientMessageEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display; /* Display the event was read from */ + Window window; /* unused */ + int request; /* one of MappingModifier, MappingKeyboard, + MappingPointer */ + int first_keycode; /* first keycode */ + int count; /* defines range of change w. first_keycode*/ +} XMappingEvent; + +typedef struct { + int type; + Display *display; /* Display the event was read from */ + XID resourceid; /* resource id */ + unsigned long serial; /* serial number of failed request */ + unsigned char error_code; /* error code of failed request */ + unsigned char request_code; /* Major op-code of failed request */ + unsigned char minor_code; /* Minor op-code of failed request */ +} XErrorEvent; + +typedef struct { + int type; + unsigned long serial; /* # of last request processed by server */ + Bool send_event; /* true if this came from a SendEvent request */ + Display *display;/* Display the event was read from */ + Window window; /* window on which event was requested in event mask */ +} XAnyEvent; + + +/*************************************************************** + * + * GenericEvent. This event is the standard event for all newer extensions. + */ + +typedef struct + { + int type; /* of event. Always GenericEvent */ + unsigned long serial; /* # of last request processed */ + Bool send_event; /* true if from SendEvent request */ + Display *display; /* Display the event was read from */ + int extension; /* major opcode of extension that caused the event */ + int evtype; /* actual event type. */ + } XGenericEvent; + +typedef struct { + int type; /* of event. Always GenericEvent */ + unsigned long serial; /* # of last request processed */ + Bool send_event; /* true if from SendEvent request */ + Display *display; /* Display the event was read from */ + int extension; /* major opcode of extension that caused the event */ + int evtype; /* actual event type. */ + unsigned int cookie; + void *data; +} XGenericEventCookie; + +/* + * this union is defined so Xlib can always use the same sized + * event structure internally, to avoid memory fragmentation. + */ +typedef union _XEvent { + int type; /* must not be changed; first element */ + XAnyEvent xany; + XKeyEvent xkey; + XButtonEvent xbutton; + XMotionEvent xmotion; + XCrossingEvent xcrossing; + XFocusChangeEvent xfocus; + XExposeEvent xexpose; + XGraphicsExposeEvent xgraphicsexpose; + XNoExposeEvent xnoexpose; + XVisibilityEvent xvisibility; + XCreateWindowEvent xcreatewindow; + XDestroyWindowEvent xdestroywindow; + XUnmapEvent xunmap; + XMapEvent xmap; + XMapRequestEvent xmaprequest; + XReparentEvent xreparent; + XConfigureEvent xconfigure; + XGravityEvent xgravity; + XResizeRequestEvent xresizerequest; + XConfigureRequestEvent xconfigurerequest; + XCirculateEvent xcirculate; + XCirculateRequestEvent xcirculaterequest; + XPropertyEvent xproperty; + XSelectionClearEvent xselectionclear; + XSelectionRequestEvent xselectionrequest; + XSelectionEvent xselection; + XColormapEvent xcolormap; + XClientMessageEvent xclient; + XMappingEvent xmapping; + XErrorEvent xerror; + XKeymapEvent xkeymap; + XGenericEvent xgeneric; + XGenericEventCookie xcookie; + long pad[24]; +} XEvent; +#endif + +#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy))) + +/* + * per character font metric information. + */ +typedef struct { + short lbearing; /* origin to left edge of raster */ + short rbearing; /* origin to right edge of raster */ + short width; /* advance to next char's origin */ + short ascent; /* baseline to top edge of raster */ + short descent; /* baseline to bottom edge of raster */ + unsigned short attributes; /* per char flags (not predefined) */ +} XCharStruct; + +/* + * To allow arbitrary information with fonts, there are additional properties + * returned. + */ +typedef struct { + Atom name; + unsigned long card32; +} XFontProp; + +typedef struct { + XExtData *ext_data; /* hook for extension to hang data */ + Font fid; /* Font id for this font */ + unsigned direction; /* hint about direction the font is painted */ + unsigned min_char_or_byte2;/* first character */ + unsigned max_char_or_byte2;/* last character */ + unsigned min_byte1; /* first row that exists */ + unsigned max_byte1; /* last row that exists */ + Bool all_chars_exist;/* flag if all characters have non-zero size*/ + unsigned default_char; /* char to print for undefined character */ + int n_properties; /* how many properties there are */ + XFontProp *properties; /* pointer to array of additional properties*/ + XCharStruct min_bounds; /* minimum bounds over all existing char*/ + XCharStruct max_bounds; /* maximum bounds over all existing char*/ + XCharStruct *per_char; /* first_char to last_char information */ + int ascent; /* log. extent above baseline for spacing */ + int descent; /* log. descent below baseline for spacing */ +} XFontStruct; + +/* + * PolyText routines take these as arguments. + */ +typedef struct { + char *chars; /* pointer to string */ + int nchars; /* number of characters */ + int delta; /* delta between strings */ + Font font; /* font to print it in, None don't change */ +} XTextItem; + +typedef struct { /* normal 16 bit characters are two bytes */ + unsigned char byte1; + unsigned char byte2; +} XChar2b; + +typedef struct { + XChar2b *chars; /* two byte characters */ + int nchars; /* number of characters */ + int delta; /* delta between strings */ + Font font; /* font to print it in, None don't change */ +} XTextItem16; + + +typedef union { Display *display; + GC gc; + Visual *visual; + Screen *screen; + ScreenFormat *pixmap_format; + XFontStruct *font; } XEDataObject; + +typedef struct { + XRectangle max_ink_extent; + XRectangle max_logical_extent; +} XFontSetExtents; + +/* unused: +typedef void (*XOMProc)(); + */ + +typedef struct _XOM *XOM; +typedef struct _XOC *XOC, *XFontSet; + +typedef struct { + char *chars; + int nchars; + int delta; + XFontSet font_set; +} XmbTextItem; + +typedef struct { + wchar_t *chars; + int nchars; + int delta; + XFontSet font_set; +} XwcTextItem; + +#define XNRequiredCharSet "requiredCharSet" +#define XNQueryOrientation "queryOrientation" +#define XNBaseFontName "baseFontName" +#define XNOMAutomatic "omAutomatic" +#define XNMissingCharSet "missingCharSet" +#define XNDefaultString "defaultString" +#define XNOrientation "orientation" +#define XNDirectionalDependentDrawing "directionalDependentDrawing" +#define XNContextualDrawing "contextualDrawing" +#define XNFontInfo "fontInfo" + +typedef struct { + int charset_count; + char **charset_list; +} XOMCharSetList; + +typedef enum { + XOMOrientation_LTR_TTB, + XOMOrientation_RTL_TTB, + XOMOrientation_TTB_LTR, + XOMOrientation_TTB_RTL, + XOMOrientation_Context +} XOrientation; + +typedef struct { + int num_orientation; + XOrientation *orientation; /* Input Text description */ +} XOMOrientation; + +typedef struct { + int num_font; + XFontStruct **font_struct_list; + char **font_name_list; +} XOMFontInfo; + +typedef struct _XIM *XIM; +typedef struct _XIC *XIC; + +typedef void (*XIMProc)( + XIM, + XPointer, + XPointer +); + +typedef Bool (*XICProc)( + XIC, + XPointer, + XPointer +); + +typedef void (*XIDProc)( + Display*, + XPointer, + XPointer +); + +typedef unsigned long XIMStyle; + +typedef struct { + unsigned short count_styles; + XIMStyle *supported_styles; +} XIMStyles; + +#define XIMPreeditArea 0x0001L +#define XIMPreeditCallbacks 0x0002L +#define XIMPreeditPosition 0x0004L +#define XIMPreeditNothing 0x0008L +#define XIMPreeditNone 0x0010L +#define XIMStatusArea 0x0100L +#define XIMStatusCallbacks 0x0200L +#define XIMStatusNothing 0x0400L +#define XIMStatusNone 0x0800L + +#define XNVaNestedList "XNVaNestedList" +#define XNQueryInputStyle "queryInputStyle" +#define XNClientWindow "clientWindow" +#define XNInputStyle "inputStyle" +#define XNFocusWindow "focusWindow" +#define XNResourceName "resourceName" +#define XNResourceClass "resourceClass" +#define XNGeometryCallback "geometryCallback" +#define XNDestroyCallback "destroyCallback" +#define XNFilterEvents "filterEvents" +#define XNPreeditStartCallback "preeditStartCallback" +#define XNPreeditDoneCallback "preeditDoneCallback" +#define XNPreeditDrawCallback "preeditDrawCallback" +#define XNPreeditCaretCallback "preeditCaretCallback" +#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback" +#define XNPreeditAttributes "preeditAttributes" +#define XNStatusStartCallback "statusStartCallback" +#define XNStatusDoneCallback "statusDoneCallback" +#define XNStatusDrawCallback "statusDrawCallback" +#define XNStatusAttributes "statusAttributes" +#define XNArea "area" +#define XNAreaNeeded "areaNeeded" +#define XNSpotLocation "spotLocation" +#define XNColormap "colorMap" +#define XNStdColormap "stdColorMap" +#define XNForeground "foreground" +#define XNBackground "background" +#define XNBackgroundPixmap "backgroundPixmap" +#define XNFontSet "fontSet" +#define XNLineSpace "lineSpace" +#define XNCursor "cursor" + +#define XNQueryIMValuesList "queryIMValuesList" +#define XNQueryICValuesList "queryICValuesList" +#define XNVisiblePosition "visiblePosition" +#define XNR6PreeditCallback "r6PreeditCallback" +#define XNStringConversionCallback "stringConversionCallback" +#define XNStringConversion "stringConversion" +#define XNResetState "resetState" +#define XNHotKey "hotKey" +#define XNHotKeyState "hotKeyState" +#define XNPreeditState "preeditState" +#define XNSeparatorofNestedList "separatorofNestedList" + +#define XBufferOverflow -1 +#define XLookupNone 1 +#define XLookupChars 2 +#define XLookupKeySym 3 +#define XLookupBoth 4 + +typedef void *XVaNestedList; + +typedef struct { + XPointer client_data; + XIMProc callback; +} XIMCallback; + +typedef struct { + XPointer client_data; + XICProc callback; +} XICCallback; + +typedef unsigned long XIMFeedback; + +#define XIMReverse 1L +#define XIMUnderline (1L<<1) +#define XIMHighlight (1L<<2) +#define XIMPrimary (1L<<5) +#define XIMSecondary (1L<<6) +#define XIMTertiary (1L<<7) +#define XIMVisibleToForward (1L<<8) +#define XIMVisibleToBackword (1L<<9) +#define XIMVisibleToCenter (1L<<10) + +typedef struct _XIMText { + unsigned short length; + XIMFeedback *feedback; + Bool encoding_is_wchar; + union { + char *multi_byte; + wchar_t *wide_char; + } string; +} XIMText; + +typedef unsigned long XIMPreeditState; + +#define XIMPreeditUnKnown 0L +#define XIMPreeditEnable 1L +#define XIMPreeditDisable (1L<<1) + +typedef struct _XIMPreeditStateNotifyCallbackStruct { + XIMPreeditState state; +} XIMPreeditStateNotifyCallbackStruct; + +typedef unsigned long XIMResetState; + +#define XIMInitialState 1L +#define XIMPreserveState (1L<<1) + +typedef unsigned long XIMStringConversionFeedback; + +#define XIMStringConversionLeftEdge (0x00000001) +#define XIMStringConversionRightEdge (0x00000002) +#define XIMStringConversionTopEdge (0x00000004) +#define XIMStringConversionBottomEdge (0x00000008) +#define XIMStringConversionConcealed (0x00000010) +#define XIMStringConversionWrapped (0x00000020) + +typedef struct _XIMStringConversionText { + unsigned short length; + XIMStringConversionFeedback *feedback; + Bool encoding_is_wchar; + union { + char *mbs; + wchar_t *wcs; + } string; +} XIMStringConversionText; + +typedef unsigned short XIMStringConversionPosition; + +typedef unsigned short XIMStringConversionType; + +#define XIMStringConversionBuffer (0x0001) +#define XIMStringConversionLine (0x0002) +#define XIMStringConversionWord (0x0003) +#define XIMStringConversionChar (0x0004) + +typedef unsigned short XIMStringConversionOperation; + +#define XIMStringConversionSubstitution (0x0001) +#define XIMStringConversionRetrieval (0x0002) + +typedef enum { + XIMForwardChar, XIMBackwardChar, + XIMForwardWord, XIMBackwardWord, + XIMCaretUp, XIMCaretDown, + XIMNextLine, XIMPreviousLine, + XIMLineStart, XIMLineEnd, + XIMAbsolutePosition, + XIMDontChange +} XIMCaretDirection; + +typedef struct _XIMStringConversionCallbackStruct { + XIMStringConversionPosition position; + XIMCaretDirection direction; + XIMStringConversionOperation operation; + unsigned short factor; + XIMStringConversionText *text; +} XIMStringConversionCallbackStruct; + +typedef struct _XIMPreeditDrawCallbackStruct { + int caret; /* Cursor offset within pre-edit string */ + int chg_first; /* Starting change position */ + int chg_length; /* Length of the change in character count */ + XIMText *text; +} XIMPreeditDrawCallbackStruct; + +typedef enum { + XIMIsInvisible, /* Disable caret feedback */ + XIMIsPrimary, /* UI defined caret feedback */ + XIMIsSecondary /* UI defined caret feedback */ +} XIMCaretStyle; + +typedef struct _XIMPreeditCaretCallbackStruct { + int position; /* Caret offset within pre-edit string */ + XIMCaretDirection direction; /* Caret moves direction */ + XIMCaretStyle style; /* Feedback of the caret */ +} XIMPreeditCaretCallbackStruct; + +typedef enum { + XIMTextType, + XIMBitmapType +} XIMStatusDataType; + +typedef struct _XIMStatusDrawCallbackStruct { + XIMStatusDataType type; + union { + XIMText *text; + Pixmap bitmap; + } data; +} XIMStatusDrawCallbackStruct; + +typedef struct _XIMHotKeyTrigger { + KeySym keysym; + int modifier; + int modifier_mask; +} XIMHotKeyTrigger; + +typedef struct _XIMHotKeyTriggers { + int num_hot_key; + XIMHotKeyTrigger *key; +} XIMHotKeyTriggers; + +typedef unsigned long XIMHotKeyState; + +#define XIMHotKeyStateON (0x0001L) +#define XIMHotKeyStateOFF (0x0002L) + +typedef struct { + unsigned short count_values; + char **supported_values; +} XIMValuesList; + +_XFUNCPROTOBEGIN + +#if defined(WIN32) && !defined(_XLIBINT_) +#define _Xdebug (*_Xdebug_p) +#endif + +extern int _Xdebug; + +extern XFontStruct *XLoadQueryFont( + Display* /* display */, + _Xconst char* /* name */ +); + +extern XFontStruct *XQueryFont( + Display* /* display */, + XID /* font_ID */ +); + + +extern XTimeCoord *XGetMotionEvents( + Display* /* display */, + Window /* w */, + Time /* start */, + Time /* stop */, + int* /* nevents_return */ +); + +extern XModifierKeymap *XDeleteModifiermapEntry( + XModifierKeymap* /* modmap */, +#if NeedWidePrototypes + unsigned int /* keycode_entry */, +#else + KeyCode /* keycode_entry */, +#endif + int /* modifier */ +); + +extern XModifierKeymap *XGetModifierMapping( + Display* /* display */ +); + +extern XModifierKeymap *XInsertModifiermapEntry( + XModifierKeymap* /* modmap */, +#if NeedWidePrototypes + unsigned int /* keycode_entry */, +#else + KeyCode /* keycode_entry */, +#endif + int /* modifier */ +); + +extern XModifierKeymap *XNewModifiermap( + int /* max_keys_per_mod */ +); + +extern XImage *XCreateImage( + Display* /* display */, + Visual* /* visual */, + unsigned int /* depth */, + int /* format */, + int /* offset */, + char* /* data */, + unsigned int /* width */, + unsigned int /* height */, + int /* bitmap_pad */, + int /* bytes_per_line */ +); +extern Status XInitImage( + XImage* /* image */ +); +extern XImage *XGetImage( + Display* /* display */, + Drawable /* d */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + unsigned long /* plane_mask */, + int /* format */ +); +extern XImage *XGetSubImage( + Display* /* display */, + Drawable /* d */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + unsigned long /* plane_mask */, + int /* format */, + XImage* /* dest_image */, + int /* dest_x */, + int /* dest_y */ +); + +/* + * X function declarations. + */ +extern Display *XOpenDisplay( + _Xconst char* /* display_name */ +); + +extern void XrmInitialize( + void +); + +extern char *XFetchBytes( + Display* /* display */, + int* /* nbytes_return */ +); +extern char *XFetchBuffer( + Display* /* display */, + int* /* nbytes_return */, + int /* buffer */ +); +extern char *XGetAtomName( + Display* /* display */, + Atom /* atom */ +); +extern Status XGetAtomNames( + Display* /* dpy */, + Atom* /* atoms */, + int /* count */, + char** /* names_return */ +); +extern char *XGetDefault( + Display* /* display */, + _Xconst char* /* program */, + _Xconst char* /* option */ +); +extern char *XDisplayName( + _Xconst char* /* string */ +); +extern char *XKeysymToString( + KeySym /* keysym */ +); + +extern int (*XSynchronize( + Display* /* display */, + Bool /* onoff */ +))( + Display* /* display */ +); +extern int (*XSetAfterFunction( + Display* /* display */, + int (*) ( + Display* /* display */ + ) /* procedure */ +))( + Display* /* display */ +); +extern Atom XInternAtom( + Display* /* display */, + _Xconst char* /* atom_name */, + Bool /* only_if_exists */ +); +extern Status XInternAtoms( + Display* /* dpy */, + char** /* names */, + int /* count */, + Bool /* onlyIfExists */, + Atom* /* atoms_return */ +); +extern Colormap XCopyColormapAndFree( + Display* /* display */, + Colormap /* colormap */ +); +extern Colormap XCreateColormap( + Display* /* display */, + Window /* w */, + Visual* /* visual */, + int /* alloc */ +); +extern Cursor XCreatePixmapCursor( + Display* /* display */, + Pixmap /* source */, + Pixmap /* mask */, + XColor* /* foreground_color */, + XColor* /* background_color */, + unsigned int /* x */, + unsigned int /* y */ +); +extern Cursor XCreateGlyphCursor( + Display* /* display */, + Font /* source_font */, + Font /* mask_font */, + unsigned int /* source_char */, + unsigned int /* mask_char */, + XColor _Xconst * /* foreground_color */, + XColor _Xconst * /* background_color */ +); +extern Cursor XCreateFontCursor( + Display* /* display */, + unsigned int /* shape */ +); +extern Font XLoadFont( + Display* /* display */, + _Xconst char* /* name */ +); +extern GC XCreateGC( + Display* /* display */, + Drawable /* d */, + unsigned long /* valuemask */, + XGCValues* /* values */ +); +extern GContext XGContextFromGC( + GC /* gc */ +); +extern void XFlushGC( + Display* /* display */, + GC /* gc */ +); +extern Pixmap XCreatePixmap( + Display* /* display */, + Drawable /* d */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int /* depth */ +); +extern Pixmap XCreateBitmapFromData( + Display* /* display */, + Drawable /* d */, + _Xconst char* /* data */, + unsigned int /* width */, + unsigned int /* height */ +); +extern Pixmap XCreatePixmapFromBitmapData( + Display* /* display */, + Drawable /* d */, + char* /* data */, + unsigned int /* width */, + unsigned int /* height */, + unsigned long /* fg */, + unsigned long /* bg */, + unsigned int /* depth */ +); +extern Window XCreateSimpleWindow( + Display* /* display */, + Window /* parent */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int /* border_width */, + unsigned long /* border */, + unsigned long /* background */ +); +extern Window XGetSelectionOwner( + Display* /* display */, + Atom /* selection */ +); +extern Window XCreateWindow( + Display* /* display */, + Window /* parent */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int /* border_width */, + int /* depth */, + unsigned int /* class */, + Visual* /* visual */, + unsigned long /* valuemask */, + XSetWindowAttributes* /* attributes */ +); +extern Colormap *XListInstalledColormaps( + Display* /* display */, + Window /* w */, + int* /* num_return */ +); +extern char **XListFonts( + Display* /* display */, + _Xconst char* /* pattern */, + int /* maxnames */, + int* /* actual_count_return */ +); +extern char **XListFontsWithInfo( + Display* /* display */, + _Xconst char* /* pattern */, + int /* maxnames */, + int* /* count_return */, + XFontStruct** /* info_return */ +); +extern char **XGetFontPath( + Display* /* display */, + int* /* npaths_return */ +); +extern char **XListExtensions( + Display* /* display */, + int* /* nextensions_return */ +); +extern Atom *XListProperties( + Display* /* display */, + Window /* w */, + int* /* num_prop_return */ +); +extern XHostAddress *XListHosts( + Display* /* display */, + int* /* nhosts_return */, + Bool* /* state_return */ +); +extern KeySym XKeycodeToKeysym( + Display* /* display */, +#if NeedWidePrototypes + unsigned int /* keycode */, +#else + KeyCode /* keycode */, +#endif + int /* index */ +); +extern KeySym XLookupKeysym( + XKeyEvent* /* key_event */, + int /* index */ +); +extern KeySym *XGetKeyboardMapping( + Display* /* display */, +#if NeedWidePrototypes + unsigned int /* first_keycode */, +#else + KeyCode /* first_keycode */, +#endif + int /* keycode_count */, + int* /* keysyms_per_keycode_return */ +); +extern KeySym XStringToKeysym( + _Xconst char* /* string */ +); +extern long XMaxRequestSize( + Display* /* display */ +); +extern long XExtendedMaxRequestSize( + Display* /* display */ +); +extern char *XResourceManagerString( + Display* /* display */ +); +extern char *XScreenResourceString( + Screen* /* screen */ +); +extern unsigned long XDisplayMotionBufferSize( + Display* /* display */ +); +extern VisualID XVisualIDFromVisual( + Visual* /* visual */ +); + +/* multithread routines */ + +extern Status XInitThreads( + void +); + +extern void XLockDisplay( + Display* /* display */ +); + +extern void XUnlockDisplay( + Display* /* display */ +); + +/* routines for dealing with extensions */ + +extern XExtCodes *XInitExtension( + Display* /* display */, + _Xconst char* /* name */ +); + +extern XExtCodes *XAddExtension( + Display* /* display */ +); +extern XExtData *XFindOnExtensionList( + XExtData** /* structure */, + int /* number */ +); +extern XExtData **XEHeadOfExtensionList( + XEDataObject /* object */ +); + +/* these are routines for which there are also macros */ +extern Window XRootWindow( + Display* /* display */, + int /* screen_number */ +); +extern Window XDefaultRootWindow( + Display* /* display */ +); +extern Window XRootWindowOfScreen( + Screen* /* screen */ +); +extern Visual *XDefaultVisual( + Display* /* display */, + int /* screen_number */ +); +extern Visual *XDefaultVisualOfScreen( + Screen* /* screen */ +); +extern GC XDefaultGC( + Display* /* display */, + int /* screen_number */ +); +extern GC XDefaultGCOfScreen( + Screen* /* screen */ +); +extern unsigned long XBlackPixel( + Display* /* display */, + int /* screen_number */ +); +extern unsigned long XWhitePixel( + Display* /* display */, + int /* screen_number */ +); +extern unsigned long XAllPlanes( + void +); +extern unsigned long XBlackPixelOfScreen( + Screen* /* screen */ +); +extern unsigned long XWhitePixelOfScreen( + Screen* /* screen */ +); +extern unsigned long XNextRequest( + Display* /* display */ +); +extern unsigned long XLastKnownRequestProcessed( + Display* /* display */ +); +extern char *XServerVendor( + Display* /* display */ +); +extern char *XDisplayString( + Display* /* display */ +); +extern Colormap XDefaultColormap( + Display* /* display */, + int /* screen_number */ +); +extern Colormap XDefaultColormapOfScreen( + Screen* /* screen */ +); +extern Display *XDisplayOfScreen( + Screen* /* screen */ +); +extern Screen *XScreenOfDisplay( + Display* /* display */, + int /* screen_number */ +); +extern Screen *XDefaultScreenOfDisplay( + Display* /* display */ +); +extern long XEventMaskOfScreen( + Screen* /* screen */ +); + +extern int XScreenNumberOfScreen( + Screen* /* screen */ +); + +typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */ + Display* /* display */, + XErrorEvent* /* error_event */ +); + +extern XErrorHandler XSetErrorHandler ( + XErrorHandler /* handler */ +); + + +typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */ + Display* /* display */ +); + +extern XIOErrorHandler XSetIOErrorHandler ( + XIOErrorHandler /* handler */ +); + + +extern XPixmapFormatValues *XListPixmapFormats( + Display* /* display */, + int* /* count_return */ +); +extern int *XListDepths( + Display* /* display */, + int /* screen_number */, + int* /* count_return */ +); + +/* ICCCM routines for things that don't require special include files; */ +/* other declarations are given in Xutil.h */ +extern Status XReconfigureWMWindow( + Display* /* display */, + Window /* w */, + int /* screen_number */, + unsigned int /* mask */, + XWindowChanges* /* changes */ +); + +extern Status XGetWMProtocols( + Display* /* display */, + Window /* w */, + Atom** /* protocols_return */, + int* /* count_return */ +); +extern Status XSetWMProtocols( + Display* /* display */, + Window /* w */, + Atom* /* protocols */, + int /* count */ +); +extern Status XIconifyWindow( + Display* /* display */, + Window /* w */, + int /* screen_number */ +); +extern Status XWithdrawWindow( + Display* /* display */, + Window /* w */, + int /* screen_number */ +); +extern Status XGetCommand( + Display* /* display */, + Window /* w */, + char*** /* argv_return */, + int* /* argc_return */ +); +extern Status XGetWMColormapWindows( + Display* /* display */, + Window /* w */, + Window** /* windows_return */, + int* /* count_return */ +); +extern Status XSetWMColormapWindows( + Display* /* display */, + Window /* w */, + Window* /* colormap_windows */, + int /* count */ +); +extern void XFreeStringList( + char** /* list */ +); +extern int XSetTransientForHint( + Display* /* display */, + Window /* w */, + Window /* prop_window */ +); + +/* The following are given in alphabetical order */ + +extern int XActivateScreenSaver( + Display* /* display */ +); + +extern int XAddHost( + Display* /* display */, + XHostAddress* /* host */ +); + +extern int XAddHosts( + Display* /* display */, + XHostAddress* /* hosts */, + int /* num_hosts */ +); + +extern int XAddToExtensionList( + struct _XExtData** /* structure */, + XExtData* /* ext_data */ +); + +extern int XAddToSaveSet( + Display* /* display */, + Window /* w */ +); + +extern Status XAllocColor( + Display* /* display */, + Colormap /* colormap */, + XColor* /* screen_in_out */ +); + +extern Status XAllocColorCells( + Display* /* display */, + Colormap /* colormap */, + Bool /* contig */, + unsigned long* /* plane_masks_return */, + unsigned int /* nplanes */, + unsigned long* /* pixels_return */, + unsigned int /* npixels */ +); + +extern Status XAllocColorPlanes( + Display* /* display */, + Colormap /* colormap */, + Bool /* contig */, + unsigned long* /* pixels_return */, + int /* ncolors */, + int /* nreds */, + int /* ngreens */, + int /* nblues */, + unsigned long* /* rmask_return */, + unsigned long* /* gmask_return */, + unsigned long* /* bmask_return */ +); + +extern Status XAllocNamedColor( + Display* /* display */, + Colormap /* colormap */, + _Xconst char* /* color_name */, + XColor* /* screen_def_return */, + XColor* /* exact_def_return */ +); + +extern int XAllowEvents( + Display* /* display */, + int /* event_mode */, + Time /* time */ +); + +extern int XAutoRepeatOff( + Display* /* display */ +); + +extern int XAutoRepeatOn( + Display* /* display */ +); + +extern int XBell( + Display* /* display */, + int /* percent */ +); + +extern int XBitmapBitOrder( + Display* /* display */ +); + +extern int XBitmapPad( + Display* /* display */ +); + +extern int XBitmapUnit( + Display* /* display */ +); + +extern int XCellsOfScreen( + Screen* /* screen */ +); + +extern int XChangeActivePointerGrab( + Display* /* display */, + unsigned int /* event_mask */, + Cursor /* cursor */, + Time /* time */ +); + +extern int XChangeGC( + Display* /* display */, + GC /* gc */, + unsigned long /* valuemask */, + XGCValues* /* values */ +); + +extern int XChangeKeyboardControl( + Display* /* display */, + unsigned long /* value_mask */, + XKeyboardControl* /* values */ +); + +extern int XChangeKeyboardMapping( + Display* /* display */, + int /* first_keycode */, + int /* keysyms_per_keycode */, + KeySym* /* keysyms */, + int /* num_codes */ +); + +extern int XChangePointerControl( + Display* /* display */, + Bool /* do_accel */, + Bool /* do_threshold */, + int /* accel_numerator */, + int /* accel_denominator */, + int /* threshold */ +); + +extern int XChangeProperty( + Display* /* display */, + Window /* w */, + Atom /* property */, + Atom /* type */, + int /* format */, + int /* mode */, + _Xconst unsigned char* /* data */, + int /* nelements */ +); + +extern int XChangeSaveSet( + Display* /* display */, + Window /* w */, + int /* change_mode */ +); + +extern int XChangeWindowAttributes( + Display* /* display */, + Window /* w */, + unsigned long /* valuemask */, + XSetWindowAttributes* /* attributes */ +); + +extern Bool XCheckIfEvent( + Display* /* display */, + XEvent* /* event_return */, + Bool (*) ( + Display* /* display */, + XEvent* /* event */, + XPointer /* arg */ + ) /* predicate */, + XPointer /* arg */ +); + +extern Bool XCheckMaskEvent( + Display* /* display */, + long /* event_mask */, + XEvent* /* event_return */ +); + +extern Bool XCheckTypedEvent( + Display* /* display */, + int /* event_type */, + XEvent* /* event_return */ +); + +extern Bool XCheckTypedWindowEvent( + Display* /* display */, + Window /* w */, + int /* event_type */, + XEvent* /* event_return */ +); + +extern Bool XCheckWindowEvent( + Display* /* display */, + Window /* w */, + long /* event_mask */, + XEvent* /* event_return */ +); + +extern int XCirculateSubwindows( + Display* /* display */, + Window /* w */, + int /* direction */ +); + +extern int XCirculateSubwindowsDown( + Display* /* display */, + Window /* w */ +); + +extern int XCirculateSubwindowsUp( + Display* /* display */, + Window /* w */ +); + +extern int XClearArea( + Display* /* display */, + Window /* w */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + Bool /* exposures */ +); + +extern int XClearWindow( + Display* /* display */, + Window /* w */ +); + +extern int XCloseDisplay( + Display* /* display */ +); + +extern int XConfigureWindow( + Display* /* display */, + Window /* w */, + unsigned int /* value_mask */, + XWindowChanges* /* values */ +); + +extern int XConnectionNumber( + Display* /* display */ +); + +extern int XConvertSelection( + Display* /* display */, + Atom /* selection */, + Atom /* target */, + Atom /* property */, + Window /* requestor */, + Time /* time */ +); + +extern int XCopyArea( + Display* /* display */, + Drawable /* src */, + Drawable /* dest */, + GC /* gc */, + int /* src_x */, + int /* src_y */, + unsigned int /* width */, + unsigned int /* height */, + int /* dest_x */, + int /* dest_y */ +); + +extern int XCopyGC( + Display* /* display */, + GC /* src */, + unsigned long /* valuemask */, + GC /* dest */ +); + +extern int XCopyPlane( + Display* /* display */, + Drawable /* src */, + Drawable /* dest */, + GC /* gc */, + int /* src_x */, + int /* src_y */, + unsigned int /* width */, + unsigned int /* height */, + int /* dest_x */, + int /* dest_y */, + unsigned long /* plane */ +); + +extern int XDefaultDepth( + Display* /* display */, + int /* screen_number */ +); + +extern int XDefaultDepthOfScreen( + Screen* /* screen */ +); + +extern int XDefaultScreen( + Display* /* display */ +); + +extern int XDefineCursor( + Display* /* display */, + Window /* w */, + Cursor /* cursor */ +); + +extern int XDeleteProperty( + Display* /* display */, + Window /* w */, + Atom /* property */ +); + +extern int XDestroyWindow( + Display* /* display */, + Window /* w */ +); + +extern int XDestroySubwindows( + Display* /* display */, + Window /* w */ +); + +extern int XDoesBackingStore( + Screen* /* screen */ +); + +extern Bool XDoesSaveUnders( + Screen* /* screen */ +); + +extern int XDisableAccessControl( + Display* /* display */ +); + + +extern int XDisplayCells( + Display* /* display */, + int /* screen_number */ +); + +extern int XDisplayHeight( + Display* /* display */, + int /* screen_number */ +); + +extern int XDisplayHeightMM( + Display* /* display */, + int /* screen_number */ +); + +extern int XDisplayKeycodes( + Display* /* display */, + int* /* min_keycodes_return */, + int* /* max_keycodes_return */ +); + +extern int XDisplayPlanes( + Display* /* display */, + int /* screen_number */ +); + +extern int XDisplayWidth( + Display* /* display */, + int /* screen_number */ +); + +extern int XDisplayWidthMM( + Display* /* display */, + int /* screen_number */ +); + +extern int XDrawArc( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + int /* angle1 */, + int /* angle2 */ +); + +extern int XDrawArcs( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XArc* /* arcs */, + int /* narcs */ +); + +extern int XDrawImageString( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* string */, + int /* length */ +); + +extern int XDrawImageString16( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst XChar2b* /* string */, + int /* length */ +); + +extern int XDrawLine( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x1 */, + int /* y1 */, + int /* x2 */, + int /* y2 */ +); + +extern int XDrawLines( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XPoint* /* points */, + int /* npoints */, + int /* mode */ +); + +extern int XDrawPoint( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */ +); + +extern int XDrawPoints( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XPoint* /* points */, + int /* npoints */, + int /* mode */ +); + +extern int XDrawRectangle( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XDrawRectangles( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XRectangle* /* rectangles */, + int /* nrectangles */ +); + +extern int XDrawSegments( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XSegment* /* segments */, + int /* nsegments */ +); + +extern int XDrawString( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* string */, + int /* length */ +); + +extern int XDrawString16( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst XChar2b* /* string */, + int /* length */ +); + +extern int XDrawText( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + XTextItem* /* items */, + int /* nitems */ +); + +extern int XDrawText16( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + XTextItem16* /* items */, + int /* nitems */ +); + +extern int XEnableAccessControl( + Display* /* display */ +); + +extern int XEventsQueued( + Display* /* display */, + int /* mode */ +); + +extern Status XFetchName( + Display* /* display */, + Window /* w */, + char** /* window_name_return */ +); + +extern int XFillArc( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */, + int /* angle1 */, + int /* angle2 */ +); + +extern int XFillArcs( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XArc* /* arcs */, + int /* narcs */ +); + +extern int XFillPolygon( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XPoint* /* points */, + int /* npoints */, + int /* shape */, + int /* mode */ +); + +extern int XFillRectangle( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XFillRectangles( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XRectangle* /* rectangles */, + int /* nrectangles */ +); + +extern int XFlush( + Display* /* display */ +); + +extern int XForceScreenSaver( + Display* /* display */, + int /* mode */ +); + +extern int XFree( + void* /* data */ +); + +extern int XFreeColormap( + Display* /* display */, + Colormap /* colormap */ +); + +extern int XFreeColors( + Display* /* display */, + Colormap /* colormap */, + unsigned long* /* pixels */, + int /* npixels */, + unsigned long /* planes */ +); + +extern int XFreeCursor( + Display* /* display */, + Cursor /* cursor */ +); + +extern int XFreeExtensionList( + char** /* list */ +); + +extern int XFreeFont( + Display* /* display */, + XFontStruct* /* font_struct */ +); + +extern int XFreeFontInfo( + char** /* names */, + XFontStruct* /* free_info */, + int /* actual_count */ +); + +extern int XFreeFontNames( + char** /* list */ +); + +extern int XFreeFontPath( + char** /* list */ +); + +extern int XFreeGC( + Display* /* display */, + GC /* gc */ +); + +extern int XFreeModifiermap( + XModifierKeymap* /* modmap */ +); + +extern int XFreePixmap( + Display* /* display */, + Pixmap /* pixmap */ +); + +extern int XGeometry( + Display* /* display */, + int /* screen */, + _Xconst char* /* position */, + _Xconst char* /* default_position */, + unsigned int /* bwidth */, + unsigned int /* fwidth */, + unsigned int /* fheight */, + int /* xadder */, + int /* yadder */, + int* /* x_return */, + int* /* y_return */, + int* /* width_return */, + int* /* height_return */ +); + +extern int XGetErrorDatabaseText( + Display* /* display */, + _Xconst char* /* name */, + _Xconst char* /* message */, + _Xconst char* /* default_string */, + char* /* buffer_return */, + int /* length */ +); + +extern int XGetErrorText( + Display* /* display */, + int /* code */, + char* /* buffer_return */, + int /* length */ +); + +extern Bool XGetFontProperty( + XFontStruct* /* font_struct */, + Atom /* atom */, + unsigned long* /* value_return */ +); + +extern Status XGetGCValues( + Display* /* display */, + GC /* gc */, + unsigned long /* valuemask */, + XGCValues* /* values_return */ +); + +extern Status XGetGeometry( + Display* /* display */, + Drawable /* d */, + Window* /* root_return */, + int* /* x_return */, + int* /* y_return */, + unsigned int* /* width_return */, + unsigned int* /* height_return */, + unsigned int* /* border_width_return */, + unsigned int* /* depth_return */ +); + +extern Status XGetIconName( + Display* /* display */, + Window /* w */, + char** /* icon_name_return */ +); + +extern int XGetInputFocus( + Display* /* display */, + Window* /* focus_return */, + int* /* revert_to_return */ +); + +extern int XGetKeyboardControl( + Display* /* display */, + XKeyboardState* /* values_return */ +); + +extern int XGetPointerControl( + Display* /* display */, + int* /* accel_numerator_return */, + int* /* accel_denominator_return */, + int* /* threshold_return */ +); + +extern int XGetPointerMapping( + Display* /* display */, + unsigned char* /* map_return */, + int /* nmap */ +); + +extern int XGetScreenSaver( + Display* /* display */, + int* /* timeout_return */, + int* /* interval_return */, + int* /* prefer_blanking_return */, + int* /* allow_exposures_return */ +); + +extern Status XGetTransientForHint( + Display* /* display */, + Window /* w */, + Window* /* prop_window_return */ +); + +extern int XGetWindowProperty( + Display* /* display */, + Window /* w */, + Atom /* property */, + long /* long_offset */, + long /* long_length */, + Bool /* delete */, + Atom /* req_type */, + Atom* /* actual_type_return */, + int* /* actual_format_return */, + unsigned long* /* nitems_return */, + unsigned long* /* bytes_after_return */, + unsigned char** /* prop_return */ +); + +extern Status XGetWindowAttributes( + Display* /* display */, + Window /* w */, + XWindowAttributes* /* window_attributes_return */ +); + +extern int XGrabButton( + Display* /* display */, + unsigned int /* button */, + unsigned int /* modifiers */, + Window /* grab_window */, + Bool /* owner_events */, + unsigned int /* event_mask */, + int /* pointer_mode */, + int /* keyboard_mode */, + Window /* confine_to */, + Cursor /* cursor */ +); + +extern int XGrabKey( + Display* /* display */, + int /* keycode */, + unsigned int /* modifiers */, + Window /* grab_window */, + Bool /* owner_events */, + int /* pointer_mode */, + int /* keyboard_mode */ +); + +extern int XGrabKeyboard( + Display* /* display */, + Window /* grab_window */, + Bool /* owner_events */, + int /* pointer_mode */, + int /* keyboard_mode */, + Time /* time */ +); + +extern int XGrabPointer( + Display* /* display */, + Window /* grab_window */, + Bool /* owner_events */, + unsigned int /* event_mask */, + int /* pointer_mode */, + int /* keyboard_mode */, + Window /* confine_to */, + Cursor /* cursor */, + Time /* time */ +); + +extern int XGrabServer( + Display* /* display */ +); + +extern int XHeightMMOfScreen( + Screen* /* screen */ +); + +extern int XHeightOfScreen( + Screen* /* screen */ +); + +extern int XIfEvent( + Display* /* display */, + XEvent* /* event_return */, + Bool (*) ( + Display* /* display */, + XEvent* /* event */, + XPointer /* arg */ + ) /* predicate */, + XPointer /* arg */ +); + +extern int XImageByteOrder( + Display* /* display */ +); + +extern int XInstallColormap( + Display* /* display */, + Colormap /* colormap */ +); + +extern KeyCode XKeysymToKeycode( + Display* /* display */, + KeySym /* keysym */ +); + +extern int XKillClient( + Display* /* display */, + XID /* resource */ +); + +extern Status XLookupColor( + Display* /* display */, + Colormap /* colormap */, + _Xconst char* /* color_name */, + XColor* /* exact_def_return */, + XColor* /* screen_def_return */ +); + +extern int XLowerWindow( + Display* /* display */, + Window /* w */ +); + +extern int XMapRaised( + Display* /* display */, + Window /* w */ +); + +extern int XMapSubwindows( + Display* /* display */, + Window /* w */ +); + +extern int XMapWindow( + Display* /* display */, + Window /* w */ +); + +extern int XMaskEvent( + Display* /* display */, + long /* event_mask */, + XEvent* /* event_return */ +); + +extern int XMaxCmapsOfScreen( + Screen* /* screen */ +); + +extern int XMinCmapsOfScreen( + Screen* /* screen */ +); + +extern int XMoveResizeWindow( + Display* /* display */, + Window /* w */, + int /* x */, + int /* y */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XMoveWindow( + Display* /* display */, + Window /* w */, + int /* x */, + int /* y */ +); + +extern int XNextEvent( + Display* /* display */, + XEvent* /* event_return */ +); + +extern int XNoOp( + Display* /* display */ +); + +extern Status XParseColor( + Display* /* display */, + Colormap /* colormap */, + _Xconst char* /* spec */, + XColor* /* exact_def_return */ +); + +extern int XParseGeometry( + _Xconst char* /* parsestring */, + int* /* x_return */, + int* /* y_return */, + unsigned int* /* width_return */, + unsigned int* /* height_return */ +); + +extern int XPeekEvent( + Display* /* display */, + XEvent* /* event_return */ +); + +extern int XPeekIfEvent( + Display* /* display */, + XEvent* /* event_return */, + Bool (*) ( + Display* /* display */, + XEvent* /* event */, + XPointer /* arg */ + ) /* predicate */, + XPointer /* arg */ +); + +extern int XPending( + Display* /* display */ +); + +extern int XPlanesOfScreen( + Screen* /* screen */ +); + +extern int XProtocolRevision( + Display* /* display */ +); + +extern int XProtocolVersion( + Display* /* display */ +); + + +extern int XPutBackEvent( + Display* /* display */, + XEvent* /* event */ +); + +extern int XPutImage( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + XImage* /* image */, + int /* src_x */, + int /* src_y */, + int /* dest_x */, + int /* dest_y */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XQLength( + Display* /* display */ +); + +extern Status XQueryBestCursor( + Display* /* display */, + Drawable /* d */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int* /* width_return */, + unsigned int* /* height_return */ +); + +extern Status XQueryBestSize( + Display* /* display */, + int /* class */, + Drawable /* which_screen */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int* /* width_return */, + unsigned int* /* height_return */ +); + +extern Status XQueryBestStipple( + Display* /* display */, + Drawable /* which_screen */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int* /* width_return */, + unsigned int* /* height_return */ +); + +extern Status XQueryBestTile( + Display* /* display */, + Drawable /* which_screen */, + unsigned int /* width */, + unsigned int /* height */, + unsigned int* /* width_return */, + unsigned int* /* height_return */ +); + +extern int XQueryColor( + Display* /* display */, + Colormap /* colormap */, + XColor* /* def_in_out */ +); + +extern int XQueryColors( + Display* /* display */, + Colormap /* colormap */, + XColor* /* defs_in_out */, + int /* ncolors */ +); + +extern Bool XQueryExtension( + Display* /* display */, + _Xconst char* /* name */, + int* /* major_opcode_return */, + int* /* first_event_return */, + int* /* first_error_return */ +); + +extern int XQueryKeymap( + Display* /* display */, + char [32] /* keys_return */ +); + +extern Bool XQueryPointer( + Display* /* display */, + Window /* w */, + Window* /* root_return */, + Window* /* child_return */, + int* /* root_x_return */, + int* /* root_y_return */, + int* /* win_x_return */, + int* /* win_y_return */, + unsigned int* /* mask_return */ +); + +extern int XQueryTextExtents( + Display* /* display */, + XID /* font_ID */, + _Xconst char* /* string */, + int /* nchars */, + int* /* direction_return */, + int* /* font_ascent_return */, + int* /* font_descent_return */, + XCharStruct* /* overall_return */ +); + +extern int XQueryTextExtents16( + Display* /* display */, + XID /* font_ID */, + _Xconst XChar2b* /* string */, + int /* nchars */, + int* /* direction_return */, + int* /* font_ascent_return */, + int* /* font_descent_return */, + XCharStruct* /* overall_return */ +); + +extern Status XQueryTree( + Display* /* display */, + Window /* w */, + Window* /* root_return */, + Window* /* parent_return */, + Window** /* children_return */, + unsigned int* /* nchildren_return */ +); + +extern int XRaiseWindow( + Display* /* display */, + Window /* w */ +); + +extern int XReadBitmapFile( + Display* /* display */, + Drawable /* d */, + _Xconst char* /* filename */, + unsigned int* /* width_return */, + unsigned int* /* height_return */, + Pixmap* /* bitmap_return */, + int* /* x_hot_return */, + int* /* y_hot_return */ +); + +extern int XReadBitmapFileData( + _Xconst char* /* filename */, + unsigned int* /* width_return */, + unsigned int* /* height_return */, + unsigned char** /* data_return */, + int* /* x_hot_return */, + int* /* y_hot_return */ +); + +extern int XRebindKeysym( + Display* /* display */, + KeySym /* keysym */, + KeySym* /* list */, + int /* mod_count */, + _Xconst unsigned char* /* string */, + int /* bytes_string */ +); + +extern int XRecolorCursor( + Display* /* display */, + Cursor /* cursor */, + XColor* /* foreground_color */, + XColor* /* background_color */ +); + +extern int XRefreshKeyboardMapping( + XMappingEvent* /* event_map */ +); + +extern int XRemoveFromSaveSet( + Display* /* display */, + Window /* w */ +); + +extern int XRemoveHost( + Display* /* display */, + XHostAddress* /* host */ +); + +extern int XRemoveHosts( + Display* /* display */, + XHostAddress* /* hosts */, + int /* num_hosts */ +); + +extern int XReparentWindow( + Display* /* display */, + Window /* w */, + Window /* parent */, + int /* x */, + int /* y */ +); + +extern int XResetScreenSaver( + Display* /* display */ +); + +extern int XResizeWindow( + Display* /* display */, + Window /* w */, + unsigned int /* width */, + unsigned int /* height */ +); + +extern int XRestackWindows( + Display* /* display */, + Window* /* windows */, + int /* nwindows */ +); + +extern int XRotateBuffers( + Display* /* display */, + int /* rotate */ +); + +extern int XRotateWindowProperties( + Display* /* display */, + Window /* w */, + Atom* /* properties */, + int /* num_prop */, + int /* npositions */ +); + +extern int XScreenCount( + Display* /* display */ +); + +extern int XSelectInput( + Display* /* display */, + Window /* w */, + long /* event_mask */ +); + +extern Status XSendEvent( + Display* /* display */, + Window /* w */, + Bool /* propagate */, + long /* event_mask */, + XEvent* /* event_send */ +); + +extern int XSetAccessControl( + Display* /* display */, + int /* mode */ +); + +extern int XSetArcMode( + Display* /* display */, + GC /* gc */, + int /* arc_mode */ +); + +extern int XSetBackground( + Display* /* display */, + GC /* gc */, + unsigned long /* background */ +); + +extern int XSetClipMask( + Display* /* display */, + GC /* gc */, + Pixmap /* pixmap */ +); + +extern int XSetClipOrigin( + Display* /* display */, + GC /* gc */, + int /* clip_x_origin */, + int /* clip_y_origin */ +); + +extern int XSetClipRectangles( + Display* /* display */, + GC /* gc */, + int /* clip_x_origin */, + int /* clip_y_origin */, + XRectangle* /* rectangles */, + int /* n */, + int /* ordering */ +); + +extern int XSetCloseDownMode( + Display* /* display */, + int /* close_mode */ +); + +extern int XSetCommand( + Display* /* display */, + Window /* w */, + char** /* argv */, + int /* argc */ +); + +extern int XSetDashes( + Display* /* display */, + GC /* gc */, + int /* dash_offset */, + _Xconst char* /* dash_list */, + int /* n */ +); + +extern int XSetFillRule( + Display* /* display */, + GC /* gc */, + int /* fill_rule */ +); + +extern int XSetFillStyle( + Display* /* display */, + GC /* gc */, + int /* fill_style */ +); + +extern int XSetFont( + Display* /* display */, + GC /* gc */, + Font /* font */ +); + +extern int XSetFontPath( + Display* /* display */, + char** /* directories */, + int /* ndirs */ +); + +extern int XSetForeground( + Display* /* display */, + GC /* gc */, + unsigned long /* foreground */ +); + +extern int XSetFunction( + Display* /* display */, + GC /* gc */, + int /* function */ +); + +extern int XSetGraphicsExposures( + Display* /* display */, + GC /* gc */, + Bool /* graphics_exposures */ +); + +extern int XSetIconName( + Display* /* display */, + Window /* w */, + _Xconst char* /* icon_name */ +); + +extern int XSetInputFocus( + Display* /* display */, + Window /* focus */, + int /* revert_to */, + Time /* time */ +); + +extern int XSetLineAttributes( + Display* /* display */, + GC /* gc */, + unsigned int /* line_width */, + int /* line_style */, + int /* cap_style */, + int /* join_style */ +); + +extern int XSetModifierMapping( + Display* /* display */, + XModifierKeymap* /* modmap */ +); + +extern int XSetPlaneMask( + Display* /* display */, + GC /* gc */, + unsigned long /* plane_mask */ +); + +extern int XSetPointerMapping( + Display* /* display */, + _Xconst unsigned char* /* map */, + int /* nmap */ +); + +extern int XSetScreenSaver( + Display* /* display */, + int /* timeout */, + int /* interval */, + int /* prefer_blanking */, + int /* allow_exposures */ +); + +extern int XSetSelectionOwner( + Display* /* display */, + Atom /* selection */, + Window /* owner */, + Time /* time */ +); + +extern int XSetState( + Display* /* display */, + GC /* gc */, + unsigned long /* foreground */, + unsigned long /* background */, + int /* function */, + unsigned long /* plane_mask */ +); + +extern int XSetStipple( + Display* /* display */, + GC /* gc */, + Pixmap /* stipple */ +); + +extern int XSetSubwindowMode( + Display* /* display */, + GC /* gc */, + int /* subwindow_mode */ +); + +extern int XSetTSOrigin( + Display* /* display */, + GC /* gc */, + int /* ts_x_origin */, + int /* ts_y_origin */ +); + +extern int XSetTile( + Display* /* display */, + GC /* gc */, + Pixmap /* tile */ +); + +extern int XSetWindowBackground( + Display* /* display */, + Window /* w */, + unsigned long /* background_pixel */ +); + +extern int XSetWindowBackgroundPixmap( + Display* /* display */, + Window /* w */, + Pixmap /* background_pixmap */ +); + +extern int XSetWindowBorder( + Display* /* display */, + Window /* w */, + unsigned long /* border_pixel */ +); + +extern int XSetWindowBorderPixmap( + Display* /* display */, + Window /* w */, + Pixmap /* border_pixmap */ +); + +extern int XSetWindowBorderWidth( + Display* /* display */, + Window /* w */, + unsigned int /* width */ +); + +extern int XSetWindowColormap( + Display* /* display */, + Window /* w */, + Colormap /* colormap */ +); + +extern int XStoreBuffer( + Display* /* display */, + _Xconst char* /* bytes */, + int /* nbytes */, + int /* buffer */ +); + +extern int XStoreBytes( + Display* /* display */, + _Xconst char* /* bytes */, + int /* nbytes */ +); + +extern int XStoreColor( + Display* /* display */, + Colormap /* colormap */, + XColor* /* color */ +); + +extern int XStoreColors( + Display* /* display */, + Colormap /* colormap */, + XColor* /* color */, + int /* ncolors */ +); + +extern int XStoreName( + Display* /* display */, + Window /* w */, + _Xconst char* /* window_name */ +); + +extern int XStoreNamedColor( + Display* /* display */, + Colormap /* colormap */, + _Xconst char* /* color */, + unsigned long /* pixel */, + int /* flags */ +); + +extern int XSync( + Display* /* display */, + Bool /* discard */ +); + +extern int XTextExtents( + XFontStruct* /* font_struct */, + _Xconst char* /* string */, + int /* nchars */, + int* /* direction_return */, + int* /* font_ascent_return */, + int* /* font_descent_return */, + XCharStruct* /* overall_return */ +); + +extern int XTextExtents16( + XFontStruct* /* font_struct */, + _Xconst XChar2b* /* string */, + int /* nchars */, + int* /* direction_return */, + int* /* font_ascent_return */, + int* /* font_descent_return */, + XCharStruct* /* overall_return */ +); + +extern int XTextWidth( + XFontStruct* /* font_struct */, + _Xconst char* /* string */, + int /* count */ +); + +extern int XTextWidth16( + XFontStruct* /* font_struct */, + _Xconst XChar2b* /* string */, + int /* count */ +); + +extern Bool XTranslateCoordinates( + Display* /* display */, + Window /* src_w */, + Window /* dest_w */, + int /* src_x */, + int /* src_y */, + int* /* dest_x_return */, + int* /* dest_y_return */, + Window* /* child_return */ +); + +extern int XUndefineCursor( + Display* /* display */, + Window /* w */ +); + +extern int XUngrabButton( + Display* /* display */, + unsigned int /* button */, + unsigned int /* modifiers */, + Window /* grab_window */ +); + +extern int XUngrabKey( + Display* /* display */, + int /* keycode */, + unsigned int /* modifiers */, + Window /* grab_window */ +); + +extern int XUngrabKeyboard( + Display* /* display */, + Time /* time */ +); + +extern int XUngrabPointer( + Display* /* display */, + Time /* time */ +); + +extern int XUngrabServer( + Display* /* display */ +); + +extern int XUninstallColormap( + Display* /* display */, + Colormap /* colormap */ +); + +extern int XUnloadFont( + Display* /* display */, + Font /* font */ +); + +extern int XUnmapSubwindows( + Display* /* display */, + Window /* w */ +); + +extern int XUnmapWindow( + Display* /* display */, + Window /* w */ +); + +extern int XVendorRelease( + Display* /* display */ +); + +extern int XWarpPointer( + Display* /* display */, + Window /* src_w */, + Window /* dest_w */, + int /* src_x */, + int /* src_y */, + unsigned int /* src_width */, + unsigned int /* src_height */, + int /* dest_x */, + int /* dest_y */ +); + +extern int XWidthMMOfScreen( + Screen* /* screen */ +); + +extern int XWidthOfScreen( + Screen* /* screen */ +); + +extern int XWindowEvent( + Display* /* display */, + Window /* w */, + long /* event_mask */, + XEvent* /* event_return */ +); + +extern int XWriteBitmapFile( + Display* /* display */, + _Xconst char* /* filename */, + Pixmap /* bitmap */, + unsigned int /* width */, + unsigned int /* height */, + int /* x_hot */, + int /* y_hot */ +); + +extern Bool XSupportsLocale (void); + +extern char *XSetLocaleModifiers( + const char* /* modifier_list */ +); + +extern XOM XOpenOM( + Display* /* display */, + struct _XrmHashBucketRec* /* rdb */, + _Xconst char* /* res_name */, + _Xconst char* /* res_class */ +); + +extern Status XCloseOM( + XOM /* om */ +); + +extern char *XSetOMValues( + XOM /* om */, + ... +) _X_SENTINEL(0); + +extern char *XGetOMValues( + XOM /* om */, + ... +) _X_SENTINEL(0); + +extern Display *XDisplayOfOM( + XOM /* om */ +); + +extern char *XLocaleOfOM( + XOM /* om */ +); + +extern XOC XCreateOC( + XOM /* om */, + ... +) _X_SENTINEL(0); + +extern void XDestroyOC( + XOC /* oc */ +); + +extern XOM XOMOfOC( + XOC /* oc */ +); + +extern char *XSetOCValues( + XOC /* oc */, + ... +) _X_SENTINEL(0); + +extern char *XGetOCValues( + XOC /* oc */, + ... +) _X_SENTINEL(0); + +extern XFontSet XCreateFontSet( + Display* /* display */, + _Xconst char* /* base_font_name_list */, + char*** /* missing_charset_list */, + int* /* missing_charset_count */, + char** /* def_string */ +); + +extern void XFreeFontSet( + Display* /* display */, + XFontSet /* font_set */ +); + +extern int XFontsOfFontSet( + XFontSet /* font_set */, + XFontStruct*** /* font_struct_list */, + char*** /* font_name_list */ +); + +extern char *XBaseFontNameListOfFontSet( + XFontSet /* font_set */ +); + +extern char *XLocaleOfFontSet( + XFontSet /* font_set */ +); + +extern Bool XContextDependentDrawing( + XFontSet /* font_set */ +); + +extern Bool XDirectionalDependentDrawing( + XFontSet /* font_set */ +); + +extern Bool XContextualDrawing( + XFontSet /* font_set */ +); + +extern XFontSetExtents *XExtentsOfFontSet( + XFontSet /* font_set */ +); + +extern int XmbTextEscapement( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern int XwcTextEscapement( + XFontSet /* font_set */, + _Xconst wchar_t* /* text */, + int /* num_wchars */ +); + +extern int Xutf8TextEscapement( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern int XmbTextExtents( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern int XwcTextExtents( + XFontSet /* font_set */, + _Xconst wchar_t* /* text */, + int /* num_wchars */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern int Xutf8TextExtents( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern Status XmbTextPerCharExtents( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */, + XRectangle* /* ink_extents_buffer */, + XRectangle* /* logical_extents_buffer */, + int /* buffer_size */, + int* /* num_chars */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern Status XwcTextPerCharExtents( + XFontSet /* font_set */, + _Xconst wchar_t* /* text */, + int /* num_wchars */, + XRectangle* /* ink_extents_buffer */, + XRectangle* /* logical_extents_buffer */, + int /* buffer_size */, + int* /* num_chars */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern Status Xutf8TextPerCharExtents( + XFontSet /* font_set */, + _Xconst char* /* text */, + int /* bytes_text */, + XRectangle* /* ink_extents_buffer */, + XRectangle* /* logical_extents_buffer */, + int /* buffer_size */, + int* /* num_chars */, + XRectangle* /* overall_ink_return */, + XRectangle* /* overall_logical_return */ +); + +extern void XmbDrawText( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + XmbTextItem* /* text_items */, + int /* nitems */ +); + +extern void XwcDrawText( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + XwcTextItem* /* text_items */, + int /* nitems */ +); + +extern void Xutf8DrawText( + Display* /* display */, + Drawable /* d */, + GC /* gc */, + int /* x */, + int /* y */, + XmbTextItem* /* text_items */, + int /* nitems */ +); + +extern void XmbDrawString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern void XwcDrawString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst wchar_t* /* text */, + int /* num_wchars */ +); + +extern void Xutf8DrawString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern void XmbDrawImageString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern void XwcDrawImageString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst wchar_t* /* text */, + int /* num_wchars */ +); + +extern void Xutf8DrawImageString( + Display* /* display */, + Drawable /* d */, + XFontSet /* font_set */, + GC /* gc */, + int /* x */, + int /* y */, + _Xconst char* /* text */, + int /* bytes_text */ +); + +extern XIM XOpenIM( + Display* /* dpy */, + struct _XrmHashBucketRec* /* rdb */, + char* /* res_name */, + char* /* res_class */ +); + +extern Status XCloseIM( + XIM /* im */ +); + +extern char *XGetIMValues( + XIM /* im */, ... +) _X_SENTINEL(0); + +extern char *XSetIMValues( + XIM /* im */, ... +) _X_SENTINEL(0); + +extern Display *XDisplayOfIM( + XIM /* im */ +); + +extern char *XLocaleOfIM( + XIM /* im*/ +); + +extern XIC XCreateIC( + XIM /* im */, ... +) _X_SENTINEL(0); + +extern void XDestroyIC( + XIC /* ic */ +); + +extern void XSetICFocus( + XIC /* ic */ +); + +extern void XUnsetICFocus( + XIC /* ic */ +); + +extern wchar_t *XwcResetIC( + XIC /* ic */ +); + +extern char *XmbResetIC( + XIC /* ic */ +); + +extern char *Xutf8ResetIC( + XIC /* ic */ +); + +extern char *XSetICValues( + XIC /* ic */, ... +) _X_SENTINEL(0); + +extern char *XGetICValues( + XIC /* ic */, ... +) _X_SENTINEL(0); + +extern XIM XIMOfIC( + XIC /* ic */ +); + +extern Bool XFilterEvent( + XEvent* /* event */, + Window /* window */ +); + +extern int XmbLookupString( + XIC /* ic */, + XKeyPressedEvent* /* event */, + char* /* buffer_return */, + int /* bytes_buffer */, + KeySym* /* keysym_return */, + Status* /* status_return */ +); + +extern int XwcLookupString( + XIC /* ic */, + XKeyPressedEvent* /* event */, + wchar_t* /* buffer_return */, + int /* wchars_buffer */, + KeySym* /* keysym_return */, + Status* /* status_return */ +); + +extern int Xutf8LookupString( + XIC /* ic */, + XKeyPressedEvent* /* event */, + char* /* buffer_return */, + int /* bytes_buffer */, + KeySym* /* keysym_return */, + Status* /* status_return */ +); + +extern XVaNestedList XVaCreateNestedList( + int /*unused*/, ... +) _X_SENTINEL(0); + +/* internal connections for IMs */ + +extern Bool XRegisterIMInstantiateCallback( + Display* /* dpy */, + struct _XrmHashBucketRec* /* rdb */, + char* /* res_name */, + char* /* res_class */, + XIDProc /* callback */, + XPointer /* client_data */ +); + +extern Bool XUnregisterIMInstantiateCallback( + Display* /* dpy */, + struct _XrmHashBucketRec* /* rdb */, + char* /* res_name */, + char* /* res_class */, + XIDProc /* callback */, + XPointer /* client_data */ +); + +typedef void (*XConnectionWatchProc)( + Display* /* dpy */, + XPointer /* client_data */, + int /* fd */, + Bool /* opening */, /* open or close flag */ + XPointer* /* watch_data */ /* open sets, close uses */ +); + + +extern Status XInternalConnectionNumbers( + Display* /* dpy */, + int** /* fd_return */, + int* /* count_return */ +); + +extern void XProcessInternalConnection( + Display* /* dpy */, + int /* fd */ +); + +extern Status XAddConnectionWatch( + Display* /* dpy */, + XConnectionWatchProc /* callback */, + XPointer /* client_data */ +); + +extern void XRemoveConnectionWatch( + Display* /* dpy */, + XConnectionWatchProc /* callback */, + XPointer /* client_data */ +); + +extern void XSetAuthorization( + char * /* name */, + int /* namelen */, + char * /* data */, + int /* datalen */ +); + +extern int _Xmbtowc( + wchar_t * /* wstr */, +#ifdef ISC + char const * /* str */, + size_t /* len */ +#else + char * /* str */, + int /* len */ +#endif +); + +extern int _Xwctomb( + char * /* str */, + wchar_t /* wc */ +); + +extern Bool XGetEventData( + Display* /* dpy */, + XGenericEventCookie* /* cookie*/ +); + +extern void XFreeEventData( + Display* /* dpy */, + XGenericEventCookie* /* cookie*/ +); + +_XFUNCPROTOEND + +#endif /* _X11_XLIB_H_ */ diff --git a/libX11/man/XInternAtom.man b/libX11/man/XInternAtom.man index 7a5ecc5b5..237ed91c0 100644 --- a/libX11/man/XInternAtom.man +++ b/libX11/man/XInternAtom.man @@ -1,279 +1,279 @@ -.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
-.\"
-.\" 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 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.
-.\"
-.\" 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.
-.\"
-.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
-.\" Digital Equipment Corporation
-.\"
-.\" Portions Copyright \(co 1990, 1991 by
-.\" Tektronix, Inc.
-.\"
-.\" Permission to use, copy, modify and distribute this documentation for
-.\" any purpose and without fee is hereby granted, provided that the above
-.\" copyright notice appears in all copies and that both that copyright notice
-.\" and this permission notice appear in all copies, and that the names of
-.\" Digital and Tektronix not be used in in advertising or publicity pertaining
-.\" to this documentation without specific, written prior permission.
-.\" Digital and Tektronix makes no representations about the suitability
-.\" of this documentation for any purpose.
-.\" It is provided ``as is'' without express or implied warranty.
-.\"
-.\"
-.ds xT X Toolkit Intrinsics \- C Language Interface
-.ds xW Athena X Widgets \- C Language X Toolkit Interface
-.ds xL Xlib \- C Language X Interface
-.ds xC Inter-Client Communication Conventions Manual
-.na
-.de Ds
-.nf
-.\\$1D \\$2 \\$1
-.ft 1
-.\".ps \\n(PS
-.\".if \\n(VS>=40 .vs \\n(VSu
-.\".if \\n(VS<=39 .vs \\n(VSp
-..
-.de De
-.ce 0
-.if \\n(BD .DF
-.nr BD 0
-.in \\n(OIu
-.if \\n(TM .ls 2
-.sp \\n(DDu
-.fi
-..
-.de FD
-.LP
-.KS
-.TA .5i 3i
-.ta .5i 3i
-.nf
-..
-.de FN
-.fi
-.KE
-.LP
-..
-.de IN \" send an index entry to the stderr
-..
-.de C{
-.KS
-.nf
-.D
-.\"
-.\" choose appropriate monospace font
-.\" the imagen conditional, 480,
-.\" may be changed to L if LB is too
-.\" heavy for your eyes...
-.\"
-.ie "\\*(.T"480" .ft L
-.el .ie "\\*(.T"300" .ft L
-.el .ie "\\*(.T"202" .ft PO
-.el .ie "\\*(.T"aps" .ft CW
-.el .ft R
-.ps \\n(PS
-.ie \\n(VS>40 .vs \\n(VSu
-.el .vs \\n(VSp
-..
-.de C}
-.DE
-.R
-..
-.de Pn
-.ie t \\$1\fB\^\\$2\^\fR\\$3
-.el \\$1\fI\^\\$2\^\fP\\$3
-..
-.de ZN
-.ie t \fB\^\\$1\^\fR\\$2
-.el \fI\^\\$1\^\fP\\$2
-..
-.de hN
-.ie t <\fB\\$1\fR>\\$2
-.el <\fI\\$1\fP>\\$2
-..
-.de NT
-.ne 7
-.ds NO Note
-.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
-.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
-.ie n .sp
-.el .sp 10p
-.TB
-.ce
-\\*(NO
-.ie n .sp
-.el .sp 5p
-.if '\\$1'C' .ce 99
-.if '\\$2'C' .ce 99
-.in +5n
-.ll -5n
-.R
-..
-. \" Note End -- doug kraft 3/85
-.de NE
-.ce 0
-.in -5n
-.ll +5n
-.ie n .sp
-.el .sp 10p
-..
-.ny0
-.TH XInternAtom __libmansuffix__ __xorgversion__ "XLIB FUNCTIONS"
-.SH NAME
-XInternAtom, XInternAtoms, XGetAtomName, XGetAtomNames \- create or return atom names
-.SH SYNTAX
-.HP
-Atom XInternAtom\^(\^Display *\fIdisplay\fP\^, const char *\fIatom_name\fP\^,
-Bool \fIonly_if_exists\fP\^);
-.HP
-Status XInternAtoms\^(\^Display *\fIdisplay\fP\^, const char **\fInames\fP\^,
-int \fIcount\fP\^, Bool \fIonly_if_exists\fP\^, Atom *\fIatoms_return\fP\^);
-.HP
-char *XGetAtomName\^(\^Display *\fIdisplay\fP\^, Atom \fIatom\fP\^);
-.HP
-Status XGetAtomNames\^(\^Display *\fIdisplay\fP\^, Atom *\fIatoms\fP\^, int
-\fIcount\fP\^, char **\fInames_return\fP\^);
-.SH ARGUMENTS
-.IP \fIatom\fP 1i
-Specifies the atom for the property name you want returned.
-.IP \fIatoms\fP 1i
-Specifies the array of atoms.
-.IP \fIatom_name\fP 1i
-Specifies the name associated with the atom you want returned.
-.IP \fIatoms_return\fP 1i
-Returns the atoms.
-.ds Cn atom names in the array
-.IP \fIcount\fP 1i
-Specifies the number of \*(Cn.
-.ds Cn atoms in the array
-.IP \fIcount\fP 1i
-Specifies the number of \*(Cn.
-.IP \fIdisplay\fP 1i
-Specifies the connection to the X server.
-.IP \fInames\fP 1i
-Specifies the array of atom names.
-.IP \fInames_return\fP 1i
-Returns the atom names.
-.IP \fIonly_if_exists\fP 1i
-Specifies a Boolean value that indicates whether the atom must be created.
-.SH DESCRIPTION
-The
-.ZN XInternAtom
-function returns the atom identifier associated with the specified atom_name
-string.
-If only_if_exists is
-.ZN False ,
-the atom is created if it does not exist.
-Therefore,
-.ZN XInternAtom
-can return
-.ZN None .
-If the atom name is not in the Host Portable Character Encoding,
-the result is implementation-dependent.
-Uppercase and lowercase matter;
-the strings ``thing'', ``Thing'', and ``thinG''
-all designate different atoms.
-The atom will remain defined even after the client's connection closes.
-It will become undefined only when the last connection to
-the X server closes.
-.LP
-.ZN XInternAtom
-can generate
-.ZN BadAlloc
-and
-.ZN BadValue
-errors.
-.LP
-The
-.ZN XInternAtoms
-function returns the atom identifiers associated with the specified names.
-The atoms are stored in the atoms_return array supplied by the caller.
-Calling this function is equivalent to calling
-.ZN XInternAtom
-for each of the names in turn with the specified value of only_if_exists,
-but this function minimizes the number of round-trip protocol exchanges
-between the client and the X server.
-.LP
-This function returns a nonzero status if atoms are returned for
-all of the names;
-otherwise, it returns zero.
-.LP
-.ZN XInternAtoms
-can generate
-.ZN BadAlloc
-and
-.ZN BadValue
-errors.
-.LP
-The
-.ZN XGetAtomName
-function returns the name associated with the specified atom.
-If the data returned by the server is in the Latin Portable Character Encoding,
-then the returned string is in the Host Portable Character Encoding.
-Otherwise, the result is implementation-dependent.
-To free the resulting string,
-call
-.ZN XFree .
-.LP
-.ZN XGetAtomName
-can generate a
-.ZN BadAtom
-error.
-.LP
-The
-.ZN XGetAtomNames
-function returns the names associated with the specified atoms.
-The names are stored in the names_return array supplied by the caller.
-Calling this function is equivalent to calling
-.ZN XGetAtomName
-for each of the atoms in turn,
-but this function minimizes the number of round-trip protocol exchanges
-between the client and the X server.
-.LP
-This function returns a nonzero status if names are returned for
-all of the atoms;
-otherwise, it returns zero.
-.LP
-.ZN XGetAtomNames
-can generate a
-.ZN BadAtom
-error.
-.SH DIAGNOSTICS
-.TP 1i
-.ZN BadAlloc
-The server failed to allocate the requested resource or server memory.
-.TP 1i
-.ZN BadAtom
-A value for an Atom argument does not name a defined Atom.
-.TP 1i
-.ZN BadValue
-Some numeric value falls outside the range of values accepted by the request.
-Unless a specific range is specified for an argument, the full range defined
-by the argument's type is accepted. Any argument defined as a set of
-alternatives can generate this error.
-.SH "SEE ALSO"
-XFree(__libmansuffix__),
-XGetWindowProperty(__libmansuffix__)
-.br
-\fI\*(xL\fP
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium +.\" +.\" 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 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. +.\" +.\" 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. +.\" +.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by +.\" Digital Equipment Corporation +.\" +.\" Portions Copyright \(co 1990, 1991 by +.\" Tektronix, Inc. +.\" +.\" Permission to use, copy, modify and distribute this documentation for +.\" any purpose and without fee is hereby granted, provided that the above +.\" copyright notice appears in all copies and that both that copyright notice +.\" and this permission notice appear in all copies, and that the names of +.\" Digital and Tektronix not be used in in advertising or publicity pertaining +.\" to this documentation without specific, written prior permission. +.\" Digital and Tektronix makes no representations about the suitability +.\" of this documentation for any purpose. +.\" It is provided ``as is'' without express or implied warranty. +.\" +.\" +.ds xT X Toolkit Intrinsics \- C Language Interface +.ds xW Athena X Widgets \- C Language X Toolkit Interface +.ds xL Xlib \- C Language X Interface +.ds xC Inter-Client Communication Conventions Manual +.na +.de Ds +.nf +.\\$1D \\$2 \\$1 +.ft 1 +.\".ps \\n(PS +.\".if \\n(VS>=40 .vs \\n(VSu +.\".if \\n(VS<=39 .vs \\n(VSp +.. +.de De +.ce 0 +.if \\n(BD .DF +.nr BD 0 +.in \\n(OIu +.if \\n(TM .ls 2 +.sp \\n(DDu +.fi +.. +.de FD +.LP +.KS +.TA .5i 3i +.ta .5i 3i +.nf +.. +.de FN +.fi +.KE +.LP +.. +.de IN \" send an index entry to the stderr +.. +.de C{ +.KS +.nf +.D +.\" +.\" choose appropriate monospace font +.\" the imagen conditional, 480, +.\" may be changed to L if LB is too +.\" heavy for your eyes... +.\" +.ie "\\*(.T"480" .ft L +.el .ie "\\*(.T"300" .ft L +.el .ie "\\*(.T"202" .ft PO +.el .ie "\\*(.T"aps" .ft CW +.el .ft R +.ps \\n(PS +.ie \\n(VS>40 .vs \\n(VSu +.el .vs \\n(VSp +.. +.de C} +.DE +.R +.. +.de Pn +.ie t \\$1\fB\^\\$2\^\fR\\$3 +.el \\$1\fI\^\\$2\^\fP\\$3 +.. +.de ZN +.ie t \fB\^\\$1\^\fR\\$2 +.el \fI\^\\$1\^\fP\\$2 +.. +.de hN +.ie t <\fB\\$1\fR>\\$2 +.el <\fI\\$1\fP>\\$2 +.. +.de NT +.ne 7 +.ds NO Note +.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2 +.if \\n(.$ .if !'\\$1'C' .ds NO \\$1 +.ie n .sp +.el .sp 10p +.TB +.ce +\\*(NO +.ie n .sp +.el .sp 5p +.if '\\$1'C' .ce 99 +.if '\\$2'C' .ce 99 +.in +5n +.ll -5n +.R +.. +. \" Note End -- doug kraft 3/85 +.de NE +.ce 0 +.in -5n +.ll +5n +.ie n .sp +.el .sp 10p +.. +.ny0 +.TH XInternAtom __libmansuffix__ __xorgversion__ "XLIB FUNCTIONS" +.SH NAME +XInternAtom, XInternAtoms, XGetAtomName, XGetAtomNames \- create or return atom names +.SH SYNTAX +.HP +Atom XInternAtom\^(\^Display *\fIdisplay\fP\^, char *\fIatom_name\fP\^, Bool +\fIonly_if_exists\fP\^); +.HP +Status XInternAtoms\^(\^Display *\fIdisplay\fP\^, char **\fInames\fP\^, int +\fIcount\fP\^, Bool \fIonly_if_exists\fP\^, Atom *\fIatoms_return\fP\^); +.HP +char *XGetAtomName\^(\^Display *\fIdisplay\fP\^, Atom \fIatom\fP\^); +.HP +Status XGetAtomNames\^(\^Display *\fIdisplay\fP\^, Atom *\fIatoms\fP\^, int +\fIcount\fP\^, char **\fInames_return\fP\^); +.SH ARGUMENTS +.IP \fIatom\fP 1i +Specifies the atom for the property name you want returned. +.IP \fIatoms\fP 1i +Specifies the array of atoms. +.IP \fIatom_name\fP 1i +Specifies the name associated with the atom you want returned. +.IP \fIatoms_return\fP 1i +Returns the atoms. +.ds Cn atom names in the array +.IP \fIcount\fP 1i +Specifies the number of \*(Cn. +.ds Cn atoms in the array +.IP \fIcount\fP 1i +Specifies the number of \*(Cn. +.IP \fIdisplay\fP 1i +Specifies the connection to the X server. +.IP \fInames\fP 1i +Specifies the array of atom names. +.IP \fInames_return\fP 1i +Returns the atom names. +.IP \fIonly_if_exists\fP 1i +Specifies a Boolean value that indicates whether the atom must be created. +.SH DESCRIPTION +The +.ZN XInternAtom +function returns the atom identifier associated with the specified atom_name +string. +If only_if_exists is +.ZN False , +the atom is created if it does not exist. +Therefore, +.ZN XInternAtom +can return +.ZN None . +If the atom name is not in the Host Portable Character Encoding, +the result is implementation-dependent. +Uppercase and lowercase matter; +the strings ``thing'', ``Thing'', and ``thinG'' +all designate different atoms. +The atom will remain defined even after the client's connection closes. +It will become undefined only when the last connection to +the X server closes. +.LP +.ZN XInternAtom +can generate +.ZN BadAlloc +and +.ZN BadValue +errors. +.LP +The +.ZN XInternAtoms +function returns the atom identifiers associated with the specified names. +The atoms are stored in the atoms_return array supplied by the caller. +Calling this function is equivalent to calling +.ZN XInternAtom +for each of the names in turn with the specified value of only_if_exists, +but this function minimizes the number of round-trip protocol exchanges +between the client and the X server. +.LP +This function returns a nonzero status if atoms are returned for +all of the names; +otherwise, it returns zero. +.LP +.ZN XInternAtoms +can generate +.ZN BadAlloc +and +.ZN BadValue +errors. +.LP +The +.ZN XGetAtomName +function returns the name associated with the specified atom. +If the data returned by the server is in the Latin Portable Character Encoding, +then the returned string is in the Host Portable Character Encoding. +Otherwise, the result is implementation-dependent. +To free the resulting string, +call +.ZN XFree . +.LP +.ZN XGetAtomName +can generate a +.ZN BadAtom +error. +.LP +The +.ZN XGetAtomNames +function returns the names associated with the specified atoms. +The names are stored in the names_return array supplied by the caller. +Calling this function is equivalent to calling +.ZN XGetAtomName +for each of the atoms in turn, +but this function minimizes the number of round-trip protocol exchanges +between the client and the X server. +.LP +This function returns a nonzero status if names are returned for +all of the atoms; +otherwise, it returns zero. +.LP +.ZN XGetAtomNames +can generate a +.ZN BadAtom +error. +.SH DIAGNOSTICS +.TP 1i +.ZN BadAlloc +The server failed to allocate the requested resource or server memory. +.TP 1i +.ZN BadAtom +A value for an Atom argument does not name a defined Atom. +.TP 1i +.ZN BadValue +Some numeric value falls outside the range of values accepted by the request. +Unless a specific range is specified for an argument, the full range defined +by the argument's type is accepted. Any argument defined as a set of +alternatives can generate this error. +.SH "SEE ALSO" +XFree(__libmansuffix__), +XGetWindowProperty(__libmansuffix__) +.br +\fI\*(xL\fP diff --git a/libX11/specs/libX11/CH04.xml b/libX11/specs/libX11/CH04.xml index 0469b2cde..8a3e8c535 100644 --- a/libX11/specs/libX11/CH04.xml +++ b/libX11/specs/libX11/CH04.xml @@ -1,2510 +1,2510 @@ -<?xml version="1.0" encoding="UTF-8" ?>
-<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
- "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
-<chapter id="window_information_functions">
-<title>Window Information Functions</title>
-
-<para>
-After you connect the display to the X server and create a window, you can use the Xlib window
-information functions to:
-</para>
-<itemizedlist>
- <listitem><para>Obtain information about a window</para></listitem>
- <listitem><para>Translate screen coordinates</para></listitem>
- <listitem><para>Manipulate property lists</para></listitem>
- <listitem><para>Obtain and change window properties</para></listitem>
- <listitem><para>Manipulate selections</para></listitem>
-</itemizedlist>
-
-<sect1 id="Obtaining_Window_Information">
-<title>Obtaining Window Information</title>
-<!-- .XS -->
-<!-- (SN Obtaining Window Information -->
-<!-- .XE -->
-<para>
-<!-- .LP -->
-Xlib provides functions that you can use to obtain information about
-the window tree, the window's current attributes,
-the window's current geometry, or the current pointer coordinates.
-Because they are most frequently used by window managers,
-these functions all return a status to indicate whether the window still
-exists.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To obtain the parent, a list of children, and number of children for
-a given window, use
-<function>XQueryTree</function>.
-<indexterm><primary>Child Window</primary></indexterm>
-<indexterm><primary>Parent Window</primary></indexterm>
-<indexterm significance="preferred"><primary>XQueryTree</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>Status <function>XQueryTree</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Window<parameter> w</parameter></paramdef>
- <paramdef>Window<parameter> *root_return</parameter></paramdef>
- <paramdef>Window<parameter> *parent_return</parameter></paramdef>
- <paramdef>Window<parameter> **children_return</parameter></paramdef>
- <paramdef>unsignedint<parameter> *nchildren_return</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
-<!-- .ds Wi whose list of children, root, parent, and number of children \ -->
-you want to obtain
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>w</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the window (Wi.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>root_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the root window.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>parent_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the parent window.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>children_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the list of children.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>nchildren_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the number of children.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XQueryTree</function>
-function returns the root ID, the parent window ID,
-a pointer to the list of children windows
-(NULL when there are no children),
-and the number of children in the list for the specified window.
-The children are listed in current stacking order, from bottom-most
-(first) to top-most (last).
-<function>XQueryTree</function>
-returns zero if it fails and nonzero if it succeeds.
-To free a non-NULL children list when it is no longer needed, use
-<function>XFree</function>.
-</para>
-<para>
-<!-- .LP -->
-<function>XQueryTree</function>
-can generate a
-<errorname>BadWindow</errorname>
-error.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To obtain the current attributes of a given window, use
-<function>XGetWindowAttributes</function>.
-<indexterm significance="preferred"><primary>XGetWindowAttributes</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>Status <function>XGetWindowAttributes</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Window<parameter> w</parameter></paramdef>
- <paramdef>XWindowAttributes<parameter> *window_attributes_return</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
-<!-- .ds Wi whose current attributes you want to obtain -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>w</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the window (Wi.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>window_attributes_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the specified window's attributes in the
-<structname>XWindowAttributes</structname>
-structure.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XGetWindowAttributes</function>
-function returns the current attributes for the specified window to an
-<structname>XWindowAttributes</structname>
-structure.
-</para>
-<para>
-<!-- .LP -->
-<indexterm significance="preferred"><primary>XWindowAttributes</primary></indexterm>
-<!-- .sM -->
-<literallayout class="monospaced">
-<!-- .TA .5i 3i -->
-<!-- .ta .5i 3i -->
-typedef struct {
- int x, y; /* location of window */
- int width, height; /* width and height of window */
- int border_width; /* border width of window */
- int depth; /* depth of window */
- Visual *visual; /* the associated visual structure */
- Window root; /* root of screen containing window */
- int class; /* InputOutput, InputOnly*/
- int bit_gravity; /* one of the bit gravity values */
- int win_gravity; /* one of the window gravity values */
- int backing_store; /* NotUseful, WhenMapped, Always */
- unsigned long backing_planes; /* planes to be preserved if possible */
- unsigned long backing_pixel; /* value to be used when restoring planes */
- Bool save_under; /* boolean, should bits under be saved? */
- Colormap colormap; /* color map to be associated with window */
- Bool map_installed; /* boolean, is color map currently installed*/
- int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
- long all_event_masks; /* set of events all people have interest in*/
- long your_event_mask; /* my event mask */
- long do_not_propagate_mask; /* set of events that should not propagate */
- Bool override_redirect; /* boolean value for override-redirect */
- Screen *screen; /* back pointer to correct screen */
-} XWindowAttributes;
-</literallayout>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The x and y members are set to the upper-left outer
-corner relative to the parent window's origin.
-The width and height members are set to the inside size of the window,
-not including the border.
-The border_width member is set to the window's border width in pixels.
-The depth member is set to the depth of the window
-(that is, bits per pixel for the object).
-The visual member is a pointer to the screen's associated
-<structname>Visual</structname>
-structure.
-The root member is set to the root window of the screen containing the window.
-The class member is set to the window's class and can be either
-<symbol>InputOutput</symbol>
-or
-<symbol>InputOnly</symbol>.
-</para>
-<para>
-<!-- .LP -->
-The bit_gravity member is set to the window's bit gravity
-and can be one of the following:
- <simplelist type="vert" columns="2">
- <member><symbol>ForgetGravity</symbol></member>
- <member><symbol>NorthWestGravity</symbol></member>
- <member><symbol>NorthGravity</symbol></member>
- <member><symbol>NorthEastGravity</symbol></member>
- <member><symbol>WestGravity</symbol></member>
-
- <member><symbol>EastGravity</symbol></member>
- <member><symbol>SouthWestGravity</symbol></member>
- <member><symbol>SouthGravity</symbol></member>
- <member><symbol>SouthEastGravity</symbol></member>
- <member><symbol>StaticGravity</symbol></member>
- </simplelist>
-</para>
-<para>
-The win_gravity member is set to the window's window gravity
-and can be one of the following:
- <simplelist type="vert" columns="2">
- <member><symbol>UnmapGravity</symbol></member>
- <member><symbol>NorthWestGravity</symbol></member>
- <member><symbol>NorthGravity</symbol></member>
- <member><symbol>NorthEastGravity</symbol></member>
- <member><symbol>WestGravity</symbol></member>
-
- <member><symbol>EastGravity</symbol></member>
- <member><symbol>SouthWestGravity</symbol></member>
- <member><symbol>SouthGravity</symbol></member>
- <member><symbol>SouthEastGravity</symbol></member>
- <member><symbol>StaticGravity</symbol></member>
- <member><symbol>CenterGravity</symbol></member>
- </simplelist>
-</para>
-<para>
-<!-- .LP -->
-For additional information on gravity,
-see section 3.2.3. <!-- xref -->
-</para>
-<para>
-<!-- .LP -->
-The backing_store member is set to indicate how the X server should maintain
-the contents of a window
-and can be
-<symbol>WhenMapped</symbol>,
-<symbol>Always</symbol>,
-or
-<symbol>NotUseful</symbol>.
-The backing_planes member is set to indicate (with bits set to 1) which bit
-planes of the window hold dynamic data that must be preserved in backing_stores
-and during save_unders.
-The backing_pixel member is set to indicate what values to use
-for planes not set in backing_planes.
-</para>
-<para>
-<!-- .LP -->
-The save_under member is set to
-<symbol>True</symbol>
-or
-<symbol>False</symbol>.
-The colormap member is set to the colormap for the specified window and can be
-a colormap ID or
-<symbol>None</symbol>.
-The map_installed member is set to indicate whether the colormap is
-currently installed and can be
-<symbol>True</symbol>
-or
-<symbol>False</symbol>.
-The map_state member is set to indicate the state of the window and can be
-<symbol>IsUnmapped</symbol>,
-<symbol>IsUnviewable</symbol>,
-or
-<symbol>IsViewable</symbol>.
-<symbol>IsUnviewable</symbol>
-is used if the window is mapped but some ancestor is unmapped.
-</para>
-<para>
-<!-- .LP -->
-The all_event_masks member is set to the bitwise inclusive OR of all event
-masks selected on the window by all clients.
-The your_event_mask member is set to the bitwise inclusive OR of all event
-masks selected by the querying client.
-The do_not_propagate_mask member is set to the bitwise inclusive OR of the
-set of events that should not propagate.
-</para>
-<para>
-<!-- .LP -->
-The override_redirect member is set to indicate whether this window overrides
-structure control facilities and can be
-<symbol>True</symbol>
-or
-<symbol>False</symbol>.
-Window manager clients should ignore the window if this member is
-<symbol>True</symbol>.
-</para>
-<para>
-<!-- .LP -->
-The screen member is set to a screen pointer that gives you a back pointer
-to the correct screen.
-This makes it easier to obtain the screen information without
-having to loop over the root window fields to see which field matches.
-</para>
-<para>
-<!-- .LP -->
-<function>XGetWindowAttributes</function>
-can generate
-<errorname>BadDrawable</errorname>
-and
-<errorname>BadWindow</errorname>
-errors.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To obtain the current geometry of a given drawable, use
-<function>XGetGeometry</function>.
-<indexterm significance="preferred"><primary>XGetGeometry</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>Status <function>XGetGeometry</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Drawable<parameter> d</parameter></paramdef>
- <paramdef>Window<parameter> *root_return</parameter></paramdef>
- <paramdef>int*x_return,<parameter> *y_return</parameter></paramdef>
- <paramdef>unsignedint*width_return,<parameter> *height_return</parameter></paramdef>
- <paramdef>unsignedint<parameter> *border_width_return</parameter></paramdef>
- <paramdef>unsignedint<parameter> *depth_return</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
-<!-- .ds Dr , which can be a window or a pixmap -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>d</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the drawable(Dr.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>root_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the root window.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>x_return</emphasis>
- </term>
- <listitem>
- <para>
-<!-- .br -->
-<!-- .ns -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>y_return</emphasis>
- </term>
- <listitem>
- <para>
-Return the x and y coordinates that define the location of the drawable.
-For a window,
-these coordinates specify the upper-left outer corner relative to
-its parent's origin.
-For pixmaps, these coordinates are always zero.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>width_return</emphasis>
- </term>
- <listitem>
- <para>
-<!-- .br -->
-<!-- .ns -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>height_return</emphasis>
- </term>
- <listitem>
- <para>
-Return the drawable's dimensions (width and height).
-For a window,
-these dimensions specify the inside size, not including the border.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>border_width_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the border width in pixels.
-If the drawable is a pixmap, it returns zero.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>depth_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the depth of the drawable (bits per pixel for the object).
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XGetGeometry</function>
-function returns the root window and the current geometry of the drawable.
-The geometry of the drawable includes the x and y coordinates, width and height,
-border width, and depth.
-These are described in the argument list.
-It is legal to pass to this function a window whose class is
-<symbol>InputOnly</symbol>.
-</para>
-<para>
-<!-- .LP -->
-<function>XGetGeometry</function>
-can generate a
-<errorname>BadDrawable</errorname>
-error.
-</para>
-</sect1>
-<sect1 id="Translating_Screen_Coordinates">
-<title>Translating Screen Coordinates</title>
-<!-- .XS -->
-<!-- (SN Translating Screen Coordinates -->
-<!-- .XE -->
-<para>
-<!-- .LP -->
-Applications sometimes
-need to perform a coordinate transformation from the coordinate
-space of one window to another window or need to determine which
-window the pointing device is in.
-<function>XTranslateCoordinates</function>
-and
-<function>XQueryPointer</function>
-fulfill these needs (and avoid any race conditions) by
-asking the X server to perform these operations.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To translate a coordinate in one window to the coordinate
-space of another window, use
-<function>XTranslateCoordinates</function>.
-<indexterm significance="preferred"><primary>XTranslateCoordinates</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function>XTranslateCoordinates</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Windowsrc_w,<parameter> dest_w</parameter></paramdef>
- <paramdef>intsrc_x,<parameter> src_y</parameter></paramdef>
- <paramdef>int*dest_x_return,<parameter> *dest_y_return</parameter></paramdef>
- <paramdef>Window<parameter> *child_return</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>src_w</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the source window.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>dest_w</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the destination window.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>src_x</emphasis>
- </term>
- <listitem>
- <para>
-<!-- .br -->
-<!-- .ns -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>src_y</emphasis>
- </term>
- <listitem>
- <para>
-Specify the x and y coordinates within the source window.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>dest_x_return</emphasis>
- </term>
- <listitem>
- <para>
-<!-- .br -->
-<!-- .ns -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>dest_y_return</emphasis>
- </term>
- <listitem>
- <para>
-Return the x and y coordinates within the destination window.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>child_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the child if the coordinates are contained in a mapped child of the
-destination window.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-If
-<function>XTranslateCoordinates</function>
-returns
-<symbol>True</symbol>,
-it takes the src_x and src_y coordinates relative
-to the source window's origin and returns these coordinates to
-dest_x_return and dest_y_return
-relative to the destination window's origin.
-If
-<function>XTranslateCoordinates</function>
-returns
-<symbol>False</symbol>,
-src_w and dest_w are on different screens,
-and dest_x_return and dest_y_return are zero.
-If the coordinates are contained in a mapped child of dest_w,
-that child is returned to child_return.
-Otherwise, child_return is set to
-<symbol>None</symbol>.
-</para>
-<para>
-<!-- .LP -->
-<function>XTranslateCoordinates</function>
-can generate a
-<errorname>BadWindow</errorname>
-error.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To obtain the screen coordinates of the pointer
-or to determine the pointer coordinates relative to a specified window, use
-<function>XQueryPointer</function>.
-<indexterm significance="preferred"><primary>XQueryPointer</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>Bool <function>XQueryPointer</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Window<parameter> w</parameter></paramdef>
- <paramdef>Window*root_return,<parameter> *child_return</parameter></paramdef>
- <paramdef>int*root_x_return,<parameter> *root_y_return</parameter></paramdef>
- <paramdef>int*win_x_return,<parameter> *win_y_return</parameter></paramdef>
- <paramdef>unsignedint<parameter> *mask_return</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>w</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the window.
-<!-- .ds Ro that the pointer is in -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>root_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the root window (Ro.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>child_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the child window that the pointer is located in, if any.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>root_x_return</emphasis>
- </term>
- <listitem>
- <para>
-<!-- .br -->
-<!-- .ns -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>root_y_return</emphasis>
- </term>
- <listitem>
- <para>
-Return the pointer coordinates relative to the root window's origin.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>win_x_return</emphasis>
- </term>
- <listitem>
- <para>
-<!-- .br -->
-<!-- .ns -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>win_y_return</emphasis>
- </term>
- <listitem>
- <para>
-Return the pointer coordinates relative to the specified window.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>mask_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the current state of the modifier keys and pointer buttons.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XQueryPointer</function>
-function returns the root window the pointer is logically on and the pointer
-coordinates relative to the root window's origin.
-If
-<function>XQueryPointer</function>
-returns
-<symbol>False</symbol>,
-the pointer is not on the same screen as the specified window, and
-<function>XQueryPointer</function>
-returns
-<symbol>None</symbol>
-to child_return and zero to win_x_return and win_y_return.
-If
-<function>XQueryPointer</function>
-returns
-<symbol>True</symbol>,
-the pointer coordinates returned to win_x_return and win_y_return
-are relative to the origin of the specified window.
-In this case,
-<function>XQueryPointer</function>
-returns the child that contains the pointer, if any,
-or else
-<symbol>None</symbol>
-to child_return.
-</para>
-<para>
-<!-- .LP -->
-<function>XQueryPointer</function>
-returns the current logical state of the keyboard buttons
-and the modifier keys in mask_return.
-It sets mask_return to the bitwise inclusive OR of one or more
-of the button or modifier key bitmasks to match
-the current state of the mouse buttons and the modifier keys.
-</para>
-<para>
-<!-- .LP -->
-Note that the logical state of a device (as seen through Xlib)
-may lag the physical state if device event processing is frozen
-(see section 12.1). <!-- xref -->
-</para>
-<para>
-<!-- .LP -->
-<function>XQueryPointer</function>
-can generate a
-<errorname>BadWindow</errorname>
-error.
-</para>
-</sect1>
-<sect1 id="Properties_and_Atoms">
-<title>Properties and Atoms</title>
-<!-- .XS -->
-<!-- (SN Properties and Atoms -->
-<!-- .XE -->
-<para>
-<!-- .LP -->
-A property is a collection of named, typed data.
-The window system has a set of predefined properties
-<indexterm><primary>Atom</primary><secondary>predefined</secondary></indexterm>
-(for example, the name of a window, size hints, and so on), and users can
-define any other arbitrary information and associate it with windows.
-Each property has a name,
-which is an ISO Latin-1 string.
-For each named property,
-a unique identifier (atom) is associated with it.
-A property also has a type, for example, string or integer.
-These types are also indicated using atoms, so arbitrary new
-types can be defined.
-Data of only one type may be associated with a single
-property name.
-Clients can store and retrieve properties associated with windows.
-For efficiency reasons,
-an atom is used rather than a character string.
-<function>XInternAtom</function>
-can be used to obtain the atom for property names.
-<indexterm><primary>Atom</primary></indexterm>
-</para>
-<para>
-<!-- .LP -->
-A property is also stored in one of several possible formats.
-The X server can store the information as 8-bit quantities, 16-bit
-quantities, or 32-bit quantities.
-This permits the X server to present the data in the byte order that the
-client expects.
-<!-- .NT Note -->
-If you define further properties of complex type,
-you must encode and decode them yourself.
-These functions must be carefully written if they are to be portable.
-For further information about how to write a library extension,
-see appendix C. <!-- xref -->
-<!-- .NE -->
-The type of a property is defined by an atom, which allows for
-arbitrary extension in this type scheme.
-<indexterm><primary>Atom</primary></indexterm>
-</para>
-<para>
-<!-- .LP -->
-Certain property names are
-predefined in the server for commonly used functions.
-The atoms for these properties are defined in
-<filename class="headerfile"><X11/Xatom.h></filename>.
-<indexterm type="file"><primary><filename class="headerfile">X11/Xatom.h</filename></primary></indexterm>
-<indexterm><primary>Files</primary><secondary><filename class="headerfile"><X11/Xatom.h></filename></secondary></indexterm>
-<indexterm><primary>Headers</primary><secondary><filename class="headerfile"><X11/Xatom.h></filename></secondary></indexterm>
-To avoid name clashes with user symbols, the
-<code>#define</code>
-name for each atom has the XA_ prefix.
-For an explanation of the functions that let you get and set
-much of the information stored in these predefined properties,
-see chapter 14. <!-- xref -->
-</para>
-<para>
-<!-- .LP -->
-The core protocol imposes no semantics on these property names,
-but semantics are specified in other X Consortium standards,
-such as the <emphasis remap='I'>Inter-Client Communication Conventions Manual</emphasis>
-and the <emphasis remap='I'>X Logical Font Description Conventions</emphasis>.
-</para>
-<para>
-<!-- .LP -->
-You can use properties to communicate other information between
-applications.
-The functions described in this section let you define new properties
-and get the unique atom IDs in your applications.
-</para>
-<para>
-<!-- .LP -->
-Although any particular atom can have some client interpretation
-within each of the name spaces,
-atoms occur in five distinct name spaces within the protocol:
-</para>
-<itemizedlist>
- <listitem>
- <para>
-Selections
- </para>
- </listitem>
- <listitem>
- <para>
-Property names
- </para>
- </listitem>
- <listitem>
- <para>
-Property types
- </para>
- </listitem>
- <listitem>
- <para>
-Font properties
- </para>
- </listitem>
- <listitem>
- <para>
-Type of a
-<symbol>ClientMessage</symbol>
-event (none are built into the X server)
- </para>
- </listitem>
-</itemizedlist>
-<para>
-<!-- .LP -->
-</para>
-<para>
-<!-- .LP -->
-The built-in selection property names are:
-<simplelist type="vert" columns="2">
- <member><property>PRIMARY</property></member>
- <member><property>SECONDARY</property></member>
-</simplelist>
-</para>
-<para>
-<!-- .LP -->
-The built-in property names are:
- <simplelist type="vert" columns="2">
- <member><property>CUT_BUFFER0</property></member>
- <member><property>CUT_BUFFER1</property></member>
- <member><property>CUT_BUFFER2</property></member>
- <member><property>CUT_BUFFER3</property></member>
- <member><property>CUT_BUFFER4</property></member>
- <member><property>CUT_BUFFER5</property></member>
- <member><property>CUT_BUFFER6</property></member>
- <member><property>CUT_BUFFER7</property></member>
- <member><property>RGB_BEST_MAP</property></member>
- <member><property>RGB_BLUE_MAP</property></member>
- <member><property>RGB_DEFAULT_MAP</property></member>
- <member><property>RGB_GRAY_MAP</property></member>
- <member><property>RGB_GREEN_MAP</property></member>
- <member><property>RGB_RED_MAP</property></member>
-
- <member><property>RESOURCE_MANAGER</property></member>
- <member><property>WM_CLASS</property></member>
- <member><property>WM_CLIENT_MACHINE</property></member>
- <member><property>WM_COLORMAP_WINDOWS</property></member>
- <member><property>WM_COMMAND</property></member>
- <member><property>WM_HINTS</property></member>
- <member><property>WM_ICON_NAME</property></member>
- <member><property>WM_ICON_SIZE</property></member>
- <member><property>WM_NAME</property></member>
- <member><property>WM_NORMAL_HINTS</property></member>
- <member><property>WM_PROTOCOLS</property></member>
- <member><property>WM_STATE</property></member>
- <member><property>WM_TRANSIENT_FOR</property></member>
- <member><property>WM_ZOOM_HINTS</property></member>
- </simplelist>
-</para>
-<para>
-The built-in property types are:
- <simplelist type="vert" columns="2">
- <member><property>ARC</property></member>
- <member><property>ATOM</property></member>
- <member><property>BITMAP</property></member>
- <member><property>CARDINAL</property></member>
- <member><property>COLORMAP</property></member>
- <member><property>CURSOR</property></member>
- <member><property>DRAWABLE</property></member>
- <member><property>FONT</property></member>
- <member><property>INTEGER</property></member>
- <member><property>PIXMAP</property></member>
- <member><property>POINT</property></member>
- <member><property>RGB_COLOR_MAP</property></member>
- <member><property>RECTANGLE</property></member>
- <member><property>STRING</property></member>
- <member><property>VISUALID</property></member>
- <member><property>WINDOW</property></member>
- <member><property>WM_HINTS</property></member>
- <member><property>WM_SIZE_HINTS</property></member>
- </simplelist>
-</para>
-<para>
-The built-in font property names are:
- <simplelist type="vert" columns="2">
- <member><property>MIN_SPACE</property></member>
- <member><property>NORM_SPACE</property></member>
- <member><property>MAX_SPACE</property></member>
- <member><property>END_SPACE</property></member>
- <member><property>SUPERSCRIPT_X</property></member>
- <member><property>SUPERSCRIPT_Y</property></member>
- <member><property>SUBSCRIPT_X</property></member>
- <member><property>SUBSCRIPT_Y</property></member>
- <member><property>UNDERLINE_POSITION</property></member>
- <member><property>UNDERLINE_THICKNESS</property></member>
- <member><property>FONT_NAME</property></member>
- <member><property>FULL_NAME</property></member>
-
- <member><property>STRIKEOUT_DESCENT</property></member>
- <member><property>STRIKEOUT_ASCENT</property></member>
- <member><property>ITALIC_ANGLE</property></member>
- <member><property>X_HEIGHT</property></member>
- <member><property>QUAD_WIDTH</property></member>
- <member><property>WEIGHT</property></member>
- <member><property>POINT_SIZE</property></member>
- <member><property>RESOLUTION</property></member>
- <member><property>COPYRIGHT</property></member>
- <member><property>NOTICE</property></member>
- <member><property>FAMILY_NAME</property></member>
- <member><property>CAP_HEIGHT</property></member>
- </simplelist>
-</para>
-<para>
-<!-- .LP -->
-For further information about font properties,
-see section 8.5. <!-- xref -->
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To return an atom for a given name, use
-<function>XInternAtom</function>.
-<indexterm><primary>Atom</primary><secondary>interning</secondary></indexterm>
-<indexterm significance="preferred"><primary>XInternAtom</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>Atom <function>XInternAtom</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>const char<parameter> *atom_name</parameter></paramdef>
- <paramdef>Bool<parameter> only_if_exists</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>atom_name</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the name associated with the atom you want returned.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>only_if_exists</emphasis>
- </term>
- <listitem>
- <para>
-Specifies a Boolean value that indicates whether the atom must be created.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XInternAtom</function>
-function returns the atom identifier associated with the specified atom_name
-string.
-If only_if_exists is
-<symbol>False</symbol>,
-the atom is created if it does not exist.
-Therefore,
-<function>XInternAtom</function>
-can return
-<symbol>None</symbol>.
-If the atom name is not in the Host Portable Character Encoding,
-the result is implementation-dependent.
-Uppercase and lowercase matter;
-the strings ``thing'', ``Thing'', and ``thinG''
-all designate different atoms.
-The atom will remain defined even after the client's connection closes.
-It will become undefined only when the last connection to
-the X server closes.
-</para>
-<para>
-<!-- .LP -->
-<function>XInternAtom</function>
-can generate
-<errorname>BadAlloc</errorname>
-and
-<errorname>BadValue</errorname>
-errors.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To return atoms for an array of names, use
-<function>XInternAtoms</function>.
-<indexterm><primary>Atom</primary><secondary>interning</secondary></indexterm>
-<indexterm significance="preferred"><primary>XInternAtoms</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>Status <function>XInternAtoms</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>const char<parameter> **names</parameter></paramdef>
- <paramdef>int<parameter> count</parameter></paramdef>
- <paramdef>Bool<parameter> only_if_exists</parameter></paramdef>
- <paramdef>Atom<parameter> *atoms_return</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>names</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the array of atom names.
-<!-- .ds Cn atom names in the array -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>count</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the number of (Cn.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>only_if_exists</emphasis>
- </term>
- <listitem>
- <para>
-Specifies a Boolean value that indicates whether the atom must be created.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>atoms_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the atoms.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XInternAtoms</function>
-function returns the atom identifiers associated with the specified names.
-The atoms are stored in the atoms_return array supplied by the caller.
-Calling this function is equivalent to calling
-<function>XInternAtom</function>
-for each of the names in turn with the specified value of only_if_exists,
-but this function minimizes the number of round-trip protocol exchanges
-between the client and the X server.
-</para>
-<para>
-<!-- .LP -->
-This function returns a nonzero status if atoms are returned for
-all of the names;
-otherwise, it returns zero.
-</para>
-<para>
-<!-- .LP -->
-<function>XInternAtoms</function>
-can generate
-<errorname>BadAlloc</errorname>
-and
-<errorname>BadValue</errorname>
-errors.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To return a name for a given atom identifier, use
-<function>XGetAtomName</function>.
-<indexterm><primary>Atom</primary><secondary>getting name</secondary></indexterm>
-<indexterm significance="preferred"><primary>XGetAtomName</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>char *<function>XGetAtomName</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Atom<parameter> atom</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>atom</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the atom for the property name you want returned.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XGetAtomName</function>
-function returns the name associated with the specified atom.
-If the data returned by the server is in the Latin Portable Character Encoding,
-then the returned string is in the Host Portable Character Encoding.
-Otherwise, the result is implementation-dependent.
-To free the resulting string,
-call
-<function>XFree</function>.
-</para>
-<para>
-<!-- .LP -->
-<function>XGetAtomName</function>
-can generate a
-<errorname>BadAtom</errorname>
-error.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To return the names for an array of atom identifiers, use
-<function>XGetAtomNames</function>.
-<indexterm><primary>Atom</primary><secondary>getting name</secondary></indexterm>
-<indexterm significance="preferred"><primary>XGetAtomNames</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>Status <function>XGetAtomNames</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Atom<parameter> *atoms</parameter></paramdef>
- <paramdef>int<parameter> count</parameter></paramdef>
- <paramdef>char<parameter> **names_return</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>atoms</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the array of atoms.
-<!-- .ds Cn atoms in the array -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>count</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the number of (Cn.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>names_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the atom names.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XGetAtomNames</function>
-function returns the names associated with the specified atoms.
-The names are stored in the names_return array supplied by the caller.
-Calling this function is equivalent to calling
-<function>XGetAtomName</function>
-for each of the atoms in turn,
-but this function minimizes the number of round-trip protocol exchanges
-between the client and the X server.
-</para>
-<para>
-<!-- .LP -->
-This function returns a nonzero status if names are returned for
-all of the atoms;
-otherwise, it returns zero.
-</para>
-<para>
-<!-- .LP -->
-<function>XGetAtomNames</function>
-can generate a
-<errorname>BadAtom</errorname>
-error.
-</para>
-</sect1>
-<sect1 id="Obtaining_and_Changing_Window_Properties">
-<title>Obtaining and Changing Window Properties</title>
-<!-- .XS -->
-<!-- (SN Obtaining and Changing Window Properties -->
-<!-- .XE -->
-<para>
-<!-- .LP -->
-You can attach a property list to every window.
-Each property has a name, a type, and a value (see section 4.3). <!-- xref -->
-The value is an array of 8-bit, 16-bit, or 32-bit quantities,
-whose interpretation is left to the clients. The type
-<type>char</type>
-is used to represent 8-bit quantities, the type
-<type>short</type>
-is used to represent 16-bit quantities, and the type
-<type>long</type>
-is used to represent 32-bit quantities.
-</para>
-<para>
-<!-- .LP -->
-Xlib provides functions that you can use to obtain,
-change, update, or interchange window properties.
-In addition, Xlib provides other utility functions for inter-client
-communication (see chapter 14). <!-- xref -->
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To obtain the type, format, and value of a property of a given window, use
-<function>XGetWindowProperty</function>.
-<indexterm><primary>Property</primary><secondary>getting</secondary></indexterm>
-</para>
-<para>
-<!-- .LP -->
-<indexterm significance="preferred"><primary>XGetWindowProperty</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>int <function>XGetWindowProperty</function></funcdef>
- <paramdef><parameter> display</parameter></paramdef>
- <paramdef><parameter> w</parameter></paramdef>
- <paramdef><parameter> property</parameter></paramdef>
- <paramdef><parameter> long_offset</parameter></paramdef>
- <paramdef><parameter> long_length</parameter></paramdef>
- <paramdef><parameter> delete</parameter></paramdef>
- <paramdef><parameter> req_type</parameter></paramdef>
- <paramdef><parameter> actual_type_return</parameter></paramdef>
- <paramdef><parameter> actual_format_return</parameter></paramdef>
- <paramdef><parameter> nitems_return</parameter></paramdef>
- <paramdef><parameter> bytes_after_return</parameter></paramdef>
- <paramdef>.br<parameter> prop_return</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
-<!-- .ds Wi whose property you want to obtain -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>w</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the window (Wi.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>property</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the property name.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>long_offset</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the offset in the specified property (in 32-bit quantities)
-where the data is to be retrieved.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>long_length</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the length in 32-bit multiples of the data to be retrieved.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>delete</emphasis>
- </term>
- <listitem>
- <para>
-Specifies a Boolean value that determines whether the property is deleted.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>req_type</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the atom identifier associated with the property type or
-<symbol>AnyPropertyType</symbol>.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>actual_type_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the atom identifier that defines the actual type of the property.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>actual_format_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the actual format of the property.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>nitems_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the actual number of 8-bit, 16-bit, or 32-bit items
-stored in the prop_return data.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>bytes_after_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the number of bytes remaining to be read in the property if
-a partial read was performed.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>prop_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the data in the specified format.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XGetWindowProperty</function>
-function returns the actual type of the property; the actual format of the property;
-the number of 8-bit, 16-bit, or 32-bit items transferred; the number of bytes remaining
-to be read in the property; and a pointer to the data actually returned.
-<function>XGetWindowProperty</function>
-sets the return arguments as follows:
-</para>
-<itemizedlist>
- <listitem>
- <para>
-If the specified property does not exist for the specified window,
-<function>XGetWindowProperty</function>
-returns
-<symbol>None</symbol>
-to actual_type_return and the value zero to
-actual_format_return and bytes_after_return.
-The nitems_return argument is empty.
-In this case, the delete argument is ignored.
- </para>
- </listitem>
- <listitem>
- <para>
-If the specified property exists
-but its type does not match the specified type,
-<function>XGetWindowProperty</function>
-returns the actual property type to actual_type_return,
-the actual property format (never zero) to actual_format_return,
-and the property length in bytes
-(even if the actual_format_return is 16 or 32)
-to bytes_after_return.
-It also ignores the delete argument.
-The nitems_return argument is empty.
- </para>
- </listitem>
- <listitem>
- <para>
-If the specified property exists and either you assign
-<symbol>AnyPropertyType</symbol>
-to the req_type argument or the specified type matches the actual property type,
-<function>XGetWindowProperty</function>
-returns the actual property type to actual_type_return and the actual
-property format (never zero) to actual_format_return.
-It also returns a value to bytes_after_return and nitems_return, by
-defining the following
-values:
- </para>
- </listitem>
- <listitem>
- <para>
-<!-- .nf -->
- N = actual length of the stored property in bytes
- (even if the format is 16 or 32)
- I = 4 * long_offset
- T = N - I
- L = MINIMUM(T, 4 * long_length)
- A = N - (I + L)
-<!-- .fi -->
- </para>
- </listitem>
- <listitem>
- <para>
-The returned value starts at byte index I in the property (indexing
-from zero), and its length in bytes is L.
-If the value for long_offset causes L to be negative,
-a
-<errorname>BadValue</errorname>
-error results.
-The value of bytes_after_return is A,
-giving the number of trailing unread bytes in the stored property.
- </para>
- </listitem>
-</itemizedlist>
-<para>
-<!-- .LP -->
-If the returned format is 8, the returned data is represented as a
-<type>char</type>
-array.
-If the returned format is 16, the returned data is represented as a
-<type>short</type>
-array and should be cast to that type to obtain the elements.
-If the returned format is 32, the returned data is represented as a
-<type>long</type>
-array and should be cast to that type to obtain the elements.
-</para>
-<para>
-<!-- .LP -->
-<function>XGetWindowProperty</function>
-always allocates one extra byte in prop_return
-(even if the property is zero length)
-and sets it to zero so that simple properties consisting of characters
-do not have to be copied into yet another string before use.
-</para>
-<para>
-<!-- .LP -->
-If delete is
-<symbol>True</symbol>
-and bytes_after_return is zero,
-<function>XGetWindowProperty</function>
-deletes the property
-from the window and generates a
-<symbol>PropertyNotify</symbol>
-event on the window.
-</para>
-<para>
-<!-- .LP -->
-The function returns
-<symbol>Success</symbol>
-if it executes successfully.
-To free the resulting data,
-use
-<function>XFree</function>.
-</para>
-<para>
-<!-- .LP -->
-<function>XGetWindowProperty</function>
-can generate
-<errorname>BadAtom</errorname>,
-<errorname>BadValue</errorname>,
-and
-<errorname>BadWindow</errorname>
-errors.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To obtain a given window's property list, use
-<function>XListProperties</function>.
-<indexterm><primary>Property</primary><secondary>listing</secondary></indexterm>
-<indexterm significance="preferred"><primary>XListProperties</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>Atom *<function>XListProperties</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Window<parameter> w</parameter></paramdef>
- <paramdef>int<parameter> *num_prop_return</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
-<!-- .ds Wi whose property list you want to obtain -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>w</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the window (Wi.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>num_prop_return</emphasis>
- </term>
- <listitem>
- <para>
-Returns the length of the properties array.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XListProperties</function>
-function returns a pointer to an array of atom properties that are defined for
-the specified window or returns NULL if no properties were found.
-To free the memory allocated by this function, use
-<function>XFree</function>.
-</para>
-<para>
-<!-- .LP -->
-<function>XListProperties</function>
-can generate a
-<errorname>BadWindow</errorname>
-error.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To change a property of a given window, use
-<function>XChangeProperty</function>.
-<indexterm><primary>Property</primary><secondary>changing</secondary></indexterm>
-<indexterm><primary>Property</primary><secondary>appending</secondary></indexterm>
-<indexterm><primary>Property</primary><secondary>prepending</secondary></indexterm>
-<indexterm><primary>Property</primary><secondary>replacing</secondary></indexterm>
-<indexterm><primary>Property</primary><secondary>format</secondary></indexterm>
-<indexterm><primary>Property</primary><secondary>type</secondary></indexterm>
-<indexterm significance="preferred"><primary>XChangeProperty</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef><function>XChangeProperty</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Window<parameter> w</parameter></paramdef>
- <paramdef>Atomproperty,<parameter> type</parameter></paramdef>
- <paramdef>int<parameter> format</parameter></paramdef>
- <paramdef>int<parameter> mode</parameter></paramdef>
- <paramdef>unsignedchar<parameter> *data</parameter></paramdef>
- <paramdef>int<parameter> nelements</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
-<!-- .ds Wi whose property you want to change -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>w</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the window (Wi.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>property</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the property name.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>type</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the type of the property.
-The X server does not interpret the type but simply
-passes it back to an application that later calls
-<function>XGetWindowProperty</function>.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>format</emphasis>
- </term>
- <listitem>
- <para>
-Specifies whether the data should be viewed as a list
-of 8-bit, 16-bit, or 32-bit quantities.
-Possible values are 8, 16, and 32.
-This information allows the X server to correctly perform
-byte-swap operations as necessary.
-If the format is 16-bit or 32-bit,
-you must explicitly cast your data pointer to an (unsigned char *) in the call
-to
-<function>XChangeProperty</function>.
-<!-- .\" Changed name of this file to prop_mode.a on 1/13/87 -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>mode</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the mode of the operation.
-You can pass
-<symbol>PropModeReplace</symbol>,
-<symbol>PropModePrepend</symbol>,
-or
-<symbol>PropModeAppend</symbol>.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>data</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the property data.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>nelements</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the number of elements of the specified data format.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XChangeProperty</function>
-function alters the property for the specified window and
-causes the X server to generate a
-<symbol>PropertyNotify</symbol>
-event on that window.
-<function>XChangeProperty</function>
-performs the following:
-</para>
-<itemizedlist>
- <listitem>
- <para>
-If mode is
-<symbol>PropModeReplace</symbol>,
-<function>XChangeProperty</function>
-discards the previous property value and stores the new data.
- </para>
- </listitem>
- <listitem>
- <para>
-If mode is
-<symbol>PropModePrepend</symbol>
-or
-<symbol>PropModeAppend</symbol>,
-<function>XChangeProperty</function>
-inserts the specified data before the beginning of the existing data
-or onto the end of the existing data, respectively.
-The type and format must match the existing property value,
-or a
-<errorname>BadMatch</errorname>
-error results.
-If the property is undefined,
-it is treated as defined with the correct type and
-format with zero-length data.
- </para>
- </listitem>
-</itemizedlist>
-<para>
-<!-- .LP -->
-If the specified format is 8, the property data must be a
-<type>char</type>
-array.
-If the specified format is 16, the property data must be a
-<type>short</type>
-array.
-If the specified format is 32, the property data must be a
-<type>long</type>
-array.
-</para>
-<para>
-<!-- .LP -->
-The lifetime of a property is not tied to the storing client.
-Properties remain until explicitly deleted, until the window is destroyed,
-or until the server resets.
-For a discussion of what happens when the connection to the X server is closed,
-see section 2.6. <!-- xref -->
-The maximum size of a property is server dependent and can vary dynamically
-depending on the amount of memory the server has available.
-(If there is insufficient space, a
-<errorname>BadAlloc</errorname>
-error results.)
-</para>
-<para>
-<!-- .LP -->
-<function>XChangeProperty</function>
-can generate
-<errorname>BadAlloc</errorname>,
-<errorname>BadAtom</errorname>,
-<errorname>BadMatch</errorname>,
-<errorname>BadValue</errorname>,
-and
-<errorname>BadWindow</errorname>
-errors.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To rotate a window's property list, use
-<function>XRotateWindowProperties</function>.
-</para>
-<para>
-<!-- .LP -->
-<indexterm significance="preferred"><primary>XRotateWindowProperties</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef><function>XRotateWindowProperties</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Window<parameter> w</parameter></paramdef>
- <paramdef>Atom<parameter> properties[]</parameter></paramdef>
- <paramdef>int<parameter> num_prop</parameter></paramdef>
- <paramdef>int<parameter> npositions</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>w</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the window.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>properties</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the array of properties that are to be rotated.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>num_prop</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the length of the properties array.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>npositions</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the rotation amount.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XRotateWindowProperties</function>
-function allows you to rotate properties on a window and causes
-the X server to generate
-<symbol>PropertyNotify</symbol>
-events.
-If the property names in the properties array are viewed as being numbered
-starting from zero and if there are num_prop property names in the list,
-then the value associated with property name I becomes the value associated
-with property name (I + npositions) mod N for all I from zero to N − 1.
-The effect is to rotate the states by npositions places around the virtual ring
-of property names (right for positive npositions,
-left for negative npositions).
-If npositions mod N is nonzero,
-the X server generates a
-<symbol>PropertyNotify</symbol>
-event for each property in the order that they are listed in the array.
-If an atom occurs more than once in the list or no property with that
-name is defined for the window,
-a
-<errorname>BadMatch</errorname>
-error results.
-If a
-<errorname>BadAtom</errorname>
-or
-<errorname>BadMatch</errorname>
-error results,
-no properties are changed.
-</para>
-<para>
-<!-- .LP -->
-<function>XRotateWindowProperties</function>
-can generate
-<errorname>BadAtom</errorname>,
-<errorname>BadMatch</errorname>,
-and
-<errorname>BadWindow</errorname>
-errors.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To delete a property on a given window, use
-<function>XDeleteProperty</function>.
-<indexterm><primary>Property</primary><secondary>deleting</secondary></indexterm>
-<indexterm significance="preferred"><primary>XDeleteProperty</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef><function>XDeleteProperty</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Window<parameter> w</parameter></paramdef>
- <paramdef>Atom<parameter> property</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
-<!-- .ds Wi whose property you want to delete -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>w</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the window (Wi.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>property</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the property name.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XDeleteProperty</function>
-function deletes the specified property only if the
-property was defined on the specified window
-and causes the X server to generate a
-<symbol>PropertyNotify</symbol>
-event on the window unless the property does not exist.
-</para>
-<para>
-<!-- .LP -->
-<function>XDeleteProperty</function>
-can generate
-<errorname>BadAtom</errorname>
-and
-<errorname>BadWindow</errorname>
-errors.
-</para>
-</sect1>
-<sect1 id="Selections">
-<title>Selections</title>
-<!-- .XS -->
-<!-- (SN Selections -->
-<!-- .XE -->
-<para>
-<!-- .LP -->
-<indexterm><primary>Selection</primary></indexterm>
-Selections are one method used by applications to exchange data.
-By using the property mechanism,
-applications can exchange data of arbitrary types and can negotiate
-the type of the data.
-A selection can be thought of as an indirect property with a dynamic type.
-That is, rather than having the property stored in the X server,
-the property is maintained by some client (the owner).
-A selection is global in nature (considered to belong to the user
-but be maintained by clients) rather than being private to a particular
-window subhierarchy or a particular set of clients.
-</para>
-<para>
-<!-- .LP -->
-Xlib provides functions that you can use to set, get, or request conversion
-of selections.
-This allows applications to implement the notion of current selection,
-which requires that notification be sent to applications when they no
-longer own the selection.
-Applications that support selection often highlight the current selection
-and so must be informed when another application has
-acquired the selection so that they can unhighlight the selection.
-</para>
-<para>
-<!-- .LP -->
-When a client asks for the contents of
-a selection, it specifies a selection target type.
-This target type
-can be used to control the transmitted representation of the contents.
-For example, if the selection is ``the last thing the user clicked on''
-and that is currently an image, then the target type might specify
-whether the contents of the image should be sent in XY format or Z format.
-</para>
-<para>
-<!-- .LP -->
-The target type can also be used to control the class of
-contents transmitted, for example,
-asking for the ``looks'' (fonts, line
-spacing, indentation, and so forth) of a paragraph selection, not the
-text of the paragraph.
-The target type can also be used for other
-purposes.
-The protocol does not constrain the semantics.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To set the selection owner, use
-<function>XSetSelectionOwner</function>.
-<indexterm><primary>Selection</primary><secondary>setting the owner</secondary></indexterm>
-<indexterm significance="preferred"><primary>XSetSelectionOwner</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef><function>XSetSelectionOwner</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Atom<parameter> selection</parameter></paramdef>
- <paramdef>Window<parameter> owner</parameter></paramdef>
- <paramdef>Time<parameter> time</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>selection</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the selection atom.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>owner</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the owner of the specified selection atom.
-You can pass a window or
-<symbol>None</symbol>.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>time</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the time.
-You can pass either a timestamp or
-<symbol>CurrentTime</symbol>.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XSetSelectionOwner</function>
-function changes the owner and last-change time for the specified selection
-and has no effect if the specified time is earlier than the current
-last-change time of the specified selection
-or is later than the current X server time.
-Otherwise, the last-change time is set to the specified time,
-with
-<symbol>CurrentTime</symbol>
-replaced by the current server time.
-If the owner window is specified as
-<symbol>None</symbol>,
-then the owner of the selection becomes
-<symbol>None</symbol>
-(that is, no owner).
-Otherwise, the owner of the selection becomes the client executing
-the request.
-</para>
-<para>
-<!-- .LP -->
-If the new owner (whether a client or
-<symbol>None</symbol>)
-is not
-the same as the current owner of the selection and the current
-owner is not
-<symbol>None</symbol>,
-the current owner is sent a
-<symbol>SelectionClear</symbol>
-event.
-If the client that is the owner of a selection is later
-terminated (that is, its connection is closed)
-or if the owner window it has specified in the request is later
-destroyed,
-the owner of the selection automatically
-reverts to
-<symbol>None</symbol>,
-but the last-change time is not affected.
-The selection atom is uninterpreted by the X server.
-<function>XGetSelectionOwner</function>
-returns the owner window, which is reported in
-<symbol>SelectionRequest</symbol>
-and
-<symbol>SelectionClear</symbol>
-events.
-Selections are global to the X server.
-</para>
-<para>
-<!-- .LP -->
-<function>XSetSelectionOwner</function>
-can generate
-<errorname>BadAtom</errorname>
-and
-<errorname>BadWindow</errorname>
-errors.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To return the selection owner, use
-<function>XGetSelectionOwner</function>.
-<indexterm><primary>Selection</primary><secondary>getting the owner</secondary></indexterm>
-<indexterm significance="preferred"><primary>XGetSelectionOwner</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef>Window <function>XGetSelectionOwner</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Atom<parameter> selection</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
-<!-- .ds Se whose owner you want returned -->
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>selection</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the selection atom (Se.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-The
-<function>XGetSelectionOwner</function>
-function
-returns the window ID associated with the window that currently owns the
-specified selection.
-If no selection was specified, the function returns the constant
-<symbol>None</symbol>.
-If
-<symbol>None</symbol>
-is returned,
-there is no owner for the selection.
-</para>
-<para>
-<!-- .LP -->
-<function>XGetSelectionOwner</function>
-can generate a
-<errorname>BadAtom</errorname>
-error.
-</para>
-<para>
-<!-- .LP -->
-<!-- .sp -->
-To request conversion of a selection, use
-<function>XConvertSelection</function>.
-<indexterm><primary>Selection</primary><secondary>converting</secondary></indexterm>
-<indexterm significance="preferred"><primary>XConvertSelection</primary></indexterm>
-<!-- .sM -->
-<funcsynopsis>
-<funcprototype>
- <funcdef><function>XConvertSelection</function></funcdef>
- <paramdef>Display<parameter> *display</parameter></paramdef>
- <paramdef>Atomselection,<parameter> target</parameter></paramdef>
- <paramdef>Atom<parameter> property</parameter></paramdef>
- <paramdef>Window<parameter> requestor</parameter></paramdef>
- <paramdef>Time<parameter> time</parameter></paramdef>
-</funcprototype>
-</funcsynopsis>
-<!-- .FN -->
-<variablelist>
- <varlistentry>
- <term>
- <emphasis remap='I'>display</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the connection to the X server.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>selection</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the selection atom.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>target</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the target atom.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>property</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the property name.
-You also can pass
-<symbol>None</symbol>.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>requestor</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the requestor.
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>
- <emphasis remap='I'>time</emphasis>
- </term>
- <listitem>
- <para>
-Specifies the time.
-You can pass either a timestamp or
-<symbol>CurrentTime</symbol>.
- </para>
- </listitem>
- </varlistentry>
-</variablelist>
-</para>
-<para>
-<!-- .LP -->
-<!-- .eM -->
-<function>XConvertSelection</function>
-requests that the specified selection be converted to the specified target
-type:
-</para>
-<itemizedlist>
- <listitem>
- <para>
-If the specified selection has an owner, the X server sends a
-<symbol>SelectionRequest</symbol>
-event to that owner.
- </para>
- </listitem>
- <listitem>
- <para>
-If no owner for the specified
-selection exists, the X server generates a
-<symbol>SelectionNotify</symbol>
-event to the
-requestor with property
-<symbol>None</symbol>.
- </para>
- </listitem>
-</itemizedlist>
-<para>
-<!-- .LP -->
-The arguments are passed on unchanged in either of the events.
-There are two predefined selection atoms: PRIMARY and SECONDARY.
-</para>
-<para>
-<!-- .LP -->
-<function>XConvertSelection</function>
-can generate
-<errorname>BadAtom</errorname>
-and
-<errorname>BadWindow</errorname>
-errors.
-<!-- .bp -->
-
-
-</para>
-</sect1>
-</chapter>
+<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" + "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"> +<chapter id="window_information_functions"> +<title>Window Information Functions</title> + +<para> +After you connect the display to the X server and create a window, you can use the Xlib window +information functions to: +</para> +<itemizedlist> + <listitem><para>Obtain information about a window</para></listitem> + <listitem><para>Translate screen coordinates</para></listitem> + <listitem><para>Manipulate property lists</para></listitem> + <listitem><para>Obtain and change window properties</para></listitem> + <listitem><para>Manipulate selections</para></listitem> +</itemizedlist> + +<sect1 id="Obtaining_Window_Information"> +<title>Obtaining Window Information</title> +<!-- .XS --> +<!-- (SN Obtaining Window Information --> +<!-- .XE --> +<para> +<!-- .LP --> +Xlib provides functions that you can use to obtain information about +the window tree, the window's current attributes, +the window's current geometry, or the current pointer coordinates. +Because they are most frequently used by window managers, +these functions all return a status to indicate whether the window still +exists. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To obtain the parent, a list of children, and number of children for +a given window, use +<function>XQueryTree</function>. +<indexterm><primary>Child Window</primary></indexterm> +<indexterm><primary>Parent Window</primary></indexterm> +<indexterm significance="preferred"><primary>XQueryTree</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>Status <function>XQueryTree</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Window<parameter> w</parameter></paramdef> + <paramdef>Window<parameter> *root_return</parameter></paramdef> + <paramdef>Window<parameter> *parent_return</parameter></paramdef> + <paramdef>Window<parameter> **children_return</parameter></paramdef> + <paramdef>unsignedint<parameter> *nchildren_return</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. +<!-- .ds Wi whose list of children, root, parent, and number of children \ --> +you want to obtain + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>w</emphasis> + </term> + <listitem> + <para> +Specifies the window (Wi. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>root_return</emphasis> + </term> + <listitem> + <para> +Returns the root window. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>parent_return</emphasis> + </term> + <listitem> + <para> +Returns the parent window. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>children_return</emphasis> + </term> + <listitem> + <para> +Returns the list of children. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>nchildren_return</emphasis> + </term> + <listitem> + <para> +Returns the number of children. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XQueryTree</function> +function returns the root ID, the parent window ID, +a pointer to the list of children windows +(NULL when there are no children), +and the number of children in the list for the specified window. +The children are listed in current stacking order, from bottom-most +(first) to top-most (last). +<function>XQueryTree</function> +returns zero if it fails and nonzero if it succeeds. +To free a non-NULL children list when it is no longer needed, use +<function>XFree</function>. +</para> +<para> +<!-- .LP --> +<function>XQueryTree</function> +can generate a +<errorname>BadWindow</errorname> +error. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To obtain the current attributes of a given window, use +<function>XGetWindowAttributes</function>. +<indexterm significance="preferred"><primary>XGetWindowAttributes</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>Status <function>XGetWindowAttributes</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Window<parameter> w</parameter></paramdef> + <paramdef>XWindowAttributes<parameter> *window_attributes_return</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. +<!-- .ds Wi whose current attributes you want to obtain --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>w</emphasis> + </term> + <listitem> + <para> +Specifies the window (Wi. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>window_attributes_return</emphasis> + </term> + <listitem> + <para> +Returns the specified window's attributes in the +<structname>XWindowAttributes</structname> +structure. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XGetWindowAttributes</function> +function returns the current attributes for the specified window to an +<structname>XWindowAttributes</structname> +structure. +</para> +<para> +<!-- .LP --> +<indexterm significance="preferred"><primary>XWindowAttributes</primary></indexterm> +<!-- .sM --> +<literallayout class="monospaced"> +<!-- .TA .5i 3i --> +<!-- .ta .5i 3i --> +typedef struct { + int x, y; /* location of window */ + int width, height; /* width and height of window */ + int border_width; /* border width of window */ + int depth; /* depth of window */ + Visual *visual; /* the associated visual structure */ + Window root; /* root of screen containing window */ + int class; /* InputOutput, InputOnly*/ + int bit_gravity; /* one of the bit gravity values */ + int win_gravity; /* one of the window gravity values */ + int backing_store; /* NotUseful, WhenMapped, Always */ + unsigned long backing_planes; /* planes to be preserved if possible */ + unsigned long backing_pixel; /* value to be used when restoring planes */ + Bool save_under; /* boolean, should bits under be saved? */ + Colormap colormap; /* color map to be associated with window */ + Bool map_installed; /* boolean, is color map currently installed*/ + int map_state; /* IsUnmapped, IsUnviewable, IsViewable */ + long all_event_masks; /* set of events all people have interest in*/ + long your_event_mask; /* my event mask */ + long do_not_propagate_mask; /* set of events that should not propagate */ + Bool override_redirect; /* boolean value for override-redirect */ + Screen *screen; /* back pointer to correct screen */ +} XWindowAttributes; +</literallayout> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The x and y members are set to the upper-left outer +corner relative to the parent window's origin. +The width and height members are set to the inside size of the window, +not including the border. +The border_width member is set to the window's border width in pixels. +The depth member is set to the depth of the window +(that is, bits per pixel for the object). +The visual member is a pointer to the screen's associated +<structname>Visual</structname> +structure. +The root member is set to the root window of the screen containing the window. +The class member is set to the window's class and can be either +<symbol>InputOutput</symbol> +or +<symbol>InputOnly</symbol>. +</para> +<para> +<!-- .LP --> +The bit_gravity member is set to the window's bit gravity +and can be one of the following: + <simplelist type="vert" columns="2"> + <member><symbol>ForgetGravity</symbol></member> + <member><symbol>NorthWestGravity</symbol></member> + <member><symbol>NorthGravity</symbol></member> + <member><symbol>NorthEastGravity</symbol></member> + <member><symbol>WestGravity</symbol></member> + + <member><symbol>EastGravity</symbol></member> + <member><symbol>SouthWestGravity</symbol></member> + <member><symbol>SouthGravity</symbol></member> + <member><symbol>SouthEastGravity</symbol></member> + <member><symbol>StaticGravity</symbol></member> + </simplelist> +</para> +<para> +The win_gravity member is set to the window's window gravity +and can be one of the following: + <simplelist type="vert" columns="2"> + <member><symbol>UnmapGravity</symbol></member> + <member><symbol>NorthWestGravity</symbol></member> + <member><symbol>NorthGravity</symbol></member> + <member><symbol>NorthEastGravity</symbol></member> + <member><symbol>WestGravity</symbol></member> + + <member><symbol>EastGravity</symbol></member> + <member><symbol>SouthWestGravity</symbol></member> + <member><symbol>SouthGravity</symbol></member> + <member><symbol>SouthEastGravity</symbol></member> + <member><symbol>StaticGravity</symbol></member> + <member><symbol>CenterGravity</symbol></member> + </simplelist> +</para> +<para> +<!-- .LP --> +For additional information on gravity, +see section 3.2.3. <!-- xref --> +</para> +<para> +<!-- .LP --> +The backing_store member is set to indicate how the X server should maintain +the contents of a window +and can be +<symbol>WhenMapped</symbol>, +<symbol>Always</symbol>, +or +<symbol>NotUseful</symbol>. +The backing_planes member is set to indicate (with bits set to 1) which bit +planes of the window hold dynamic data that must be preserved in backing_stores +and during save_unders. +The backing_pixel member is set to indicate what values to use +for planes not set in backing_planes. +</para> +<para> +<!-- .LP --> +The save_under member is set to +<symbol>True</symbol> +or +<symbol>False</symbol>. +The colormap member is set to the colormap for the specified window and can be +a colormap ID or +<symbol>None</symbol>. +The map_installed member is set to indicate whether the colormap is +currently installed and can be +<symbol>True</symbol> +or +<symbol>False</symbol>. +The map_state member is set to indicate the state of the window and can be +<symbol>IsUnmapped</symbol>, +<symbol>IsUnviewable</symbol>, +or +<symbol>IsViewable</symbol>. +<symbol>IsUnviewable</symbol> +is used if the window is mapped but some ancestor is unmapped. +</para> +<para> +<!-- .LP --> +The all_event_masks member is set to the bitwise inclusive OR of all event +masks selected on the window by all clients. +The your_event_mask member is set to the bitwise inclusive OR of all event +masks selected by the querying client. +The do_not_propagate_mask member is set to the bitwise inclusive OR of the +set of events that should not propagate. +</para> +<para> +<!-- .LP --> +The override_redirect member is set to indicate whether this window overrides +structure control facilities and can be +<symbol>True</symbol> +or +<symbol>False</symbol>. +Window manager clients should ignore the window if this member is +<symbol>True</symbol>. +</para> +<para> +<!-- .LP --> +The screen member is set to a screen pointer that gives you a back pointer +to the correct screen. +This makes it easier to obtain the screen information without +having to loop over the root window fields to see which field matches. +</para> +<para> +<!-- .LP --> +<function>XGetWindowAttributes</function> +can generate +<errorname>BadDrawable</errorname> +and +<errorname>BadWindow</errorname> +errors. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To obtain the current geometry of a given drawable, use +<function>XGetGeometry</function>. +<indexterm significance="preferred"><primary>XGetGeometry</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>Status <function>XGetGeometry</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Drawable<parameter> d</parameter></paramdef> + <paramdef>Window<parameter> *root_return</parameter></paramdef> + <paramdef>int*x_return,<parameter> *y_return</parameter></paramdef> + <paramdef>unsignedint*width_return,<parameter> *height_return</parameter></paramdef> + <paramdef>unsignedint<parameter> *border_width_return</parameter></paramdef> + <paramdef>unsignedint<parameter> *depth_return</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. +<!-- .ds Dr , which can be a window or a pixmap --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>d</emphasis> + </term> + <listitem> + <para> +Specifies the drawable(Dr. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>root_return</emphasis> + </term> + <listitem> + <para> +Returns the root window. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>x_return</emphasis> + </term> + <listitem> + <para> +<!-- .br --> +<!-- .ns --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>y_return</emphasis> + </term> + <listitem> + <para> +Return the x and y coordinates that define the location of the drawable. +For a window, +these coordinates specify the upper-left outer corner relative to +its parent's origin. +For pixmaps, these coordinates are always zero. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>width_return</emphasis> + </term> + <listitem> + <para> +<!-- .br --> +<!-- .ns --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>height_return</emphasis> + </term> + <listitem> + <para> +Return the drawable's dimensions (width and height). +For a window, +these dimensions specify the inside size, not including the border. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>border_width_return</emphasis> + </term> + <listitem> + <para> +Returns the border width in pixels. +If the drawable is a pixmap, it returns zero. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>depth_return</emphasis> + </term> + <listitem> + <para> +Returns the depth of the drawable (bits per pixel for the object). + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XGetGeometry</function> +function returns the root window and the current geometry of the drawable. +The geometry of the drawable includes the x and y coordinates, width and height, +border width, and depth. +These are described in the argument list. +It is legal to pass to this function a window whose class is +<symbol>InputOnly</symbol>. +</para> +<para> +<!-- .LP --> +<function>XGetGeometry</function> +can generate a +<errorname>BadDrawable</errorname> +error. +</para> +</sect1> +<sect1 id="Translating_Screen_Coordinates"> +<title>Translating Screen Coordinates</title> +<!-- .XS --> +<!-- (SN Translating Screen Coordinates --> +<!-- .XE --> +<para> +<!-- .LP --> +Applications sometimes +need to perform a coordinate transformation from the coordinate +space of one window to another window or need to determine which +window the pointing device is in. +<function>XTranslateCoordinates</function> +and +<function>XQueryPointer</function> +fulfill these needs (and avoid any race conditions) by +asking the X server to perform these operations. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To translate a coordinate in one window to the coordinate +space of another window, use +<function>XTranslateCoordinates</function>. +<indexterm significance="preferred"><primary>XTranslateCoordinates</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function>XTranslateCoordinates</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Windowsrc_w,<parameter> dest_w</parameter></paramdef> + <paramdef>intsrc_x,<parameter> src_y</parameter></paramdef> + <paramdef>int*dest_x_return,<parameter> *dest_y_return</parameter></paramdef> + <paramdef>Window<parameter> *child_return</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>src_w</emphasis> + </term> + <listitem> + <para> +Specifies the source window. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>dest_w</emphasis> + </term> + <listitem> + <para> +Specifies the destination window. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>src_x</emphasis> + </term> + <listitem> + <para> +<!-- .br --> +<!-- .ns --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>src_y</emphasis> + </term> + <listitem> + <para> +Specify the x and y coordinates within the source window. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>dest_x_return</emphasis> + </term> + <listitem> + <para> +<!-- .br --> +<!-- .ns --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>dest_y_return</emphasis> + </term> + <listitem> + <para> +Return the x and y coordinates within the destination window. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>child_return</emphasis> + </term> + <listitem> + <para> +Returns the child if the coordinates are contained in a mapped child of the +destination window. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +If +<function>XTranslateCoordinates</function> +returns +<symbol>True</symbol>, +it takes the src_x and src_y coordinates relative +to the source window's origin and returns these coordinates to +dest_x_return and dest_y_return +relative to the destination window's origin. +If +<function>XTranslateCoordinates</function> +returns +<symbol>False</symbol>, +src_w and dest_w are on different screens, +and dest_x_return and dest_y_return are zero. +If the coordinates are contained in a mapped child of dest_w, +that child is returned to child_return. +Otherwise, child_return is set to +<symbol>None</symbol>. +</para> +<para> +<!-- .LP --> +<function>XTranslateCoordinates</function> +can generate a +<errorname>BadWindow</errorname> +error. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To obtain the screen coordinates of the pointer +or to determine the pointer coordinates relative to a specified window, use +<function>XQueryPointer</function>. +<indexterm significance="preferred"><primary>XQueryPointer</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>Bool <function>XQueryPointer</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Window<parameter> w</parameter></paramdef> + <paramdef>Window*root_return,<parameter> *child_return</parameter></paramdef> + <paramdef>int*root_x_return,<parameter> *root_y_return</parameter></paramdef> + <paramdef>int*win_x_return,<parameter> *win_y_return</parameter></paramdef> + <paramdef>unsignedint<parameter> *mask_return</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>w</emphasis> + </term> + <listitem> + <para> +Specifies the window. +<!-- .ds Ro that the pointer is in --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>root_return</emphasis> + </term> + <listitem> + <para> +Returns the root window (Ro. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>child_return</emphasis> + </term> + <listitem> + <para> +Returns the child window that the pointer is located in, if any. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>root_x_return</emphasis> + </term> + <listitem> + <para> +<!-- .br --> +<!-- .ns --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>root_y_return</emphasis> + </term> + <listitem> + <para> +Return the pointer coordinates relative to the root window's origin. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>win_x_return</emphasis> + </term> + <listitem> + <para> +<!-- .br --> +<!-- .ns --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>win_y_return</emphasis> + </term> + <listitem> + <para> +Return the pointer coordinates relative to the specified window. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>mask_return</emphasis> + </term> + <listitem> + <para> +Returns the current state of the modifier keys and pointer buttons. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XQueryPointer</function> +function returns the root window the pointer is logically on and the pointer +coordinates relative to the root window's origin. +If +<function>XQueryPointer</function> +returns +<symbol>False</symbol>, +the pointer is not on the same screen as the specified window, and +<function>XQueryPointer</function> +returns +<symbol>None</symbol> +to child_return and zero to win_x_return and win_y_return. +If +<function>XQueryPointer</function> +returns +<symbol>True</symbol>, +the pointer coordinates returned to win_x_return and win_y_return +are relative to the origin of the specified window. +In this case, +<function>XQueryPointer</function> +returns the child that contains the pointer, if any, +or else +<symbol>None</symbol> +to child_return. +</para> +<para> +<!-- .LP --> +<function>XQueryPointer</function> +returns the current logical state of the keyboard buttons +and the modifier keys in mask_return. +It sets mask_return to the bitwise inclusive OR of one or more +of the button or modifier key bitmasks to match +the current state of the mouse buttons and the modifier keys. +</para> +<para> +<!-- .LP --> +Note that the logical state of a device (as seen through Xlib) +may lag the physical state if device event processing is frozen +(see section 12.1). <!-- xref --> +</para> +<para> +<!-- .LP --> +<function>XQueryPointer</function> +can generate a +<errorname>BadWindow</errorname> +error. +</para> +</sect1> +<sect1 id="Properties_and_Atoms"> +<title>Properties and Atoms</title> +<!-- .XS --> +<!-- (SN Properties and Atoms --> +<!-- .XE --> +<para> +<!-- .LP --> +A property is a collection of named, typed data. +The window system has a set of predefined properties +<indexterm><primary>Atom</primary><secondary>predefined</secondary></indexterm> +(for example, the name of a window, size hints, and so on), and users can +define any other arbitrary information and associate it with windows. +Each property has a name, +which is an ISO Latin-1 string. +For each named property, +a unique identifier (atom) is associated with it. +A property also has a type, for example, string or integer. +These types are also indicated using atoms, so arbitrary new +types can be defined. +Data of only one type may be associated with a single +property name. +Clients can store and retrieve properties associated with windows. +For efficiency reasons, +an atom is used rather than a character string. +<function>XInternAtom</function> +can be used to obtain the atom for property names. +<indexterm><primary>Atom</primary></indexterm> +</para> +<para> +<!-- .LP --> +A property is also stored in one of several possible formats. +The X server can store the information as 8-bit quantities, 16-bit +quantities, or 32-bit quantities. +This permits the X server to present the data in the byte order that the +client expects. +<!-- .NT Note --> +If you define further properties of complex type, +you must encode and decode them yourself. +These functions must be carefully written if they are to be portable. +For further information about how to write a library extension, +see appendix C. <!-- xref --> +<!-- .NE --> +The type of a property is defined by an atom, which allows for +arbitrary extension in this type scheme. +<indexterm><primary>Atom</primary></indexterm> +</para> +<para> +<!-- .LP --> +Certain property names are +predefined in the server for commonly used functions. +The atoms for these properties are defined in +<filename class="headerfile"><X11/Xatom.h></filename>. +<indexterm type="file"><primary><filename class="headerfile">X11/Xatom.h</filename></primary></indexterm> +<indexterm><primary>Files</primary><secondary><filename class="headerfile"><X11/Xatom.h></filename></secondary></indexterm> +<indexterm><primary>Headers</primary><secondary><filename class="headerfile"><X11/Xatom.h></filename></secondary></indexterm> +To avoid name clashes with user symbols, the +<code>#define</code> +name for each atom has the XA_ prefix. +For an explanation of the functions that let you get and set +much of the information stored in these predefined properties, +see chapter 14. <!-- xref --> +</para> +<para> +<!-- .LP --> +The core protocol imposes no semantics on these property names, +but semantics are specified in other X Consortium standards, +such as the <emphasis remap='I'>Inter-Client Communication Conventions Manual</emphasis> +and the <emphasis remap='I'>X Logical Font Description Conventions</emphasis>. +</para> +<para> +<!-- .LP --> +You can use properties to communicate other information between +applications. +The functions described in this section let you define new properties +and get the unique atom IDs in your applications. +</para> +<para> +<!-- .LP --> +Although any particular atom can have some client interpretation +within each of the name spaces, +atoms occur in five distinct name spaces within the protocol: +</para> +<itemizedlist> + <listitem> + <para> +Selections + </para> + </listitem> + <listitem> + <para> +Property names + </para> + </listitem> + <listitem> + <para> +Property types + </para> + </listitem> + <listitem> + <para> +Font properties + </para> + </listitem> + <listitem> + <para> +Type of a +<symbol>ClientMessage</symbol> +event (none are built into the X server) + </para> + </listitem> +</itemizedlist> +<para> +<!-- .LP --> +</para> +<para> +<!-- .LP --> +The built-in selection property names are: +<simplelist type="vert" columns="2"> + <member><property>PRIMARY</property></member> + <member><property>SECONDARY</property></member> +</simplelist> +</para> +<para> +<!-- .LP --> +The built-in property names are: + <simplelist type="vert" columns="2"> + <member><property>CUT_BUFFER0</property></member> + <member><property>CUT_BUFFER1</property></member> + <member><property>CUT_BUFFER2</property></member> + <member><property>CUT_BUFFER3</property></member> + <member><property>CUT_BUFFER4</property></member> + <member><property>CUT_BUFFER5</property></member> + <member><property>CUT_BUFFER6</property></member> + <member><property>CUT_BUFFER7</property></member> + <member><property>RGB_BEST_MAP</property></member> + <member><property>RGB_BLUE_MAP</property></member> + <member><property>RGB_DEFAULT_MAP</property></member> + <member><property>RGB_GRAY_MAP</property></member> + <member><property>RGB_GREEN_MAP</property></member> + <member><property>RGB_RED_MAP</property></member> + + <member><property>RESOURCE_MANAGER</property></member> + <member><property>WM_CLASS</property></member> + <member><property>WM_CLIENT_MACHINE</property></member> + <member><property>WM_COLORMAP_WINDOWS</property></member> + <member><property>WM_COMMAND</property></member> + <member><property>WM_HINTS</property></member> + <member><property>WM_ICON_NAME</property></member> + <member><property>WM_ICON_SIZE</property></member> + <member><property>WM_NAME</property></member> + <member><property>WM_NORMAL_HINTS</property></member> + <member><property>WM_PROTOCOLS</property></member> + <member><property>WM_STATE</property></member> + <member><property>WM_TRANSIENT_FOR</property></member> + <member><property>WM_ZOOM_HINTS</property></member> + </simplelist> +</para> +<para> +The built-in property types are: + <simplelist type="vert" columns="2"> + <member><property>ARC</property></member> + <member><property>ATOM</property></member> + <member><property>BITMAP</property></member> + <member><property>CARDINAL</property></member> + <member><property>COLORMAP</property></member> + <member><property>CURSOR</property></member> + <member><property>DRAWABLE</property></member> + <member><property>FONT</property></member> + <member><property>INTEGER</property></member> + <member><property>PIXMAP</property></member> + <member><property>POINT</property></member> + <member><property>RGB_COLOR_MAP</property></member> + <member><property>RECTANGLE</property></member> + <member><property>STRING</property></member> + <member><property>VISUALID</property></member> + <member><property>WINDOW</property></member> + <member><property>WM_HINTS</property></member> + <member><property>WM_SIZE_HINTS</property></member> + </simplelist> +</para> +<para> +The built-in font property names are: + <simplelist type="vert" columns="2"> + <member><property>MIN_SPACE</property></member> + <member><property>NORM_SPACE</property></member> + <member><property>MAX_SPACE</property></member> + <member><property>END_SPACE</property></member> + <member><property>SUPERSCRIPT_X</property></member> + <member><property>SUPERSCRIPT_Y</property></member> + <member><property>SUBSCRIPT_X</property></member> + <member><property>SUBSCRIPT_Y</property></member> + <member><property>UNDERLINE_POSITION</property></member> + <member><property>UNDERLINE_THICKNESS</property></member> + <member><property>FONT_NAME</property></member> + <member><property>FULL_NAME</property></member> + + <member><property>STRIKEOUT_DESCENT</property></member> + <member><property>STRIKEOUT_ASCENT</property></member> + <member><property>ITALIC_ANGLE</property></member> + <member><property>X_HEIGHT</property></member> + <member><property>QUAD_WIDTH</property></member> + <member><property>WEIGHT</property></member> + <member><property>POINT_SIZE</property></member> + <member><property>RESOLUTION</property></member> + <member><property>COPYRIGHT</property></member> + <member><property>NOTICE</property></member> + <member><property>FAMILY_NAME</property></member> + <member><property>CAP_HEIGHT</property></member> + </simplelist> +</para> +<para> +<!-- .LP --> +For further information about font properties, +see section 8.5. <!-- xref --> +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To return an atom for a given name, use +<function>XInternAtom</function>. +<indexterm><primary>Atom</primary><secondary>interning</secondary></indexterm> +<indexterm significance="preferred"><primary>XInternAtom</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>Atom <function>XInternAtom</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>char<parameter> *atom_name</parameter></paramdef> + <paramdef>Bool<parameter> only_if_exists</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>atom_name</emphasis> + </term> + <listitem> + <para> +Specifies the name associated with the atom you want returned. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>only_if_exists</emphasis> + </term> + <listitem> + <para> +Specifies a Boolean value that indicates whether the atom must be created. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XInternAtom</function> +function returns the atom identifier associated with the specified atom_name +string. +If only_if_exists is +<symbol>False</symbol>, +the atom is created if it does not exist. +Therefore, +<function>XInternAtom</function> +can return +<symbol>None</symbol>. +If the atom name is not in the Host Portable Character Encoding, +the result is implementation-dependent. +Uppercase and lowercase matter; +the strings ``thing'', ``Thing'', and ``thinG'' +all designate different atoms. +The atom will remain defined even after the client's connection closes. +It will become undefined only when the last connection to +the X server closes. +</para> +<para> +<!-- .LP --> +<function>XInternAtom</function> +can generate +<errorname>BadAlloc</errorname> +and +<errorname>BadValue</errorname> +errors. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To return atoms for an array of names, use +<function>XInternAtoms</function>. +<indexterm><primary>Atom</primary><secondary>interning</secondary></indexterm> +<indexterm significance="preferred"><primary>XInternAtoms</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>Status <function>XInternAtoms</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>char<parameter> **names</parameter></paramdef> + <paramdef>int<parameter> count</parameter></paramdef> + <paramdef>Bool<parameter> only_if_exists</parameter></paramdef> + <paramdef>Atom<parameter> *atoms_return</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>names</emphasis> + </term> + <listitem> + <para> +Specifies the array of atom names. +<!-- .ds Cn atom names in the array --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>count</emphasis> + </term> + <listitem> + <para> +Specifies the number of (Cn. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>only_if_exists</emphasis> + </term> + <listitem> + <para> +Specifies a Boolean value that indicates whether the atom must be created. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>atoms_return</emphasis> + </term> + <listitem> + <para> +Returns the atoms. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XInternAtoms</function> +function returns the atom identifiers associated with the specified names. +The atoms are stored in the atoms_return array supplied by the caller. +Calling this function is equivalent to calling +<function>XInternAtom</function> +for each of the names in turn with the specified value of only_if_exists, +but this function minimizes the number of round-trip protocol exchanges +between the client and the X server. +</para> +<para> +<!-- .LP --> +This function returns a nonzero status if atoms are returned for +all of the names; +otherwise, it returns zero. +</para> +<para> +<!-- .LP --> +<function>XInternAtoms</function> +can generate +<errorname>BadAlloc</errorname> +and +<errorname>BadValue</errorname> +errors. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To return a name for a given atom identifier, use +<function>XGetAtomName</function>. +<indexterm><primary>Atom</primary><secondary>getting name</secondary></indexterm> +<indexterm significance="preferred"><primary>XGetAtomName</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>char *<function>XGetAtomName</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Atom<parameter> atom</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>atom</emphasis> + </term> + <listitem> + <para> +Specifies the atom for the property name you want returned. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XGetAtomName</function> +function returns the name associated with the specified atom. +If the data returned by the server is in the Latin Portable Character Encoding, +then the returned string is in the Host Portable Character Encoding. +Otherwise, the result is implementation-dependent. +To free the resulting string, +call +<function>XFree</function>. +</para> +<para> +<!-- .LP --> +<function>XGetAtomName</function> +can generate a +<errorname>BadAtom</errorname> +error. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To return the names for an array of atom identifiers, use +<function>XGetAtomNames</function>. +<indexterm><primary>Atom</primary><secondary>getting name</secondary></indexterm> +<indexterm significance="preferred"><primary>XGetAtomNames</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>Status <function>XGetAtomNames</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Atom<parameter> *atoms</parameter></paramdef> + <paramdef>int<parameter> count</parameter></paramdef> + <paramdef>char<parameter> **names_return</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>atoms</emphasis> + </term> + <listitem> + <para> +Specifies the array of atoms. +<!-- .ds Cn atoms in the array --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>count</emphasis> + </term> + <listitem> + <para> +Specifies the number of (Cn. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>names_return</emphasis> + </term> + <listitem> + <para> +Returns the atom names. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XGetAtomNames</function> +function returns the names associated with the specified atoms. +The names are stored in the names_return array supplied by the caller. +Calling this function is equivalent to calling +<function>XGetAtomName</function> +for each of the atoms in turn, +but this function minimizes the number of round-trip protocol exchanges +between the client and the X server. +</para> +<para> +<!-- .LP --> +This function returns a nonzero status if names are returned for +all of the atoms; +otherwise, it returns zero. +</para> +<para> +<!-- .LP --> +<function>XGetAtomNames</function> +can generate a +<errorname>BadAtom</errorname> +error. +</para> +</sect1> +<sect1 id="Obtaining_and_Changing_Window_Properties"> +<title>Obtaining and Changing Window Properties</title> +<!-- .XS --> +<!-- (SN Obtaining and Changing Window Properties --> +<!-- .XE --> +<para> +<!-- .LP --> +You can attach a property list to every window. +Each property has a name, a type, and a value (see section 4.3). <!-- xref --> +The value is an array of 8-bit, 16-bit, or 32-bit quantities, +whose interpretation is left to the clients. The type +<type>char</type> +is used to represent 8-bit quantities, the type +<type>short</type> +is used to represent 16-bit quantities, and the type +<type>long</type> +is used to represent 32-bit quantities. +</para> +<para> +<!-- .LP --> +Xlib provides functions that you can use to obtain, +change, update, or interchange window properties. +In addition, Xlib provides other utility functions for inter-client +communication (see chapter 14). <!-- xref --> +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To obtain the type, format, and value of a property of a given window, use +<function>XGetWindowProperty</function>. +<indexterm><primary>Property</primary><secondary>getting</secondary></indexterm> +</para> +<para> +<!-- .LP --> +<indexterm significance="preferred"><primary>XGetWindowProperty</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>int <function>XGetWindowProperty</function></funcdef> + <paramdef><parameter> display</parameter></paramdef> + <paramdef><parameter> w</parameter></paramdef> + <paramdef><parameter> property</parameter></paramdef> + <paramdef><parameter> long_offset</parameter></paramdef> + <paramdef><parameter> long_length</parameter></paramdef> + <paramdef><parameter> delete</parameter></paramdef> + <paramdef><parameter> req_type</parameter></paramdef> + <paramdef><parameter> actual_type_return</parameter></paramdef> + <paramdef><parameter> actual_format_return</parameter></paramdef> + <paramdef><parameter> nitems_return</parameter></paramdef> + <paramdef><parameter> bytes_after_return</parameter></paramdef> + <paramdef>.br<parameter> prop_return</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. +<!-- .ds Wi whose property you want to obtain --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>w</emphasis> + </term> + <listitem> + <para> +Specifies the window (Wi. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>property</emphasis> + </term> + <listitem> + <para> +Specifies the property name. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>long_offset</emphasis> + </term> + <listitem> + <para> +Specifies the offset in the specified property (in 32-bit quantities) +where the data is to be retrieved. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>long_length</emphasis> + </term> + <listitem> + <para> +Specifies the length in 32-bit multiples of the data to be retrieved. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>delete</emphasis> + </term> + <listitem> + <para> +Specifies a Boolean value that determines whether the property is deleted. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>req_type</emphasis> + </term> + <listitem> + <para> +Specifies the atom identifier associated with the property type or +<symbol>AnyPropertyType</symbol>. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>actual_type_return</emphasis> + </term> + <listitem> + <para> +Returns the atom identifier that defines the actual type of the property. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>actual_format_return</emphasis> + </term> + <listitem> + <para> +Returns the actual format of the property. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>nitems_return</emphasis> + </term> + <listitem> + <para> +Returns the actual number of 8-bit, 16-bit, or 32-bit items +stored in the prop_return data. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>bytes_after_return</emphasis> + </term> + <listitem> + <para> +Returns the number of bytes remaining to be read in the property if +a partial read was performed. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>prop_return</emphasis> + </term> + <listitem> + <para> +Returns the data in the specified format. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XGetWindowProperty</function> +function returns the actual type of the property; the actual format of the property; +the number of 8-bit, 16-bit, or 32-bit items transferred; the number of bytes remaining +to be read in the property; and a pointer to the data actually returned. +<function>XGetWindowProperty</function> +sets the return arguments as follows: +</para> +<itemizedlist> + <listitem> + <para> +If the specified property does not exist for the specified window, +<function>XGetWindowProperty</function> +returns +<symbol>None</symbol> +to actual_type_return and the value zero to +actual_format_return and bytes_after_return. +The nitems_return argument is empty. +In this case, the delete argument is ignored. + </para> + </listitem> + <listitem> + <para> +If the specified property exists +but its type does not match the specified type, +<function>XGetWindowProperty</function> +returns the actual property type to actual_type_return, +the actual property format (never zero) to actual_format_return, +and the property length in bytes +(even if the actual_format_return is 16 or 32) +to bytes_after_return. +It also ignores the delete argument. +The nitems_return argument is empty. + </para> + </listitem> + <listitem> + <para> +If the specified property exists and either you assign +<symbol>AnyPropertyType</symbol> +to the req_type argument or the specified type matches the actual property type, +<function>XGetWindowProperty</function> +returns the actual property type to actual_type_return and the actual +property format (never zero) to actual_format_return. +It also returns a value to bytes_after_return and nitems_return, by +defining the following +values: + </para> + </listitem> + <listitem> + <para> +<!-- .nf --> + N = actual length of the stored property in bytes + (even if the format is 16 or 32) + I = 4 * long_offset + T = N - I + L = MINIMUM(T, 4 * long_length) + A = N - (I + L) +<!-- .fi --> + </para> + </listitem> + <listitem> + <para> +The returned value starts at byte index I in the property (indexing +from zero), and its length in bytes is L. +If the value for long_offset causes L to be negative, +a +<errorname>BadValue</errorname> +error results. +The value of bytes_after_return is A, +giving the number of trailing unread bytes in the stored property. + </para> + </listitem> +</itemizedlist> +<para> +<!-- .LP --> +If the returned format is 8, the returned data is represented as a +<type>char</type> +array. +If the returned format is 16, the returned data is represented as a +<type>short</type> +array and should be cast to that type to obtain the elements. +If the returned format is 32, the returned data is represented as a +<type>long</type> +array and should be cast to that type to obtain the elements. +</para> +<para> +<!-- .LP --> +<function>XGetWindowProperty</function> +always allocates one extra byte in prop_return +(even if the property is zero length) +and sets it to zero so that simple properties consisting of characters +do not have to be copied into yet another string before use. +</para> +<para> +<!-- .LP --> +If delete is +<symbol>True</symbol> +and bytes_after_return is zero, +<function>XGetWindowProperty</function> +deletes the property +from the window and generates a +<symbol>PropertyNotify</symbol> +event on the window. +</para> +<para> +<!-- .LP --> +The function returns +<symbol>Success</symbol> +if it executes successfully. +To free the resulting data, +use +<function>XFree</function>. +</para> +<para> +<!-- .LP --> +<function>XGetWindowProperty</function> +can generate +<errorname>BadAtom</errorname>, +<errorname>BadValue</errorname>, +and +<errorname>BadWindow</errorname> +errors. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To obtain a given window's property list, use +<function>XListProperties</function>. +<indexterm><primary>Property</primary><secondary>listing</secondary></indexterm> +<indexterm significance="preferred"><primary>XListProperties</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>Atom *<function>XListProperties</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Window<parameter> w</parameter></paramdef> + <paramdef>int<parameter> *num_prop_return</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. +<!-- .ds Wi whose property list you want to obtain --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>w</emphasis> + </term> + <listitem> + <para> +Specifies the window (Wi. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>num_prop_return</emphasis> + </term> + <listitem> + <para> +Returns the length of the properties array. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XListProperties</function> +function returns a pointer to an array of atom properties that are defined for +the specified window or returns NULL if no properties were found. +To free the memory allocated by this function, use +<function>XFree</function>. +</para> +<para> +<!-- .LP --> +<function>XListProperties</function> +can generate a +<errorname>BadWindow</errorname> +error. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To change a property of a given window, use +<function>XChangeProperty</function>. +<indexterm><primary>Property</primary><secondary>changing</secondary></indexterm> +<indexterm><primary>Property</primary><secondary>appending</secondary></indexterm> +<indexterm><primary>Property</primary><secondary>prepending</secondary></indexterm> +<indexterm><primary>Property</primary><secondary>replacing</secondary></indexterm> +<indexterm><primary>Property</primary><secondary>format</secondary></indexterm> +<indexterm><primary>Property</primary><secondary>type</secondary></indexterm> +<indexterm significance="preferred"><primary>XChangeProperty</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef><function>XChangeProperty</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Window<parameter> w</parameter></paramdef> + <paramdef>Atomproperty,<parameter> type</parameter></paramdef> + <paramdef>int<parameter> format</parameter></paramdef> + <paramdef>int<parameter> mode</parameter></paramdef> + <paramdef>unsignedchar<parameter> *data</parameter></paramdef> + <paramdef>int<parameter> nelements</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. +<!-- .ds Wi whose property you want to change --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>w</emphasis> + </term> + <listitem> + <para> +Specifies the window (Wi. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>property</emphasis> + </term> + <listitem> + <para> +Specifies the property name. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>type</emphasis> + </term> + <listitem> + <para> +Specifies the type of the property. +The X server does not interpret the type but simply +passes it back to an application that later calls +<function>XGetWindowProperty</function>. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>format</emphasis> + </term> + <listitem> + <para> +Specifies whether the data should be viewed as a list +of 8-bit, 16-bit, or 32-bit quantities. +Possible values are 8, 16, and 32. +This information allows the X server to correctly perform +byte-swap operations as necessary. +If the format is 16-bit or 32-bit, +you must explicitly cast your data pointer to an (unsigned char *) in the call +to +<function>XChangeProperty</function>. +<!-- .\" Changed name of this file to prop_mode.a on 1/13/87 --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>mode</emphasis> + </term> + <listitem> + <para> +Specifies the mode of the operation. +You can pass +<symbol>PropModeReplace</symbol>, +<symbol>PropModePrepend</symbol>, +or +<symbol>PropModeAppend</symbol>. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>data</emphasis> + </term> + <listitem> + <para> +Specifies the property data. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>nelements</emphasis> + </term> + <listitem> + <para> +Specifies the number of elements of the specified data format. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XChangeProperty</function> +function alters the property for the specified window and +causes the X server to generate a +<symbol>PropertyNotify</symbol> +event on that window. +<function>XChangeProperty</function> +performs the following: +</para> +<itemizedlist> + <listitem> + <para> +If mode is +<symbol>PropModeReplace</symbol>, +<function>XChangeProperty</function> +discards the previous property value and stores the new data. + </para> + </listitem> + <listitem> + <para> +If mode is +<symbol>PropModePrepend</symbol> +or +<symbol>PropModeAppend</symbol>, +<function>XChangeProperty</function> +inserts the specified data before the beginning of the existing data +or onto the end of the existing data, respectively. +The type and format must match the existing property value, +or a +<errorname>BadMatch</errorname> +error results. +If the property is undefined, +it is treated as defined with the correct type and +format with zero-length data. + </para> + </listitem> +</itemizedlist> +<para> +<!-- .LP --> +If the specified format is 8, the property data must be a +<type>char</type> +array. +If the specified format is 16, the property data must be a +<type>short</type> +array. +If the specified format is 32, the property data must be a +<type>long</type> +array. +</para> +<para> +<!-- .LP --> +The lifetime of a property is not tied to the storing client. +Properties remain until explicitly deleted, until the window is destroyed, +or until the server resets. +For a discussion of what happens when the connection to the X server is closed, +see section 2.6. <!-- xref --> +The maximum size of a property is server dependent and can vary dynamically +depending on the amount of memory the server has available. +(If there is insufficient space, a +<errorname>BadAlloc</errorname> +error results.) +</para> +<para> +<!-- .LP --> +<function>XChangeProperty</function> +can generate +<errorname>BadAlloc</errorname>, +<errorname>BadAtom</errorname>, +<errorname>BadMatch</errorname>, +<errorname>BadValue</errorname>, +and +<errorname>BadWindow</errorname> +errors. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To rotate a window's property list, use +<function>XRotateWindowProperties</function>. +</para> +<para> +<!-- .LP --> +<indexterm significance="preferred"><primary>XRotateWindowProperties</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef><function>XRotateWindowProperties</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Window<parameter> w</parameter></paramdef> + <paramdef>Atom<parameter> properties[]</parameter></paramdef> + <paramdef>int<parameter> num_prop</parameter></paramdef> + <paramdef>int<parameter> npositions</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>w</emphasis> + </term> + <listitem> + <para> +Specifies the window. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>properties</emphasis> + </term> + <listitem> + <para> +Specifies the array of properties that are to be rotated. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>num_prop</emphasis> + </term> + <listitem> + <para> +Specifies the length of the properties array. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>npositions</emphasis> + </term> + <listitem> + <para> +Specifies the rotation amount. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XRotateWindowProperties</function> +function allows you to rotate properties on a window and causes +the X server to generate +<symbol>PropertyNotify</symbol> +events. +If the property names in the properties array are viewed as being numbered +starting from zero and if there are num_prop property names in the list, +then the value associated with property name I becomes the value associated +with property name (I + npositions) mod N for all I from zero to N − 1. +The effect is to rotate the states by npositions places around the virtual ring +of property names (right for positive npositions, +left for negative npositions). +If npositions mod N is nonzero, +the X server generates a +<symbol>PropertyNotify</symbol> +event for each property in the order that they are listed in the array. +If an atom occurs more than once in the list or no property with that +name is defined for the window, +a +<errorname>BadMatch</errorname> +error results. +If a +<errorname>BadAtom</errorname> +or +<errorname>BadMatch</errorname> +error results, +no properties are changed. +</para> +<para> +<!-- .LP --> +<function>XRotateWindowProperties</function> +can generate +<errorname>BadAtom</errorname>, +<errorname>BadMatch</errorname>, +and +<errorname>BadWindow</errorname> +errors. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To delete a property on a given window, use +<function>XDeleteProperty</function>. +<indexterm><primary>Property</primary><secondary>deleting</secondary></indexterm> +<indexterm significance="preferred"><primary>XDeleteProperty</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef><function>XDeleteProperty</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Window<parameter> w</parameter></paramdef> + <paramdef>Atom<parameter> property</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. +<!-- .ds Wi whose property you want to delete --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>w</emphasis> + </term> + <listitem> + <para> +Specifies the window (Wi. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>property</emphasis> + </term> + <listitem> + <para> +Specifies the property name. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XDeleteProperty</function> +function deletes the specified property only if the +property was defined on the specified window +and causes the X server to generate a +<symbol>PropertyNotify</symbol> +event on the window unless the property does not exist. +</para> +<para> +<!-- .LP --> +<function>XDeleteProperty</function> +can generate +<errorname>BadAtom</errorname> +and +<errorname>BadWindow</errorname> +errors. +</para> +</sect1> +<sect1 id="Selections"> +<title>Selections</title> +<!-- .XS --> +<!-- (SN Selections --> +<!-- .XE --> +<para> +<!-- .LP --> +<indexterm><primary>Selection</primary></indexterm> +Selections are one method used by applications to exchange data. +By using the property mechanism, +applications can exchange data of arbitrary types and can negotiate +the type of the data. +A selection can be thought of as an indirect property with a dynamic type. +That is, rather than having the property stored in the X server, +the property is maintained by some client (the owner). +A selection is global in nature (considered to belong to the user +but be maintained by clients) rather than being private to a particular +window subhierarchy or a particular set of clients. +</para> +<para> +<!-- .LP --> +Xlib provides functions that you can use to set, get, or request conversion +of selections. +This allows applications to implement the notion of current selection, +which requires that notification be sent to applications when they no +longer own the selection. +Applications that support selection often highlight the current selection +and so must be informed when another application has +acquired the selection so that they can unhighlight the selection. +</para> +<para> +<!-- .LP --> +When a client asks for the contents of +a selection, it specifies a selection target type. +This target type +can be used to control the transmitted representation of the contents. +For example, if the selection is ``the last thing the user clicked on'' +and that is currently an image, then the target type might specify +whether the contents of the image should be sent in XY format or Z format. +</para> +<para> +<!-- .LP --> +The target type can also be used to control the class of +contents transmitted, for example, +asking for the ``looks'' (fonts, line +spacing, indentation, and so forth) of a paragraph selection, not the +text of the paragraph. +The target type can also be used for other +purposes. +The protocol does not constrain the semantics. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To set the selection owner, use +<function>XSetSelectionOwner</function>. +<indexterm><primary>Selection</primary><secondary>setting the owner</secondary></indexterm> +<indexterm significance="preferred"><primary>XSetSelectionOwner</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef><function>XSetSelectionOwner</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Atom<parameter> selection</parameter></paramdef> + <paramdef>Window<parameter> owner</parameter></paramdef> + <paramdef>Time<parameter> time</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>selection</emphasis> + </term> + <listitem> + <para> +Specifies the selection atom. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>owner</emphasis> + </term> + <listitem> + <para> +Specifies the owner of the specified selection atom. +You can pass a window or +<symbol>None</symbol>. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>time</emphasis> + </term> + <listitem> + <para> +Specifies the time. +You can pass either a timestamp or +<symbol>CurrentTime</symbol>. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XSetSelectionOwner</function> +function changes the owner and last-change time for the specified selection +and has no effect if the specified time is earlier than the current +last-change time of the specified selection +or is later than the current X server time. +Otherwise, the last-change time is set to the specified time, +with +<symbol>CurrentTime</symbol> +replaced by the current server time. +If the owner window is specified as +<symbol>None</symbol>, +then the owner of the selection becomes +<symbol>None</symbol> +(that is, no owner). +Otherwise, the owner of the selection becomes the client executing +the request. +</para> +<para> +<!-- .LP --> +If the new owner (whether a client or +<symbol>None</symbol>) +is not +the same as the current owner of the selection and the current +owner is not +<symbol>None</symbol>, +the current owner is sent a +<symbol>SelectionClear</symbol> +event. +If the client that is the owner of a selection is later +terminated (that is, its connection is closed) +or if the owner window it has specified in the request is later +destroyed, +the owner of the selection automatically +reverts to +<symbol>None</symbol>, +but the last-change time is not affected. +The selection atom is uninterpreted by the X server. +<function>XGetSelectionOwner</function> +returns the owner window, which is reported in +<symbol>SelectionRequest</symbol> +and +<symbol>SelectionClear</symbol> +events. +Selections are global to the X server. +</para> +<para> +<!-- .LP --> +<function>XSetSelectionOwner</function> +can generate +<errorname>BadAtom</errorname> +and +<errorname>BadWindow</errorname> +errors. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To return the selection owner, use +<function>XGetSelectionOwner</function>. +<indexterm><primary>Selection</primary><secondary>getting the owner</secondary></indexterm> +<indexterm significance="preferred"><primary>XGetSelectionOwner</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef>Window <function>XGetSelectionOwner</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Atom<parameter> selection</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. +<!-- .ds Se whose owner you want returned --> + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>selection</emphasis> + </term> + <listitem> + <para> +Specifies the selection atom (Se. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +The +<function>XGetSelectionOwner</function> +function +returns the window ID associated with the window that currently owns the +specified selection. +If no selection was specified, the function returns the constant +<symbol>None</symbol>. +If +<symbol>None</symbol> +is returned, +there is no owner for the selection. +</para> +<para> +<!-- .LP --> +<function>XGetSelectionOwner</function> +can generate a +<errorname>BadAtom</errorname> +error. +</para> +<para> +<!-- .LP --> +<!-- .sp --> +To request conversion of a selection, use +<function>XConvertSelection</function>. +<indexterm><primary>Selection</primary><secondary>converting</secondary></indexterm> +<indexterm significance="preferred"><primary>XConvertSelection</primary></indexterm> +<!-- .sM --> +<funcsynopsis> +<funcprototype> + <funcdef><function>XConvertSelection</function></funcdef> + <paramdef>Display<parameter> *display</parameter></paramdef> + <paramdef>Atomselection,<parameter> target</parameter></paramdef> + <paramdef>Atom<parameter> property</parameter></paramdef> + <paramdef>Window<parameter> requestor</parameter></paramdef> + <paramdef>Time<parameter> time</parameter></paramdef> +</funcprototype> +</funcsynopsis> +<!-- .FN --> +<variablelist> + <varlistentry> + <term> + <emphasis remap='I'>display</emphasis> + </term> + <listitem> + <para> +Specifies the connection to the X server. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>selection</emphasis> + </term> + <listitem> + <para> +Specifies the selection atom. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>target</emphasis> + </term> + <listitem> + <para> +Specifies the target atom. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>property</emphasis> + </term> + <listitem> + <para> +Specifies the property name. +You also can pass +<symbol>None</symbol>. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>requestor</emphasis> + </term> + <listitem> + <para> +Specifies the requestor. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis remap='I'>time</emphasis> + </term> + <listitem> + <para> +Specifies the time. +You can pass either a timestamp or +<symbol>CurrentTime</symbol>. + </para> + </listitem> + </varlistentry> +</variablelist> +</para> +<para> +<!-- .LP --> +<!-- .eM --> +<function>XConvertSelection</function> +requests that the specified selection be converted to the specified target +type: +</para> +<itemizedlist> + <listitem> + <para> +If the specified selection has an owner, the X server sends a +<symbol>SelectionRequest</symbol> +event to that owner. + </para> + </listitem> + <listitem> + <para> +If no owner for the specified +selection exists, the X server generates a +<symbol>SelectionNotify</symbol> +event to the +requestor with property +<symbol>None</symbol>. + </para> + </listitem> +</itemizedlist> +<para> +<!-- .LP --> +The arguments are passed on unchanged in either of the events. +There are two predefined selection atoms: PRIMARY and SECONDARY. +</para> +<para> +<!-- .LP --> +<function>XConvertSelection</function> +can generate +<errorname>BadAtom</errorname> +and +<errorname>BadWindow</errorname> +errors. +<!-- .bp --> + + +</para> +</sect1> +</chapter> diff --git a/libX11/src/IntAtom.c b/libX11/src/IntAtom.c index a06689950..7a5625840 100644 --- a/libX11/src/IntAtom.c +++ b/libX11/src/IntAtom.c @@ -1,297 +1,297 @@ -/*
-
-Copyright 1986, 1990, 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.
-
-*/
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include "Xlibint.h"
-#include "Xintatom.h"
-
-#define HASH(sig) ((sig) & (TABLESIZE-1))
-#define REHASHVAL(sig) ((((sig) % (TABLESIZE-3)) + 2) | 1)
-#define REHASH(idx,rehash) ((idx + rehash) & (TABLESIZE-1))
-
-void
-_XFreeAtomTable(Display *dpy)
-{
- register Entry *table;
- register int i;
- register Entry e;
-
- if (dpy->atoms) {
- table = dpy->atoms->table;
- for (i = TABLESIZE; --i >= 0; ) {
- if ((e = *table++) && (e != RESERVED))
- Xfree((char *)e);
- }
- Xfree((char *)dpy->atoms);
- }
-}
-
-static
-Atom _XInternAtom(
- Display *dpy,
- _Xconst char *name,
- Bool onlyIfExists,
- unsigned long *psig,
- int *pidx,
- int *pn)
-{
- register AtomTable *atoms;
- register char *s1, c, *s2;
- register unsigned long sig;
- register int idx = 0, i;
- Entry e;
- int n, firstidx, rehash = 0;
- xInternAtomReq *req;
-
- /* look in the cache first */
- if (!(atoms = dpy->atoms)) {
- dpy->atoms = atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable));
- dpy->free_funcs->atoms = _XFreeAtomTable;
- }
- sig = 0;
- for (s1 = (char *)name; (c = *s1++); )
- sig += c;
- n = s1 - (char *)name - 1;
- if (atoms) {
- firstidx = idx = HASH(sig);
- while ((e = atoms->table[idx])) {
- if (e != RESERVED && e->sig == sig) {
- for (i = n, s1 = (char *)name, s2 = EntryName(e); --i >= 0; ) {
- if (*s1++ != *s2++)
- goto nomatch;
- }
- if (!*s2)
- return e->atom;
- }
-nomatch: if (idx == firstidx)
- rehash = REHASHVAL(sig);
- idx = REHASH(idx, rehash);
- if (idx == firstidx)
- break;
- }
- }
- *psig = sig;
- *pidx = idx;
- if (atoms && !atoms->table[idx])
- atoms->table[idx] = RESERVED; /* reserve slot */
- *pn = n;
- /* not found, go to the server */
- GetReq(InternAtom, req);
- req->nbytes = n;
- req->onlyIfExists = onlyIfExists;
- req->length += (n+3)>>2;
- Data(dpy, name, n);
- return None;
-}
-
-void
-_XUpdateAtomCache(
- Display *dpy,
- const char *name,
- Atom atom,
- unsigned long sig,
- int idx,
- int n)
-{
- Entry e, oe;
- register char *s1;
- register char c;
- int firstidx, rehash;
-
- if (!dpy->atoms) {
- if (idx < 0) {
- dpy->atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable));
- dpy->free_funcs->atoms = _XFreeAtomTable;
- }
- if (!dpy->atoms)
- return;
- }
- if (!sig) {
- for (s1 = (char *)name; (c = *s1++); )
- sig += c;
- n = s1 - (char *)name - 1;
- if (idx < 0) {
- firstidx = idx = HASH(sig);
- if (dpy->atoms->table[idx]) {
- rehash = REHASHVAL(sig);
- do
- idx = REHASH(idx, rehash);
- while (idx != firstidx && dpy->atoms->table[idx]);
- }
- }
- }
- e = (Entry)Xmalloc(sizeof(EntryRec) + n + 1);
- if (e) {
- e->sig = sig;
- e->atom = atom;
- strcpy(EntryName(e), name);
- if ((oe = dpy->atoms->table[idx]) && (oe != RESERVED))
- Xfree((char *)oe);
- dpy->atoms->table[idx] = e;
- }
-}
-
-Atom
-XInternAtom (
- Display *dpy,
- const char *name,
- Bool onlyIfExists)
-{
- Atom atom;
- unsigned long sig;
- int idx, n;
- xInternAtomReply rep;
-
- if (!name)
- name = "";
- LockDisplay(dpy);
- if ((atom = _XInternAtom(dpy, name, onlyIfExists, &sig, &idx, &n))) {
- UnlockDisplay(dpy);
- return atom;
- }
- if (dpy->atoms && dpy->atoms->table[idx] == RESERVED)
- dpy->atoms->table[idx] = NULL; /* unreserve slot */
- if (_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
- if ((atom = rep.atom))
- _XUpdateAtomCache(dpy, name, atom, sig, idx, n);
- }
- UnlockDisplay(dpy);
- SyncHandle();
- return (rep.atom);
-}
-
-typedef struct {
- unsigned long start_seq;
- unsigned long stop_seq;
- const char **names;
- Atom *atoms;
- int count;
- Status status;
-} _XIntAtomState;
-
-static
-Bool _XIntAtomHandler(
- register Display *dpy,
- register xReply *rep,
- char *buf,
- int len,
- XPointer data)
-{
- register _XIntAtomState *state;
- register int i, idx = 0;
- xInternAtomReply replbuf;
- register xInternAtomReply *repl;
-
- state = (_XIntAtomState *)data;
- if (dpy->last_request_read < state->start_seq ||
- dpy->last_request_read > state->stop_seq)
- return False;
- for (i = 0; i < state->count; i++) {
- if (state->atoms[i] & 0x80000000) {
- idx = ~state->atoms[i];
- state->atoms[i] = None;
- break;
- }
- }
- if (i >= state->count)
- return False;
- if (rep->generic.type == X_Error) {
- state->status = 0;
- return False;
- }
- repl = (xInternAtomReply *)
- _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
- (SIZEOF(xInternAtomReply) - SIZEOF(xReply)) >> 2,
- True);
- if ((state->atoms[i] = repl->atom))
- _XUpdateAtomCache(dpy, state->names[i], (Atom) repl->atom,
- (unsigned long)0, idx, 0);
- return True;
-}
-
-Status
-XInternAtoms (
- Display *dpy,
- const char **names,
- int count,
- Bool onlyIfExists,
- Atom *atoms_return)
-{
- int i, idx, n, tidx;
- unsigned long sig;
- _XAsyncHandler async;
- _XIntAtomState async_state;
- int missed = -1;
- xInternAtomReply rep;
-
- LockDisplay(dpy);
- async_state.start_seq = dpy->request + 1;
- async_state.atoms = atoms_return;
- async_state.names = names;
- async_state.count = count - 1;
- async_state.status = 1;
- async.next = dpy->async_handlers;
- async.handler = _XIntAtomHandler;
- async.data = (XPointer)&async_state;
- dpy->async_handlers = &async;
- for (i = 0; i < count; i++) {
- if (!(atoms_return[i] = _XInternAtom(dpy, names[i], onlyIfExists,
- &sig, &idx, &n))) {
- missed = i;
- atoms_return[i] = ~((Atom)idx);
- async_state.stop_seq = dpy->request;
- }
- }
- if (missed >= 0) {
- if (dpy->atoms) {
- /* unreserve anything we just reserved */
- for (i = 0; i < count; i++) {
- if (atoms_return[i] & 0x80000000) {
- tidx = ~atoms_return[i];
- if (dpy->atoms->table[tidx] == RESERVED)
- dpy->atoms->table[tidx] = NULL;
- }
- }
- }
- if (_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
- if ((atoms_return[missed] = rep.atom))
- _XUpdateAtomCache(dpy, names[missed], (Atom) rep.atom,
- sig, idx, n);
- } else {
- atoms_return[missed] = None;
- async_state.status = 0;
- }
- }
- DeqAsyncHandler(dpy, &async);
- UnlockDisplay(dpy);
- if (missed >= 0)
- SyncHandle();
- return async_state.status;
-}
+/* + +Copyright 1986, 1990, 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. + +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "Xlibint.h" +#include "Xintatom.h" + +#define HASH(sig) ((sig) & (TABLESIZE-1)) +#define REHASHVAL(sig) ((((sig) % (TABLESIZE-3)) + 2) | 1) +#define REHASH(idx,rehash) ((idx + rehash) & (TABLESIZE-1)) + +void +_XFreeAtomTable(Display *dpy) +{ + register Entry *table; + register int i; + register Entry e; + + if (dpy->atoms) { + table = dpy->atoms->table; + for (i = TABLESIZE; --i >= 0; ) { + if ((e = *table++) && (e != RESERVED)) + Xfree((char *)e); + } + Xfree((char *)dpy->atoms); + } +} + +static +Atom _XInternAtom( + Display *dpy, + _Xconst char *name, + Bool onlyIfExists, + unsigned long *psig, + int *pidx, + int *pn) +{ + register AtomTable *atoms; + register char *s1, c, *s2; + register unsigned long sig; + register int idx = 0, i; + Entry e; + int n, firstidx, rehash = 0; + xInternAtomReq *req; + + /* look in the cache first */ + if (!(atoms = dpy->atoms)) { + dpy->atoms = atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable)); + dpy->free_funcs->atoms = _XFreeAtomTable; + } + sig = 0; + for (s1 = (char *)name; (c = *s1++); ) + sig += c; + n = s1 - (char *)name - 1; + if (atoms) { + firstidx = idx = HASH(sig); + while ((e = atoms->table[idx])) { + if (e != RESERVED && e->sig == sig) { + for (i = n, s1 = (char *)name, s2 = EntryName(e); --i >= 0; ) { + if (*s1++ != *s2++) + goto nomatch; + } + if (!*s2) + return e->atom; + } +nomatch: if (idx == firstidx) + rehash = REHASHVAL(sig); + idx = REHASH(idx, rehash); + if (idx == firstidx) + break; + } + } + *psig = sig; + *pidx = idx; + if (atoms && !atoms->table[idx]) + atoms->table[idx] = RESERVED; /* reserve slot */ + *pn = n; + /* not found, go to the server */ + GetReq(InternAtom, req); + req->nbytes = n; + req->onlyIfExists = onlyIfExists; + req->length += (n+3)>>2; + Data(dpy, name, n); + return None; +} + +void +_XUpdateAtomCache( + Display *dpy, + const char *name, + Atom atom, + unsigned long sig, + int idx, + int n) +{ + Entry e, oe; + register char *s1; + register char c; + int firstidx, rehash; + + if (!dpy->atoms) { + if (idx < 0) { + dpy->atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable)); + dpy->free_funcs->atoms = _XFreeAtomTable; + } + if (!dpy->atoms) + return; + } + if (!sig) { + for (s1 = (char *)name; (c = *s1++); ) + sig += c; + n = s1 - (char *)name - 1; + if (idx < 0) { + firstidx = idx = HASH(sig); + if (dpy->atoms->table[idx]) { + rehash = REHASHVAL(sig); + do + idx = REHASH(idx, rehash); + while (idx != firstidx && dpy->atoms->table[idx]); + } + } + } + e = (Entry)Xmalloc(sizeof(EntryRec) + n + 1); + if (e) { + e->sig = sig; + e->atom = atom; + strcpy(EntryName(e), name); + if ((oe = dpy->atoms->table[idx]) && (oe != RESERVED)) + Xfree((char *)oe); + dpy->atoms->table[idx] = e; + } +} + +Atom +XInternAtom ( + Display *dpy, + const char *name, + Bool onlyIfExists) +{ + Atom atom; + unsigned long sig; + int idx, n; + xInternAtomReply rep; + + if (!name) + name = ""; + LockDisplay(dpy); + if ((atom = _XInternAtom(dpy, name, onlyIfExists, &sig, &idx, &n))) { + UnlockDisplay(dpy); + return atom; + } + if (dpy->atoms && dpy->atoms->table[idx] == RESERVED) + dpy->atoms->table[idx] = NULL; /* unreserve slot */ + if (_XReply (dpy, (xReply *)&rep, 0, xTrue)) { + if ((atom = rep.atom)) + _XUpdateAtomCache(dpy, name, atom, sig, idx, n); + } + UnlockDisplay(dpy); + SyncHandle(); + return (rep.atom); +} + +typedef struct { + unsigned long start_seq; + unsigned long stop_seq; + char **names; + Atom *atoms; + int count; + Status status; +} _XIntAtomState; + +static +Bool _XIntAtomHandler( + register Display *dpy, + register xReply *rep, + char *buf, + int len, + XPointer data) +{ + register _XIntAtomState *state; + register int i, idx = 0; + xInternAtomReply replbuf; + register xInternAtomReply *repl; + + state = (_XIntAtomState *)data; + if (dpy->last_request_read < state->start_seq || + dpy->last_request_read > state->stop_seq) + return False; + for (i = 0; i < state->count; i++) { + if (state->atoms[i] & 0x80000000) { + idx = ~state->atoms[i]; + state->atoms[i] = None; + break; + } + } + if (i >= state->count) + return False; + if (rep->generic.type == X_Error) { + state->status = 0; + return False; + } + repl = (xInternAtomReply *) + _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len, + (SIZEOF(xInternAtomReply) - SIZEOF(xReply)) >> 2, + True); + if ((state->atoms[i] = repl->atom)) + _XUpdateAtomCache(dpy, state->names[i], (Atom) repl->atom, + (unsigned long)0, idx, 0); + return True; +} + +Status +XInternAtoms ( + Display *dpy, + char **names, + int count, + Bool onlyIfExists, + Atom *atoms_return) +{ + int i, idx, n, tidx; + unsigned long sig; + _XAsyncHandler async; + _XIntAtomState async_state; + int missed = -1; + xInternAtomReply rep; + + LockDisplay(dpy); + async_state.start_seq = dpy->request + 1; + async_state.atoms = atoms_return; + async_state.names = names; + async_state.count = count - 1; + async_state.status = 1; + async.next = dpy->async_handlers; + async.handler = _XIntAtomHandler; + async.data = (XPointer)&async_state; + dpy->async_handlers = &async; + for (i = 0; i < count; i++) { + if (!(atoms_return[i] = _XInternAtom(dpy, names[i], onlyIfExists, + &sig, &idx, &n))) { + missed = i; + atoms_return[i] = ~((Atom)idx); + async_state.stop_seq = dpy->request; + } + } + if (missed >= 0) { + if (dpy->atoms) { + /* unreserve anything we just reserved */ + for (i = 0; i < count; i++) { + if (atoms_return[i] & 0x80000000) { + tidx = ~atoms_return[i]; + if (dpy->atoms->table[tidx] == RESERVED) + dpy->atoms->table[tidx] = NULL; + } + } + } + if (_XReply (dpy, (xReply *)&rep, 0, xTrue)) { + if ((atoms_return[missed] = rep.atom)) + _XUpdateAtomCache(dpy, names[missed], (Atom) rep.atom, + sig, idx, n); + } else { + atoms_return[missed] = None; + async_state.status = 0; + } + } + DeqAsyncHandler(dpy, &async); + UnlockDisplay(dpy); + if (missed >= 0) + SyncHandle(); + return async_state.status; +} diff --git a/libXdmcp/Makefile.am b/libXdmcp/Makefile.am index 3da33e5b8..c3b85aad6 100644 --- a/libXdmcp/Makefile.am +++ b/libXdmcp/Makefile.am @@ -7,7 +7,7 @@ AM_CFLAGS = \ $(XDMCP_CFLAGS) \ $(CWARNFLAGS) -libXdmcp_la_LDFLAGS = -export-symbols-regex '^Xdmcp.*' -version-number 6:0:0 -no-undefined +libXdmcp_la_LDFLAGS = -version-number 6:0:0 -no-undefined libXdmcp_la_LIBADD = $(XDMCP_LIBS) libXdmcp_la_SOURCES = \ Array.c \ diff --git a/libXext/specs/dbelib.tex b/libXext/specs/dbelib.tex deleted file mode 100644 index e9793bc32..000000000 --- a/libXext/specs/dbelib.tex +++ /dev/null @@ -1,620 +0,0 @@ -% edited for DP edits and code consistency w/ core protocol/xlib 3/30/96
-% split into separate library and protocol documentos 4/15/96
-\documentstyle{article}
-\pagestyle{myheadings}
-\markboth{Double Buffer Extension Specification}{Double Buffer Extension Specification}
-\setlength{\parindent}{0 pt}
-\setlength{\parskip}{6pt}
-\setlength{\topsep}{0 pt}
-
-% Request names are literal symbols; therefore, use the same font for both.
-\newcommand{\requestname}[1]{{\tt #1}}
-\newcommand{\literal}[1]{\mbox{\tt #1}}
-
-\newcommand{\encodingsection}[1]{{\bf #1}}
-\newcommand{\requestsection}[1]{{\bf #1}}
-
-% Font treatment of type names differs between protocol and library sections.
-\newcommand{\libtypename}[1]{\mbox{\tt #1}}
-\newcommand{\typename}[1]{\mbox{\rm #1}} % default font
-\newcommand{\typeargname}[1]{\mbox{\rm #1}} % default font
-\newcommand{\argname}[1]{\mbox{\it #1}}
-\newcommand{\argdecl}[2]{\argname{#1} & : \typename{#2}\\}
-\newcommand{\areplyargdecl}[2]{#1 & : \typename{#2}\\}
-
-\newenvironment{arequest}[1]{\requestsection{#1} \\ \begin{tabular}{ll}}{\end{tabular}}
-\newcommand{\areply}{$\Rightarrow$\\}
-
-\newcommand{\etabstops}{\hspace*{0cm}\=\hspace*{1cm}\=\hspace*{5cm}\=\kill}
-
-\newcommand{\eargdecl}[3]{\> #1 \> \typename{#2} \> #3 \\}
-
-\newenvironment{keeptogether}{\vbox \bgroup}{\egroup}
-
-\newenvironment{erequest}[3]{\pagebreak[3] \begin{keeptogether} \encodingsection{#1} \begin{tabbing} \etabstops \eargdecl{1}{CARD8}{major-opcode} \eargdecl{1}{#2}{minor-opcode} \eargdecl{2}{#3}{request length}}{\end{tabbing} \end{keeptogether}}
-
-\newenvironment{eerror}[1]{\begin{keeptogether} \encodingsection{#1} \begin{tabbing} \etabstops }{\end{tabbing} \end{keeptogether}}
-
-\newenvironment{etypedef}[1]{\begin{keeptogether} \typename{#1} \begin{tabbing} \etabstops }{\end{tabbing} \end{keeptogether}}
-
-\newcommand{\cfunctionname}[1]{\mbox{\tt #1}}
-\newcommand{\cfunctiondecl}[1]{\mbox{\rm #1}}
-\newcommand{\cargdecl}[2]{\penalty -1\typename{#1} \argname{#2}}
-\newenvironment{cfunction}[2]{\begin{sloppypar}\begin{keeptogether}\vspace{5mm}\typename{#1}\\ \cfunctiondecl{#2}\ (}{)\end{keeptogether}\end{sloppypar}{\hangafter=2 \hangindent=20pt \raggedright\par}}
-
-% make things easier with all the long names
-\spaceskip .3333em plus 5em
-\tolerance=2000
-
-\begin{document}
-
-\title{Double Buffer Extension Library\\Protocol Version 1.0\\X Consortium Standard}
-\author{Ian Elliott\\Hewlett-Packard Company \and David P. Wiggins\\X Consortium, Inc.}
-\maketitle
-\thispagestyle{empty}
-
-\eject
-
-Copyright \copyright 1989 X Consortium, Inc. and Digital Equipment Corporation.
-
-Copyright \copyright 1992 X Consortium, Inc. and Intergraph Corporation.
-
-Copyright \copyright 1993 X Consortium, Inc. and Silicon Graphics, Inc.
-
-Copyright \copyright 1994, 1995 X Consortium, Inc. and Hewlett-Packard Company.
-
-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.
-Digital Equipment Corporation, Intergraph Corporation, Silicon
-Graphics, Hewlett-Packard, and the X Consortium make no
-representations about the suitability for any purpose of the
-information in this document. This documentation is provided ``as is''
-without express or implied warranty.
-
-\eject
-
-\section{Introduction}
-
-The Double Buffer Extension (DBE) provides a standard way to utilize
-double-buffering within the framework of the X Window System.
-Double-buffering uses two buffers, called front and back, which hold
-images. The front buffer is visible to the user; the back buffer is
-not. Successive frames of an animation are rendered into the back
-buffer while the previously rendered frame is displayed in the front
-buffer. When a new frame is ready, the back and front buffers swap
-roles, making the new frame visible. Ideally, this exchange appears to
-happen instantaneously to the user and with no visual artifacts. Thus,
-only completely rendered images are presented to the user, and they remain
-visible during the entire time it takes to render a new frame. The
-result is a flicker-free animation.
-
-\section{Goals}
-
-This extension should enable clients to:
-\begin{itemize}
-
-\item Allocate and deallocate double-buffering for a window.
-
-\item Draw to and read from the front and back buffers associated with
-a window.
-
-\item Swap the front and back buffers associated with a window.
-
-\item Specify a wide range of actions to be taken when a window is
-swapped. This includes explicit, simple swap actions (defined
-below), and more complex actions (for example, clearing ancillary buffers)
-that can be put together within explicit ``begin'' and ``end''
-requests (defined below).
-
-\item Request that the front and back buffers associated with multiple
-double-buffered windows be swapped simultaneously.
-
-\end{itemize}
-
-In addition, the extension should:
-
-\begin{itemize}
-
-\item Allow multiple clients to use double-buffering on the same window.
-
-\item Support a range of implementation methods that can capitalize on
-existing hardware features.
-
-\item Add no new event types.
-
-\item Be reasonably easy to integrate with a variety of direct graphics
-hardware access (DGHA) architectures.
-\end{itemize}
-
-\section{Concepts}
-
-Normal windows are created using the core \requestname{CreateWindow}
-request, which allocates a set of window attributes and, for
-\literal{InputOutput} windows, a front buffer,
-into which an image can be drawn.
-The contents of this buffer will be displayed when the window is
-visible.
-
-This extension enables applications to use double-buffering with a
-window. This involves creating a second buffer, called a back buffer,
-and associating one or more back buffer names (\typename{XID}s) with
-the window for use when referring to (that is, drawing to or reading
-from) the window's back buffer. The back buffer name is a
-\typename{DRAWABLE} of type \typename{BACKBUFFER}.
-
-DBE provides a relative double-buffering model. One XID, the window,
-always refers to the front buffer. One or more other XIDs, the back buffer
-names, always refer to the back buffer. After a buffer swap, the
-window continues to refer to the (new) front buffer, and the
-back buffer name continues to refer to the (new) back buffer. Thus,
-applications and toolkits that want to just render to the back buffer
-always use the back buffer name for all drawing requests to the
-window. Portions of an application that want to render to the front
-buffer always use the window XID for all drawing requests to the
-window.
-
-Multiple clients and toolkits can all use double-buffering on the same
-window. DBE does not provide a request for querying whether a window
-has double-buffering support, and if so, what the back buffer name is.
-Given the asynchronous nature of the X Window System, this would cause
-race conditions. Instead, DBE allows multiple back buffer names to
-exist for the same window; they all refer to the same physical back
-buffer. The first time a back buffer name is allocated for a window,
-the window becomes double-buffered and the back buffer name is
-associated with the window. Subsequently, the window already is a
-double-buffered window, and nothing about the window changes when a
-new back buffer name is allocated, except that the new back buffer
-name is associated with the window. The window remains
-double-buffered until either the window is destroyed or until all of
-the back buffer names for the window are deallocated.
-
-In general, both the front and back buffers are treated the same. In
-particular, here are some important characteristics:
-
-\begin{itemize}
-
-\item Only one buffer per window can be visible at a time (the
-front buffer).
-
-\item Both buffers associated with a window have the same visual type,
-depth, width, height, and shape as the window.
-
-\item Both buffers associated with a window are ``visible'' (or
-``obscured'') in the same way. When an \literal{Expose} event is
-generated for
-a window, both buffers should be considered to be damaged in the
-exposed area. Damage that occurs to either buffer will result in an
-\literal{Expose} event on the window. When a double-buffered window is
-exposed,
-both buffers are tiled with the window background, exactly as stated
-by the core protocol. Even though the back buffer is not visible,
-terms such as obscure apply to the back buffer as well as to the front
-buffer.
-
-\item It is acceptable at any time to pass a \typename{BACKBUFFER} in
-any request, notably any core or extension drawing request, that
-expects a \typename{DRAWABLE}. This enables an application to draw
-directly into \typename{BACKBUFFER}s in the same fashion as it would
-draw into any other \typename{DRAWABLE}.
-
-\item It is an error (\literal{Window}) to pass a \typename{BACKBUFFER} in a
-core request that expects a Window.
-
-\item A \typename{BACKBUFFER} will never be sent by core X in a reply,
-event, or error where a Window is specified.
-\item If core X11 backing-store and save-under applies to a
-double-buffered window, it applies to both buffers equally.
-
-\item If the core \requestname{ClearArea} request is executed on a
-double-buffered window, the same area in both the front and back
-buffers is cleared.
-
-\end{itemize}
-
-The effect of passing a window to a request that accepts a
-\typename{DRAWABLE} is unchanged by this extension. The window and
-front buffer are synonomous with each other. This includes obeying
-the \requestname{GetImage} semantics and the subwindow-mode semantics
-if a core graphics context is involved. Regardless of whether the
-window was explicitly passed in a \requestname{GetImage} request, or
-implicitly referenced (that is, one of the window's ancestors was passed
-in the request), the front (that is, visible) buffer is always referenced.
-Thus, DBE-na\"{\i}ve screen dump clients will always get the front buffer.
-\requestname{GetImage} on a back buffer returns undefined image
-contents for any obscured regions of the back buffer that fall within
-the image.
-
-Drawing to a back buffer always uses the clip region that would be
-used to draw to the front buffer with a GC subwindow-mode of
-\literal{ClipByChildren}. If an ancestor of a double-buffered window is drawn
-to with a core GC having a subwindow-mode of \literal{IncludeInferiors}, the
-effect on the double-buffered window's back buffer depends on the
-depth of the double-buffered window and the ancestor. If the depths
-are the same, the contents of the back buffer of the double-buffered
-window are not changed. If the depths are different, the contents of
-the back buffer of the double-buffered window are undefined for the
-pixels that the \literal{IncludeInferiors} drawing touched.
-
-DBE adds no new events. DBE does not extend the semantics of any
-existing events with the exception of adding a new \typename{DRAWABLE}
-type called \typename{BACKBUFFER}. If events, replies, or errors that
-contain a \typename{DRAWABLE} (for example, \literal{GraphicsExpose}) are
-generated in
-response to a request, the \typename{DRAWABLE} returned will be the
-one specified in the request.
-
-DBE advertises which visuals support double-buffering.
-
-DBE does not include any timing or synchronization facilities.
-Applications that need such facilities (for example, to maintain a constant
-frame rate) should investigate the Synchronization Extension, an X
-Consortium standard.
-
-\subsection{Window Management Operations}
-
-The basic philosophy of DBE is that both buffers are treated the same by
-core X window management operations.
-
-When the core \requestname{DestroyWindow} is executed on a
-double-buffered window, both buffers associated with the window are
-destroyed, and all back buffer names associated with the window are
-freed.
-
-If the core \requestname{ConfigureWindow} request changes the size of
-a window, both buffers assume the new size. If the window's size
-increases, the effect on the buffers depends on whether the
-implementation honors bit gravity for buffers. If bit gravity is
-implemented, then the contents of both buffers are moved in accordance
-with the window's bit gravity (see the core
-\requestname{ConfigureWindow} request), and the remaining areas are
-tiled with the window background. If bit gravity is not implemented,
-then the entire unobscured region of both buffers is tiled with the
-window background. In either case, \literal{Expose} events are generated for
-the region that is tiled with the window background.
-
-If the core \requestname{GetGeometry} request is executed on a
-\typename{BACKBUFFER}, the returned x, y, and border-width will be
-zero.
-
-If the Shape extension \requestname{ShapeRectangles},
-\requestname{ShapeMask}, \requestname{ShapeCombine}, or
-\requestname{ShapeOffset} request is executed on a double-buffered
-window, both buffers are reshaped to match the new window shape. The
-region difference is the following:
-
-\[ D = new shape - old shape \]
-
-It is tiled with the window background in both buffers,
-and \literal{Expose} events are generated for D.
-
-\subsection{Complex Swap Actions}
-
-DBE has no explicit knowledge of ancillary buffers (for example, depth buffers
-or alpha buffers), and only has a limited set of defined swap actions.
-Some applications may need a richer set of swap actions than DBE
-provides. Some DBE implementations have knowledge of ancillary
-buffers, and/or can provide a rich set of swap actions. Instead of
-continually extending DBE to increase its set of swap actions, DBE
-provides a flexible ``idiom'' mechanism. If an application's needs
-are served by the defined swap actions, it should use them; otherwise,
-it should use the following method of expressing a complex swap action
-as an idiom. Following this policy will ensure the best possible
-performance across a wide variety of implementations.
-
-As suggested by the term ``idiom,'' a complex swap action should be
-expressed as a group/series of requests. Taken together, this group
-of requests may be combined into an atomic operation by the
-implementation, in order to maximize performance. The set of idioms
-actually recognized for optimization is implementation dependent. To
-help with idiom expression and interpretation, an idiom must be
-surrounded by two protocol requests: \requestname{DBEBeginIdiom} and
-\requestname{DBEEndIdiom}. Unless this begin-end pair surrounds the
-idiom, it may not be recognized by a given implementation, and
-performance will suffer.
-
-For example, if an application wants to swap buffers for two windows,
-and use core X to clear only certain planes of the back buffers, the
-application would issue the following protocol requests as a group, and
-in the following order:
-
-\begin{itemize}
-\item \requestname{DBEBeginIdiom} request.
-\item \requestname{DBESwapBuffers} request with XIDs for two windows, each
-of which uses a swap action of \literal{Untouched}.
-\item Core X \requestname{PolyFillRectangle} request to the back buffer of one window.
-\item Core X \requestname{PolyFillRectangle} request to the back buffer of the other window.
-\item \requestname{DBEEndIdiom} request.
-\end{itemize}
-
-The \requestname{DBEBeginIdiom} and \requestname{DBEEndIdiom} requests
-do not perform any actions themselves. They are treated as markers by
-implementations that can combine certain groups/series of requests as
-idioms, and are ignored by other implementations or for nonrecognized
-groups/series of requests. If these requests are sent out of order,
-or are mismatched, no errors are sent, and the requests are executed
-as usual, though performance may suffer.
-
-An idiom need not include a \requestname{DBESwapBuffers} request. For
-example, if a swap action of \literal{Copied} is desired, but only some of the
-planes should be copied, a core X \requestname{CopyArea} request may
-be used instead of \requestname{DBESwapBuffers}. If
-\requestname{DBESwapBuffers} is included in an idiom, it should
-immediately follow the \requestname{DBEBeginIdiom} request. Also,
-when the \requestname{DBESwapBuffers} is included in an idiom, that
-request's swap action will still be valid, and if the swap action
-might overlap with another request, then the final result of the idiom
-must be as if the separate requests were executed serially. For
-example, if the specified swap action is \literal{Untouched}, and if a
-\requestname{PolyFillRectangle} using a client clip rectangle is done
-to the window's back buffer after the \requestname{DBESwapBuffers}
-request, then the contents of the new back buffer (after the idiom)
-will be the same as if the idiom was not recognized by the
-implementation.
-
-It is highly recommended that Application Programming Interface (API)
-providers define, and application developers use, ``convenience'' functions
-that allow client applications to call one procedure that encapsulates common idioms.
-These functions will generate the \requestname{DBEBeginIdiom} request,
-the idiom requests, and \requestname{DBEEndIdiom} request. Usage of
-these functions will ensure best possible performance across a wide
-variety of implementations.
-
-\section{C Language Binding}
-
-The header for this extension is \verb|<X11/extensions/Xdbe.h>|. All
-identifier names provided by this header begin with Xdbe.
-
-\subsection{Types}
-
-The type \libtypename{XdbeBackBuffer} is a \libtypename{Drawable}.
-
-The type \libtypename{XdbeSwapAction} can be one of the constants
-\literal{XdbeUndefined}, \literal{XdbeBackground},
-\literal{XdbeUntouched}, or \literal{XdbeCopied}.
-
-\subsection{C Functions}
-
-The C functions provide direct access to the protocol and add no
-additional semantics. For complete details on the effects of these
-functions, refer to the appropriate protocol request, which can be
-derived by replacing Xdbe at the start of the function name with DBE\@.
-All functions that have return type \libtypename{Status} will return
-nonzero for success and zero for failure.
-
-% start marker
-\begin{keeptogether}
-\begin{cfunction}{Status}{XdbeQueryExtension}
-\cargdecl{Display *}{dpy},
-\cargdecl{int *}{major\_version\_return},
-\cargdecl{int *}{minor\_version\_return}
-\end{cfunction}
-% end marker
-
-\cfunctionname{XdbeQueryExtension} sets major\_version\_return and
-minor\_version\_return to the major and minor DBE protocol
-version supported by the server. If the DBE library is compatible
-with the version returned by the server, it returns
-nonzero. If dpy does not support the DBE extension, or if
-there was an error during communication with the server, or if the
-server and library protocol versions are incompatible, it
-returns zero. No other Xdbe functions may be called before this
-function. If a client violates this rule, the effects of all
-subsequent Xdbe calls that it makes are undefined.
-\end{keeptogether}
-
-% start marker
-\begin{keeptogether}
-\begin{cfunction}{XdbeScreenVisualInfo *}{XdbeGetVisualInfo}
-\cargdecl{Display *}{dpy},
-\cargdecl{Drawable *}{screen\_specifiers},
-\cargdecl{int *}{num\_screens}
-\end{cfunction}
-% end marker
-
-\cfunctionname{XdbeGetVisualInfo} returns information about which visuals support
-double buffering. The argument num\_screens specifies how many
-elements there are in the screen\_specifiers list. Each
-drawable in screen\_specifiers designates a screen for which
-the supported visuals are being requested. If num\_screens
-is zero, information for all screens is requested. In this case, upon
-return from this function, num\_screens will be set to the
-number of screens that were found. If an error occurs, this function
-returns NULL; otherwise, it returns a pointer to a list of
-\libtypename{XdbeScreenVisualInfo} structures of length num\_screens.
-The {\it n}th element in the returned list corresponds to the {\it n}th
-drawable in the screen\_specifiers list, unless
-num\_screens was passed in with the value zero, in which
-case the {\it n}th element in the returned list corresponds to the
-{\it n}th screen of the server, starting with screen zero.
-
-The \libtypename{XdbeScreenVisualInfo} structure has the following
-fields:
-
-\begin{tabular}{lll}
-\typename{int} & \argname{count} & number of items in visinfo \\
-\typename{XdbeVisualInfo *} & \argname{visinfo} & list of visuals and depths for this screen \\
-\end{tabular}
-
-The \libtypename{XdbeVisualInfo} structure has the following fields:
-
-\begin{tabular}{lll}
-\typename{VisualID} & \argname{visual} & one visual ID that supports double-buffering\\
-\typename{int} & \argname{depth} & depth of visual in bits \\
-\typename{int} & \argname{perflevel} & performance level of visual \\
-\end{tabular}
-\end{keeptogether}
-
-% start marker
-\begin{keeptogether}
-\begin{cfunction}{void }{XdbeFreeVisualInfo}
-\cargdecl{XdbeScreenVisualInfo *}{visual\_info}
-\end{cfunction}
-% end marker
-
-\cfunctionname{XdbeFreeVisualInfo} frees the list of \libtypename{XdbeScreenVisualInfo}
-returned by \cfunctionname{XdbeGetVisualInfo}.
-\end{keeptogether}
-
-% start marker
-\begin{keeptogether}
-\begin{cfunction}{XdbeBackBuffer}{XdbeAllocateBackBufferName}
-\cargdecl{Display *}{dpy},
-\cargdecl{Window}{window},
-\cargdecl{XdbeSwapAction}{swap\_action}
-\end{cfunction}
-% end marker
-
-\cfunctionname{XdbeAllocateBackBufferName} returns a drawable ID used to refer
-to the back buffer of the specified window.
-The swap\_action is a hint to indicate the swap action
-that will likely be used in subsequent calls to
-\cfunctionname{XdbeSwapBuffers}.
-The actual swap action used in calls to
-\cfunctionname{XdbeSwapBuffers} does not have
-to be the same as the swap\_action passed to this function,
-though clients are encouraged to provide accurate information whenever
-possible.
-\end{keeptogether}
-
-% start marker
-\begin{keeptogether}
-\begin{cfunction}{Status}{XdbeDeallocateBackBufferName}
-\cargdecl{Display *}{dpy},
-\cargdecl{XdbeBackBuffer}{buffer}
-\end{cfunction}
-% end marker
-
-\cfunctionname{XdbeDeallocateBackBufferName} frees the specified
-drawable ID, buffer,
-that was obtained via \cfunctionname{XdbeAllocateBackBufferName}. The buffer
-must be a valid name for the back buffer of a window, or an
-\literal{XdbeBadBuffer}
-error results.
-\end{keeptogether}
-
-% start marker
-\begin{keeptogether}
-\begin{cfunction}{Status}{XdbeSwapBuffers}
-\cargdecl{Display *}{dpy},
-\cargdecl{XdbeSwapInfo *}{swap\_info},
-\cargdecl{int}{num\_windows}
-\end{cfunction}
-% end marker
-
-\cfunctionname{XdbeSwapBuffers} swaps the front and back buffers for a list of windows.
-The argument num\_windows specifies how many windows are to
-have their buffers swapped; it is the number of elements in the
-swap\_info array. The argument swap\_info
-specifies the information needed per window to do the swap.
-
-The \libtypename{XdbeSwapInfo} structure has the following fields:
-
-\begin{tabular}{lll}
-\typename{Window} & \argname{swap\_window} & window for which to swap buffers \\
-\typename{XdbeSwapAction} & \argname{swap\_action} & swap action to use for this swap\_window \\
-\end{tabular}
-\end{keeptogether}
-
-% start marker
-\begin{keeptogether}
-\begin{cfunction}{Status}{XdbeBeginIdiom}
-\cargdecl{Display *}{dpy}
-\end{cfunction}
-% end marker
-
-\cfunctionname{XdbeBeginIdiom} marks the beginning of an idiom sequence.
-See section 3.2
-for a complete discussion of idioms.
-\end{keeptogether}
-
-% start marker
-\begin{keeptogether}
-\begin{cfunction}{Status}{XdbeEndIdiom}
-\cargdecl{Display *}{dpy}
-\end{cfunction}
-% end marker
-
-\cfunctionname{XdbeEndIdiom} marks the end of an idiom sequence.
-\end{keeptogether}
-
-% start marker
-\begin{keeptogether}
-\begin{cfunction}{XdbeBackBufferAttributes *}{XdbeGetBackBufferAttributes}
-\cargdecl{Display *}{dpy},
-\cargdecl{XdbeBackBuffer}{buffer}
-\end{cfunction}
-% end marker
-
-\cfunctionname{XdbeGetBackBufferAttributes} returns the attributes associated
-with the specified buffer.
-
-The \libtypename{XdbeBackBufferAttributes} structure has the following fields:
-
-\begin{tabular}{lll}
-\typename{Window} & \argname{window} & window that buffer belongs to \\
-\end{tabular}
-
-If buffer is not a valid \libtypename{XdbeBackBuffer},
-window is set to \literal{None}.
-
-The returned \libtypename{XdbeBackBufferAttributes} structure can be
-freed with the Xlib function \cfunctionname{XFree}.
-\end{keeptogether}
-
-\begin{keeptogether}
-\subsection{Errors}
-
-The \libtypename{XdbeBufferError} structure has the following fields:
-
-\begin{tabular}{lll}
-\typename{int} & \argname{type} \\
-\typename{Display *} & \argname{display}& Display the event was read from\\
-\typename{XdbeBackBuffer} & \argname{buffer}& resource id \\
-\typename{unsigned long} & \argname{serial}& serial number of failed request\\
-\typename{unsigned char} & \argname{error\_code}& error base + \literal{XdbeBadBuffer}\\
-\typename{unsigned char} & \argname{request\_code}& Major op-code of failed request\\
-\typename{unsigned char} & \argname{minor\_code}& Minor op-code of failed request\\
-\end{tabular}
-\end{keeptogether}
-
-\pagebreak[4]
-\section{Acknowledgements}
-
-We wish to thank the following individuals who have contributed their
-time and talent toward shaping the DBE specification:
-
-T. Alex Chen, IBM;
-Peter Daifuku, Silicon Graphics, Inc.;
-Ian Elliott, Hewlett-Packard Company;
-Stephen Gildea, X Consortium, Inc.;
-Jim Graham, Sun;
-Larry Hare, AGE Logic;
-Jay Hersh, X Consortium, Inc.;
-Daryl Huff, Sun;
-Deron Dann Johnson, Sun;
-Louis Khouw, Sun;
-Mark Kilgard, Silicon Graphics, Inc.;
-Rob Lembree, Digital Equipment Corporation;
-Alan Ricker, Metheus;
-Michael Rosenblum, Digital Equipment Corporation;
-Bob Scheifler, X Consortium, Inc.;
-Larry Seiler, Digital Equipment Corporation;
-Jeanne Sparlin Smith, IBM;
-Jeff Stevenson, Hewlett-Packard Company;
-Walter Strand, Metheus;
-Ken Tidwell, Hewlett-Packard Company; and
-David P. Wiggins, X Consortium, Inc.
-
-Mark provided the impetus to start the DBE project. Ian wrote the
-first draft of the specification. David served as architect.
-
-\section{References}
-
-Jeffrey Friedberg, Larry Seiler, and Jeff Vroom, ``Multi-buffering Extension
-Specification Version 3.3.''
-
-Tim Glauert, Dave Carver, Jim Gettys, and David P. Wiggins,
-``X Synchronization Extension Version 3.0.''
-
-\end{document}
diff --git a/libXext/specs/synclib.tex b/libXext/specs/synclib.tex deleted file mode 100644 index 0775eb9fd..000000000 --- a/libXext/specs/synclib.tex +++ /dev/null @@ -1,770 +0,0 @@ -% Copyright 1991 by Olivetti Research Limited, Cambridge, England and
-% 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 names of Digital or Olivetti
-% not be used in advertising or publicity pertaining to distribution of the
-% software without specific, written prior permission.
-%
-% DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
-% INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
-% SHALL THEY 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.
-
-%\documentstyle[a4]{article}
-\documentstyle{article}
-
-\setlength{\parindent}{0 pt}
-\setlength{\parskip}{6pt}
-
-% Protocol Section
-% For the DP book, these four should be assigned the font for global symbols.
-
-\newcommand{\request}[1]{{\bf #1}}
-\newcommand{\event}[1]{{\bf #1}}
-\newcommand{\error}[1]{{\bf #1}}
-\newcommand{\enum}[1]{{\bf #1}}
-
-% The following fonts are not reassigned for the DP book.
-
-\newcommand{\system}[1]{{\sc #1}}
-\newcommand{\param}[1]{{\it #1}}
-
-\newcommand{\eventdef}[1]{\item {\bf#1}}
-\newcommand{\requestdef}[1]{\item {\bf#1}}
-\newcommand{\errordef}[1]{\item {\bf#1}}
-
-\newcommand{\defn}[1]{{\bf #1}}
-
-\newcommand{\tabstopsA}{\hspace*{4cm}\=\hspace*{1cm}\=\hspace*{7cm}\=\kill}
-\newcommand{\tabstopsB}{\hspace*{1cm}\=\hspace*{1cm}\=\hspace*{3cm}\=\kill}
-\newcommand{\tabstopsC}{\hspace*{1cm}\=\hspace*{1cm}\=\hspace*{5cm}\=\kill}
-
-% commands for formatting the API
-% For the DP book, these three should be assigned the font for global symbols.
-
-\newcommand{\cfunctionname}[1]{\mbox{\tt#1}}
-\newcommand{\ctypename}[1]{\mbox{\tt#1}}
-\newcommand{\cconst}[1]{\mbox{\tt#1}}
-
-% For the DP book, within function definitions, the type and name are in
-% the ordinary font; therefore, ctypenamedef and cfunctionnamedef are used
-% and defined below.
-\newcommand{\ctypenamedef}[1]{\mbox{#1}}
-\newcommand{\cfunctionnamedef}[1]{\mbox{#1}}
-\newcommand{\cargname}[1]{\mbox{\it#1}}
-\newcommand{\cstartfunction}[2]{\begin{sloppypar}\begin{samepage}\ctypenamedef{#1}\\ \cfunctionnamedef{#2}\ (}
-\newcommand{\cargdecl}[2]{\penalty -1\ctypenamedef{#1} \cargname{#2}}
-\newcommand{\cendfunctiondecl}{){\hangafter=2 \hangindent=20pt \raggedright\par}}
-\newcommand{\cendfuncdescription}{\end{samepage}\end{sloppypar}}
-
-\newcommand{\cstartmacro}[2]{\begin{sloppypar}\begin{samepage}\ctypenamedef{#1}\\ \cfunctionnamedef{#2}\ (}
-\newcommand{\cendmacrodecl}{)\par}
-\newcommand{\cendmacrodescription}{\end{samepage}\end{sloppypar}}
-
-% make things easier with all the long names
-\spaceskip .3333em plus 5em
-\tolerance=2000
-
-\begin{document}
-
-\begin{center}
-
-{\large X Synchronization Extension Library}\\[10pt]
-{\large Version 3.0}\\[15pt]
-{\large X Consortium Standard}\\[15pt]
-{\large X Version 11, Release 6.8}\\[15pt]
-{\it Tim Glauert}\\[0pt]
-{\tt thg@cam-orl.co.uk}\\[0pt]
-{\bf Olivetti Research / MultiWorks}\\[5pt]
-{\it Dave Carver}\\[0pt]
-{\tt dcc@athena.mit.edu}\\[0pt]
-{\bf Digital Equipment Corporation,}\\[0pt]
-{\bf MIT / Project Athena}\\[5pt]
-{\it Jim Gettys}\\[0pt]
-{\tt jg@crl.dec.com}\\[0pt]
-{\bf Digital Equipment Corporation,}\\[0pt]
-{\bf Cambridge Research Laboratory}\\[5pt]
-{\it David P. Wiggins}\\[0pt]
-{\tt dpw@x.org}\\[0pt]
-{\bf X Consortium, Inc.}\\[0pt]
-
-\end {center}
-
-Copyright 1991 by Olivetti Research Limited, Cambridge, England and
-Digital Equipment Corporation, Maynard, Massachusetts.
-
-{\small Permission to use, copy, modify, and distribute this documentation
-for any purpose and without fee is hereby granted, provided that the above
-copyright notice appear in all copies. Olivetti, Digital, MIT, and the
-X Consortium
-make no representations about the suitability for any purpose of the
-information in this document. This documentation is provided as is without
-express or implied warranty.}
-
-Copyright (c) 1991 X Consortium, Inc.
-
-{\small 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
-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.
-
-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.}
-\eject
-
-\section{Synchronization Protocol}
-
-The core X protocol makes no guarantees about the relative order of execution
-of requests for different clients. This means that any synchronization between
-clients must be done at the client level in an operating system-dependent and
-network-dependent manner. Even if there was an accepted standard for such
-synchronization, the use of a network introduces unpredictable delays between
-the synchronization of the clients and the delivery of the resulting requests
-to the X server.
-
-The core X protocol also makes no guarantees about the time at which requests
-are executed, which means that all clients with real-time constraints must
-implement their timing on the host computer. Any such timings are subject to
-error introduced by delays within the operating system and network and are
-inefficient because of the need for round-trip requests that keep the client and
-server synchronized.
-
-The synchronization extension provides primitives that allow synchronization
-between clients to take place entirely within the X server. This removes any
-error introduced by the network and makes it possible to synchronize clients
-on different hosts running different operating systems. This is important for
-multimedia applications, where audio, video, and graphics data streams are
-being synchronized. The extension also provides internal timers within the X
-server to which client requests can be synchronized. This allows simple
-animation applications to be implemented without any round-trip requests and
-makes best use of buffering within the client, network, and server.
-
-\subsection{Description}
-
-The mechanism used by this extension for synchronization within the X server
-is to block the processing of requests from a client until a specific
-synchronization condition occurs. When the condition occurs, the client is
-released and processing of requests continues. Multiple clients may block on
-the same condition to give inter-client synchronization. Alternatively, a
-single client may block on a condition such as an animation frame marker.
-
-The extension adds \defn{Counter} and \defn{Alarm} to the set of resources
-managed by the server. A counter has a 64-bit integer value that may be
-increased or decreased by client requests or by the server internally. A
-client can block by sending an \request{Await} request that waits until
-one of a set of synchronization conditions, called TRIGGERs, becomes TRUE.
-
-The \request{CreateCounter} request allows a client to create a
-\defn{Counter} that can be changed by explicit \request{SetCounter} and
-\request{ChangeCounter} requests. These can be used to implement
-synchronization between different clients.
-
-There are some counters, called \defn{System Counters}, that are changed by
-the server internally rather than by client requests. The effect of any change
-to a system counter is not visible until the server has finished processing the
-current request. In other words, system counters are apparently updated in the
-gaps between the execution of requests rather than during the actual execution
-of a request. The extension provides a system counter that advances with the
-server time as defined by the core protocol, and it may also provide counters
-that advance with the real-world time or that change each time the CRT
-screen is refreshed. Other extensions may provide their own
-extension-specific system counters.
-
-The extension provides an \defn{Alarm} mechanism that allows clients to
-receive an event on a regular basis when a particular counter is changed.
-
-\section{C Language Binding}
-
-The C routines provide direct access to the protocol and add
-no additional semantics.
-
-The include file for this extension is \verb|<X11/extensions/sync.h>|.
-
-Most of the names in the language binding are derived from the
-protocol names by prepending \cfunctionname{XSync} to the protocol name and changing
-the capitalization.
-
-\subsection{C Functions}
-
-Most of the following functions generate SYNC protocol requests.
-
-% start marker
-\cstartfunction{Status}{XSyncQueryExtension}
-\cargdecl{Display *}{dpy},
-\cargdecl{int *}{event\_base\_return},
-\cargdecl{int *}{error\_base\_return}
-\cendfunctiondecl
-% end marker
-
-If dpy supports the SYNC extension, \cfunctionname{XSyncQueryExtension}
-returns \cconst{True}, sets *event\_base\_return to the event number for the
-first SYNC event, and sets
-*error\_base\_return to the error number for the first SYNC
-error. If dpy does not support the SYNC extension, it
-returns \cconst{False}.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{Status}{XSyncInitialize}
-\cargdecl{Display *}{dpy},
-\cargdecl{int *}{major\_version\_return},
-\cargdecl{int *}{minor\_version\_return}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncInitialize} sets *major\_version\_return and
-*minor\_version\_return to the major/minor SYNC protocol
-version supported by the server. If the XSync library is compatible
-with the version returned by the server, this function returns \cconst{True}.
-If dpy does not support the SYNC extension, or if there was an error during
-communication with the server, or if the server and library protocol
-versions are incompatible, this function returns \cconst{False}. The only
-XSync function that may be called before this function is
-\cfunctionname{XSyncQueryExtension}. If a client violates this rule,
-the effects of all XSync calls that it makes are undefined.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{XSyncSystemCounter *}{XSyncListSystemCounters}
-\cargdecl{Display *}{dpy},
-\cargdecl{int *}{n\_counters\_return}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncListSystemCounters} returns a pointer to an
-array of system counters supported by the display and sets
-*n\_counters\_return to the number of
-counters in the array. The array should be freed with
-\cfunctionname{XSyncFreeSystemCounterList}. If dpy does not
-support the SYNC extension,
-or if there was an error during communication with the
-server, or if the server does not support any system counters, this
-function returns NULL.
-
-\ctypename{XSyncSystemCounter} has the following fields:
-
-\begin{tabular}{lll}
-char * & name; & /* null-terminated name of system counter */\\
-XSyncCounter & counter; & /* counter id of this system counter */\\
-XSyncValue & resolution; & /* resolution of this system counter */\\
-\end{tabular}
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{void}{XSyncFreeSystemCounterList}
-\cargdecl{XSyncSystemCounter *}{list}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncFreeSystemCounterList} frees the memory associated
-with the system counter list returned by \cfunctionname{XSyncListSystemCounters}.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{XSyncCounter}{XSyncCreateCounter}
-\cargdecl{Display *}{dpy},
-\cargdecl{XSyncValue}{initial\_value}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncCreateCounter} creates a counter on the dpy
-with the given initial\_value and returns the counter ID.
-It returns \cconst{None} if dpy does not
-support the SYNC extension.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{Status}{XSyncSetCounter}
-\cargdecl{Display *}{dpy},
-\cargdecl{XSyncCounter}{counter},
-\cargdecl{XSyncValue}{value}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncSetCounter} sets counter to value.
-It returns \cconst{False} if dpy does not support the SYNC extension;
-otherwise, it returns \cconst{True}.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{Status}{XSyncChangeCounter}
-\cargdecl{Display *}{dpy},
-\cargdecl{XSyncCounter}{counter},
-\cargdecl{XSyncValue}{value}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncChangeCounter} adds value to counter.
-It returns \cconst{False} if dpy does not support the SYNC extension;
-otherwise, it returns \cconst{True}.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{Status}{XSyncDestroyCounter}
-\cargdecl{Display *}{dpy},
-\cargdecl{XSyncCounter}{counter}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncDestroyCounter} destroys counter.
-It returns \cconst{False} if dpy does not
-support the SYNC extension; otherwise, it returns \cconst{True}.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{Status}{XSyncQueryCounter}
-\cargdecl{Display *}{dpy},
-\cargdecl{XSyncCounter}{counter},
-\cargdecl{XSyncValue *}{value\_return}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncQueryCounter} sets *value\_return to the current value of
-counter. It returns \cconst{False} if there was an error during
-communication with the server or if dpy does not support
-the SYNC extension; otherwise, it returns \cconst{True}.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{Status}{XSyncAwait}
-\cargdecl{Display *}{dpy},
-\cargdecl{XSyncWaitCondition *}{wait\_list},
-\cargdecl{int}{n\_conditions}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncAwait} awaits on the conditions in wait\_list.
-The n\_conditions is the number of wait conditions in
-wait\_list. It returns \cconst{False} if dpy does not
-support the SYNC extension; otherwise, it returns \cconst{True}.
-The await is processed asynchronously by the server;
-this function always returns immediately
-after issuing the request.
-
-\ctypename{XSyncWaitCondition} has the following fields:
-
-\begin{tabular}{lll}
-XSyncCounter & trigger.counter; & /* counter to trigger on */ \\
-XSyncValueType & trigger.value\_type; & /* absolute/relative */ \\
-XSyncValue & trigger.wait\_value; & /* value to compare counter to */ \\
-XSyncTestType & trigger.test\_type; & /* pos/neg comparison/transtion */ \\
-XSyncValue & event\_threshold; & /* send event if past threshold */ \\
-\end{tabular}
-
-\ctypename{XSyncValueType} can be either \cconst{XSyncAbsolute} or \cconst{XSyncRelative}.
-
-\ctypename{XSyncTestType} can be one of \cconst{XSyncPositiveTransition},
-\cconst{XSyncNegativeTransition}, \cconst{XSyncPositiveComparison}, or
-\cconst{XSyncNegativeComparison}.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{XSyncAlarm}{XSyncCreateAlarm}
-\cargdecl{Display *}{dpy},
-\cargdecl{unsigned long}{values\_mask},
-\cargdecl{XSyncAlarmAttributes *}{values}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncCreateAlarm} creates an alarm and returns the alarm ID.
-It returns \cconst{None} if the display does not support the SYNC extension.
-The values\_mask and values specify the alarm attributes.
-
-\ctypename{XSyncAlarmAttributes} has the following fields. The attribute\_mask
-column specifies the symbol that the caller should OR into
-values\_mask to indicate that the value for the corresponding
-attribute was actually supplied. Default values are used for all
-attributes that do not have their attribute\_mask OR'ed into
-values\_mask.
-See the protocol
-description for \request{CreateAlarm} for the defaults.
-
-\begin{tabular}{lll}
-type & field name & attribute\_mask \\
-XSyncCounter & trigger.counter; & \cconst{XSyncCACounter} \\
-XSyncValueType & trigger.value\_type; & \cconst{XSyncCAValueType} \\
-XSyncValue & trigger.wait\_value; & \cconst{XSyncCAValue} \\
-XSyncTestType & trigger.test\_type; & \cconst{XSyncCATestType} \\
-XSyncValue & delta; & \cconst{XSyncCADelta} \\
-Bool & events; & \cconst{XSyncCAEvents} \\
-XSyncAlarmState & state; & client cannot set this \\
-\end{tabular}
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{Status}{XSyncDestroyAlarm}
-\cargdecl{Display *}{dpy},
-\cargdecl{XSyncAlarm}{alarm}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncDestroyAlarm} destroys alarm.
-It returns \cconst{False} if dpy does not
-support the SYNC extension; otherwise, it returns \cconst{True}.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{Status}{XSyncQueryAlarm}
-\cargdecl{Display *}{dpy},
-\cargdecl{XSyncAlarm}{alarm},
-\cargdecl{XSyncAlarmAttributes *}{values\_return}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncQueryAlarm} sets *values\_return to the alarm's
-attributes. It returns \cconst{False} if there was an error
-during communication with the server or if dpy does not support
-the SYNC extension; otherwise, it returns \cconst{True}.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{Status}{XSyncChangeAlarm}
-\cargdecl{Display *}{dpy},
-\cargdecl{XSyncAlarm}{alarm},
-\cargdecl{unsigned long}{values\_mask},
-\cargdecl{XSyncAlarmAttributes *}{values}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncChangeAlarm} changes alarm's attributes.
-The attributes to change are specified as in \cfunctionname{XSyncCreateAlarm}.
-It returns \cconst{False} if dpy does not support the SYNC extension;
-otherwise, it returns \cconst{True}.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{Status}{XSyncSetPriority}
-\cargdecl{Display *}{dpy},
-\cargdecl{XID}{client\_resource\_id},
-\cargdecl{int}{priority}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncSetPriority} sets the priority of the client owning
-client\_resource\_id to priority.
-If client\_resource\_id is \cconst{None},
-it sets the caller's priority. It returns \cconst{False} if dpy
-does not support the SYNC extension; otherwise, it returns \cconst{True}.
-\cendfuncdescription
-
-
-% start marker
-\cstartfunction{Status}{XSyncGetPriority}
-\cargdecl{Display *}{dpy},
-\cargdecl{XID}{client\_resource\_id},
-\cargdecl{int *}{return\_priority}
-\cendfunctiondecl
-% end marker
-
-\cfunctionname{XSyncGetPriority} sets *return\_priority to the priority
-of the client owning client\_resource\_id.
-If client\_resource\_id is
-\cconst{None}, it sets *return\_priority to the caller's priority.
-It returns \cconst{False} if there was an error
-during communication with the server or if dpy does not
-support the SYNC extension; otherwise, it returns \cconst{True}.
-\cendfuncdescription
-
-\subsection{C Macros/Functions}
-
-The following procedures manipulate 64-bit values. They are defined
-both as macros and as functions. By default, the macro form is used.
-To use the function form, \#undef the macro name to uncover the
-function.
-
-
-% start marker
-\cstartmacro{void}{XSyncIntToValue}
-\cargdecl{XSyncValue}{*pv},
-\cargdecl{int}{i}
-\cendmacrodecl
-% end marker
-
-Converts i to an \ctypename{XSyncValue} and stores it in
-*pv. Performs sign extension (*pv will have the
-same sign as i.)
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{void}{XSyncIntsToValue}
-\cargdecl{XSyncValue}{*pv},
-\cargdecl{unsigned int}{low},
-\cargdecl{int}{high}
-\cendmacrodecl
-% end marker
-
-Stores low in the low 32 bits of *pv and
-high in the high 32 bits of *pv.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{Bool}{XSyncValueGreaterThan}
-\cargdecl{XSyncValue}{a},
-\cargdecl{XSyncValue}{b}
-\cendmacrodecl
-% end marker
-
-Returns \cconst{True} if a is greater than b,
-else returns \cconst{False}.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{Bool}{XSyncValueLessThan}
-\cargdecl{XSyncValue}{a},
-\cargdecl{XSyncValue}{b}
-\cendmacrodecl
-% end marker
-
-Returns \cconst{True} if a is less than b,
-else returns \cconst{False}.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{Bool}{XSyncValueGreaterOrEqual}
-\cargdecl{XSyncValue}{a},
-\cargdecl{XSyncValue}{b}
-\cendmacrodecl
-% end marker
-
-Returns \cconst{True} if a is greater than or equal to b,
-else returns \cconst{False}.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{Bool}{XSyncValueLessOrEqual}
-\cargdecl{XSyncValue}{a},
-\cargdecl{XSyncValue}{b}
-\cendmacrodecl
-% end marker
-
-Returns \cconst{True} if a is less than or equal to b.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{Bool}{XSyncValueEqual}
-\cargdecl{XSyncValue}{a},
-\cargdecl{XSyncValue}{b}
-\cendmacrodecl
-% end marker
-
-Returns \cconst{True} if a is equal to b,
-else returns \cconst{False}.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{Bool}{XSyncValueIsNegative}
-\cargdecl{XSyncValue}{v}
-\cendmacrodecl
-% end marker
-
-Returns \cconst{True} if v is negative, else returns
-\cconst{False}.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{Bool}{XSyncValueIsZero}
-\cargdecl{XSyncValue}{v}
-\cendmacrodecl
-% end marker
-
-Returns \cconst{True} if v is zero,
-else returns \cconst{False}.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{Bool}{XSyncValueIsPositive}
-\cargdecl{XSyncValue}{v}
-\cendmacrodecl
-% end marker
-
-Returns \cconst{True} if v is positive, else returns
-\cconst{False}.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{unsigned int}{XSyncValueLow32}
-\cargdecl{XSyncValue}{v}
-\cendmacrodecl
-% end marker
-
-Returns the low 32 bits of v.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{int}{XSyncValueHigh32}
-\cargdecl{XSyncValue}{v}
-\cendmacrodecl
-% end marker
-
-Returns the high 32 bits of v.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{void}{XSyncValueAdd}
-\cargdecl{XSyncValue *}{presult},
-\cargdecl{XSyncValue}{a},
-\cargdecl{XSyncValue}{b},
-\cargdecl{Bool *}{poverflow}
-\cendmacrodecl
-% end marker
-
-Adds a to b and stores the result in *presult.
-If the result could not fit in 64 bits, *poverflow is set to
-\cconst{True}, else it is set to \cconst{False}.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{void}{XSyncValueSubtract}
-\cargdecl{XSyncValue *}{presult},
-\cargdecl{XSyncValue}{a},
-\cargdecl{XSyncValue}{b},
-\cargdecl{Bool *}{poverflow}
-\cendmacrodecl
-% end marker
-
-Subtracts b from a and stores the result in
-*presult.
-If the result could not fit in 64 bits, overflow is set to
-\cconst{True}, else it is set to \cconst{False}.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{void}{XSyncMaxValue}
-\cargdecl{XSyncValue *}{pv}
-\cendmacrodecl
-% end marker
-
-Sets *pv to the maximum value expressible in 64 bits.
-\cendmacrodescription
-
-
-% start marker
-\cstartmacro{void}{XSyncMinValue}
-\cargdecl{XSyncValue *}{pv}
-\cendmacrodecl
-% end marker
-
-Sets *pv to the minimum value expressible in 64 bits.
-\cendmacrodescription
-
-\subsection{Events}
-
-Let \cargname{event\_base} be the value \cargname{event\_base\_return}
-as defined in the function \cfunctionname{XSyncQueryExtension}.
-
-An \ctypename{XSyncCounterNotifyEvent}'s type field has the value
-\cargname{event\_base} + \cconst{XSyncCounterNotify}. The fields of
-this structure are:
-
-\begin{tabular}{lll}
-int & type; & /* event base + \cconst{XSyncCounterNotify} */ \\
-unsigned long & serial; & /* number of last request processed by server */ \\
-Bool & send\_event;& /* true if this came from a SendEvent request */ \\
-Display * & display; & /* Display the event was read from */\\
-XSyncCounter & counter; & /* counter involved in await */\\
-XSyncValue & wait\_value; & /* value being waited for */\\
-XSyncValue & counter\_value; & /* counter value when this event was sent */\\
-Time & time; & /* milliseconds */\\
-int & count; & /* how many more events to come */\\
-Bool & destroyed; & /* True if counter was destroyed */\\
-\end{tabular}
-
-An \ctypename{XSyncAlarmNotifyEvent}'s type field has the value
-\cargname{event\_base} + \cconst{XSyncAlarmNotify}. The fields of this
-structure are:
-
-\begin{tabular}{lll}
-int & type;& /* event base + \cconst{XSyncAlarmNotify} */\\
-unsigned long & serial;&/* number of last request processed by server */\\
-Bool & send\_event;& /* true if this came from a SendEvent request */\\
-Display * & display;& /* Display the event was read from */\\
-XSyncAlarm & alarm;& /* alarm that triggered */\\
-XSyncValue & counter\_value;&/* value that triggered the alarm */\\
-XSyncValue & alarm\_value;& /* test value of trigger in alarm */\\
-Time & time;& /* milliseconds */\\
-XSyncAlarmState & state;& /* new state of alarm */\\
-\end{tabular}
-
-\subsection{Errors}
-
-Let \cargname{error\_base} be the value \cargname{error\_base\_return}
-as defined in the function \cfunctionname{XSyncQueryExtension}.
-
-An \ctypename{XSyncAlarmError}'s error\_code field has the value
-\cargname{error\_base} + \cconst{XSyncBadAlarm}. The fields of
-this structure are:
-
-\begin{tabular}{lll}
-int & type; \\
-Display * & display;& /* Display the event was read from */\\
-XSyncAlarm & alarm;& /* resource id */\\
-unsigned long & serial;& /* serial number of failed request */\\
-unsigned char & error\_code;&/* error base + XSyncBadAlarm */\\
-unsigned char & request\_code;&/* Major op-code of failed request */\\
-unsigned char & minor\_code;&/* Minor op-code of failed request */\\
-\end{tabular}
-
-An \ctypename{XSyncCounterError}'s error\_code field has the value
-\cargname{error\_base} + \cconst{XSyncBadCounter}. The fields of
-this structure are:
-
-\begin{tabular}{lll}
-int &type;\\
-Display * & display;& /* Display the event was read from */\\
-XSyncCounter & counter;& /* resource id */\\
-unsigned long & serial;& /* serial number of failed request */\\
-unsigned char & error\_code;&/* error base + XSyncBadCounter */\\
-unsigned char & request\_code;&/* Major op-code of failed request */\\
-unsigned char & minor\_code;& /* Minor op-code of failed request */\\
-\end{tabular}
-
-\end{document}
diff --git a/pixman/pixman/pixman-combine.c.template b/pixman/pixman/pixman-combine.c.template index 9b84de4bc..f5dd8e120 100644 --- a/pixman/pixman/pixman-combine.c.template +++ b/pixman/pixman/pixman-combine.c.template @@ -1,2443 +1,2461 @@ -#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <math.h>
-#include <string.h>
-
-#include "pixman-private.h"
-
-#include "pixman-combine.h"
-
-/*** per channel helper functions ***/
-
-static void
-combine_mask_ca (comp4_t *src, comp4_t *mask)
-{
- comp4_t a = *mask;
-
- comp4_t x;
- comp2_t xa;
-
- if (!a)
- {
- *(src) = 0;
- return;
- }
-
- x = *(src);
- if (a == ~0)
- {
- x = x >> A_SHIFT;
- x |= x << G_SHIFT;
- x |= x << R_SHIFT;
- *(mask) = x;
- return;
- }
-
- xa = x >> A_SHIFT;
- UNcx4_MUL_UNcx4 (x, a);
- *(src) = x;
-
- UNcx4_MUL_UNc (a, xa);
- *(mask) = a;
-}
-
-static void
-combine_mask_value_ca (comp4_t *src, const comp4_t *mask)
-{
- comp4_t a = *mask;
- comp4_t x;
-
- if (!a)
- {
- *(src) = 0;
- return;
- }
-
- if (a == ~0)
- return;
-
- x = *(src);
- UNcx4_MUL_UNcx4 (x, a);
- *(src) = x;
-}
-
-static void
-combine_mask_alpha_ca (const comp4_t *src, comp4_t *mask)
-{
- comp4_t a = *(mask);
- comp4_t x;
-
- if (!a)
- return;
-
- x = *(src) >> A_SHIFT;
- if (x == MASK)
- return;
-
- if (a == ~0)
- {
- x |= x << G_SHIFT;
- x |= x << R_SHIFT;
- *(mask) = x;
- return;
- }
-
- UNcx4_MUL_UNc (a, x);
- *(mask) = a;
-}
-
-/*
- * There are two ways of handling alpha -- either as a single unified value or
- * a separate value for each component, hence each macro must have two
- * versions. The unified alpha version has a 'U' at the end of the name,
- * the component version has a 'C'. Similarly, functions which deal with
- * this difference will have two versions using the same convention.
- */
-
-/*
- * All of the composing functions
- */
-
-static force_inline comp4_t
-combine_mask (const comp4_t *src, const comp4_t *mask, int i)
-{
- comp4_t s, m;
-
- if (mask)
- {
- m = *(mask + i) >> A_SHIFT;
-
- if (!m)
- return 0;
- }
-
- s = *(src + i);
-
- if (mask)
- UNcx4_MUL_UNc (s, m);
-
- return s;
-}
-
-static void
-combine_clear (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- memset (dest, 0, width * sizeof(comp4_t));
-}
-
-static void
-combine_dst (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- return;
-}
-
-static void
-combine_src_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- if (!mask)
- memcpy (dest, src, width * sizeof (comp4_t));
- else
- {
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
-
- *(dest + i) = s;
- }
- }
-}
-
-/* if the Src is opaque, call combine_src_u */
-static void
-combine_over_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- comp4_t ia = ALPHA_c (~s);
-
- UNcx4_MUL_UNc_ADD_UNcx4 (d, ia, s);
- *(dest + i) = d;
- }
-}
-
-/* if the Dst is opaque, this is a noop */
-static void
-combine_over_reverse_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- comp4_t ia = ALPHA_c (~*(dest + i));
- UNcx4_MUL_UNc_ADD_UNcx4 (s, ia, d);
- *(dest + i) = s;
- }
-}
-
-/* if the Dst is opaque, call combine_src_u */
-static void
-combine_in_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t a = ALPHA_c (*(dest + i));
- UNcx4_MUL_UNc (s, a);
- *(dest + i) = s;
- }
-}
-
-/* if the Src is opaque, this is a noop */
-static void
-combine_in_reverse_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- comp4_t a = ALPHA_c (s);
- UNcx4_MUL_UNc (d, a);
- *(dest + i) = d;
- }
-}
-
-/* if the Dst is opaque, call combine_clear */
-static void
-combine_out_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t a = ALPHA_c (~*(dest + i));
- UNcx4_MUL_UNc (s, a);
- *(dest + i) = s;
- }
-}
-
-/* if the Src is opaque, call combine_clear */
-static void
-combine_out_reverse_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- comp4_t a = ALPHA_c (~s);
- UNcx4_MUL_UNc (d, a);
- *(dest + i) = d;
- }
-}
-
-/* if the Src is opaque, call combine_in_u */
-/* if the Dst is opaque, call combine_over_u */
-/* if both the Src and Dst are opaque, call combine_src_u */
-static void
-combine_atop_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- comp4_t dest_a = ALPHA_c (d);
- comp4_t src_ia = ALPHA_c (~s);
-
- UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (s, dest_a, d, src_ia);
- *(dest + i) = s;
- }
-}
-
-/* if the Src is opaque, call combine_over_reverse_u */
-/* if the Dst is opaque, call combine_in_reverse_u */
-/* if both the Src and Dst are opaque, call combine_dst_u */
-static void
-combine_atop_reverse_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- comp4_t src_a = ALPHA_c (s);
- comp4_t dest_ia = ALPHA_c (~d);
-
- UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (s, dest_ia, d, src_a);
- *(dest + i) = s;
- }
-}
-
-/* if the Src is opaque, call combine_over_u */
-/* if the Dst is opaque, call combine_over_reverse_u */
-/* if both the Src and Dst are opaque, call combine_clear */
-static void
-combine_xor_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- comp4_t src_ia = ALPHA_c (~s);
- comp4_t dest_ia = ALPHA_c (~d);
-
- UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (s, dest_ia, d, src_ia);
- *(dest + i) = s;
- }
-}
-
-static void
-combine_add_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- UNcx4_ADD_UNcx4 (d, s);
- *(dest + i) = d;
- }
-}
-
-/* if the Src is opaque, call combine_add_u */
-/* if the Dst is opaque, call combine_add_u */
-/* if both the Src and Dst are opaque, call combine_add_u */
-static void
-combine_saturate_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- comp2_t sa, da;
-
- sa = s >> A_SHIFT;
- da = ~d >> A_SHIFT;
- if (sa > da)
- {
- sa = DIV_UNc (da, sa);
- UNcx4_MUL_UNc (s, sa);
- }
- ;
- UNcx4_ADD_UNcx4 (d, s);
- *(dest + i) = d;
- }
-}
-
-/*
- * PDF blend modes:
- * The following blend modes have been taken from the PDF ISO 32000
- * specification, which at this point in time is available from
- * http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf
- * The relevant chapters are 11.3.5 and 11.3.6.
- * The formula for computing the final pixel color given in 11.3.6 is:
- * αr × Cr = (1 – αs) × αb × Cb + (1 – αb) × αs × Cs + αb × αs × B(Cb, Cs)
- * with B() being the blend function.
- * Note that OVER is a special case of this operation, using B(Cb, Cs) = Cs
- *
- * These blend modes should match the SVG filter draft specification, as
- * it has been designed to mirror ISO 32000. Note that at the current point
- * no released draft exists that shows this, as the formulas have not been
- * updated yet after the release of ISO 32000.
- *
- * The default implementation here uses the PDF_SEPARABLE_BLEND_MODE and
- * PDF_NON_SEPARABLE_BLEND_MODE macros, which take the blend function as an
- * argument. Note that this implementation operates on premultiplied colors,
- * while the PDF specification does not. Therefore the code uses the formula
- * ar.Cra = (1 – as) . Dca + (1 – ad) . Sca + B(Dca, ad, Sca, as)
- */
-
-/*
- * Multiply
- * B(Dca, ad, Sca, as) = Dca.Sca
- */
-
-static void
-combine_multiply_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- comp4_t ss = s;
- comp4_t src_ia = ALPHA_c (~s);
- comp4_t dest_ia = ALPHA_c (~d);
-
- UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (ss, dest_ia, d, src_ia);
- UNcx4_MUL_UNcx4 (d, s);
- UNcx4_ADD_UNcx4 (d, ss);
-
- *(dest + i) = d;
- }
-}
-
-static void
-combine_multiply_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t m = *(mask + i);
- comp4_t s = *(src + i);
- comp4_t d = *(dest + i);
- comp4_t r = d;
- comp4_t dest_ia = ALPHA_c (~d);
-
- combine_mask_value_ca (&s, &m);
-
- UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (r, ~m, s, dest_ia);
- UNcx4_MUL_UNcx4 (d, s);
- UNcx4_ADD_UNcx4 (r, d);
-
- *(dest + i) = r;
- }
-}
-
-#define PDF_SEPARABLE_BLEND_MODE(name) \
- static void \
- combine_ ## name ## _u (pixman_implementation_t *imp, \
- pixman_op_t op, \
- comp4_t * dest, \
- const comp4_t * src, \
- const comp4_t * mask, \
- int width) \
- { \
- int i; \
- for (i = 0; i < width; ++i) { \
- comp4_t s = combine_mask (src, mask, i); \
- comp4_t d = *(dest + i); \
- comp1_t sa = ALPHA_c (s); \
- comp1_t isa = ~sa; \
- comp1_t da = ALPHA_c (d); \
- comp1_t ida = ~da; \
- comp4_t result; \
- \
- result = d; \
- UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (result, isa, s, ida); \
- \
- *(dest + i) = result + \
- (DIV_ONE_UNc (sa * da) << A_SHIFT) + \
- (blend_ ## name (RED_c (d), da, RED_c (s), sa) << R_SHIFT) + \
- (blend_ ## name (GREEN_c (d), da, GREEN_c (s), sa) << G_SHIFT) + \
- (blend_ ## name (BLUE_c (d), da, BLUE_c (s), sa)); \
- } \
- } \
- \
- static void \
- combine_ ## name ## _ca (pixman_implementation_t *imp, \
- pixman_op_t op, \
- comp4_t * dest, \
- const comp4_t * src, \
- const comp4_t * mask, \
- int width) \
- { \
- int i; \
- for (i = 0; i < width; ++i) { \
- comp4_t m = *(mask + i); \
- comp4_t s = *(src + i); \
- comp4_t d = *(dest + i); \
- comp1_t da = ALPHA_c (d); \
- comp1_t ida = ~da; \
- comp4_t result; \
- \
- combine_mask_value_ca (&s, &m); \
- \
- result = d; \
- UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (result, ~m, s, ida); \
- \
- result += \
- (DIV_ONE_UNc (ALPHA_c (m) * da) << A_SHIFT) + \
- (blend_ ## name (RED_c (d), da, RED_c (s), RED_c (m)) << R_SHIFT) + \
- (blend_ ## name (GREEN_c (d), da, GREEN_c (s), GREEN_c (m)) << G_SHIFT) + \
- (blend_ ## name (BLUE_c (d), da, BLUE_c (s), BLUE_c (m))); \
- \
- *(dest + i) = result; \
- } \
- }
-
-/*
- * Screen
- * B(Dca, ad, Sca, as) = Dca.sa + Sca.da - Dca.Sca
- */
-static inline comp4_t
-blend_screen (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
-{
- return DIV_ONE_UNc (sca * da + dca * sa - sca * dca);
-}
-
-PDF_SEPARABLE_BLEND_MODE (screen)
-
-/*
- * Overlay
- * B(Dca, Da, Sca, Sa) =
- * if 2.Dca < Da
- * 2.Sca.Dca
- * otherwise
- * Sa.Da - 2.(Da - Dca).(Sa - Sca)
- */
-static inline comp4_t
-blend_overlay (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
-{
- comp4_t rca;
-
- if (2 * dca < da)
- rca = 2 * sca * dca;
- else
- rca = sa * da - 2 * (da - dca) * (sa - sca);
- return DIV_ONE_UNc (rca);
-}
-
-PDF_SEPARABLE_BLEND_MODE (overlay)
-
-/*
- * Darken
- * B(Dca, Da, Sca, Sa) = min (Sca.Da, Dca.Sa)
- */
-static inline comp4_t
-blend_darken (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
-{
- comp4_t s, d;
-
- s = sca * da;
- d = dca * sa;
- return DIV_ONE_UNc (s > d ? d : s);
-}
-
-PDF_SEPARABLE_BLEND_MODE (darken)
-
-/*
- * Lighten
- * B(Dca, Da, Sca, Sa) = max (Sca.Da, Dca.Sa)
- */
-static inline comp4_t
-blend_lighten (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
-{
- comp4_t s, d;
-
- s = sca * da;
- d = dca * sa;
- return DIV_ONE_UNc (s > d ? s : d);
-}
-
-PDF_SEPARABLE_BLEND_MODE (lighten)
-
-/*
- * Color dodge
- * B(Dca, Da, Sca, Sa) =
- * if Dca == 0
- * 0
- * if Sca == Sa
- * Sa.Da
- * otherwise
- * Sa.Da. min (1, Dca / Da / (1 - Sca/Sa))
- */
-static inline comp4_t
-blend_color_dodge (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
-{
- if (sca >= sa)
- {
- return dca == 0 ? 0 : DIV_ONE_UNc (sa * da);
- }
- else
- {
- comp4_t rca = dca * sa / (sa - sca);
- return DIV_ONE_UNc (sa * MIN (rca, da));
- }
-}
-
-PDF_SEPARABLE_BLEND_MODE (color_dodge)
-
-/*
- * Color burn
- * B(Dca, Da, Sca, Sa) =
- * if Dca == Da
- * Sa.Da
- * if Sca == 0
- * 0
- * otherwise
- * Sa.Da.(1 - min (1, (1 - Dca/Da).Sa / Sca))
- */
-static inline comp4_t
-blend_color_burn (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
-{
- if (sca == 0)
- {
- return dca < da ? 0 : DIV_ONE_UNc (sa * da);
- }
- else
- {
- comp4_t rca = (da - dca) * sa / sca;
- return DIV_ONE_UNc (sa * (MAX (rca, da) - rca));
- }
-}
-
-PDF_SEPARABLE_BLEND_MODE (color_burn)
-
-/*
- * Hard light
- * B(Dca, Da, Sca, Sa) =
- * if 2.Sca < Sa
- * 2.Sca.Dca
- * otherwise
- * Sa.Da - 2.(Da - Dca).(Sa - Sca)
- */
-static inline comp4_t
-blend_hard_light (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
-{
- if (2 * sca < sa)
- return DIV_ONE_UNc (2 * sca * dca);
- else
- return DIV_ONE_UNc (sa * da - 2 * (da - dca) * (sa - sca));
-}
-
-PDF_SEPARABLE_BLEND_MODE (hard_light)
-
-/*
- * Soft light
- * B(Dca, Da, Sca, Sa) =
- * if (2.Sca <= Sa)
- * Dca.(Sa - (1 - Dca/Da).(2.Sca - Sa))
- * otherwise if Dca.4 <= Da
- * Dca.(Sa + (2.Sca - Sa).((16.Dca/Da - 12).Dca/Da + 3)
- * otherwise
- * (Dca.Sa + (SQRT (Dca/Da).Da - Dca).(2.Sca - Sa))
- */
-static inline comp4_t
-blend_soft_light (comp4_t dca_org,
- comp4_t da_org,
- comp4_t sca_org,
- comp4_t sa_org)
-{
- double dca = dca_org * (1.0 / MASK);
- double da = da_org * (1.0 / MASK);
- double sca = sca_org * (1.0 / MASK);
- double sa = sa_org * (1.0 / MASK);
- double rca;
-
- if (2 * sca < sa)
- {
- if (da == 0)
- rca = dca * sa;
- else
- rca = dca * sa - dca * (da - dca) * (sa - 2 * sca) / da;
- }
- else if (da == 0)
- {
- rca = 0;
- }
- else if (4 * dca <= da)
- {
- rca = dca * sa +
- (2 * sca - sa) * dca * ((16 * dca / da - 12) * dca / da + 3);
- }
- else
- {
- rca = dca * sa + (sqrt (dca * da) - dca) * (2 * sca - sa);
- }
- return rca * MASK + 0.5;
-}
-
-PDF_SEPARABLE_BLEND_MODE (soft_light)
-
-/*
- * Difference
- * B(Dca, Da, Sca, Sa) = abs (Dca.Sa - Sca.Da)
- */
-static inline comp4_t
-blend_difference (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
-{
- comp4_t dcasa = dca * sa;
- comp4_t scada = sca * da;
-
- if (scada < dcasa)
- return DIV_ONE_UNc (dcasa - scada);
- else
- return DIV_ONE_UNc (scada - dcasa);
-}
-
-PDF_SEPARABLE_BLEND_MODE (difference)
-
-/*
- * Exclusion
- * B(Dca, Da, Sca, Sa) = (Sca.Da + Dca.Sa - 2.Sca.Dca)
- */
-
-/* This can be made faster by writing it directly and not using
- * PDF_SEPARABLE_BLEND_MODE, but that's a performance optimization */
-
-static inline comp4_t
-blend_exclusion (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
-{
- return DIV_ONE_UNc (sca * da + dca * sa - 2 * dca * sca);
-}
-
-PDF_SEPARABLE_BLEND_MODE (exclusion)
-
-#undef PDF_SEPARABLE_BLEND_MODE
-
-/*
- * PDF nonseperable blend modes are implemented using the following functions
- * to operate in Hsl space, with Cmax, Cmid, Cmin referring to the max, mid
- * and min value of the red, green and blue components.
- *
- * LUM (C) = 0.3 × Cred + 0.59 × Cgreen + 0.11 × Cblue
- *
- * clip_color (C):
- * l = LUM (C)
- * min = Cmin
- * max = Cmax
- * if n < 0.0
- * C = l + ( ( ( C – l ) × l ) ⁄ ( l – min ) )
- * if x > 1.0
- * C = l + ( ( ( C – l ) × ( 1 – l ) ) ⁄ ( max – l ) )
- * return C
- *
- * set_lum (C, l):
- * d = l – LUM (C)
- * C += d
- * return clip_color (C)
- *
- * SAT (C) = CH_MAX (C) - CH_MIN (C)
- *
- * set_sat (C, s):
- * if Cmax > Cmin
- * Cmid = ( ( ( Cmid – Cmin ) × s ) ⁄ ( Cmax – Cmin ) )
- * Cmax = s
- * else
- * Cmid = Cmax = 0.0
- * Cmin = 0.0
- * return C
- */
-
-/* For premultiplied colors, we need to know what happens when C is
- * multiplied by a real number. LUM and SAT are linear:
- *
- * LUM (r × C) = r × LUM (C) SAT (r * C) = r * SAT (C)
- *
- * If we extend clip_color with an extra argument a and change
- *
- * if x >= 1.0
- *
- * into
- *
- * if x >= a
- *
- * then clip_color is also linear:
- *
- * r * clip_color (C, a) = clip_color (r_c, ra);
- *
- * for positive r.
- *
- * Similarly, we can extend set_lum with an extra argument that is just passed
- * on to clip_color:
- *
- * r * set_lum ( C, l, a)
- *
- * = r × clip_color ( C + l - LUM (C), a)
- *
- * = clip_color ( r * C + r × l - r * LUM (C), r * a)
- *
- * = set_lum ( r * C, r * l, r * a)
- *
- * Finally, set_sat:
- *
- * r * set_sat (C, s) = set_sat (x * C, r * s)
- *
- * The above holds for all non-zero x, because they x'es in the fraction for
- * C_mid cancel out. Specifically, it holds for x = r:
- *
- * r * set_sat (C, s) = set_sat (r_c, rs)
- *
- */
-
-/* So, for the non-separable PDF blend modes, we have (using s, d for
- * non-premultiplied colors, and S, D for premultiplied:
- *
- * Color:
- *
- * a_s * a_d * B(s, d)
- * = a_s * a_d * set_lum (S/a_s, LUM (D/a_d), 1)
- * = set_lum (S * a_d, a_s * LUM (D), a_s * a_d)
- *
- *
- * Luminosity:
- *
- * a_s * a_d * B(s, d)
- * = a_s * a_d * set_lum (D/a_d, LUM(S/a_s), 1)
- * = set_lum (a_s * D, a_d * LUM(S), a_s * a_d)
- *
- *
- * Saturation:
- *
- * a_s * a_d * B(s, d)
- * = a_s * a_d * set_lum (set_sat (D/a_d, SAT (S/a_s)), LUM (D/a_d), 1)
- * = set_lum (a_s * a_d * set_sat (D/a_d, SAT (S/a_s)),
- * a_s * LUM (D), a_s * a_d)
- * = set_lum (set_sat (a_s * D, a_d * SAT (S), a_s * LUM (D), a_s * a_d))
- *
- * Hue:
- *
- * a_s * a_d * B(s, d)
- * = a_s * a_d * set_lum (set_sat (S/a_s, SAT (D/a_d)), LUM (D/a_d), 1)
- * = a_s * a_d * set_lum (set_sat (a_d * S, a_s * SAT (D)),
- * a_s * LUM (D), a_s * a_d)
- *
- */
-
-#define CH_MIN(c) (c[0] < c[1] ? (c[0] < c[2] ? c[0] : c[2]) : (c[1] < c[2] ? c[1] : c[2]))
-#define CH_MAX(c) (c[0] > c[1] ? (c[0] > c[2] ? c[0] : c[2]) : (c[1] > c[2] ? c[1] : c[2]))
-#define LUM(c) ((c[0] * 30 + c[1] * 59 + c[2] * 11) / 100)
-#define SAT(c) (CH_MAX (c) - CH_MIN (c))
-
-#define PDF_NON_SEPARABLE_BLEND_MODE(name) \
- static void \
- combine_ ## name ## _u (pixman_implementation_t *imp, \
- pixman_op_t op, \
- comp4_t *dest, \
- const comp4_t *src, \
- const comp4_t *mask, \
- int width) \
- { \
- int i; \
- for (i = 0; i < width; ++i) \
- { \
- comp4_t s = combine_mask (src, mask, i); \
- comp4_t d = *(dest + i); \
- comp1_t sa = ALPHA_c (s); \
- comp1_t isa = ~sa; \
- comp1_t da = ALPHA_c (d); \
- comp1_t ida = ~da; \
- comp4_t result; \
- comp4_t sc[3], dc[3], c[3]; \
- \
- result = d; \
- UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (result, isa, s, ida); \
- dc[0] = RED_c (d); \
- sc[0] = RED_c (s); \
- dc[1] = GREEN_c (d); \
- sc[1] = GREEN_c (s); \
- dc[2] = BLUE_c (d); \
- sc[2] = BLUE_c (s); \
- blend_ ## name (c, dc, da, sc, sa); \
- \
- *(dest + i) = result + \
- (DIV_ONE_UNc (sa * da) << A_SHIFT) + \
- (DIV_ONE_UNc (c[0]) << R_SHIFT) + \
- (DIV_ONE_UNc (c[1]) << G_SHIFT) + \
- (DIV_ONE_UNc (c[2])); \
- } \
- }
-
-static void
-set_lum (comp4_t dest[3], comp4_t src[3], comp4_t sa, comp4_t lum)
-{
- double a, l, min, max;
- double tmp[3];
-
- a = sa * (1.0 / MASK);
-
- l = lum * (1.0 / MASK);
- tmp[0] = src[0] * (1.0 / MASK);
- tmp[1] = src[1] * (1.0 / MASK);
- tmp[2] = src[2] * (1.0 / MASK);
-
- l = l - LUM (tmp);
- tmp[0] += l;
- tmp[1] += l;
- tmp[2] += l;
-
- /* clip_color */
- l = LUM (tmp);
- min = CH_MIN (tmp);
- max = CH_MAX (tmp);
-
- if (min < 0)
- {
- tmp[0] = l + (tmp[0] - l) * l / (l - min);
- tmp[1] = l + (tmp[1] - l) * l / (l - min);
- tmp[2] = l + (tmp[2] - l) * l / (l - min);
- }
- if (max > a)
- {
- tmp[0] = l + (tmp[0] - l) * (a - l) / (max - l);
- tmp[1] = l + (tmp[1] - l) * (a - l) / (max - l);
- tmp[2] = l + (tmp[2] - l) * (a - l) / (max - l);
- }
-
- dest[0] = tmp[0] * MASK + 0.5;
- dest[1] = tmp[1] * MASK + 0.5;
- dest[2] = tmp[2] * MASK + 0.5;
-}
-
-static void
-set_sat (comp4_t dest[3], comp4_t src[3], comp4_t sat)
-{
- int id[3];
- comp4_t min, max;
-
- if (src[0] > src[1])
- {
- if (src[0] > src[2])
- {
- id[0] = 0;
- if (src[1] > src[2])
- {
- id[1] = 1;
- id[2] = 2;
- }
- else
- {
- id[1] = 2;
- id[2] = 1;
- }
- }
- else
- {
- id[0] = 2;
- id[1] = 0;
- id[2] = 1;
- }
- }
- else
- {
- if (src[0] > src[2])
- {
- id[0] = 1;
- id[1] = 0;
- id[2] = 2;
- }
- else
- {
- id[2] = 0;
- if (src[1] > src[2])
- {
- id[0] = 1;
- id[1] = 2;
- }
- else
- {
- id[0] = 2;
- id[1] = 1;
- }
- }
- }
-
- max = dest[id[0]];
- min = dest[id[2]];
- if (max > min)
- {
- dest[id[1]] = (dest[id[1]] - min) * sat / (max - min);
- dest[id[0]] = sat;
- dest[id[2]] = 0;
- }
- else
- {
- dest[0] = dest[1] = dest[2] = 0;
- }
-}
-
-/*
- * Hue:
- * B(Cb, Cs) = set_lum (set_sat (Cs, SAT (Cb)), LUM (Cb))
- */
-static inline void
-blend_hsl_hue (comp4_t c[3],
- comp4_t dc[3],
- comp4_t da,
- comp4_t sc[3],
- comp4_t sa)
-{
- c[0] = sc[0] * da;
- c[1] = sc[1] * da;
- c[2] = sc[2] * da;
- set_sat (c, c, SAT (dc) * sa);
- set_lum (c, c, sa * da, LUM (dc) * sa);
-}
-
-PDF_NON_SEPARABLE_BLEND_MODE (hsl_hue)
-
-/*
- * Saturation:
- * B(Cb, Cs) = set_lum (set_sat (Cb, SAT (Cs)), LUM (Cb))
- */
-static inline void
-blend_hsl_saturation (comp4_t c[3],
- comp4_t dc[3],
- comp4_t da,
- comp4_t sc[3],
- comp4_t sa)
-{
- c[0] = dc[0] * sa;
- c[1] = dc[1] * sa;
- c[2] = dc[2] * sa;
- set_sat (c, c, SAT (sc) * da);
- set_lum (c, c, sa * da, LUM (dc) * sa);
-}
-
-PDF_NON_SEPARABLE_BLEND_MODE (hsl_saturation)
-
-/*
- * Color:
- * B(Cb, Cs) = set_lum (Cs, LUM (Cb))
- */
-static inline void
-blend_hsl_color (comp4_t c[3],
- comp4_t dc[3],
- comp4_t da,
- comp4_t sc[3],
- comp4_t sa)
-{
- c[0] = sc[0] * da;
- c[1] = sc[1] * da;
- c[2] = sc[2] * da;
- set_lum (c, c, sa * da, LUM (dc) * sa);
-}
-
-PDF_NON_SEPARABLE_BLEND_MODE (hsl_color)
-
-/*
- * Luminosity:
- * B(Cb, Cs) = set_lum (Cb, LUM (Cs))
- */
-static inline void
-blend_hsl_luminosity (comp4_t c[3],
- comp4_t dc[3],
- comp4_t da,
- comp4_t sc[3],
- comp4_t sa)
-{
- c[0] = dc[0] * sa;
- c[1] = dc[1] * sa;
- c[2] = dc[2] * sa;
- set_lum (c, c, sa * da, LUM (sc) * da);
-}
-
-PDF_NON_SEPARABLE_BLEND_MODE (hsl_luminosity)
-
-#undef SAT
-#undef LUM
-#undef CH_MAX
-#undef CH_MIN
-#undef PDF_NON_SEPARABLE_BLEND_MODE
-
-/* Overlay
- *
- * All of the disjoint composing functions
- *
- * The four entries in the first column indicate what source contributions
- * come from each of the four areas of the picture -- areas covered by neither
- * A nor B, areas covered only by A, areas covered only by B and finally
- * areas covered by both A and B.
- *
- * Disjoint Conjoint
- * Fa Fb Fa Fb
- * (0,0,0,0) 0 0 0 0
- * (0,A,0,A) 1 0 1 0
- * (0,0,B,B) 0 1 0 1
- * (0,A,B,A) 1 min((1-a)/b,1) 1 max(1-a/b,0)
- * (0,A,B,B) min((1-b)/a,1) 1 max(1-b/a,0) 1
- * (0,0,0,A) max(1-(1-b)/a,0) 0 min(1,b/a) 0
- * (0,0,0,B) 0 max(1-(1-a)/b,0) 0 min(a/b,1)
- * (0,A,0,0) min(1,(1-b)/a) 0 max(1-b/a,0) 0
- * (0,0,B,0) 0 min(1,(1-a)/b) 0 max(1-a/b,0)
- * (0,0,B,A) max(1-(1-b)/a,0) min(1,(1-a)/b) min(1,b/a) max(1-a/b,0)
- * (0,A,0,B) min(1,(1-b)/a) max(1-(1-a)/b,0) max(1-b/a,0) min(1,a/b)
- * (0,A,B,0) min(1,(1-b)/a) min(1,(1-a)/b) max(1-b/a,0) max(1-a/b,0)
- */
-
-#define COMBINE_A_OUT 1
-#define COMBINE_A_IN 2
-#define COMBINE_B_OUT 4
-#define COMBINE_B_IN 8
-
-#define COMBINE_CLEAR 0
-#define COMBINE_A (COMBINE_A_OUT | COMBINE_A_IN)
-#define COMBINE_B (COMBINE_B_OUT | COMBINE_B_IN)
-#define COMBINE_A_OVER (COMBINE_A_OUT | COMBINE_B_OUT | COMBINE_A_IN)
-#define COMBINE_B_OVER (COMBINE_A_OUT | COMBINE_B_OUT | COMBINE_B_IN)
-#define COMBINE_A_ATOP (COMBINE_B_OUT | COMBINE_A_IN)
-#define COMBINE_B_ATOP (COMBINE_A_OUT | COMBINE_B_IN)
-#define COMBINE_XOR (COMBINE_A_OUT | COMBINE_B_OUT)
-
-/* portion covered by a but not b */
-static comp1_t
-combine_disjoint_out_part (comp1_t a, comp1_t b)
-{
- /* min (1, (1-b) / a) */
-
- b = ~b; /* 1 - b */
- if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
- return MASK; /* 1 */
- return DIV_UNc (b, a); /* (1-b) / a */
-}
-
-/* portion covered by both a and b */
-static comp1_t
-combine_disjoint_in_part (comp1_t a, comp1_t b)
-{
- /* max (1-(1-b)/a,0) */
- /* = - min ((1-b)/a - 1, 0) */
- /* = 1 - min (1, (1-b)/a) */
-
- b = ~b; /* 1 - b */
- if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
- return 0; /* 1 - 1 */
- return ~DIV_UNc(b, a); /* 1 - (1-b) / a */
-}
-
-/* portion covered by a but not b */
-static comp1_t
-combine_conjoint_out_part (comp1_t a, comp1_t b)
-{
- /* max (1-b/a,0) */
- /* = 1-min(b/a,1) */
-
- /* min (1, (1-b) / a) */
-
- if (b >= a) /* b >= a -> b/a >= 1 */
- return 0x00; /* 0 */
- return ~DIV_UNc(b, a); /* 1 - b/a */
-}
-
-/* portion covered by both a and b */
-static comp1_t
-combine_conjoint_in_part (comp1_t a, comp1_t b)
-{
- /* min (1,b/a) */
-
- if (b >= a) /* b >= a -> b/a >= 1 */
- return MASK; /* 1 */
- return DIV_UNc (b, a); /* b/a */
-}
-
-#define GET_COMP(v, i) ((comp2_t) (comp1_t) ((v) >> i))
-
-#define ADD(x, y, i, t) \
- ((t) = GET_COMP (x, i) + GET_COMP (y, i), \
- (comp4_t) ((comp1_t) ((t) | (0 - ((t) >> G_SHIFT)))) << (i))
-
-#define GENERIC(x, y, i, ax, ay, t, u, v) \
- ((t) = (MUL_UNc (GET_COMP (y, i), ay, (u)) + \
- MUL_UNc (GET_COMP (x, i), ax, (v))), \
- (comp4_t) ((comp1_t) ((t) | \
- (0 - ((t) >> G_SHIFT)))) << (i))
-
-static void
-combine_disjoint_general_u (comp4_t * dest,
- const comp4_t *src,
- const comp4_t *mask,
- int width,
- comp1_t combine)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- comp4_t m, n, o, p;
- comp2_t Fa, Fb, t, u, v;
- comp1_t sa = s >> A_SHIFT;
- comp1_t da = d >> A_SHIFT;
-
- switch (combine & COMBINE_A)
- {
- default:
- Fa = 0;
- break;
-
- case COMBINE_A_OUT:
- Fa = combine_disjoint_out_part (sa, da);
- break;
-
- case COMBINE_A_IN:
- Fa = combine_disjoint_in_part (sa, da);
- break;
-
- case COMBINE_A:
- Fa = MASK;
- break;
- }
-
- switch (combine & COMBINE_B)
- {
- default:
- Fb = 0;
- break;
-
- case COMBINE_B_OUT:
- Fb = combine_disjoint_out_part (da, sa);
- break;
-
- case COMBINE_B_IN:
- Fb = combine_disjoint_in_part (da, sa);
- break;
-
- case COMBINE_B:
- Fb = MASK;
- break;
- }
- m = GENERIC (s, d, 0, Fa, Fb, t, u, v);
- n = GENERIC (s, d, G_SHIFT, Fa, Fb, t, u, v);
- o = GENERIC (s, d, R_SHIFT, Fa, Fb, t, u, v);
- p = GENERIC (s, d, A_SHIFT, Fa, Fb, t, u, v);
- s = m | n | o | p;
- *(dest + i) = s;
- }
-}
-
-static void
-combine_disjoint_over_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp2_t a = s >> A_SHIFT;
-
- if (s != 0x00)
- {
- comp4_t d = *(dest + i);
- a = combine_disjoint_out_part (d >> A_SHIFT, a);
- UNcx4_MUL_UNc_ADD_UNcx4 (d, a, s);
-
- *(dest + i) = d;
- }
- }
-}
-
-static void
-combine_disjoint_in_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_IN);
-}
-
-static void
-combine_disjoint_in_reverse_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_IN);
-}
-
-static void
-combine_disjoint_out_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_OUT);
-}
-
-static void
-combine_disjoint_out_reverse_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_OUT);
-}
-
-static void
-combine_disjoint_atop_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_ATOP);
-}
-
-static void
-combine_disjoint_atop_reverse_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_ATOP);
-}
-
-static void
-combine_disjoint_xor_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_u (dest, src, mask, width, COMBINE_XOR);
-}
-
-static void
-combine_conjoint_general_u (comp4_t * dest,
- const comp4_t *src,
- const comp4_t *mask,
- int width,
- comp1_t combine)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = combine_mask (src, mask, i);
- comp4_t d = *(dest + i);
- comp4_t m, n, o, p;
- comp2_t Fa, Fb, t, u, v;
- comp1_t sa = s >> A_SHIFT;
- comp1_t da = d >> A_SHIFT;
-
- switch (combine & COMBINE_A)
- {
- default:
- Fa = 0;
- break;
-
- case COMBINE_A_OUT:
- Fa = combine_conjoint_out_part (sa, da);
- break;
-
- case COMBINE_A_IN:
- Fa = combine_conjoint_in_part (sa, da);
- break;
-
- case COMBINE_A:
- Fa = MASK;
- break;
- }
-
- switch (combine & COMBINE_B)
- {
- default:
- Fb = 0;
- break;
-
- case COMBINE_B_OUT:
- Fb = combine_conjoint_out_part (da, sa);
- break;
-
- case COMBINE_B_IN:
- Fb = combine_conjoint_in_part (da, sa);
- break;
-
- case COMBINE_B:
- Fb = MASK;
- break;
- }
-
- m = GENERIC (s, d, 0, Fa, Fb, t, u, v);
- n = GENERIC (s, d, G_SHIFT, Fa, Fb, t, u, v);
- o = GENERIC (s, d, R_SHIFT, Fa, Fb, t, u, v);
- p = GENERIC (s, d, A_SHIFT, Fa, Fb, t, u, v);
-
- s = m | n | o | p;
-
- *(dest + i) = s;
- }
-}
-
-static void
-combine_conjoint_over_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_OVER);
-}
-
-static void
-combine_conjoint_over_reverse_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_OVER);
-}
-
-static void
-combine_conjoint_in_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_IN);
-}
-
-static void
-combine_conjoint_in_reverse_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_IN);
-}
-
-static void
-combine_conjoint_out_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_OUT);
-}
-
-static void
-combine_conjoint_out_reverse_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_OUT);
-}
-
-static void
-combine_conjoint_atop_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_ATOP);
-}
-
-static void
-combine_conjoint_atop_reverse_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_ATOP);
-}
-
-static void
-combine_conjoint_xor_u (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_u (dest, src, mask, width, COMBINE_XOR);
-}
-
-/************************************************************************/
-/*********************** Per Channel functions **************************/
-/************************************************************************/
-
-static void
-combine_clear_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- memset (dest, 0, width * sizeof(comp4_t));
-}
-
-static void
-combine_src_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = *(src + i);
- comp4_t m = *(mask + i);
-
- combine_mask_value_ca (&s, &m);
-
- *(dest + i) = s;
- }
-}
-
-static void
-combine_over_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = *(src + i);
- comp4_t m = *(mask + i);
- comp4_t a;
-
- combine_mask_ca (&s, &m);
-
- a = ~m;
- if (a)
- {
- comp4_t d = *(dest + i);
- UNcx4_MUL_UNcx4_ADD_UNcx4 (d, a, s);
- s = d;
- }
-
- *(dest + i) = s;
- }
-}
-
-static void
-combine_over_reverse_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t d = *(dest + i);
- comp4_t a = ~d >> A_SHIFT;
-
- if (a)
- {
- comp4_t s = *(src + i);
- comp4_t m = *(mask + i);
-
- UNcx4_MUL_UNcx4 (s, m);
- UNcx4_MUL_UNc_ADD_UNcx4 (s, a, d);
-
- *(dest + i) = s;
- }
- }
-}
-
-static void
-combine_in_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t d = *(dest + i);
- comp2_t a = d >> A_SHIFT;
- comp4_t s = 0;
-
- if (a)
- {
- comp4_t m = *(mask + i);
-
- s = *(src + i);
- combine_mask_value_ca (&s, &m);
-
- if (a != MASK)
- UNcx4_MUL_UNc (s, a);
- }
-
- *(dest + i) = s;
- }
-}
-
-static void
-combine_in_reverse_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = *(src + i);
- comp4_t m = *(mask + i);
- comp4_t a;
-
- combine_mask_alpha_ca (&s, &m);
-
- a = m;
- if (a != ~0)
- {
- comp4_t d = 0;
-
- if (a)
- {
- d = *(dest + i);
- UNcx4_MUL_UNcx4 (d, a);
- }
-
- *(dest + i) = d;
- }
- }
-}
-
-static void
-combine_out_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t d = *(dest + i);
- comp2_t a = ~d >> A_SHIFT;
- comp4_t s = 0;
-
- if (a)
- {
- comp4_t m = *(mask + i);
-
- s = *(src + i);
- combine_mask_value_ca (&s, &m);
-
- if (a != MASK)
- UNcx4_MUL_UNc (s, a);
- }
-
- *(dest + i) = s;
- }
-}
-
-static void
-combine_out_reverse_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = *(src + i);
- comp4_t m = *(mask + i);
- comp4_t a;
-
- combine_mask_alpha_ca (&s, &m);
-
- a = ~m;
- if (a != ~0)
- {
- comp4_t d = 0;
-
- if (a)
- {
- d = *(dest + i);
- UNcx4_MUL_UNcx4 (d, a);
- }
-
- *(dest + i) = d;
- }
- }
-}
-
-static void
-combine_atop_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t d = *(dest + i);
- comp4_t s = *(src + i);
- comp4_t m = *(mask + i);
- comp4_t ad;
- comp2_t as = d >> A_SHIFT;
-
- combine_mask_ca (&s, &m);
-
- ad = ~m;
-
- UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (d, ad, s, as);
-
- *(dest + i) = d;
- }
-}
-
-static void
-combine_atop_reverse_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t d = *(dest + i);
- comp4_t s = *(src + i);
- comp4_t m = *(mask + i);
- comp4_t ad;
- comp2_t as = ~d >> A_SHIFT;
-
- combine_mask_ca (&s, &m);
-
- ad = m;
-
- UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (d, ad, s, as);
-
- *(dest + i) = d;
- }
-}
-
-static void
-combine_xor_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t d = *(dest + i);
- comp4_t s = *(src + i);
- comp4_t m = *(mask + i);
- comp4_t ad;
- comp2_t as = ~d >> A_SHIFT;
-
- combine_mask_ca (&s, &m);
-
- ad = ~m;
-
- UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (d, ad, s, as);
-
- *(dest + i) = d;
- }
-}
-
-static void
-combine_add_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s = *(src + i);
- comp4_t m = *(mask + i);
- comp4_t d = *(dest + i);
-
- combine_mask_value_ca (&s, &m);
-
- UNcx4_ADD_UNcx4 (d, s);
-
- *(dest + i) = d;
- }
-}
-
-static void
-combine_saturate_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s, d;
- comp2_t sa, sr, sg, sb, da;
- comp2_t t, u, v;
- comp4_t m, n, o, p;
-
- d = *(dest + i);
- s = *(src + i);
- m = *(mask + i);
-
- combine_mask_ca (&s, &m);
-
- sa = (m >> A_SHIFT);
- sr = (m >> R_SHIFT) & MASK;
- sg = (m >> G_SHIFT) & MASK;
- sb = m & MASK;
- da = ~d >> A_SHIFT;
-
- if (sb <= da)
- m = ADD (s, d, 0, t);
- else
- m = GENERIC (s, d, 0, (da << G_SHIFT) / sb, MASK, t, u, v);
-
- if (sg <= da)
- n = ADD (s, d, G_SHIFT, t);
- else
- n = GENERIC (s, d, G_SHIFT, (da << G_SHIFT) / sg, MASK, t, u, v);
-
- if (sr <= da)
- o = ADD (s, d, R_SHIFT, t);
- else
- o = GENERIC (s, d, R_SHIFT, (da << G_SHIFT) / sr, MASK, t, u, v);
-
- if (sa <= da)
- p = ADD (s, d, A_SHIFT, t);
- else
- p = GENERIC (s, d, A_SHIFT, (da << G_SHIFT) / sa, MASK, t, u, v);
-
- *(dest + i) = m | n | o | p;
- }
-}
-
-static void
-combine_disjoint_general_ca (comp4_t * dest,
- const comp4_t *src,
- const comp4_t *mask,
- int width,
- comp1_t combine)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s, d;
- comp4_t m, n, o, p;
- comp4_t Fa, Fb;
- comp2_t t, u, v;
- comp4_t sa;
- comp1_t da;
-
- s = *(src + i);
- m = *(mask + i);
- d = *(dest + i);
- da = d >> A_SHIFT;
-
- combine_mask_ca (&s, &m);
-
- sa = m;
-
- switch (combine & COMBINE_A)
- {
- default:
- Fa = 0;
- break;
-
- case COMBINE_A_OUT:
- m = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> 0), da);
- n = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
- o = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
- p = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
- Fa = m | n | o | p;
- break;
-
- case COMBINE_A_IN:
- m = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> 0), da);
- n = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
- o = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
- p = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
- Fa = m | n | o | p;
- break;
-
- case COMBINE_A:
- Fa = ~0;
- break;
- }
-
- switch (combine & COMBINE_B)
- {
- default:
- Fb = 0;
- break;
-
- case COMBINE_B_OUT:
- m = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> 0));
- n = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
- o = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
- p = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
- Fb = m | n | o | p;
- break;
-
- case COMBINE_B_IN:
- m = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> 0));
- n = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
- o = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
- p = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
- Fb = m | n | o | p;
- break;
-
- case COMBINE_B:
- Fb = ~0;
- break;
- }
- m = GENERIC (s, d, 0, GET_COMP (Fa, 0), GET_COMP (Fb, 0), t, u, v);
- n = GENERIC (s, d, G_SHIFT, GET_COMP (Fa, G_SHIFT), GET_COMP (Fb, G_SHIFT), t, u, v);
- o = GENERIC (s, d, R_SHIFT, GET_COMP (Fa, R_SHIFT), GET_COMP (Fb, R_SHIFT), t, u, v);
- p = GENERIC (s, d, A_SHIFT, GET_COMP (Fa, A_SHIFT), GET_COMP (Fb, A_SHIFT), t, u, v);
-
- s = m | n | o | p;
-
- *(dest + i) = s;
- }
-}
-
-static void
-combine_disjoint_over_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_OVER);
-}
-
-static void
-combine_disjoint_in_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_IN);
-}
-
-static void
-combine_disjoint_in_reverse_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_IN);
-}
-
-static void
-combine_disjoint_out_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_OUT);
-}
-
-static void
-combine_disjoint_out_reverse_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_OUT);
-}
-
-static void
-combine_disjoint_atop_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_ATOP);
-}
-
-static void
-combine_disjoint_atop_reverse_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_ATOP);
-}
-
-static void
-combine_disjoint_xor_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_disjoint_general_ca (dest, src, mask, width, COMBINE_XOR);
-}
-
-static void
-combine_conjoint_general_ca (comp4_t * dest,
- const comp4_t *src,
- const comp4_t *mask,
- int width,
- comp1_t combine)
-{
- int i;
-
- for (i = 0; i < width; ++i)
- {
- comp4_t s, d;
- comp4_t m, n, o, p;
- comp4_t Fa, Fb;
- comp2_t t, u, v;
- comp4_t sa;
- comp1_t da;
-
- s = *(src + i);
- m = *(mask + i);
- d = *(dest + i);
- da = d >> A_SHIFT;
-
- combine_mask_ca (&s, &m);
-
- sa = m;
-
- switch (combine & COMBINE_A)
- {
- default:
- Fa = 0;
- break;
-
- case COMBINE_A_OUT:
- m = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> 0), da);
- n = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
- o = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
- p = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
- Fa = m | n | o | p;
- break;
-
- case COMBINE_A_IN:
- m = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> 0), da);
- n = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
- o = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
- p = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
- Fa = m | n | o | p;
- break;
-
- case COMBINE_A:
- Fa = ~0;
- break;
- }
-
- switch (combine & COMBINE_B)
- {
- default:
- Fb = 0;
- break;
-
- case COMBINE_B_OUT:
- m = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> 0));
- n = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
- o = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
- p = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
- Fb = m | n | o | p;
- break;
-
- case COMBINE_B_IN:
- m = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> 0));
- n = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
- o = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
- p = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
- Fb = m | n | o | p;
- break;
-
- case COMBINE_B:
- Fb = ~0;
- break;
- }
- m = GENERIC (s, d, 0, GET_COMP (Fa, 0), GET_COMP (Fb, 0), t, u, v);
- n = GENERIC (s, d, G_SHIFT, GET_COMP (Fa, G_SHIFT), GET_COMP (Fb, G_SHIFT), t, u, v);
- o = GENERIC (s, d, R_SHIFT, GET_COMP (Fa, R_SHIFT), GET_COMP (Fb, R_SHIFT), t, u, v);
- p = GENERIC (s, d, A_SHIFT, GET_COMP (Fa, A_SHIFT), GET_COMP (Fb, A_SHIFT), t, u, v);
-
- s = m | n | o | p;
-
- *(dest + i) = s;
- }
-}
-
-static void
-combine_conjoint_over_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_OVER);
-}
-
-static void
-combine_conjoint_over_reverse_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_OVER);
-}
-
-static void
-combine_conjoint_in_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_IN);
-}
-
-static void
-combine_conjoint_in_reverse_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_IN);
-}
-
-static void
-combine_conjoint_out_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_OUT);
-}
-
-static void
-combine_conjoint_out_reverse_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_OUT);
-}
-
-static void
-combine_conjoint_atop_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_ATOP);
-}
-
-static void
-combine_conjoint_atop_reverse_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_ATOP);
-}
-
-static void
-combine_conjoint_xor_ca (pixman_implementation_t *imp,
- pixman_op_t op,
- comp4_t * dest,
- const comp4_t * src,
- const comp4_t * mask,
- int width)
-{
- combine_conjoint_general_ca (dest, src, mask, width, COMBINE_XOR);
-}
-
-void
-_pixman_setup_combiner_functions_width (pixman_implementation_t *imp)
-{
- /* Unified alpha */
- imp->combine_width[PIXMAN_OP_CLEAR] = combine_clear;
- imp->combine_width[PIXMAN_OP_SRC] = combine_src_u;
- imp->combine_width[PIXMAN_OP_DST] = combine_dst;
- imp->combine_width[PIXMAN_OP_OVER] = combine_over_u;
- imp->combine_width[PIXMAN_OP_OVER_REVERSE] = combine_over_reverse_u;
- imp->combine_width[PIXMAN_OP_IN] = combine_in_u;
- imp->combine_width[PIXMAN_OP_IN_REVERSE] = combine_in_reverse_u;
- imp->combine_width[PIXMAN_OP_OUT] = combine_out_u;
- imp->combine_width[PIXMAN_OP_OUT_REVERSE] = combine_out_reverse_u;
- imp->combine_width[PIXMAN_OP_ATOP] = combine_atop_u;
- imp->combine_width[PIXMAN_OP_ATOP_REVERSE] = combine_atop_reverse_u;
- imp->combine_width[PIXMAN_OP_XOR] = combine_xor_u;
- imp->combine_width[PIXMAN_OP_ADD] = combine_add_u;
- imp->combine_width[PIXMAN_OP_SATURATE] = combine_saturate_u;
-
- /* Disjoint, unified */
- imp->combine_width[PIXMAN_OP_DISJOINT_CLEAR] = combine_clear;
- imp->combine_width[PIXMAN_OP_DISJOINT_SRC] = combine_src_u;
- imp->combine_width[PIXMAN_OP_DISJOINT_DST] = combine_dst;
- imp->combine_width[PIXMAN_OP_DISJOINT_OVER] = combine_disjoint_over_u;
- imp->combine_width[PIXMAN_OP_DISJOINT_OVER_REVERSE] = combine_saturate_u;
- imp->combine_width[PIXMAN_OP_DISJOINT_IN] = combine_disjoint_in_u;
- imp->combine_width[PIXMAN_OP_DISJOINT_IN_REVERSE] = combine_disjoint_in_reverse_u;
- imp->combine_width[PIXMAN_OP_DISJOINT_OUT] = combine_disjoint_out_u;
- imp->combine_width[PIXMAN_OP_DISJOINT_OUT_REVERSE] = combine_disjoint_out_reverse_u;
- imp->combine_width[PIXMAN_OP_DISJOINT_ATOP] = combine_disjoint_atop_u;
- imp->combine_width[PIXMAN_OP_DISJOINT_ATOP_REVERSE] = combine_disjoint_atop_reverse_u;
- imp->combine_width[PIXMAN_OP_DISJOINT_XOR] = combine_disjoint_xor_u;
-
- /* Conjoint, unified */
- imp->combine_width[PIXMAN_OP_CONJOINT_CLEAR] = combine_clear;
- imp->combine_width[PIXMAN_OP_CONJOINT_SRC] = combine_src_u;
- imp->combine_width[PIXMAN_OP_CONJOINT_DST] = combine_dst;
- imp->combine_width[PIXMAN_OP_CONJOINT_OVER] = combine_conjoint_over_u;
- imp->combine_width[PIXMAN_OP_CONJOINT_OVER_REVERSE] = combine_conjoint_over_reverse_u;
- imp->combine_width[PIXMAN_OP_CONJOINT_IN] = combine_conjoint_in_u;
- imp->combine_width[PIXMAN_OP_CONJOINT_IN_REVERSE] = combine_conjoint_in_reverse_u;
- imp->combine_width[PIXMAN_OP_CONJOINT_OUT] = combine_conjoint_out_u;
- imp->combine_width[PIXMAN_OP_CONJOINT_OUT_REVERSE] = combine_conjoint_out_reverse_u;
- imp->combine_width[PIXMAN_OP_CONJOINT_ATOP] = combine_conjoint_atop_u;
- imp->combine_width[PIXMAN_OP_CONJOINT_ATOP_REVERSE] = combine_conjoint_atop_reverse_u;
- imp->combine_width[PIXMAN_OP_CONJOINT_XOR] = combine_conjoint_xor_u;
-
- imp->combine_width[PIXMAN_OP_MULTIPLY] = combine_multiply_u;
- imp->combine_width[PIXMAN_OP_SCREEN] = combine_screen_u;
- imp->combine_width[PIXMAN_OP_OVERLAY] = combine_overlay_u;
- imp->combine_width[PIXMAN_OP_DARKEN] = combine_darken_u;
- imp->combine_width[PIXMAN_OP_LIGHTEN] = combine_lighten_u;
- imp->combine_width[PIXMAN_OP_COLOR_DODGE] = combine_color_dodge_u;
- imp->combine_width[PIXMAN_OP_COLOR_BURN] = combine_color_burn_u;
- imp->combine_width[PIXMAN_OP_HARD_LIGHT] = combine_hard_light_u;
- imp->combine_width[PIXMAN_OP_SOFT_LIGHT] = combine_soft_light_u;
- imp->combine_width[PIXMAN_OP_DIFFERENCE] = combine_difference_u;
- imp->combine_width[PIXMAN_OP_EXCLUSION] = combine_exclusion_u;
- imp->combine_width[PIXMAN_OP_HSL_HUE] = combine_hsl_hue_u;
- imp->combine_width[PIXMAN_OP_HSL_SATURATION] = combine_hsl_saturation_u;
- imp->combine_width[PIXMAN_OP_HSL_COLOR] = combine_hsl_color_u;
- imp->combine_width[PIXMAN_OP_HSL_LUMINOSITY] = combine_hsl_luminosity_u;
-
- /* Component alpha combiners */
- imp->combine_width_ca[PIXMAN_OP_CLEAR] = combine_clear_ca;
- imp->combine_width_ca[PIXMAN_OP_SRC] = combine_src_ca;
- /* dest */
- imp->combine_width_ca[PIXMAN_OP_OVER] = combine_over_ca;
- imp->combine_width_ca[PIXMAN_OP_OVER_REVERSE] = combine_over_reverse_ca;
- imp->combine_width_ca[PIXMAN_OP_IN] = combine_in_ca;
- imp->combine_width_ca[PIXMAN_OP_IN_REVERSE] = combine_in_reverse_ca;
- imp->combine_width_ca[PIXMAN_OP_OUT] = combine_out_ca;
- imp->combine_width_ca[PIXMAN_OP_OUT_REVERSE] = combine_out_reverse_ca;
- imp->combine_width_ca[PIXMAN_OP_ATOP] = combine_atop_ca;
- imp->combine_width_ca[PIXMAN_OP_ATOP_REVERSE] = combine_atop_reverse_ca;
- imp->combine_width_ca[PIXMAN_OP_XOR] = combine_xor_ca;
- imp->combine_width_ca[PIXMAN_OP_ADD] = combine_add_ca;
- imp->combine_width_ca[PIXMAN_OP_SATURATE] = combine_saturate_ca;
-
- /* Disjoint CA */
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_CLEAR] = combine_clear_ca;
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_SRC] = combine_src_ca;
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_DST] = combine_dst;
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_OVER] = combine_disjoint_over_ca;
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_OVER_REVERSE] = combine_saturate_ca;
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_IN] = combine_disjoint_in_ca;
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_IN_REVERSE] = combine_disjoint_in_reverse_ca;
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_OUT] = combine_disjoint_out_ca;
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_OUT_REVERSE] = combine_disjoint_out_reverse_ca;
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_ATOP] = combine_disjoint_atop_ca;
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_ATOP_REVERSE] = combine_disjoint_atop_reverse_ca;
- imp->combine_width_ca[PIXMAN_OP_DISJOINT_XOR] = combine_disjoint_xor_ca;
-
- /* Conjoint CA */
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_CLEAR] = combine_clear_ca;
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_SRC] = combine_src_ca;
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_DST] = combine_dst;
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_OVER] = combine_conjoint_over_ca;
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_OVER_REVERSE] = combine_conjoint_over_reverse_ca;
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_IN] = combine_conjoint_in_ca;
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_IN_REVERSE] = combine_conjoint_in_reverse_ca;
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_OUT] = combine_conjoint_out_ca;
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_OUT_REVERSE] = combine_conjoint_out_reverse_ca;
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_ATOP] = combine_conjoint_atop_ca;
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_ATOP_REVERSE] = combine_conjoint_atop_reverse_ca;
- imp->combine_width_ca[PIXMAN_OP_CONJOINT_XOR] = combine_conjoint_xor_ca;
-
- imp->combine_width_ca[PIXMAN_OP_MULTIPLY] = combine_multiply_ca;
- imp->combine_width_ca[PIXMAN_OP_SCREEN] = combine_screen_ca;
- imp->combine_width_ca[PIXMAN_OP_OVERLAY] = combine_overlay_ca;
- imp->combine_width_ca[PIXMAN_OP_DARKEN] = combine_darken_ca;
- imp->combine_width_ca[PIXMAN_OP_LIGHTEN] = combine_lighten_ca;
- imp->combine_width_ca[PIXMAN_OP_COLOR_DODGE] = combine_color_dodge_ca;
- imp->combine_width_ca[PIXMAN_OP_COLOR_BURN] = combine_color_burn_ca;
- imp->combine_width_ca[PIXMAN_OP_HARD_LIGHT] = combine_hard_light_ca;
- imp->combine_width_ca[PIXMAN_OP_SOFT_LIGHT] = combine_soft_light_ca;
- imp->combine_width_ca[PIXMAN_OP_DIFFERENCE] = combine_difference_ca;
- imp->combine_width_ca[PIXMAN_OP_EXCLUSION] = combine_exclusion_ca;
-
- /* It is not clear that these make sense, so make them noops for now */
- imp->combine_width_ca[PIXMAN_OP_HSL_HUE] = combine_dst;
- imp->combine_width_ca[PIXMAN_OP_HSL_SATURATION] = combine_dst;
- imp->combine_width_ca[PIXMAN_OP_HSL_COLOR] = combine_dst;
- imp->combine_width_ca[PIXMAN_OP_HSL_LUMINOSITY] = combine_dst;
-}
-
+#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <math.h> +#include <string.h> + +#include "pixman-private.h" + +#include "pixman-combine.h" + +/*** per channel helper functions ***/ + +static void +combine_mask_ca (comp4_t *src, comp4_t *mask) +{ + comp4_t a = *mask; + + comp4_t x; + comp2_t xa; + + if (!a) + { + *(src) = 0; + return; + } + + x = *(src); + if (a == ~0) + { + x = x >> A_SHIFT; + x |= x << G_SHIFT; + x |= x << R_SHIFT; + *(mask) = x; + return; + } + + xa = x >> A_SHIFT; + UNcx4_MUL_UNcx4 (x, a); + *(src) = x; + + UNcx4_MUL_UNc (a, xa); + *(mask) = a; +} + +static void +combine_mask_value_ca (comp4_t *src, const comp4_t *mask) +{ + comp4_t a = *mask; + comp4_t x; + + if (!a) + { + *(src) = 0; + return; + } + + if (a == ~0) + return; + + x = *(src); + UNcx4_MUL_UNcx4 (x, a); + *(src) = x; +} + +static void +combine_mask_alpha_ca (const comp4_t *src, comp4_t *mask) +{ + comp4_t a = *(mask); + comp4_t x; + + if (!a) + return; + + x = *(src) >> A_SHIFT; + if (x == MASK) + return; + + if (a == ~0) + { + x |= x << G_SHIFT; + x |= x << R_SHIFT; + *(mask) = x; + return; + } + + UNcx4_MUL_UNc (a, x); + *(mask) = a; +} + +/* + * There are two ways of handling alpha -- either as a single unified value or + * a separate value for each component, hence each macro must have two + * versions. The unified alpha version has a 'U' at the end of the name, + * the component version has a 'C'. Similarly, functions which deal with + * this difference will have two versions using the same convention. + */ + +/* + * All of the composing functions + */ + +static force_inline comp4_t +combine_mask (const comp4_t *src, const comp4_t *mask, int i) +{ + comp4_t s, m; + + if (mask) + { + m = *(mask + i) >> A_SHIFT; + + if (!m) + return 0; + } + + s = *(src + i); + + if (mask) + UNcx4_MUL_UNc (s, m); + + return s; +} + +static void +combine_clear (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + memset (dest, 0, width * sizeof(comp4_t)); +} + +static void +combine_dst (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + return; +} + +static void +combine_src_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + if (!mask) + memcpy (dest, src, width * sizeof (comp4_t)); + else + { + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + + *(dest + i) = s; + } + } +} + +/* if the Src is opaque, call combine_src_u */ +static void +combine_over_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + comp4_t ia = ALPHA_c (~s); + + UNcx4_MUL_UNc_ADD_UNcx4 (d, ia, s); + *(dest + i) = d; + } +} + +/* if the Dst is opaque, this is a noop */ +static void +combine_over_reverse_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + comp4_t ia = ALPHA_c (~*(dest + i)); + UNcx4_MUL_UNc_ADD_UNcx4 (s, ia, d); + *(dest + i) = s; + } +} + +/* if the Dst is opaque, call combine_src_u */ +static void +combine_in_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t a = ALPHA_c (*(dest + i)); + UNcx4_MUL_UNc (s, a); + *(dest + i) = s; + } +} + +/* if the Src is opaque, this is a noop */ +static void +combine_in_reverse_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + comp4_t a = ALPHA_c (s); + UNcx4_MUL_UNc (d, a); + *(dest + i) = d; + } +} + +/* if the Dst is opaque, call combine_clear */ +static void +combine_out_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t a = ALPHA_c (~*(dest + i)); + UNcx4_MUL_UNc (s, a); + *(dest + i) = s; + } +} + +/* if the Src is opaque, call combine_clear */ +static void +combine_out_reverse_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + comp4_t a = ALPHA_c (~s); + UNcx4_MUL_UNc (d, a); + *(dest + i) = d; + } +} + +/* if the Src is opaque, call combine_in_u */ +/* if the Dst is opaque, call combine_over_u */ +/* if both the Src and Dst are opaque, call combine_src_u */ +static void +combine_atop_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + comp4_t dest_a = ALPHA_c (d); + comp4_t src_ia = ALPHA_c (~s); + + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (s, dest_a, d, src_ia); + *(dest + i) = s; + } +} + +/* if the Src is opaque, call combine_over_reverse_u */ +/* if the Dst is opaque, call combine_in_reverse_u */ +/* if both the Src and Dst are opaque, call combine_dst_u */ +static void +combine_atop_reverse_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + comp4_t src_a = ALPHA_c (s); + comp4_t dest_ia = ALPHA_c (~d); + + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (s, dest_ia, d, src_a); + *(dest + i) = s; + } +} + +/* if the Src is opaque, call combine_over_u */ +/* if the Dst is opaque, call combine_over_reverse_u */ +/* if both the Src and Dst are opaque, call combine_clear */ +static void +combine_xor_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + comp4_t src_ia = ALPHA_c (~s); + comp4_t dest_ia = ALPHA_c (~d); + + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (s, dest_ia, d, src_ia); + *(dest + i) = s; + } +} + +static void +combine_add_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + UNcx4_ADD_UNcx4 (d, s); + *(dest + i) = d; + } +} + +/* if the Src is opaque, call combine_add_u */ +/* if the Dst is opaque, call combine_add_u */ +/* if both the Src and Dst are opaque, call combine_add_u */ +static void +combine_saturate_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + comp2_t sa, da; + + sa = s >> A_SHIFT; + da = ~d >> A_SHIFT; + if (sa > da) + { + sa = DIV_UNc (da, sa); + UNcx4_MUL_UNc (s, sa); + } + ; + UNcx4_ADD_UNcx4 (d, s); + *(dest + i) = d; + } +} + +/* + * PDF blend modes: + * The following blend modes have been taken from the PDF ISO 32000 + * specification, which at this point in time is available from + * http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf + * The relevant chapters are 11.3.5 and 11.3.6. + * The formula for computing the final pixel color given in 11.3.6 is: + * αr × Cr = (1 – αs) × αb × Cb + (1 – αb) × αs × Cs + αb × αs × B(Cb, Cs) + * with B() being the blend function. + * Note that OVER is a special case of this operation, using B(Cb, Cs) = Cs + * + * These blend modes should match the SVG filter draft specification, as + * it has been designed to mirror ISO 32000. Note that at the current point + * no released draft exists that shows this, as the formulas have not been + * updated yet after the release of ISO 32000. + * + * The default implementation here uses the PDF_SEPARABLE_BLEND_MODE and + * PDF_NON_SEPARABLE_BLEND_MODE macros, which take the blend function as an + * argument. Note that this implementation operates on premultiplied colors, + * while the PDF specification does not. Therefore the code uses the formula + * ar.Cra = (1 – as) . Dca + (1 – ad) . Sca + B(Dca, ad, Sca, as) + */ + +/* + * Multiply + * B(Dca, ad, Sca, as) = Dca.Sca + */ + +static void +combine_multiply_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + comp4_t ss = s; + comp4_t src_ia = ALPHA_c (~s); + comp4_t dest_ia = ALPHA_c (~d); + + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (ss, dest_ia, d, src_ia); + UNcx4_MUL_UNcx4 (d, s); + UNcx4_ADD_UNcx4 (d, ss); + + *(dest + i) = d; + } +} + +static void +combine_multiply_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t m = *(mask + i); + comp4_t s = *(src + i); + comp4_t d = *(dest + i); + comp4_t r = d; + comp4_t dest_ia = ALPHA_c (~d); + + combine_mask_value_ca (&s, &m); + + UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (r, ~m, s, dest_ia); + UNcx4_MUL_UNcx4 (d, s); + UNcx4_ADD_UNcx4 (r, d); + + *(dest + i) = r; + } +} + +#define PDF_SEPARABLE_BLEND_MODE(name) \ + static void \ + combine_ ## name ## _u (pixman_implementation_t *imp, \ + pixman_op_t op, \ + comp4_t * dest, \ + const comp4_t * src, \ + const comp4_t * mask, \ + int width) \ + { \ + int i; \ + for (i = 0; i < width; ++i) { \ + comp4_t s = combine_mask (src, mask, i); \ + comp4_t d = *(dest + i); \ + comp1_t sa = ALPHA_c (s); \ + comp1_t isa = ~sa; \ + comp1_t da = ALPHA_c (d); \ + comp1_t ida = ~da; \ + comp4_t result; \ + \ + result = d; \ + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (result, isa, s, ida); \ + \ + *(dest + i) = result + \ + (DIV_ONE_UNc (sa * da) << A_SHIFT) + \ + (blend_ ## name (RED_c (d), da, RED_c (s), sa) << R_SHIFT) + \ + (blend_ ## name (GREEN_c (d), da, GREEN_c (s), sa) << G_SHIFT) + \ + (blend_ ## name (BLUE_c (d), da, BLUE_c (s), sa)); \ + } \ + } \ + \ + static void \ + combine_ ## name ## _ca (pixman_implementation_t *imp, \ + pixman_op_t op, \ + comp4_t * dest, \ + const comp4_t * src, \ + const comp4_t * mask, \ + int width) \ + { \ + int i; \ + for (i = 0; i < width; ++i) { \ + comp4_t m = *(mask + i); \ + comp4_t s = *(src + i); \ + comp4_t d = *(dest + i); \ + comp1_t da = ALPHA_c (d); \ + comp1_t ida = ~da; \ + comp4_t result; \ + \ + combine_mask_value_ca (&s, &m); \ + \ + result = d; \ + UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (result, ~m, s, ida); \ + \ + result += \ + (DIV_ONE_UNc (ALPHA_c (m) * da) << A_SHIFT) + \ + (blend_ ## name (RED_c (d), da, RED_c (s), RED_c (m)) << R_SHIFT) + \ + (blend_ ## name (GREEN_c (d), da, GREEN_c (s), GREEN_c (m)) << G_SHIFT) + \ + (blend_ ## name (BLUE_c (d), da, BLUE_c (s), BLUE_c (m))); \ + \ + *(dest + i) = result; \ + } \ + } + +/* + * Screen + * B(Dca, ad, Sca, as) = Dca.sa + Sca.da - Dca.Sca + */ +static inline comp4_t +blend_screen (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) +{ + return DIV_ONE_UNc (sca * da + dca * sa - sca * dca); +} + +PDF_SEPARABLE_BLEND_MODE (screen) + +/* + * Overlay + * B(Dca, Da, Sca, Sa) = + * if 2.Dca < Da + * 2.Sca.Dca + * otherwise + * Sa.Da - 2.(Da - Dca).(Sa - Sca) + */ +static inline comp4_t +blend_overlay (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) +{ + comp4_t rca; + + if (2 * dca < da) + rca = 2 * sca * dca; + else + rca = sa * da - 2 * (da - dca) * (sa - sca); + return DIV_ONE_UNc (rca); +} + +PDF_SEPARABLE_BLEND_MODE (overlay) + +/* + * Darken + * B(Dca, Da, Sca, Sa) = min (Sca.Da, Dca.Sa) + */ +static inline comp4_t +blend_darken (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) +{ + comp4_t s, d; + + s = sca * da; + d = dca * sa; + return DIV_ONE_UNc (s > d ? d : s); +} + +PDF_SEPARABLE_BLEND_MODE (darken) + +/* + * Lighten + * B(Dca, Da, Sca, Sa) = max (Sca.Da, Dca.Sa) + */ +static inline comp4_t +blend_lighten (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) +{ + comp4_t s, d; + + s = sca * da; + d = dca * sa; + return DIV_ONE_UNc (s > d ? s : d); +} + +PDF_SEPARABLE_BLEND_MODE (lighten) + +/* + * Color dodge + * B(Dca, Da, Sca, Sa) = + * if Dca == 0 + * 0 + * if Sca == Sa + * Sa.Da + * otherwise + * Sa.Da. min (1, Dca / Da / (1 - Sca/Sa)) + */ +static inline comp4_t +blend_color_dodge (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) +{ + if (sca >= sa) + { + return dca == 0 ? 0 : DIV_ONE_UNc (sa * da); + } + else + { + comp4_t rca = dca * sa / (sa - sca); + return DIV_ONE_UNc (sa * MIN (rca, da)); + } +} + +PDF_SEPARABLE_BLEND_MODE (color_dodge) + +/* + * Color burn + * B(Dca, Da, Sca, Sa) = + * if Dca == Da + * Sa.Da + * if Sca == 0 + * 0 + * otherwise + * Sa.Da.(1 - min (1, (1 - Dca/Da).Sa / Sca)) + */ +static inline comp4_t +blend_color_burn (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) +{ + if (sca == 0) + { + return dca < da ? 0 : DIV_ONE_UNc (sa * da); + } + else + { + comp4_t rca = (da - dca) * sa / sca; + return DIV_ONE_UNc (sa * (MAX (rca, da) - rca)); + } +} + +PDF_SEPARABLE_BLEND_MODE (color_burn) + +/* + * Hard light + * B(Dca, Da, Sca, Sa) = + * if 2.Sca < Sa + * 2.Sca.Dca + * otherwise + * Sa.Da - 2.(Da - Dca).(Sa - Sca) + */ +static inline comp4_t +blend_hard_light (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) +{ + if (2 * sca < sa) + return DIV_ONE_UNc (2 * sca * dca); + else + return DIV_ONE_UNc (sa * da - 2 * (da - dca) * (sa - sca)); +} + +PDF_SEPARABLE_BLEND_MODE (hard_light) + +/* + * Soft light + * B(Dca, Da, Sca, Sa) = + * if (2.Sca <= Sa) + * Dca.(Sa - (1 - Dca/Da).(2.Sca - Sa)) + * otherwise if Dca.4 <= Da + * Dca.(Sa + (2.Sca - Sa).((16.Dca/Da - 12).Dca/Da + 3) + * otherwise + * (Dca.Sa + (SQRT (Dca/Da).Da - Dca).(2.Sca - Sa)) + */ +static inline comp4_t +blend_soft_light (comp4_t dca_org, + comp4_t da_org, + comp4_t sca_org, + comp4_t sa_org) +{ + double dca = dca_org * (1.0 / MASK); + double da = da_org * (1.0 / MASK); + double sca = sca_org * (1.0 / MASK); + double sa = sa_org * (1.0 / MASK); + double rca; + + if (2 * sca < sa) + { + if (da == 0) + rca = dca * sa; + else + rca = dca * sa - dca * (da - dca) * (sa - 2 * sca) / da; + } + else if (da == 0) + { + rca = 0; + } + else if (4 * dca <= da) + { + rca = dca * sa + + (2 * sca - sa) * dca * ((16 * dca / da - 12) * dca / da + 3); + } + else + { + rca = dca * sa + (sqrt (dca * da) - dca) * (2 * sca - sa); + } + return rca * MASK + 0.5; +} + +PDF_SEPARABLE_BLEND_MODE (soft_light) + +/* + * Difference + * B(Dca, Da, Sca, Sa) = abs (Dca.Sa - Sca.Da) + */ +static inline comp4_t +blend_difference (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) +{ + comp4_t dcasa = dca * sa; + comp4_t scada = sca * da; + + if (scada < dcasa) + return DIV_ONE_UNc (dcasa - scada); + else + return DIV_ONE_UNc (scada - dcasa); +} + +PDF_SEPARABLE_BLEND_MODE (difference) + +/* + * Exclusion + * B(Dca, Da, Sca, Sa) = (Sca.Da + Dca.Sa - 2.Sca.Dca) + */ + +/* This can be made faster by writing it directly and not using + * PDF_SEPARABLE_BLEND_MODE, but that's a performance optimization */ + +static inline comp4_t +blend_exclusion (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) +{ + return DIV_ONE_UNc (sca * da + dca * sa - 2 * dca * sca); +} + +PDF_SEPARABLE_BLEND_MODE (exclusion) + +#undef PDF_SEPARABLE_BLEND_MODE + +/* + * PDF nonseperable blend modes are implemented using the following functions + * to operate in Hsl space, with Cmax, Cmid, Cmin referring to the max, mid + * and min value of the red, green and blue components. + * + * LUM (C) = 0.3 × Cred + 0.59 × Cgreen + 0.11 × Cblue + * + * clip_color (C): + * l = LUM (C) + * min = Cmin + * max = Cmax + * if n < 0.0 + * C = l + ( ( ( C – l ) × l ) ⁄ ( l – min ) ) + * if x > 1.0 + * C = l + ( ( ( C – l ) × ( 1 – l ) ) ⁄ ( max – l ) ) + * return C + * + * set_lum (C, l): + * d = l – LUM (C) + * C += d + * return clip_color (C) + * + * SAT (C) = CH_MAX (C) - CH_MIN (C) + * + * set_sat (C, s): + * if Cmax > Cmin + * Cmid = ( ( ( Cmid – Cmin ) × s ) ⁄ ( Cmax – Cmin ) ) + * Cmax = s + * else + * Cmid = Cmax = 0.0 + * Cmin = 0.0 + * return C + */ + +/* For premultiplied colors, we need to know what happens when C is + * multiplied by a real number. LUM and SAT are linear: + * + * LUM (r × C) = r × LUM (C) SAT (r * C) = r * SAT (C) + * + * If we extend clip_color with an extra argument a and change + * + * if x >= 1.0 + * + * into + * + * if x >= a + * + * then clip_color is also linear: + * + * r * clip_color (C, a) = clip_color (r_c, ra); + * + * for positive r. + * + * Similarly, we can extend set_lum with an extra argument that is just passed + * on to clip_color: + * + * r * set_lum ( C, l, a) + * + * = r × clip_color ( C + l - LUM (C), a) + * + * = clip_color ( r * C + r × l - r * LUM (C), r * a) + * + * = set_lum ( r * C, r * l, r * a) + * + * Finally, set_sat: + * + * r * set_sat (C, s) = set_sat (x * C, r * s) + * + * The above holds for all non-zero x, because they x'es in the fraction for + * C_mid cancel out. Specifically, it holds for x = r: + * + * r * set_sat (C, s) = set_sat (r_c, rs) + * + */ + +/* So, for the non-separable PDF blend modes, we have (using s, d for + * non-premultiplied colors, and S, D for premultiplied: + * + * Color: + * + * a_s * a_d * B(s, d) + * = a_s * a_d * set_lum (S/a_s, LUM (D/a_d), 1) + * = set_lum (S * a_d, a_s * LUM (D), a_s * a_d) + * + * + * Luminosity: + * + * a_s * a_d * B(s, d) + * = a_s * a_d * set_lum (D/a_d, LUM(S/a_s), 1) + * = set_lum (a_s * D, a_d * LUM(S), a_s * a_d) + * + * + * Saturation: + * + * a_s * a_d * B(s, d) + * = a_s * a_d * set_lum (set_sat (D/a_d, SAT (S/a_s)), LUM (D/a_d), 1) + * = set_lum (a_s * a_d * set_sat (D/a_d, SAT (S/a_s)), + * a_s * LUM (D), a_s * a_d) + * = set_lum (set_sat (a_s * D, a_d * SAT (S), a_s * LUM (D), a_s * a_d)) + * + * Hue: + * + * a_s * a_d * B(s, d) + * = a_s * a_d * set_lum (set_sat (S/a_s, SAT (D/a_d)), LUM (D/a_d), 1) + * = a_s * a_d * set_lum (set_sat (a_d * S, a_s * SAT (D)), + * a_s * LUM (D), a_s * a_d) + * + */ + +#define CH_MIN(c) (c[0] < c[1] ? (c[0] < c[2] ? c[0] : c[2]) : (c[1] < c[2] ? c[1] : c[2])) +#define CH_MAX(c) (c[0] > c[1] ? (c[0] > c[2] ? c[0] : c[2]) : (c[1] > c[2] ? c[1] : c[2])) +#define LUM(c) ((c[0] * 30 + c[1] * 59 + c[2] * 11) / 100) +#define SAT(c) (CH_MAX (c) - CH_MIN (c)) + +#define PDF_NON_SEPARABLE_BLEND_MODE(name) \ + static void \ + combine_ ## name ## _u (pixman_implementation_t *imp, \ + pixman_op_t op, \ + comp4_t *dest, \ + const comp4_t *src, \ + const comp4_t *mask, \ + int width) \ + { \ + int i; \ + for (i = 0; i < width; ++i) \ + { \ + comp4_t s = combine_mask (src, mask, i); \ + comp4_t d = *(dest + i); \ + comp1_t sa = ALPHA_c (s); \ + comp1_t isa = ~sa; \ + comp1_t da = ALPHA_c (d); \ + comp1_t ida = ~da; \ + comp4_t result; \ + comp4_t sc[3], dc[3], c[3]; \ + \ + result = d; \ + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (result, isa, s, ida); \ + dc[0] = RED_c (d); \ + sc[0] = RED_c (s); \ + dc[1] = GREEN_c (d); \ + sc[1] = GREEN_c (s); \ + dc[2] = BLUE_c (d); \ + sc[2] = BLUE_c (s); \ + blend_ ## name (c, dc, da, sc, sa); \ + \ + *(dest + i) = result + \ + (DIV_ONE_UNc (sa * da) << A_SHIFT) + \ + (DIV_ONE_UNc (c[0]) << R_SHIFT) + \ + (DIV_ONE_UNc (c[1]) << G_SHIFT) + \ + (DIV_ONE_UNc (c[2])); \ + } \ + } + +static void +set_lum (comp4_t dest[3], comp4_t src[3], comp4_t sa, comp4_t lum) +{ + double a, l, min, max; + double tmp[3]; + + a = sa * (1.0 / MASK); + + l = lum * (1.0 / MASK); + tmp[0] = src[0] * (1.0 / MASK); + tmp[1] = src[1] * (1.0 / MASK); + tmp[2] = src[2] * (1.0 / MASK); + + l = l - LUM (tmp); + tmp[0] += l; + tmp[1] += l; + tmp[2] += l; + + /* clip_color */ + l = LUM (tmp); + min = CH_MIN (tmp); + max = CH_MAX (tmp); + + if (min < 0) + { + if (l - min == 0.0) + { + tmp[0] = 0; + tmp[1] = 0; + tmp[2] = 0; + } + else + { + tmp[0] = l + (tmp[0] - l) * l / (l - min); + tmp[1] = l + (tmp[1] - l) * l / (l - min); + tmp[2] = l + (tmp[2] - l) * l / (l - min); + } + } + if (max > a) + { + if (max - l == 0.0) + { + tmp[0] = a; + tmp[1] = a; + tmp[2] = a; + } + else + { + tmp[0] = l + (tmp[0] - l) * (a - l) / (max - l); + tmp[1] = l + (tmp[1] - l) * (a - l) / (max - l); + tmp[2] = l + (tmp[2] - l) * (a - l) / (max - l); + } + } + + dest[0] = tmp[0] * MASK + 0.5; + dest[1] = tmp[1] * MASK + 0.5; + dest[2] = tmp[2] * MASK + 0.5; +} + +static void +set_sat (comp4_t dest[3], comp4_t src[3], comp4_t sat) +{ + int id[3]; + comp4_t min, max; + + if (src[0] > src[1]) + { + if (src[0] > src[2]) + { + id[0] = 0; + if (src[1] > src[2]) + { + id[1] = 1; + id[2] = 2; + } + else + { + id[1] = 2; + id[2] = 1; + } + } + else + { + id[0] = 2; + id[1] = 0; + id[2] = 1; + } + } + else + { + if (src[0] > src[2]) + { + id[0] = 1; + id[1] = 0; + id[2] = 2; + } + else + { + id[2] = 0; + if (src[1] > src[2]) + { + id[0] = 1; + id[1] = 2; + } + else + { + id[0] = 2; + id[1] = 1; + } + } + } + + max = dest[id[0]]; + min = dest[id[2]]; + if (max > min) + { + dest[id[1]] = (dest[id[1]] - min) * sat / (max - min); + dest[id[0]] = sat; + dest[id[2]] = 0; + } + else + { + dest[0] = dest[1] = dest[2] = 0; + } +} + +/* + * Hue: + * B(Cb, Cs) = set_lum (set_sat (Cs, SAT (Cb)), LUM (Cb)) + */ +static inline void +blend_hsl_hue (comp4_t c[3], + comp4_t dc[3], + comp4_t da, + comp4_t sc[3], + comp4_t sa) +{ + c[0] = sc[0] * da; + c[1] = sc[1] * da; + c[2] = sc[2] * da; + set_sat (c, c, SAT (dc) * sa); + set_lum (c, c, sa * da, LUM (dc) * sa); +} + +PDF_NON_SEPARABLE_BLEND_MODE (hsl_hue) + +/* + * Saturation: + * B(Cb, Cs) = set_lum (set_sat (Cb, SAT (Cs)), LUM (Cb)) + */ +static inline void +blend_hsl_saturation (comp4_t c[3], + comp4_t dc[3], + comp4_t da, + comp4_t sc[3], + comp4_t sa) +{ + c[0] = dc[0] * sa; + c[1] = dc[1] * sa; + c[2] = dc[2] * sa; + set_sat (c, c, SAT (sc) * da); + set_lum (c, c, sa * da, LUM (dc) * sa); +} + +PDF_NON_SEPARABLE_BLEND_MODE (hsl_saturation) + +/* + * Color: + * B(Cb, Cs) = set_lum (Cs, LUM (Cb)) + */ +static inline void +blend_hsl_color (comp4_t c[3], + comp4_t dc[3], + comp4_t da, + comp4_t sc[3], + comp4_t sa) +{ + c[0] = sc[0] * da; + c[1] = sc[1] * da; + c[2] = sc[2] * da; + set_lum (c, c, sa * da, LUM (dc) * sa); +} + +PDF_NON_SEPARABLE_BLEND_MODE (hsl_color) + +/* + * Luminosity: + * B(Cb, Cs) = set_lum (Cb, LUM (Cs)) + */ +static inline void +blend_hsl_luminosity (comp4_t c[3], + comp4_t dc[3], + comp4_t da, + comp4_t sc[3], + comp4_t sa) +{ + c[0] = dc[0] * sa; + c[1] = dc[1] * sa; + c[2] = dc[2] * sa; + set_lum (c, c, sa * da, LUM (sc) * da); +} + +PDF_NON_SEPARABLE_BLEND_MODE (hsl_luminosity) + +#undef SAT +#undef LUM +#undef CH_MAX +#undef CH_MIN +#undef PDF_NON_SEPARABLE_BLEND_MODE + +/* Overlay + * + * All of the disjoint composing functions + * + * The four entries in the first column indicate what source contributions + * come from each of the four areas of the picture -- areas covered by neither + * A nor B, areas covered only by A, areas covered only by B and finally + * areas covered by both A and B. + * + * Disjoint Conjoint + * Fa Fb Fa Fb + * (0,0,0,0) 0 0 0 0 + * (0,A,0,A) 1 0 1 0 + * (0,0,B,B) 0 1 0 1 + * (0,A,B,A) 1 min((1-a)/b,1) 1 max(1-a/b,0) + * (0,A,B,B) min((1-b)/a,1) 1 max(1-b/a,0) 1 + * (0,0,0,A) max(1-(1-b)/a,0) 0 min(1,b/a) 0 + * (0,0,0,B) 0 max(1-(1-a)/b,0) 0 min(a/b,1) + * (0,A,0,0) min(1,(1-b)/a) 0 max(1-b/a,0) 0 + * (0,0,B,0) 0 min(1,(1-a)/b) 0 max(1-a/b,0) + * (0,0,B,A) max(1-(1-b)/a,0) min(1,(1-a)/b) min(1,b/a) max(1-a/b,0) + * (0,A,0,B) min(1,(1-b)/a) max(1-(1-a)/b,0) max(1-b/a,0) min(1,a/b) + * (0,A,B,0) min(1,(1-b)/a) min(1,(1-a)/b) max(1-b/a,0) max(1-a/b,0) + */ + +#define COMBINE_A_OUT 1 +#define COMBINE_A_IN 2 +#define COMBINE_B_OUT 4 +#define COMBINE_B_IN 8 + +#define COMBINE_CLEAR 0 +#define COMBINE_A (COMBINE_A_OUT | COMBINE_A_IN) +#define COMBINE_B (COMBINE_B_OUT | COMBINE_B_IN) +#define COMBINE_A_OVER (COMBINE_A_OUT | COMBINE_B_OUT | COMBINE_A_IN) +#define COMBINE_B_OVER (COMBINE_A_OUT | COMBINE_B_OUT | COMBINE_B_IN) +#define COMBINE_A_ATOP (COMBINE_B_OUT | COMBINE_A_IN) +#define COMBINE_B_ATOP (COMBINE_A_OUT | COMBINE_B_IN) +#define COMBINE_XOR (COMBINE_A_OUT | COMBINE_B_OUT) + +/* portion covered by a but not b */ +static comp1_t +combine_disjoint_out_part (comp1_t a, comp1_t b) +{ + /* min (1, (1-b) / a) */ + + b = ~b; /* 1 - b */ + if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */ + return MASK; /* 1 */ + return DIV_UNc (b, a); /* (1-b) / a */ +} + +/* portion covered by both a and b */ +static comp1_t +combine_disjoint_in_part (comp1_t a, comp1_t b) +{ + /* max (1-(1-b)/a,0) */ + /* = - min ((1-b)/a - 1, 0) */ + /* = 1 - min (1, (1-b)/a) */ + + b = ~b; /* 1 - b */ + if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */ + return 0; /* 1 - 1 */ + return ~DIV_UNc(b, a); /* 1 - (1-b) / a */ +} + +/* portion covered by a but not b */ +static comp1_t +combine_conjoint_out_part (comp1_t a, comp1_t b) +{ + /* max (1-b/a,0) */ + /* = 1-min(b/a,1) */ + + /* min (1, (1-b) / a) */ + + if (b >= a) /* b >= a -> b/a >= 1 */ + return 0x00; /* 0 */ + return ~DIV_UNc(b, a); /* 1 - b/a */ +} + +/* portion covered by both a and b */ +static comp1_t +combine_conjoint_in_part (comp1_t a, comp1_t b) +{ + /* min (1,b/a) */ + + if (b >= a) /* b >= a -> b/a >= 1 */ + return MASK; /* 1 */ + return DIV_UNc (b, a); /* b/a */ +} + +#define GET_COMP(v, i) ((comp2_t) (comp1_t) ((v) >> i)) + +#define ADD(x, y, i, t) \ + ((t) = GET_COMP (x, i) + GET_COMP (y, i), \ + (comp4_t) ((comp1_t) ((t) | (0 - ((t) >> G_SHIFT)))) << (i)) + +#define GENERIC(x, y, i, ax, ay, t, u, v) \ + ((t) = (MUL_UNc (GET_COMP (y, i), ay, (u)) + \ + MUL_UNc (GET_COMP (x, i), ax, (v))), \ + (comp4_t) ((comp1_t) ((t) | \ + (0 - ((t) >> G_SHIFT)))) << (i)) + +static void +combine_disjoint_general_u (comp4_t * dest, + const comp4_t *src, + const comp4_t *mask, + int width, + comp1_t combine) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + comp4_t m, n, o, p; + comp2_t Fa, Fb, t, u, v; + comp1_t sa = s >> A_SHIFT; + comp1_t da = d >> A_SHIFT; + + switch (combine & COMBINE_A) + { + default: + Fa = 0; + break; + + case COMBINE_A_OUT: + Fa = combine_disjoint_out_part (sa, da); + break; + + case COMBINE_A_IN: + Fa = combine_disjoint_in_part (sa, da); + break; + + case COMBINE_A: + Fa = MASK; + break; + } + + switch (combine & COMBINE_B) + { + default: + Fb = 0; + break; + + case COMBINE_B_OUT: + Fb = combine_disjoint_out_part (da, sa); + break; + + case COMBINE_B_IN: + Fb = combine_disjoint_in_part (da, sa); + break; + + case COMBINE_B: + Fb = MASK; + break; + } + m = GENERIC (s, d, 0, Fa, Fb, t, u, v); + n = GENERIC (s, d, G_SHIFT, Fa, Fb, t, u, v); + o = GENERIC (s, d, R_SHIFT, Fa, Fb, t, u, v); + p = GENERIC (s, d, A_SHIFT, Fa, Fb, t, u, v); + s = m | n | o | p; + *(dest + i) = s; + } +} + +static void +combine_disjoint_over_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp2_t a = s >> A_SHIFT; + + if (s != 0x00) + { + comp4_t d = *(dest + i); + a = combine_disjoint_out_part (d >> A_SHIFT, a); + UNcx4_MUL_UNc_ADD_UNcx4 (d, a, s); + + *(dest + i) = d; + } + } +} + +static void +combine_disjoint_in_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_IN); +} + +static void +combine_disjoint_in_reverse_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_IN); +} + +static void +combine_disjoint_out_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_OUT); +} + +static void +combine_disjoint_out_reverse_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_OUT); +} + +static void +combine_disjoint_atop_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_ATOP); +} + +static void +combine_disjoint_atop_reverse_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_ATOP); +} + +static void +combine_disjoint_xor_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_u (dest, src, mask, width, COMBINE_XOR); +} + +static void +combine_conjoint_general_u (comp4_t * dest, + const comp4_t *src, + const comp4_t *mask, + int width, + comp1_t combine) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = combine_mask (src, mask, i); + comp4_t d = *(dest + i); + comp4_t m, n, o, p; + comp2_t Fa, Fb, t, u, v; + comp1_t sa = s >> A_SHIFT; + comp1_t da = d >> A_SHIFT; + + switch (combine & COMBINE_A) + { + default: + Fa = 0; + break; + + case COMBINE_A_OUT: + Fa = combine_conjoint_out_part (sa, da); + break; + + case COMBINE_A_IN: + Fa = combine_conjoint_in_part (sa, da); + break; + + case COMBINE_A: + Fa = MASK; + break; + } + + switch (combine & COMBINE_B) + { + default: + Fb = 0; + break; + + case COMBINE_B_OUT: + Fb = combine_conjoint_out_part (da, sa); + break; + + case COMBINE_B_IN: + Fb = combine_conjoint_in_part (da, sa); + break; + + case COMBINE_B: + Fb = MASK; + break; + } + + m = GENERIC (s, d, 0, Fa, Fb, t, u, v); + n = GENERIC (s, d, G_SHIFT, Fa, Fb, t, u, v); + o = GENERIC (s, d, R_SHIFT, Fa, Fb, t, u, v); + p = GENERIC (s, d, A_SHIFT, Fa, Fb, t, u, v); + + s = m | n | o | p; + + *(dest + i) = s; + } +} + +static void +combine_conjoint_over_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_OVER); +} + +static void +combine_conjoint_over_reverse_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_OVER); +} + +static void +combine_conjoint_in_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_IN); +} + +static void +combine_conjoint_in_reverse_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_IN); +} + +static void +combine_conjoint_out_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_OUT); +} + +static void +combine_conjoint_out_reverse_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_OUT); +} + +static void +combine_conjoint_atop_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_ATOP); +} + +static void +combine_conjoint_atop_reverse_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_ATOP); +} + +static void +combine_conjoint_xor_u (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_u (dest, src, mask, width, COMBINE_XOR); +} + +/************************************************************************/ +/*********************** Per Channel functions **************************/ +/************************************************************************/ + +static void +combine_clear_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + memset (dest, 0, width * sizeof(comp4_t)); +} + +static void +combine_src_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = *(src + i); + comp4_t m = *(mask + i); + + combine_mask_value_ca (&s, &m); + + *(dest + i) = s; + } +} + +static void +combine_over_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = *(src + i); + comp4_t m = *(mask + i); + comp4_t a; + + combine_mask_ca (&s, &m); + + a = ~m; + if (a) + { + comp4_t d = *(dest + i); + UNcx4_MUL_UNcx4_ADD_UNcx4 (d, a, s); + s = d; + } + + *(dest + i) = s; + } +} + +static void +combine_over_reverse_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t d = *(dest + i); + comp4_t a = ~d >> A_SHIFT; + + if (a) + { + comp4_t s = *(src + i); + comp4_t m = *(mask + i); + + UNcx4_MUL_UNcx4 (s, m); + UNcx4_MUL_UNc_ADD_UNcx4 (s, a, d); + + *(dest + i) = s; + } + } +} + +static void +combine_in_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t d = *(dest + i); + comp2_t a = d >> A_SHIFT; + comp4_t s = 0; + + if (a) + { + comp4_t m = *(mask + i); + + s = *(src + i); + combine_mask_value_ca (&s, &m); + + if (a != MASK) + UNcx4_MUL_UNc (s, a); + } + + *(dest + i) = s; + } +} + +static void +combine_in_reverse_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = *(src + i); + comp4_t m = *(mask + i); + comp4_t a; + + combine_mask_alpha_ca (&s, &m); + + a = m; + if (a != ~0) + { + comp4_t d = 0; + + if (a) + { + d = *(dest + i); + UNcx4_MUL_UNcx4 (d, a); + } + + *(dest + i) = d; + } + } +} + +static void +combine_out_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t d = *(dest + i); + comp2_t a = ~d >> A_SHIFT; + comp4_t s = 0; + + if (a) + { + comp4_t m = *(mask + i); + + s = *(src + i); + combine_mask_value_ca (&s, &m); + + if (a != MASK) + UNcx4_MUL_UNc (s, a); + } + + *(dest + i) = s; + } +} + +static void +combine_out_reverse_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = *(src + i); + comp4_t m = *(mask + i); + comp4_t a; + + combine_mask_alpha_ca (&s, &m); + + a = ~m; + if (a != ~0) + { + comp4_t d = 0; + + if (a) + { + d = *(dest + i); + UNcx4_MUL_UNcx4 (d, a); + } + + *(dest + i) = d; + } + } +} + +static void +combine_atop_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t d = *(dest + i); + comp4_t s = *(src + i); + comp4_t m = *(mask + i); + comp4_t ad; + comp2_t as = d >> A_SHIFT; + + combine_mask_ca (&s, &m); + + ad = ~m; + + UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (d, ad, s, as); + + *(dest + i) = d; + } +} + +static void +combine_atop_reverse_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t d = *(dest + i); + comp4_t s = *(src + i); + comp4_t m = *(mask + i); + comp4_t ad; + comp2_t as = ~d >> A_SHIFT; + + combine_mask_ca (&s, &m); + + ad = m; + + UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (d, ad, s, as); + + *(dest + i) = d; + } +} + +static void +combine_xor_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t d = *(dest + i); + comp4_t s = *(src + i); + comp4_t m = *(mask + i); + comp4_t ad; + comp2_t as = ~d >> A_SHIFT; + + combine_mask_ca (&s, &m); + + ad = ~m; + + UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (d, ad, s, as); + + *(dest + i) = d; + } +} + +static void +combine_add_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s = *(src + i); + comp4_t m = *(mask + i); + comp4_t d = *(dest + i); + + combine_mask_value_ca (&s, &m); + + UNcx4_ADD_UNcx4 (d, s); + + *(dest + i) = d; + } +} + +static void +combine_saturate_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s, d; + comp2_t sa, sr, sg, sb, da; + comp2_t t, u, v; + comp4_t m, n, o, p; + + d = *(dest + i); + s = *(src + i); + m = *(mask + i); + + combine_mask_ca (&s, &m); + + sa = (m >> A_SHIFT); + sr = (m >> R_SHIFT) & MASK; + sg = (m >> G_SHIFT) & MASK; + sb = m & MASK; + da = ~d >> A_SHIFT; + + if (sb <= da) + m = ADD (s, d, 0, t); + else + m = GENERIC (s, d, 0, (da << G_SHIFT) / sb, MASK, t, u, v); + + if (sg <= da) + n = ADD (s, d, G_SHIFT, t); + else + n = GENERIC (s, d, G_SHIFT, (da << G_SHIFT) / sg, MASK, t, u, v); + + if (sr <= da) + o = ADD (s, d, R_SHIFT, t); + else + o = GENERIC (s, d, R_SHIFT, (da << G_SHIFT) / sr, MASK, t, u, v); + + if (sa <= da) + p = ADD (s, d, A_SHIFT, t); + else + p = GENERIC (s, d, A_SHIFT, (da << G_SHIFT) / sa, MASK, t, u, v); + + *(dest + i) = m | n | o | p; + } +} + +static void +combine_disjoint_general_ca (comp4_t * dest, + const comp4_t *src, + const comp4_t *mask, + int width, + comp1_t combine) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s, d; + comp4_t m, n, o, p; + comp4_t Fa, Fb; + comp2_t t, u, v; + comp4_t sa; + comp1_t da; + + s = *(src + i); + m = *(mask + i); + d = *(dest + i); + da = d >> A_SHIFT; + + combine_mask_ca (&s, &m); + + sa = m; + + switch (combine & COMBINE_A) + { + default: + Fa = 0; + break; + + case COMBINE_A_OUT: + m = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> 0), da); + n = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT; + o = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT; + p = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT; + Fa = m | n | o | p; + break; + + case COMBINE_A_IN: + m = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> 0), da); + n = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT; + o = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT; + p = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT; + Fa = m | n | o | p; + break; + + case COMBINE_A: + Fa = ~0; + break; + } + + switch (combine & COMBINE_B) + { + default: + Fb = 0; + break; + + case COMBINE_B_OUT: + m = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> 0)); + n = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT; + o = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT; + p = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT; + Fb = m | n | o | p; + break; + + case COMBINE_B_IN: + m = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> 0)); + n = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT; + o = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT; + p = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT; + Fb = m | n | o | p; + break; + + case COMBINE_B: + Fb = ~0; + break; + } + m = GENERIC (s, d, 0, GET_COMP (Fa, 0), GET_COMP (Fb, 0), t, u, v); + n = GENERIC (s, d, G_SHIFT, GET_COMP (Fa, G_SHIFT), GET_COMP (Fb, G_SHIFT), t, u, v); + o = GENERIC (s, d, R_SHIFT, GET_COMP (Fa, R_SHIFT), GET_COMP (Fb, R_SHIFT), t, u, v); + p = GENERIC (s, d, A_SHIFT, GET_COMP (Fa, A_SHIFT), GET_COMP (Fb, A_SHIFT), t, u, v); + + s = m | n | o | p; + + *(dest + i) = s; + } +} + +static void +combine_disjoint_over_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_OVER); +} + +static void +combine_disjoint_in_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_IN); +} + +static void +combine_disjoint_in_reverse_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_IN); +} + +static void +combine_disjoint_out_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_OUT); +} + +static void +combine_disjoint_out_reverse_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_OUT); +} + +static void +combine_disjoint_atop_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_ATOP); +} + +static void +combine_disjoint_atop_reverse_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_ATOP); +} + +static void +combine_disjoint_xor_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_XOR); +} + +static void +combine_conjoint_general_ca (comp4_t * dest, + const comp4_t *src, + const comp4_t *mask, + int width, + comp1_t combine) +{ + int i; + + for (i = 0; i < width; ++i) + { + comp4_t s, d; + comp4_t m, n, o, p; + comp4_t Fa, Fb; + comp2_t t, u, v; + comp4_t sa; + comp1_t da; + + s = *(src + i); + m = *(mask + i); + d = *(dest + i); + da = d >> A_SHIFT; + + combine_mask_ca (&s, &m); + + sa = m; + + switch (combine & COMBINE_A) + { + default: + Fa = 0; + break; + + case COMBINE_A_OUT: + m = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> 0), da); + n = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT; + o = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT; + p = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT; + Fa = m | n | o | p; + break; + + case COMBINE_A_IN: + m = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> 0), da); + n = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT; + o = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT; + p = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT; + Fa = m | n | o | p; + break; + + case COMBINE_A: + Fa = ~0; + break; + } + + switch (combine & COMBINE_B) + { + default: + Fb = 0; + break; + + case COMBINE_B_OUT: + m = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> 0)); + n = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT; + o = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT; + p = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT; + Fb = m | n | o | p; + break; + + case COMBINE_B_IN: + m = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> 0)); + n = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT; + o = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT; + p = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT; + Fb = m | n | o | p; + break; + + case COMBINE_B: + Fb = ~0; + break; + } + m = GENERIC (s, d, 0, GET_COMP (Fa, 0), GET_COMP (Fb, 0), t, u, v); + n = GENERIC (s, d, G_SHIFT, GET_COMP (Fa, G_SHIFT), GET_COMP (Fb, G_SHIFT), t, u, v); + o = GENERIC (s, d, R_SHIFT, GET_COMP (Fa, R_SHIFT), GET_COMP (Fb, R_SHIFT), t, u, v); + p = GENERIC (s, d, A_SHIFT, GET_COMP (Fa, A_SHIFT), GET_COMP (Fb, A_SHIFT), t, u, v); + + s = m | n | o | p; + + *(dest + i) = s; + } +} + +static void +combine_conjoint_over_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_OVER); +} + +static void +combine_conjoint_over_reverse_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_OVER); +} + +static void +combine_conjoint_in_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_IN); +} + +static void +combine_conjoint_in_reverse_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_IN); +} + +static void +combine_conjoint_out_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_OUT); +} + +static void +combine_conjoint_out_reverse_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_OUT); +} + +static void +combine_conjoint_atop_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_ATOP); +} + +static void +combine_conjoint_atop_reverse_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_ATOP); +} + +static void +combine_conjoint_xor_ca (pixman_implementation_t *imp, + pixman_op_t op, + comp4_t * dest, + const comp4_t * src, + const comp4_t * mask, + int width) +{ + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_XOR); +} + +void +_pixman_setup_combiner_functions_width (pixman_implementation_t *imp) +{ + /* Unified alpha */ + imp->combine_width[PIXMAN_OP_CLEAR] = combine_clear; + imp->combine_width[PIXMAN_OP_SRC] = combine_src_u; + imp->combine_width[PIXMAN_OP_DST] = combine_dst; + imp->combine_width[PIXMAN_OP_OVER] = combine_over_u; + imp->combine_width[PIXMAN_OP_OVER_REVERSE] = combine_over_reverse_u; + imp->combine_width[PIXMAN_OP_IN] = combine_in_u; + imp->combine_width[PIXMAN_OP_IN_REVERSE] = combine_in_reverse_u; + imp->combine_width[PIXMAN_OP_OUT] = combine_out_u; + imp->combine_width[PIXMAN_OP_OUT_REVERSE] = combine_out_reverse_u; + imp->combine_width[PIXMAN_OP_ATOP] = combine_atop_u; + imp->combine_width[PIXMAN_OP_ATOP_REVERSE] = combine_atop_reverse_u; + imp->combine_width[PIXMAN_OP_XOR] = combine_xor_u; + imp->combine_width[PIXMAN_OP_ADD] = combine_add_u; + imp->combine_width[PIXMAN_OP_SATURATE] = combine_saturate_u; + + /* Disjoint, unified */ + imp->combine_width[PIXMAN_OP_DISJOINT_CLEAR] = combine_clear; + imp->combine_width[PIXMAN_OP_DISJOINT_SRC] = combine_src_u; + imp->combine_width[PIXMAN_OP_DISJOINT_DST] = combine_dst; + imp->combine_width[PIXMAN_OP_DISJOINT_OVER] = combine_disjoint_over_u; + imp->combine_width[PIXMAN_OP_DISJOINT_OVER_REVERSE] = combine_saturate_u; + imp->combine_width[PIXMAN_OP_DISJOINT_IN] = combine_disjoint_in_u; + imp->combine_width[PIXMAN_OP_DISJOINT_IN_REVERSE] = combine_disjoint_in_reverse_u; + imp->combine_width[PIXMAN_OP_DISJOINT_OUT] = combine_disjoint_out_u; + imp->combine_width[PIXMAN_OP_DISJOINT_OUT_REVERSE] = combine_disjoint_out_reverse_u; + imp->combine_width[PIXMAN_OP_DISJOINT_ATOP] = combine_disjoint_atop_u; + imp->combine_width[PIXMAN_OP_DISJOINT_ATOP_REVERSE] = combine_disjoint_atop_reverse_u; + imp->combine_width[PIXMAN_OP_DISJOINT_XOR] = combine_disjoint_xor_u; + + /* Conjoint, unified */ + imp->combine_width[PIXMAN_OP_CONJOINT_CLEAR] = combine_clear; + imp->combine_width[PIXMAN_OP_CONJOINT_SRC] = combine_src_u; + imp->combine_width[PIXMAN_OP_CONJOINT_DST] = combine_dst; + imp->combine_width[PIXMAN_OP_CONJOINT_OVER] = combine_conjoint_over_u; + imp->combine_width[PIXMAN_OP_CONJOINT_OVER_REVERSE] = combine_conjoint_over_reverse_u; + imp->combine_width[PIXMAN_OP_CONJOINT_IN] = combine_conjoint_in_u; + imp->combine_width[PIXMAN_OP_CONJOINT_IN_REVERSE] = combine_conjoint_in_reverse_u; + imp->combine_width[PIXMAN_OP_CONJOINT_OUT] = combine_conjoint_out_u; + imp->combine_width[PIXMAN_OP_CONJOINT_OUT_REVERSE] = combine_conjoint_out_reverse_u; + imp->combine_width[PIXMAN_OP_CONJOINT_ATOP] = combine_conjoint_atop_u; + imp->combine_width[PIXMAN_OP_CONJOINT_ATOP_REVERSE] = combine_conjoint_atop_reverse_u; + imp->combine_width[PIXMAN_OP_CONJOINT_XOR] = combine_conjoint_xor_u; + + imp->combine_width[PIXMAN_OP_MULTIPLY] = combine_multiply_u; + imp->combine_width[PIXMAN_OP_SCREEN] = combine_screen_u; + imp->combine_width[PIXMAN_OP_OVERLAY] = combine_overlay_u; + imp->combine_width[PIXMAN_OP_DARKEN] = combine_darken_u; + imp->combine_width[PIXMAN_OP_LIGHTEN] = combine_lighten_u; + imp->combine_width[PIXMAN_OP_COLOR_DODGE] = combine_color_dodge_u; + imp->combine_width[PIXMAN_OP_COLOR_BURN] = combine_color_burn_u; + imp->combine_width[PIXMAN_OP_HARD_LIGHT] = combine_hard_light_u; + imp->combine_width[PIXMAN_OP_SOFT_LIGHT] = combine_soft_light_u; + imp->combine_width[PIXMAN_OP_DIFFERENCE] = combine_difference_u; + imp->combine_width[PIXMAN_OP_EXCLUSION] = combine_exclusion_u; + imp->combine_width[PIXMAN_OP_HSL_HUE] = combine_hsl_hue_u; + imp->combine_width[PIXMAN_OP_HSL_SATURATION] = combine_hsl_saturation_u; + imp->combine_width[PIXMAN_OP_HSL_COLOR] = combine_hsl_color_u; + imp->combine_width[PIXMAN_OP_HSL_LUMINOSITY] = combine_hsl_luminosity_u; + + /* Component alpha combiners */ + imp->combine_width_ca[PIXMAN_OP_CLEAR] = combine_clear_ca; + imp->combine_width_ca[PIXMAN_OP_SRC] = combine_src_ca; + /* dest */ + imp->combine_width_ca[PIXMAN_OP_OVER] = combine_over_ca; + imp->combine_width_ca[PIXMAN_OP_OVER_REVERSE] = combine_over_reverse_ca; + imp->combine_width_ca[PIXMAN_OP_IN] = combine_in_ca; + imp->combine_width_ca[PIXMAN_OP_IN_REVERSE] = combine_in_reverse_ca; + imp->combine_width_ca[PIXMAN_OP_OUT] = combine_out_ca; + imp->combine_width_ca[PIXMAN_OP_OUT_REVERSE] = combine_out_reverse_ca; + imp->combine_width_ca[PIXMAN_OP_ATOP] = combine_atop_ca; + imp->combine_width_ca[PIXMAN_OP_ATOP_REVERSE] = combine_atop_reverse_ca; + imp->combine_width_ca[PIXMAN_OP_XOR] = combine_xor_ca; + imp->combine_width_ca[PIXMAN_OP_ADD] = combine_add_ca; + imp->combine_width_ca[PIXMAN_OP_SATURATE] = combine_saturate_ca; + + /* Disjoint CA */ + imp->combine_width_ca[PIXMAN_OP_DISJOINT_CLEAR] = combine_clear_ca; + imp->combine_width_ca[PIXMAN_OP_DISJOINT_SRC] = combine_src_ca; + imp->combine_width_ca[PIXMAN_OP_DISJOINT_DST] = combine_dst; + imp->combine_width_ca[PIXMAN_OP_DISJOINT_OVER] = combine_disjoint_over_ca; + imp->combine_width_ca[PIXMAN_OP_DISJOINT_OVER_REVERSE] = combine_saturate_ca; + imp->combine_width_ca[PIXMAN_OP_DISJOINT_IN] = combine_disjoint_in_ca; + imp->combine_width_ca[PIXMAN_OP_DISJOINT_IN_REVERSE] = combine_disjoint_in_reverse_ca; + imp->combine_width_ca[PIXMAN_OP_DISJOINT_OUT] = combine_disjoint_out_ca; + imp->combine_width_ca[PIXMAN_OP_DISJOINT_OUT_REVERSE] = combine_disjoint_out_reverse_ca; + imp->combine_width_ca[PIXMAN_OP_DISJOINT_ATOP] = combine_disjoint_atop_ca; + imp->combine_width_ca[PIXMAN_OP_DISJOINT_ATOP_REVERSE] = combine_disjoint_atop_reverse_ca; + imp->combine_width_ca[PIXMAN_OP_DISJOINT_XOR] = combine_disjoint_xor_ca; + + /* Conjoint CA */ + imp->combine_width_ca[PIXMAN_OP_CONJOINT_CLEAR] = combine_clear_ca; + imp->combine_width_ca[PIXMAN_OP_CONJOINT_SRC] = combine_src_ca; + imp->combine_width_ca[PIXMAN_OP_CONJOINT_DST] = combine_dst; + imp->combine_width_ca[PIXMAN_OP_CONJOINT_OVER] = combine_conjoint_over_ca; + imp->combine_width_ca[PIXMAN_OP_CONJOINT_OVER_REVERSE] = combine_conjoint_over_reverse_ca; + imp->combine_width_ca[PIXMAN_OP_CONJOINT_IN] = combine_conjoint_in_ca; + imp->combine_width_ca[PIXMAN_OP_CONJOINT_IN_REVERSE] = combine_conjoint_in_reverse_ca; + imp->combine_width_ca[PIXMAN_OP_CONJOINT_OUT] = combine_conjoint_out_ca; + imp->combine_width_ca[PIXMAN_OP_CONJOINT_OUT_REVERSE] = combine_conjoint_out_reverse_ca; + imp->combine_width_ca[PIXMAN_OP_CONJOINT_ATOP] = combine_conjoint_atop_ca; + imp->combine_width_ca[PIXMAN_OP_CONJOINT_ATOP_REVERSE] = combine_conjoint_atop_reverse_ca; + imp->combine_width_ca[PIXMAN_OP_CONJOINT_XOR] = combine_conjoint_xor_ca; + + imp->combine_width_ca[PIXMAN_OP_MULTIPLY] = combine_multiply_ca; + imp->combine_width_ca[PIXMAN_OP_SCREEN] = combine_screen_ca; + imp->combine_width_ca[PIXMAN_OP_OVERLAY] = combine_overlay_ca; + imp->combine_width_ca[PIXMAN_OP_DARKEN] = combine_darken_ca; + imp->combine_width_ca[PIXMAN_OP_LIGHTEN] = combine_lighten_ca; + imp->combine_width_ca[PIXMAN_OP_COLOR_DODGE] = combine_color_dodge_ca; + imp->combine_width_ca[PIXMAN_OP_COLOR_BURN] = combine_color_burn_ca; + imp->combine_width_ca[PIXMAN_OP_HARD_LIGHT] = combine_hard_light_ca; + imp->combine_width_ca[PIXMAN_OP_SOFT_LIGHT] = combine_soft_light_ca; + imp->combine_width_ca[PIXMAN_OP_DIFFERENCE] = combine_difference_ca; + imp->combine_width_ca[PIXMAN_OP_EXCLUSION] = combine_exclusion_ca; + + /* It is not clear that these make sense, so make them noops for now */ + imp->combine_width_ca[PIXMAN_OP_HSL_HUE] = combine_dst; + imp->combine_width_ca[PIXMAN_OP_HSL_SATURATION] = combine_dst; + imp->combine_width_ca[PIXMAN_OP_HSL_COLOR] = combine_dst; + imp->combine_width_ca[PIXMAN_OP_HSL_LUMINOSITY] = combine_dst; +} + diff --git a/pixman/test/Makefile.am b/pixman/test/Makefile.am index f2fbf4ce2..19c4f8006 100644 --- a/pixman/test/Makefile.am +++ b/pixman/test/Makefile.am @@ -1,113 +1,117 @@ -AM_CFLAGS = @OPENMP_CFLAGS@
-AM_LDFLAGS = @OPENMP_CFLAGS@
-
-TEST_LDADD = $(top_builddir)/pixman/libpixman-1.la
-INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman
-
-TESTPROGRAMS = \
- a1-trap-test \
- region-test \
- region-translate-test \
- fetch-test \
- oob-test \
- trap-crasher \
- alpha-loop \
- scaling-crash-test \
- gradient-crash-test \
- alphamap \
- stress-test \
- blitters-test \
- scaling-test \
- affine-test \
- composite
-
-a1_trap_test_LDADD = $(TEST_LDADD)
-fetch_test_LDADD = $(TEST_LDADD)
-trap_crasher_LDADD = $(TEST_LDADD)
-oob_test_LDADD = $(TEST_LDADD)
-scaling_crash_test_LDADD = $(TEST_LDADD)
-region_translate_test_LDADD = $(TEST_LDADD)
-
-region_test_LDADD = $(TEST_LDADD)
-region_test_SOURCES = region-test.c utils.c utils.h
-
-blitters_test_LDADD = $(TEST_LDADD)
-blitters_test_SOURCES = blitters-test.c utils.c utils.h
-
-scaling_test_LDADD = $(TEST_LDADD)
-scaling_test_SOURCES = scaling-test.c utils.c utils.h
-
-affine_test_LDADD = $(TEST_LDADD)
-affine_test_SOURCES = affine-test.c utils.c utils.h
-
-alphamap_LDADD = $(TEST_LDADD)
-alphamap_SOURCES = alphamap.c utils.c utils.h
-
-alpha_loop_LDADD = $(TEST_LDADD)
-alpha_loop_SOURCES = alpha-loop.c utils.c utils.h
-
-composite_LDADD = $(TEST_LDADD)
-composite_SOURCES = composite.c utils.c utils.h
-
-gradient_crash_test_LDADD = $(TEST_LDADD)
-gradient_crash_test_SOURCES = gradient-crash-test.c utils.c utils.h
-
-stress_test_LDADD = $(TEST_LDADD)
-stress_test_SOURCES = stress-test.c utils.c utils.h
-
-# GTK using test programs
-
-if HAVE_GTK
-
-GTK_LDADD = $(TEST_LDADD) $(GTK_LIBS)
-GTK_UTILS = gtk-utils.c gtk-utils.h
-
-TESTPROGRAMS_GTK = \
- clip-test \
- clip-in \
- composite-test \
- gradient-test \
- alpha-test \
- screen-test \
- convolution-test \
- trap-test
-
-INCLUDES += $(GTK_CFLAGS)
-
-gradient_test_LDADD = $(GTK_LDADD)
-gradient_test_SOURCES = gradient-test.c $(GTK_UTILS)
-
-alpha_test_LDADD = $(GTK_LDADD)
-alpha_test_SOURCES = alpha-test.c $(GTK_UTILS)
-
-composite_test_LDADD = $(GTK_LDADD)
-composite_test_SOURCES = composite-test.c $(GTK_UTILS)
-
-clip_test_LDADD = $(GTK_LDADD)
-clip_test_SOURCES = clip-test.c $(GTK_UTILS)
-
-clip_in_LDADD = $(GTK_LDADD)
-clip_in_SOURCES = clip-in.c $(GTK_UTILS)
-
-trap_test_LDADD = $(GTK_LDADD)
-trap_test_SOURCES = trap-test.c $(GTK_UTILS)
-
-screen_test_LDADD = $(GTK_LDADD)
-screen_test_SOURCES = screen-test.c $(GTK_UTILS)
-
-convolution_test_LDADD = $(GTK_LDADD)
-convolution_test_SOURCES = convolution-test.c $(GTK_UTILS)
-
-endif
-
-# Benchmarks
-
-BENCHMARKS = \
- lowlevel-blt-bench
-
-lowlevel_blt_bench_SOURCES = lowlevel-blt-bench.c utils.c utils.h
-lowlevel_blt_bench_LDADD = $(TEST_LDADD)
-
-noinst_PROGRAMS = $(TESTPROGRAMS) $(TESTPROGRAMS_GTK) $(BENCHMARKS)
-
-TESTS = $(TESTPROGRAMS)
+AM_CFLAGS = @OPENMP_CFLAGS@ +AM_LDFLAGS = @OPENMP_CFLAGS@ + +TEST_LDADD = $(top_builddir)/pixman/libpixman-1.la -lm +INCLUDES = -I$(top_srcdir)/pixman -I$(top_builddir)/pixman + +TESTPROGRAMS = \ + a1-trap-test \ + pdf-op-test \ + region-test \ + region-translate-test \ + fetch-test \ + oob-test \ + trap-crasher \ + alpha-loop \ + scaling-crash-test \ + gradient-crash-test \ + alphamap \ + stress-test \ + blitters-test \ + scaling-test \ + affine-test \ + composite + +a1_trap_test_LDADD = $(TEST_LDADD) +fetch_test_LDADD = $(TEST_LDADD) +trap_crasher_LDADD = $(TEST_LDADD) +oob_test_LDADD = $(TEST_LDADD) +scaling_crash_test_LDADD = $(TEST_LDADD) +region_translate_test_LDADD = $(TEST_LDADD) + +pdf_op_test_LDADD = $(TEST_LDADD) +pdf_op_test_SOURCES = pdf-op-test.c utils.c utils.h + +region_test_LDADD = $(TEST_LDADD) +region_test_SOURCES = region-test.c utils.c utils.h + +blitters_test_LDADD = $(TEST_LDADD) +blitters_test_SOURCES = blitters-test.c utils.c utils.h + +scaling_test_LDADD = $(TEST_LDADD) +scaling_test_SOURCES = scaling-test.c utils.c utils.h + +affine_test_LDADD = $(TEST_LDADD) +affine_test_SOURCES = affine-test.c utils.c utils.h + +alphamap_LDADD = $(TEST_LDADD) +alphamap_SOURCES = alphamap.c utils.c utils.h + +alpha_loop_LDADD = $(TEST_LDADD) +alpha_loop_SOURCES = alpha-loop.c utils.c utils.h + +composite_LDADD = $(TEST_LDADD) +composite_SOURCES = composite.c utils.c utils.h + +gradient_crash_test_LDADD = $(TEST_LDADD) +gradient_crash_test_SOURCES = gradient-crash-test.c utils.c utils.h + +stress_test_LDADD = $(TEST_LDADD) +stress_test_SOURCES = stress-test.c utils.c utils.h + +# GTK using test programs + +if HAVE_GTK + +GTK_LDADD = $(TEST_LDADD) $(GTK_LIBS) +GTK_UTILS = gtk-utils.c gtk-utils.h + +TESTPROGRAMS_GTK = \ + clip-test \ + clip-in \ + composite-test \ + gradient-test \ + alpha-test \ + screen-test \ + convolution-test \ + trap-test + +INCLUDES += $(GTK_CFLAGS) + +gradient_test_LDADD = $(GTK_LDADD) +gradient_test_SOURCES = gradient-test.c $(GTK_UTILS) + +alpha_test_LDADD = $(GTK_LDADD) +alpha_test_SOURCES = alpha-test.c $(GTK_UTILS) + +composite_test_LDADD = $(GTK_LDADD) +composite_test_SOURCES = composite-test.c $(GTK_UTILS) + +clip_test_LDADD = $(GTK_LDADD) +clip_test_SOURCES = clip-test.c $(GTK_UTILS) + +clip_in_LDADD = $(GTK_LDADD) +clip_in_SOURCES = clip-in.c $(GTK_UTILS) + +trap_test_LDADD = $(GTK_LDADD) +trap_test_SOURCES = trap-test.c $(GTK_UTILS) + +screen_test_LDADD = $(GTK_LDADD) +screen_test_SOURCES = screen-test.c $(GTK_UTILS) + +convolution_test_LDADD = $(GTK_LDADD) +convolution_test_SOURCES = convolution-test.c $(GTK_UTILS) + +endif + +# Benchmarks + +BENCHMARKS = \ + lowlevel-blt-bench + +lowlevel_blt_bench_SOURCES = lowlevel-blt-bench.c utils.c utils.h +lowlevel_blt_bench_LDADD = $(TEST_LDADD) + +noinst_PROGRAMS = $(TESTPROGRAMS) $(TESTPROGRAMS_GTK) $(BENCHMARKS) + +TESTS = $(TESTPROGRAMS) diff --git a/pixman/test/pdf-op-test.c b/pixman/test/pdf-op-test.c new file mode 100644 index 000000000..dc7a4fd0b --- /dev/null +++ b/pixman/test/pdf-op-test.c @@ -0,0 +1,84 @@ +#include <config.h> +#include <stdlib.h> +#include "utils.h" + +static const pixman_op_t pdf_ops[] = +{ + PIXMAN_OP_MULTIPLY, + PIXMAN_OP_SCREEN, + PIXMAN_OP_OVERLAY, + PIXMAN_OP_DARKEN, + PIXMAN_OP_LIGHTEN, + PIXMAN_OP_COLOR_DODGE, + PIXMAN_OP_COLOR_BURN, + PIXMAN_OP_HARD_LIGHT, + PIXMAN_OP_SOFT_LIGHT, + PIXMAN_OP_DIFFERENCE, + PIXMAN_OP_EXCLUSION, + PIXMAN_OP_HSL_HUE, + PIXMAN_OP_HSL_SATURATION, + PIXMAN_OP_HSL_COLOR, + PIXMAN_OP_HSL_LUMINOSITY +}; + +static const uint32_t pixels[] = +{ + 0x00808080, + 0x80123456, + 0x00000000, + 0xffffffff, + 0x00ffffff, + 0x80808080, + 0x00123456, +}; + +int +main () +{ + int o, s, m, d; + + enable_fp_exceptions(); + + for (o = 0; o < ARRAY_LENGTH (pdf_ops); ++o) + { + pixman_op_t op = pdf_ops[o]; + + for (s = 0; s < ARRAY_LENGTH (pixels); ++s) + { + pixman_image_t *src; + + src = pixman_image_create_bits ( + PIXMAN_a8r8g8b8, 1, 1, (uint32_t *)&(pixels[s]), 4); + + for (m = -1; m < ARRAY_LENGTH (pixels); ++m) + { + pixman_image_t *msk = NULL; + if (m >= 0) + { + msk = pixman_image_create_bits ( + PIXMAN_a8r8g8b8, 1, 1, (uint32_t *)&(pixels[m]), 4); + } + + for (d = 0; d < ARRAY_LENGTH (pixels); ++d) + { + pixman_image_t *dst; + uint32_t dp = pixels[d]; + + dst = pixman_image_create_bits ( + PIXMAN_a8r8g8b8, 1, 1, &dp, 4); + + pixman_image_composite (op, src, msk, dst, + 0, 0, 0, 0, 0, 0, 1, 1); + + pixman_image_unref (dst); + } + if (msk) + pixman_image_unref (msk); + } + + pixman_image_unref (src); + } + } + + return 0; +} diff --git a/xorg-server/Xext/sync.c b/xorg-server/Xext/sync.c index d1948d3ed..5af055a7d 100644 --- a/xorg-server/Xext/sync.c +++ b/xorg-server/Xext/sync.c @@ -1,2869 +1,2899 @@ -/*
-
-Copyright 1991, 1993, 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 1991, 1993 by Digital Equipment Corporation, Maynard, Massachusetts,
-and Olivetti Research Limited, Cambridge, England.
-
- 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 names of Digital or Olivetti
-not be used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission. Digital and Olivetti
-make no representations about the suitability of this software
-for any purpose. It is provided "as is" without express or implied warranty.
-
-DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS, IN NO EVENT SHALL THEY 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 <string.h>
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include <X11/Xmd.h>
-#include "scrnintstr.h"
-#include "os.h"
-#include "extnsionst.h"
-#include "dixstruct.h"
-#include "pixmapstr.h"
-#include "resource.h"
-#include "opaque.h"
-#include <X11/extensions/syncproto.h>
-#include "syncsrv.h"
-#include "syncsdk.h"
-#include "protocol-versions.h"
-
-#include <stdio.h>
-#if !defined(WIN32)
-#include <sys/time.h>
-#endif
-
-#include "modinit.h"
-
-/*
- * Local Global Variables
- */
-static int SyncEventBase;
-static int SyncErrorBase;
-static RESTYPE RTCounter = 0;
-static RESTYPE RTAwait;
-static RESTYPE RTAlarm;
-static RESTYPE RTAlarmClient;
-static RESTYPE RTFence;
-static int SyncNumSystemCounters = 0;
-static SyncCounter **SysCounterList = NULL;
-
-#define IsSystemCounter(pCounter) \
- (pCounter && (pCounter->sync.client == NULL))
-
-/* these are all the alarm attributes that pertain to the alarm's trigger */
-#define XSyncCAAllTrigger \
- (XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType)
-
-static void SyncComputeBracketValues(SyncCounter *);
-
-static void SyncInitServerTime(void);
-
-static void SyncInitIdleTime(void);
-
-
-/* Each counter maintains a simple linked list of triggers that are
- * interested in the counter. The two functions below are used to
- * delete and add triggers on this list.
- */
-static void
-SyncDeleteTriggerFromSyncObject(SyncTrigger *pTrigger)
-{
- SyncTriggerList *pCur;
- SyncTriggerList *pPrev;
- SyncCounter *pCounter;
-
- /* pSync needs to be stored in pTrigger before calling here. */
-
- if (!pTrigger->pSync)
- return;
-
- pPrev = NULL;
- pCur = pTrigger->pSync->pTriglist;
-
- while (pCur)
- {
- if (pCur->pTrigger == pTrigger)
- {
- if (pPrev)
- pPrev->next = pCur->next;
- else
- pTrigger->pSync->pTriglist = pCur->next;
-
- free(pCur);
- break;
- }
-
- pPrev = pCur;
- pCur = pCur->next;
- }
-
- if (SYNC_COUNTER == pTrigger->pSync->type)
- {
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- if (IsSystemCounter(pCounter))
- SyncComputeBracketValues(pCounter);
- } else if (SYNC_FENCE == pTrigger->pSync->type) {
- SyncFence* pFence = (SyncFence*) pTrigger->pSync;
- pFence->funcs.DeleteTrigger(pTrigger);
- }
-}
-
-
-static int
-SyncAddTriggerToSyncObject(SyncTrigger *pTrigger)
-{
- SyncTriggerList *pCur;
- SyncCounter *pCounter;
-
- if (!pTrigger->pSync)
- return Success;
-
- /* don't do anything if it's already there */
- for (pCur = pTrigger->pSync->pTriglist; pCur; pCur = pCur->next)
- {
- if (pCur->pTrigger == pTrigger)
- return Success;
- }
-
- if (!(pCur = malloc(sizeof(SyncTriggerList))))
- return BadAlloc;
-
- pCur->pTrigger = pTrigger;
- pCur->next = pTrigger->pSync->pTriglist;
- pTrigger->pSync->pTriglist = pCur;
-
- if (SYNC_COUNTER == pTrigger->pSync->type)
- {
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- if (IsSystemCounter(pCounter))
- SyncComputeBracketValues(pCounter);
- } else if (SYNC_FENCE == pTrigger->pSync->type) {
- SyncFence* pFence = (SyncFence*) pTrigger->pSync;
- pFence->funcs.AddTrigger(pTrigger);
- }
-
- return Success;
-}
-
-
-/* Below are five possible functions that can be plugged into
- * pTrigger->CheckTrigger for counter sync objects, corresponding to
- * the four possible test-types, and the one possible function that
- * can be plugged into pTrigger->CheckTrigger for fence sync objects.
- * These functions are called after the sync object's state changes
- * but are also passed the old state so they can inspect both the old
- * and new values. (PositiveTransition and NegativeTransition need to
- * see both pieces of information.) These functions return the truth
- * value of the trigger.
- *
- * All of them include the condition pTrigger->pSync == NULL.
- * This is because the spec says that a trigger with a sync value
- * of None is always TRUE.
- */
-
-static Bool
-SyncCheckTriggerPositiveComparison(SyncTrigger *pTrigger, CARD64 oldval)
-{
- SyncCounter *pCounter;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- return (pCounter == NULL ||
- XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value));
-}
-
-static Bool
-SyncCheckTriggerNegativeComparison(SyncTrigger *pTrigger, CARD64 oldval)
-{
- SyncCounter *pCounter;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- return (pCounter == NULL ||
- XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value));
-}
-
-static Bool
-SyncCheckTriggerPositiveTransition(SyncTrigger *pTrigger, CARD64 oldval)
-{
- SyncCounter *pCounter;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- return (pCounter == NULL ||
- (XSyncValueLessThan(oldval, pTrigger->test_value) &&
- XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value)));
-}
-
-static Bool
-SyncCheckTriggerNegativeTransition(SyncTrigger *pTrigger, CARD64 oldval)
-{
- SyncCounter *pCounter;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- return (pCounter == NULL ||
- (XSyncValueGreaterThan(oldval, pTrigger->test_value) &&
- XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value)));
-}
-
-static Bool
-SyncCheckTriggerFence(SyncTrigger *pTrigger, CARD64 unused)
-{
- SyncFence* pFence = (SyncFence*) pTrigger->pSync;
- (void)unused;
-
- return (pFence == NULL ||
- pFence->funcs.CheckTriggered(pFence));
-}
-
-static int
-SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XID syncObject,
- RESTYPE resType, Mask changes)
-{
- SyncObject *pSync = pTrigger->pSync;
- SyncCounter *pCounter = NULL;
- int rc;
- Bool newSyncObject = FALSE;
-
- if (changes & XSyncCACounter)
- {
- if (syncObject == None)
- pSync = NULL;
- else if (Success != (rc = dixLookupResourceByType ((pointer *)&pSync,
- syncObject, resType, client, DixReadAccess)))
- {
- client->errorValue = syncObject;
- return rc;
- }
- if (pSync != pTrigger->pSync)
- { /* new counter for trigger */
- SyncDeleteTriggerFromSyncObject(pTrigger);
- pTrigger->pSync = pSync;
- newSyncObject = TRUE;
- }
- }
-
- /* if system counter, ask it what the current value is */
-
- if (pSync && SYNC_COUNTER == pSync->type)
- {
- pCounter = (SyncCounter *)pSync;
-
- if (IsSystemCounter(pCounter))
- {
- (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter,
- &pCounter->value);
- }
- }
-
- if (changes & XSyncCAValueType)
- {
- if (pTrigger->value_type != XSyncRelative &&
- pTrigger->value_type != XSyncAbsolute)
- {
- client->errorValue = pTrigger->value_type;
- return BadValue;
- }
- }
-
- if (changes & XSyncCATestType)
- {
-
- if (pSync && SYNC_FENCE == pSync->type)
- {
- pTrigger->CheckTrigger = SyncCheckTriggerFence;
- }
- else
- {
- if (pTrigger->test_type != XSyncPositiveTransition &&
- pTrigger->test_type != XSyncNegativeTransition &&
- pTrigger->test_type != XSyncPositiveComparison &&
- pTrigger->test_type != XSyncNegativeComparison)
- {
- client->errorValue = pTrigger->test_type;
- return BadValue;
- }
- /* select appropriate CheckTrigger function */
-
- switch (pTrigger->test_type)
- {
- case XSyncPositiveTransition:
- pTrigger->CheckTrigger = SyncCheckTriggerPositiveTransition;
- break;
- case XSyncNegativeTransition:
- pTrigger->CheckTrigger = SyncCheckTriggerNegativeTransition;
- break;
- case XSyncPositiveComparison:
- pTrigger->CheckTrigger = SyncCheckTriggerPositiveComparison;
- break;
- case XSyncNegativeComparison:
- pTrigger->CheckTrigger = SyncCheckTriggerNegativeComparison;
- break;
- }
- }
- }
-
- if (changes & (XSyncCAValueType | XSyncCAValue))
- {
- if (pTrigger->value_type == XSyncAbsolute)
- pTrigger->test_value = pTrigger->wait_value;
- else /* relative */
- {
- Bool overflow;
- if (pCounter == NULL)
- return BadMatch;
-
- XSyncValueAdd(&pTrigger->test_value, pCounter->value,
- pTrigger->wait_value, &overflow);
- if (overflow)
- {
- client->errorValue = XSyncValueHigh32(pTrigger->wait_value);
- return BadValue;
- }
- }
- }
-
- /* we wait until we're sure there are no errors before registering
- * a new counter on a trigger
- */
- if (newSyncObject)
- {
- if ((rc = SyncAddTriggerToSyncObject(pTrigger)) != Success)
- return rc;
- }
- else if (pCounter && IsSystemCounter(pCounter))
- {
- SyncComputeBracketValues(pCounter);
- }
-
- return Success;
-}
-
-/* AlarmNotify events happen in response to actions taken on an Alarm or
- * the counter used by the alarm. AlarmNotify may be sent to multiple
- * clients. The alarm maintains a list of clients interested in events.
- */
-static void
-SyncSendAlarmNotifyEvents(SyncAlarm *pAlarm)
-{
- SyncAlarmClientList *pcl;
- xSyncAlarmNotifyEvent ane;
- SyncTrigger *pTrigger = &pAlarm->trigger;
- SyncCounter *pCounter;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
-
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- UpdateCurrentTime();
-
- ane.type = SyncEventBase + XSyncAlarmNotify;
- ane.kind = XSyncAlarmNotify;
- ane.alarm = pAlarm->alarm_id;
- if (pTrigger->pSync && SYNC_COUNTER == pTrigger->pSync->type)
- {
- ane.counter_value_hi = XSyncValueHigh32(pCounter->value);
- ane.counter_value_lo = XSyncValueLow32(pCounter->value);
- }
- else
- { /* XXX what else can we do if there's no counter? */
- ane.counter_value_hi = ane.counter_value_lo = 0;
- }
-
- ane.alarm_value_hi = XSyncValueHigh32(pTrigger->test_value);
- ane.alarm_value_lo = XSyncValueLow32(pTrigger->test_value);
- ane.time = currentTime.milliseconds;
- ane.state = pAlarm->state;
-
- /* send to owner */
- if (pAlarm->events)
- WriteEventsToClient(pAlarm->client, 1, (xEvent *) &ane);
-
- /* send to other interested clients */
- for (pcl = pAlarm->pEventClients; pcl; pcl = pcl->next)
- WriteEventsToClient(pcl->client, 1, (xEvent *) &ane);
-}
-
-
-/* CounterNotify events only occur in response to an Await. The events
- * go only to the Awaiting client.
- */
-static void
-SyncSendCounterNotifyEvents(ClientPtr client, SyncAwait **ppAwait,
- int num_events)
-{
- xSyncCounterNotifyEvent *pEvents, *pev;
- int i;
-
- if (client->clientGone)
- return;
- pev = pEvents = malloc(num_events * sizeof(xSyncCounterNotifyEvent));
- if (!pEvents)
- return;
- UpdateCurrentTime();
- for (i = 0; i < num_events; i++, ppAwait++, pev++)
- {
- SyncTrigger *pTrigger = &(*ppAwait)->trigger;
- pev->type = SyncEventBase + XSyncCounterNotify;
- pev->kind = XSyncCounterNotify;
- pev->counter = pTrigger->pSync->id;
- pev->wait_value_lo = XSyncValueLow32(pTrigger->test_value);
- pev->wait_value_hi = XSyncValueHigh32(pTrigger->test_value);
- if (SYNC_COUNTER == pTrigger->pSync->type)
- {
- SyncCounter *pCounter = (SyncCounter *)pTrigger->pSync;
-
- pev->counter_value_lo = XSyncValueLow32(pCounter->value);
- pev->counter_value_hi = XSyncValueHigh32(pCounter->value);
- }
- else
- {
- pev->counter_value_lo = 0;
- pev->counter_value_hi = 0;
- }
-
- pev->time = currentTime.milliseconds;
- pev->count = num_events - i - 1; /* events remaining */
- pev->destroyed = pTrigger->pSync->beingDestroyed;
- }
- /* swapping will be taken care of by this */
- WriteEventsToClient(client, num_events, (xEvent *)pEvents);
- free(pEvents);
-}
-
-
-/* This function is called when an alarm's counter is destroyed.
- * It is plugged into pTrigger->CounterDestroyed (for alarm triggers).
- */
-static void
-SyncAlarmCounterDestroyed(SyncTrigger *pTrigger)
-{
- SyncAlarm *pAlarm = (SyncAlarm *)pTrigger;
-
- pAlarm->state = XSyncAlarmInactive;
- SyncSendAlarmNotifyEvents(pAlarm);
- pTrigger->pSync = NULL;
-}
-
-
-/* This function is called when an alarm "goes off."
- * It is plugged into pTrigger->TriggerFired (for alarm triggers).
- */
-static void
-SyncAlarmTriggerFired(SyncTrigger *pTrigger)
-{
- SyncAlarm *pAlarm = (SyncAlarm *)pTrigger;
- SyncCounter *pCounter;
- CARD64 new_test_value;
-
- assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type));
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- /* no need to check alarm unless it's active */
- if (pAlarm->state != XSyncAlarmActive)
- return;
-
- /* " if the counter value is None, or if the delta is 0 and
- * the test-type is PositiveComparison or NegativeComparison,
- * no change is made to value (test-value) and the alarm
- * state is changed to Inactive before the event is generated."
- */
- if (pCounter == NULL
- || (XSyncValueIsZero(pAlarm->delta)
- && (pAlarm->trigger.test_type == XSyncPositiveComparison
- || pAlarm->trigger.test_type == XSyncNegativeComparison)))
- pAlarm->state = XSyncAlarmInactive;
-
- new_test_value = pAlarm->trigger.test_value;
-
- if (pAlarm->state == XSyncAlarmActive)
- {
- Bool overflow;
- CARD64 oldvalue;
- SyncTrigger *paTrigger = &pAlarm->trigger;
- SyncCounter *paCounter;
-
- assert(!paTrigger->pSync || (SYNC_COUNTER == paTrigger->pSync->type));
- paCounter = (SyncCounter *)pTrigger->pSync;
-
- /* "The alarm is updated by repeatedly adding delta to the
- * value of the trigger and re-initializing it until it
- * becomes FALSE."
- */
- oldvalue = paTrigger->test_value;
-
- /* XXX really should do something smarter here */
-
- do
- {
- XSyncValueAdd(&paTrigger->test_value, paTrigger->test_value,
- pAlarm->delta, &overflow);
- } while (!overflow &&
- (*paTrigger->CheckTrigger)(paTrigger,
- paCounter->value));
-
- new_test_value = paTrigger->test_value;
- paTrigger->test_value = oldvalue;
-
- /* "If this update would cause value to fall outside the range
- * for an INT64...no change is made to value (test-value) and
- * the alarm state is changed to Inactive before the event is
- * generated."
- */
- if (overflow)
- {
- new_test_value = oldvalue;
- pAlarm->state = XSyncAlarmInactive;
- }
- }
- /* The AlarmNotify event has to have the "new state of the alarm"
- * which we can't be sure of until this point. However, it has
- * to have the "old" trigger test value. That's the reason for
- * all the newvalue/oldvalue shuffling above. After we send the
- * events, give the trigger its new test value.
- */
- SyncSendAlarmNotifyEvents(pAlarm);
- pTrigger->test_value = new_test_value;
-}
-
-
-/* This function is called when an Await unblocks, either as a result
- * of the trigger firing OR the counter being destroyed.
- * It goes into pTrigger->TriggerFired AND pTrigger->CounterDestroyed
- * (for Await triggers).
- */
-static void
-SyncAwaitTriggerFired(SyncTrigger *pTrigger)
-{
- SyncAwait *pAwait = (SyncAwait *)pTrigger;
- int numwaits;
- SyncAwaitUnion *pAwaitUnion;
- SyncAwait **ppAwait;
- int num_events = 0;
-
- pAwaitUnion = (SyncAwaitUnion *)pAwait->pHeader;
- numwaits = pAwaitUnion->header.num_waitconditions;
- ppAwait = malloc(numwaits * sizeof(SyncAwait *));
- if (!ppAwait)
- goto bail;
-
- pAwait = &(pAwaitUnion+1)->await;
-
- /* "When a client is unblocked, all the CounterNotify events for
- * the Await request are generated contiguously. If count is 0
- * there are no more events to follow for this request. If
- * count is n, there are at least n more events to follow."
- *
- * Thus, it is best to find all the counters for which events
- * need to be sent first, so that an accurate count field can
- * be stored in the events.
- */
- for ( ; numwaits; numwaits--, pAwait++)
- {
- CARD64 diff;
- Bool overflow, diffgreater, diffequal;
-
- /* "A CounterNotify event with the destroyed flag set to TRUE is
- * always generated if the counter for one of the triggers is
- * destroyed."
- */
- if (pAwait->trigger.pSync->beingDestroyed)
- {
- ppAwait[num_events++] = pAwait;
- continue;
- }
-
- if (SYNC_COUNTER == pAwait->trigger.pSync->type)
- {
- SyncCounter *pCounter = (SyncCounter *) pAwait->trigger.pSync;
-
- /* "The difference between the counter and the test value is
- * calculated by subtracting the test value from the value of
- * the counter."
- */
- XSyncValueSubtract(&diff, pCounter->value,
- pAwait->trigger.test_value, &overflow);
-
- /* "If the difference lies outside the range for an INT64, an
- * event is not generated."
- */
- if (overflow)
- continue;
- diffgreater = XSyncValueGreaterThan(diff, pAwait->event_threshold);
- diffequal = XSyncValueEqual(diff, pAwait->event_threshold);
-
- /* "If the test-type is PositiveTransition or
- * PositiveComparison, a CounterNotify event is generated if
- * the difference is at least event-threshold. If the test-type
- * is NegativeTransition or NegativeComparison, a CounterNotify
- * event is generated if the difference is at most
- * event-threshold."
- */
-
- if ( ((pAwait->trigger.test_type == XSyncPositiveComparison ||
- pAwait->trigger.test_type == XSyncPositiveTransition)
- && (diffgreater || diffequal))
- ||
- ((pAwait->trigger.test_type == XSyncNegativeComparison ||
- pAwait->trigger.test_type == XSyncNegativeTransition)
- && (!diffgreater) /* less or equal */
- )
- )
- {
- ppAwait[num_events++] = pAwait;
- }
- }
- }
- if (num_events)
- SyncSendCounterNotifyEvents(pAwaitUnion->header.client, ppAwait,
- num_events);
- free(ppAwait);
-
-bail:
- /* unblock the client */
- AttendClient(pAwaitUnion->header.client);
- /* delete the await */
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
-}
-
-
-/* This function should always be used to change a counter's value so that
- * any triggers depending on the counter will be checked.
- */
-void
-SyncChangeCounter(SyncCounter *pCounter, CARD64 newval)
-{
- SyncTriggerList *ptl, *pnext;
- CARD64 oldval;
-
- oldval = pCounter->value;
- pCounter->value = newval;
-
- /* run through triggers to see if any become true */
- for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext)
- {
- pnext = ptl->next;
- if ((*ptl->pTrigger->CheckTrigger)(ptl->pTrigger, oldval))
- (*ptl->pTrigger->TriggerFired)(ptl->pTrigger);
- }
-
- if (IsSystemCounter(pCounter))
- {
- SyncComputeBracketValues(pCounter);
- }
-}
-
-
-/* loosely based on dix/events.c/EventSelectForWindow */
-static Bool
-SyncEventSelectForAlarm(SyncAlarm *pAlarm, ClientPtr client, Bool wantevents)
-{
- SyncAlarmClientList *pClients;
-
- if (client == pAlarm->client) /* alarm owner */
- {
- pAlarm->events = wantevents;
- return Success;
- }
-
- /* see if the client is already on the list (has events selected) */
-
- for (pClients = pAlarm->pEventClients; pClients;
- pClients = pClients->next)
- {
- if (pClients->client == client)
- {
- /* client's presence on the list indicates desire for
- * events. If the client doesn't want events, remove it
- * from the list. If the client does want events, do
- * nothing, since it's already got them.
- */
- if (!wantevents)
- {
- FreeResource(pClients->delete_id, RT_NONE);
- }
- return Success;
- }
- }
-
- /* if we get here, this client does not currently have
- * events selected on the alarm
- */
-
- if (!wantevents)
- /* client doesn't want events, and we just discovered that it
- * doesn't have them, so there's nothing to do.
- */
- return Success;
-
- /* add new client to pAlarm->pEventClients */
-
- pClients = malloc(sizeof(SyncAlarmClientList));
- if (!pClients)
- return BadAlloc;
-
- /* register it as a resource so it will be cleaned up
- * if the client dies
- */
-
- pClients->delete_id = FakeClientID(client->index);
- if (!AddResource(pClients->delete_id, RTAlarmClient, pAlarm))
- {
- free(pClients);
- return BadAlloc;
- }
-
- /* link it into list after we know all the allocations succeed */
-
- pClients->next = pAlarm->pEventClients;
- pAlarm->pEventClients = pClients;
- pClients->client = client;
- return Success;
-}
-
-/*
- * ** SyncChangeAlarmAttributes ** This is used by CreateAlarm and ChangeAlarm
- */
-static int
-SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm *pAlarm, Mask mask,
- CARD32 *values)
-{
- int status;
- XSyncCounter counter;
- Mask origmask = mask;
-
- counter =
- pAlarm->trigger.pSync ? pAlarm->trigger.pSync->id : None;
-
- while (mask)
- {
- int index2 = lowbit(mask);
- mask &= ~index2;
- switch (index2)
- {
- case XSyncCACounter:
- mask &= ~XSyncCACounter;
- /* sanity check in SyncInitTrigger */
- counter = *values++;
- break;
-
- case XSyncCAValueType:
- mask &= ~XSyncCAValueType;
- /* sanity check in SyncInitTrigger */
- pAlarm->trigger.value_type = *values++;
- break;
-
- case XSyncCAValue:
- mask &= ~XSyncCAValue;
- XSyncIntsToValue(&pAlarm->trigger.wait_value, values[1], values[0]);
- values += 2;
- break;
-
- case XSyncCATestType:
- mask &= ~XSyncCATestType;
- /* sanity check in SyncInitTrigger */
- pAlarm->trigger.test_type = *values++;
- break;
-
- case XSyncCADelta:
- mask &= ~XSyncCADelta;
- XSyncIntsToValue(&pAlarm->delta, values[1], values[0]);
- values += 2;
- break;
-
- case XSyncCAEvents:
- mask &= ~XSyncCAEvents;
- if ((*values != xTrue) && (*values != xFalse))
- {
- client->errorValue = *values;
- return BadValue;
- }
- status = SyncEventSelectForAlarm(pAlarm, client,
- (Bool)(*values++));
- if (status != Success)
- return status;
- break;
-
- default:
- client->errorValue = mask;
- return BadValue;
- }
- }
-
- /* "If the test-type is PositiveComparison or PositiveTransition
- * and delta is less than zero, or if the test-type is
- * NegativeComparison or NegativeTransition and delta is
- * greater than zero, a Match error is generated."
- */
- if (origmask & (XSyncCADelta|XSyncCATestType))
- {
- CARD64 zero;
- XSyncIntToValue(&zero, 0);
- if ((((pAlarm->trigger.test_type == XSyncPositiveComparison) ||
- (pAlarm->trigger.test_type == XSyncPositiveTransition))
- && XSyncValueLessThan(pAlarm->delta, zero))
- ||
- (((pAlarm->trigger.test_type == XSyncNegativeComparison) ||
- (pAlarm->trigger.test_type == XSyncNegativeTransition))
- && XSyncValueGreaterThan(pAlarm->delta, zero))
- )
- {
- return BadMatch;
- }
- }
-
- /* postpone this until now, when we're sure nothing else can go wrong */
- if ((status = SyncInitTrigger(client, &pAlarm->trigger, counter, RTCounter,
- origmask & XSyncCAAllTrigger)) != Success)
- return status;
-
- /* XXX spec does not really say to do this - needs clarification */
- pAlarm->state = XSyncAlarmActive;
- return Success;
-}
-
-static SyncObject *
-SyncCreate(ClientPtr client, XID id, unsigned char type)
-{
- SyncObject *pSync;
- RESTYPE resType;
-
- switch (type) {
- case SYNC_COUNTER:
- resType = RTCounter;
- pSync = malloc(sizeof(SyncCounter));
- break;
- case SYNC_FENCE:
- resType = RTFence;
- pSync = dixAllocateObjectWithPrivates(SyncFence,
- PRIVATE_SYNC_FENCE);
- break;
- default:
- return NULL;
- }
-
- if (!pSync)
- return NULL;
-
- if (!AddResource(id, resType, (pointer) pSync))
- {
- switch (type) {
- case SYNC_FENCE:
- dixFreeObjectWithPrivates((SyncFence *)pSync, PRIVATE_SYNC_FENCE);
- break;
- default:
- free(pSync);
- }
-
- return NULL;
- }
-
- pSync->client = client;
- pSync->id = id;
- pSync->pTriglist = NULL;
- pSync->beingDestroyed = FALSE;
- pSync->type = type;
-
- return pSync;
-}
-
-
-static SyncCounter *
-SyncCreateCounter(ClientPtr client, XSyncCounter id, CARD64 initialvalue)
-{
- SyncCounter *pCounter;
-
- if (!(pCounter = (SyncCounter *)SyncCreate(client,
- id,
- SYNC_COUNTER)))
- return NULL;
-
- pCounter->value = initialvalue;
- pCounter->pSysCounterInfo = NULL;
- return pCounter;
-}
-
-static int FreeCounter(void *, XID);
-
-/*
- * ***** System Counter utilities
- */
-
-pointer
-SyncCreateSystemCounter(
- char *name,
- CARD64 initial,
- CARD64 resolution,
- SyncCounterType counterType,
- void (*QueryValue)(pointer /* pCounter */,
- CARD64 * /* pValue_return */),
- void (*BracketValues)(pointer /* pCounter */,
- CARD64 * /* pbracket_less */,
- CARD64 * /* pbracket_greater */)
- )
-{
- SyncCounter *pCounter;
-
- SysCounterList = realloc(SysCounterList,
- (SyncNumSystemCounters+1)*sizeof(SyncCounter *));
- if (!SysCounterList)
- return NULL;
-
- /* this function may be called before SYNC has been initialized, so we
- * have to make sure RTCounter is created.
- */
- if (RTCounter == 0)
- {
- RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter");
- if (RTCounter == 0)
- {
- return NULL;
- }
- }
-
- pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial);
-
- if (pCounter)
- {
- SysCounterInfo *psci;
-
- psci = malloc(sizeof(SysCounterInfo));
- if (!psci)
- {
- FreeResource(pCounter->sync.id, RT_NONE);
- return pCounter;
- }
- pCounter->pSysCounterInfo = psci;
- psci->name = name;
- psci->resolution = resolution;
- psci->counterType = counterType;
- psci->QueryValue = QueryValue;
- psci->BracketValues = BracketValues;
- XSyncMaxValue(&psci->bracket_greater);
- XSyncMinValue(&psci->bracket_less);
- SysCounterList[SyncNumSystemCounters++] = pCounter;
- }
- return pCounter;
-}
-
-void
-SyncDestroySystemCounter(pointer pSysCounter)
-{
- SyncCounter *pCounter = (SyncCounter *)pSysCounter;
- FreeResource(pCounter->sync.id, RT_NONE);
-}
-
-static void
-SyncComputeBracketValues(SyncCounter *pCounter)
-{
- SyncTriggerList *pCur;
- SyncTrigger *pTrigger;
- SysCounterInfo *psci;
- CARD64 *pnewgtval = NULL;
- CARD64 *pnewltval = NULL;
- SyncCounterType ct;
-
- if (!pCounter)
- return;
-
- psci = pCounter->pSysCounterInfo;
- ct = pCounter->pSysCounterInfo->counterType;
- if (ct == XSyncCounterNeverChanges)
- return;
-
- XSyncMaxValue(&psci->bracket_greater);
- XSyncMinValue(&psci->bracket_less);
-
- for (pCur = pCounter->sync.pTriglist; pCur; pCur = pCur->next)
- {
- pTrigger = pCur->pTrigger;
-
- if (pTrigger->test_type == XSyncPositiveComparison &&
- ct != XSyncCounterNeverIncreases)
- {
- if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) &&
- XSyncValueLessThan(pTrigger->test_value,
- psci->bracket_greater))
- {
- psci->bracket_greater = pTrigger->test_value;
- pnewgtval = &psci->bracket_greater;
- }
- }
- else if (pTrigger->test_type == XSyncNegativeComparison &&
- ct != XSyncCounterNeverDecreases)
- {
- if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) &&
- XSyncValueGreaterThan(pTrigger->test_value,
- psci->bracket_less))
- {
- psci->bracket_less = pTrigger->test_value;
- pnewltval = &psci->bracket_less;
- }
- }
- else if (pTrigger->test_type == XSyncNegativeTransition &&
- ct != XSyncCounterNeverIncreases)
- {
- if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) &&
- XSyncValueGreaterThan(pTrigger->test_value, psci->bracket_less))
- {
- psci->bracket_less = pTrigger->test_value;
- pnewltval = &psci->bracket_less;
- }
- }
- else if (pTrigger->test_type == XSyncPositiveTransition &&
- ct != XSyncCounterNeverDecreases)
- {
- if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) &&
- XSyncValueLessThan(pTrigger->test_value, psci->bracket_greater))
- {
- psci->bracket_greater = pTrigger->test_value;
- pnewgtval = &psci->bracket_greater;
- }
- }
- } /* end for each trigger */
-
- if (pnewgtval || pnewltval)
- {
- (*psci->BracketValues)((pointer)pCounter, pnewltval, pnewgtval);
- }
-}
-
-/*
- * ***** Resource delete functions
- */
-
-/* ARGSUSED */
-static int
-FreeAlarm(void *addr, XID id)
-{
- SyncAlarm *pAlarm = (SyncAlarm *) addr;
-
- pAlarm->state = XSyncAlarmDestroyed;
-
- SyncSendAlarmNotifyEvents(pAlarm);
-
- /* delete event selections */
-
- while (pAlarm->pEventClients)
- FreeResource(pAlarm->pEventClients->delete_id, RT_NONE);
-
- SyncDeleteTriggerFromSyncObject(&pAlarm->trigger);
-
- free(pAlarm);
- return Success;
-}
-
-
-/*
- * ** Cleanup after the destruction of a Counter
- */
-/* ARGSUSED */
-static int
-FreeCounter(void *env, XID id)
-{
- SyncCounter *pCounter = (SyncCounter *) env;
- SyncTriggerList *ptl, *pnext;
-
- pCounter->sync.beingDestroyed = TRUE;
- /* tell all the counter's triggers that the counter has been destroyed */
- for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext)
- {
- (*ptl->pTrigger->CounterDestroyed)(ptl->pTrigger);
- pnext = ptl->next;
- free(ptl); /* destroy the trigger list as we go */
- }
- if (IsSystemCounter(pCounter))
- {
- int i, found = 0;
-
- free(pCounter->pSysCounterInfo);
-
- /* find the counter in the list of system counters and remove it */
-
- if (SysCounterList)
- {
- for (i = 0; i < SyncNumSystemCounters; i++)
- {
- if (SysCounterList[i] == pCounter)
- {
- found = i;
- break;
- }
- }
- if (found < (SyncNumSystemCounters-1))
- {
- for (i = found; i < SyncNumSystemCounters-1; i++)
- {
- SysCounterList[i] = SysCounterList[i+1];
- }
- }
- }
- SyncNumSystemCounters--;
- }
- free(pCounter);
- return Success;
-}
-
-/*
- * ** Cleanup after Await
- */
-/* ARGSUSED */
-static int
-FreeAwait(void *addr, XID id)
-{
- SyncAwaitUnion *pAwaitUnion = (SyncAwaitUnion *) addr;
- SyncAwait *pAwait;
- int numwaits;
-
- pAwait = &(pAwaitUnion+1)->await; /* first await on list */
-
- /* remove triggers from counters */
-
- for (numwaits = pAwaitUnion->header.num_waitconditions; numwaits;
- numwaits--, pAwait++)
- {
- /* If the counter is being destroyed, FreeCounter will delete
- * the trigger list itself, so don't do it here.
- */
- SyncObject *pSync = pAwait->trigger.pSync;
- if (pSync && !pSync->beingDestroyed)
- SyncDeleteTriggerFromSyncObject(&pAwait->trigger);
- }
- free(pAwaitUnion);
- return Success;
-}
-
-#ifdef _MSC_VER
-#pragma warning(disable:4715) /* Not all control paths return a value */
-#endif
-
-/* loosely based on dix/events.c/OtherClientGone */
-static int
-FreeAlarmClient(void *value, XID id)
-{
- SyncAlarm *pAlarm = (SyncAlarm *)value;
- SyncAlarmClientList *pCur, *pPrev;
-
- for (pPrev = NULL, pCur = pAlarm->pEventClients;
- pCur;
- pPrev = pCur, pCur = pCur->next)
- {
- if (pCur->delete_id == id)
- {
- if (pPrev)
- pPrev->next = pCur->next;
- else
- pAlarm->pEventClients = pCur->next;
- free(pCur);
- return Success;
- }
- }
- FatalError("alarm client not on event list");
- /*NOTREACHED*/
-}
-
-
-/*
- * ***** Proc functions
- */
-
-
-/*
- * ** Initialize the extension
- */
-static int
-ProcSyncInitialize(ClientPtr client)
-{
- xSyncInitializeReply rep;
- int n;
-
- REQUEST_SIZE_MATCH(xSyncInitializeReq);
-
- memset(&rep, 0, sizeof(xSyncInitializeReply));
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.majorVersion = SERVER_SYNC_MAJOR_VERSION;
- rep.minorVersion = SERVER_SYNC_MINOR_VERSION;
- rep.length = 0;
-
- if (client->swapped)
- {
- swaps(&rep.sequenceNumber, n);
- }
- WriteToClient(client, sizeof(rep), (char *) &rep);
- return Success;
-}
-
-/*
- * ** Get list of system counters available through the extension
- */
-static int
-ProcSyncListSystemCounters(ClientPtr client)
-{
- xSyncListSystemCountersReply rep;
- int i, len;
- xSyncSystemCounter *list = NULL, *walklist = NULL;
-
- REQUEST_SIZE_MATCH(xSyncListSystemCountersReq);
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.nCounters = SyncNumSystemCounters;
-
- for (i = len = 0; i < SyncNumSystemCounters; i++)
- {
- char *name = SysCounterList[i]->pSysCounterInfo->name;
- /* pad to 4 byte boundary */
- len += pad_to_int32(sz_xSyncSystemCounter + strlen(name));
- }
-
- if (len)
- {
- walklist = list = malloc(len);
- if (!list)
- return BadAlloc;
- }
-
- rep.length = bytes_to_int32(len);
-
- if (client->swapped)
- {
- char n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.nCounters, n);
- }
-
- for (i = 0; i < SyncNumSystemCounters; i++)
- {
- int namelen;
- char *pname_in_reply;
- SysCounterInfo *psci = SysCounterList[i]->pSysCounterInfo;
-
- walklist->counter = SysCounterList[i]->sync.id;
- walklist->resolution_hi = XSyncValueHigh32(psci->resolution);
- walklist->resolution_lo = XSyncValueLow32(psci->resolution);
- namelen = strlen(psci->name);
- walklist->name_length = namelen;
-
- if (client->swapped)
- {
- char n;
- swapl(&walklist->counter, n);
- swapl(&walklist->resolution_hi, n);
- swapl(&walklist->resolution_lo, n);
- swaps(&walklist->name_length, n);
- }
-
- pname_in_reply = ((char *)walklist) + sz_xSyncSystemCounter;
- strncpy(pname_in_reply, psci->name, namelen);
- walklist = (xSyncSystemCounter *) (((char *)walklist) +
- pad_to_int32(sz_xSyncSystemCounter + namelen));
- }
-
- WriteToClient(client, sizeof(rep), (char *) &rep);
- if (len)
- {
- WriteToClient(client, len, (char *) list);
- free(list);
- }
-
- return Success;
-}
-
-/*
- * ** Set client Priority
- */
-static int
-ProcSyncSetPriority(ClientPtr client)
-{
- REQUEST(xSyncSetPriorityReq);
- ClientPtr priorityclient;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncSetPriorityReq);
-
- if (stuff->id == None)
- priorityclient = client;
- else {
- rc = dixLookupClient(&priorityclient, stuff->id, client,
- DixSetAttrAccess);
- if (rc != Success)
- return rc;
- }
-
- if (priorityclient->priority != stuff->priority)
- {
- priorityclient->priority = stuff->priority;
-
- /* The following will force the server back into WaitForSomething
- * so that the change in this client's priority is immediately
- * reflected.
- */
- isItTimeToYield = TRUE;
- dispatchException |= DE_PRIORITYCHANGE;
- }
- return Success;
-}
-
-/*
- * ** Get client Priority
- */
-static int
-ProcSyncGetPriority(ClientPtr client)
-{
- REQUEST(xSyncGetPriorityReq);
- xSyncGetPriorityReply rep;
- ClientPtr priorityclient;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncGetPriorityReq);
-
- if (stuff->id == None)
- priorityclient = client;
- else {
- rc = dixLookupClient(&priorityclient, stuff->id, client,
- DixGetAttrAccess);
- if (rc != Success)
- return rc;
- }
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
- rep.priority = priorityclient->priority;
-
- if (client->swapped)
- {
- char n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.priority, n);
- }
-
- WriteToClient(client, sizeof(xSyncGetPriorityReply), (char *) &rep);
-
- return Success;
-}
-
-/*
- * ** Create a new counter
- */
-static int
-ProcSyncCreateCounter(ClientPtr client)
-{
- REQUEST(xSyncCreateCounterReq);
- CARD64 initial;
-
- REQUEST_SIZE_MATCH(xSyncCreateCounterReq);
-
- LEGAL_NEW_RESOURCE(stuff->cid, client);
-
- XSyncIntsToValue(&initial, stuff->initial_value_lo, stuff->initial_value_hi);
- if (!SyncCreateCounter(client, stuff->cid, initial))
- return BadAlloc;
-
- return Success;
-}
-
-/*
- * ** Set Counter value
- */
-static int
-ProcSyncSetCounter(ClientPtr client)
-{
- REQUEST(xSyncSetCounterReq);
- SyncCounter *pCounter;
- CARD64 newvalue;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncSetCounterReq);
-
- rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
- client, DixWriteAccess);
- if (rc != Success)
- return rc;
-
- if (IsSystemCounter(pCounter))
- {
- client->errorValue = stuff->cid;
- return BadAccess;
- }
-
- XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi);
- SyncChangeCounter(pCounter, newvalue);
- return Success;
-}
-
-/*
- * ** Change Counter value
- */
-static int
-ProcSyncChangeCounter(ClientPtr client)
-{
- REQUEST(xSyncChangeCounterReq);
- SyncCounter *pCounter;
- CARD64 newvalue;
- Bool overflow;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncChangeCounterReq);
-
- rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter,
- client, DixWriteAccess);
- if (rc != Success)
- return rc;
-
- if (IsSystemCounter(pCounter))
- {
- client->errorValue = stuff->cid;
- return BadAccess;
- }
-
- XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi);
- XSyncValueAdd(&newvalue, pCounter->value, newvalue, &overflow);
- if (overflow)
- {
- /* XXX 64 bit value can't fit in 32 bits; do the best we can */
- client->errorValue = stuff->value_hi;
- return BadValue;
- }
- SyncChangeCounter(pCounter, newvalue);
- return Success;
-}
-
-/*
- * ** Destroy a counter
- */
-static int
-ProcSyncDestroyCounter(ClientPtr client)
-{
- REQUEST(xSyncDestroyCounterReq);
- SyncCounter *pCounter;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncDestroyCounterReq);
-
- rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, RTCounter,
- client, DixDestroyAccess);
- if (rc != Success)
- return rc;
-
- if (IsSystemCounter(pCounter))
- {
- client->errorValue = stuff->counter;
- return BadAccess;
- }
- FreeResource(pCounter->sync.id, RT_NONE);
- return Success;
-}
-
-static SyncAwaitUnion*
-SyncAwaitPrologue(ClientPtr client, int items)
-{
- SyncAwaitUnion *pAwaitUnion;
-
- /* all the memory for the entire await list is allocated
- * here in one chunk
- */
- pAwaitUnion = malloc((items+1) * sizeof(SyncAwaitUnion));
- if (!pAwaitUnion)
- return NULL;
-
- /* first item is the header, remainder are real wait conditions */
-
- pAwaitUnion->header.delete_id = FakeClientID(client->index);
- if (!AddResource(pAwaitUnion->header.delete_id, RTAwait, pAwaitUnion))
- {
- free(pAwaitUnion);
- return NULL;
- }
-
- pAwaitUnion->header.client = client;
- pAwaitUnion->header.num_waitconditions = 0;
-
- return pAwaitUnion;
-}
-
-static void
-SyncAwaitEpilogue(ClientPtr client, int items, SyncAwaitUnion *pAwaitUnion)
-{
- SyncAwait *pAwait;
- int i;
-
- IgnoreClient(client);
-
- /* see if any of the triggers are already true */
-
- pAwait = &(pAwaitUnion+1)->await; /* skip over header */
- for (i = 0; i < items; i++, pAwait++)
- {
- CARD64 value;
-
- /* don't have to worry about NULL counters because the request
- * errors before we get here out if they occur
- */
- switch (pAwait->trigger.pSync->type) {
- case SYNC_COUNTER:
- value = ((SyncCounter *)pAwait->trigger.pSync)->value;
- break;
- default:
- XSyncIntToValue(&value, 0);
- }
-
- if ((*pAwait->trigger.CheckTrigger)(&pAwait->trigger, value))
- {
- (*pAwait->trigger.TriggerFired)(&pAwait->trigger);
- break; /* once is enough */
- }
- }
-}
-
-/*
- * ** Await
- */
-static int
-ProcSyncAwait(ClientPtr client)
-{
- REQUEST(xSyncAwaitReq);
- int len, items;
- int i;
- xSyncWaitCondition *pProtocolWaitConds;
- SyncAwaitUnion *pAwaitUnion;
- SyncAwait *pAwait;
- int status;
-
- REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
-
- len = client->req_len << 2;
- len -= sz_xSyncAwaitReq;
- items = len / sz_xSyncWaitCondition;
-
- if (items * sz_xSyncWaitCondition != len)
- {
- return BadLength;
- }
- if (items == 0)
- {
- client->errorValue = items; /* XXX protocol change */
- return BadValue;
- }
-
- if (!(pAwaitUnion = SyncAwaitPrologue(client, items)))
- return BadAlloc;
-
- /* don't need to do any more memory allocation for this request! */
-
- pProtocolWaitConds = (xSyncWaitCondition *) & stuff[1];
-
- pAwait = &(pAwaitUnion+1)->await; /* skip over header */
- for (i = 0; i < items; i++, pProtocolWaitConds++, pAwait++)
- {
- if (pProtocolWaitConds->counter == None) /* XXX protocol change */
- {
- /* this should take care of removing any triggers created by
- * this request that have already been registered on sync objects
- */
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
- client->errorValue = pProtocolWaitConds->counter;
- return SyncErrorBase + XSyncBadCounter;
- }
-
- /* sanity checks are in SyncInitTrigger */
- pAwait->trigger.pSync = NULL;
- pAwait->trigger.value_type = pProtocolWaitConds->value_type;
- XSyncIntsToValue(&pAwait->trigger.wait_value,
- pProtocolWaitConds->wait_value_lo,
- pProtocolWaitConds->wait_value_hi);
- pAwait->trigger.test_type = pProtocolWaitConds->test_type;
-
- status = SyncInitTrigger(client, &pAwait->trigger,
- pProtocolWaitConds->counter, RTCounter,
- XSyncCAAllTrigger);
- if (status != Success)
- {
- /* this should take care of removing any triggers created by
- * this request that have already been registered on sync objects
- */
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
- return status;
- }
- /* this is not a mistake -- same function works for both cases */
- pAwait->trigger.TriggerFired = SyncAwaitTriggerFired;
- pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired;
- XSyncIntsToValue(&pAwait->event_threshold,
- pProtocolWaitConds->event_threshold_lo,
- pProtocolWaitConds->event_threshold_hi);
- pAwait->pHeader = &pAwaitUnion->header;
- pAwaitUnion->header.num_waitconditions++;
- }
-
- SyncAwaitEpilogue(client, items, pAwaitUnion);
-
- return Success;
-}
-
-
-/*
- * ** Query a counter
- */
-static int
-ProcSyncQueryCounter(ClientPtr client)
-{
- REQUEST(xSyncQueryCounterReq);
- xSyncQueryCounterReply rep;
- SyncCounter *pCounter;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncQueryCounterReq);
-
- rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter,
- RTCounter, client, DixReadAccess);
- if (rc != Success)
- return rc;
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- /* if system counter, ask it what the current value is */
-
- if (IsSystemCounter(pCounter))
- {
- (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter,
- &pCounter->value);
- }
-
- rep.value_hi = XSyncValueHigh32(pCounter->value);
- rep.value_lo = XSyncValueLow32(pCounter->value);
- if (client->swapped)
- {
- char n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.value_hi, n);
- swapl(&rep.value_lo, n);
- }
- WriteToClient(client, sizeof(xSyncQueryCounterReply), (char *) &rep);
- return Success;
-}
-
-
-/*
- * ** Create Alarm
- */
-static int
-ProcSyncCreateAlarm(ClientPtr client)
-{
- REQUEST(xSyncCreateAlarmReq);
- SyncAlarm *pAlarm;
- int status;
- unsigned long len, vmask;
- SyncTrigger *pTrigger;
-
- REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq);
-
- LEGAL_NEW_RESOURCE(stuff->id, client);
-
- vmask = stuff->valueMask;
- len = client->req_len - bytes_to_int32(sizeof(xSyncCreateAlarmReq));
- /* the "extra" call to Ones accounts for the presence of 64 bit values */
- if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
- return BadLength;
-
- if (!(pAlarm = malloc(sizeof(SyncAlarm))))
- {
- return BadAlloc;
- }
-
- /* set up defaults */
-
- pTrigger = &pAlarm->trigger;
- pTrigger->pSync = NULL;
- pTrigger->value_type = XSyncAbsolute;
- XSyncIntToValue(&pTrigger->wait_value, 0L);
- pTrigger->test_type = XSyncPositiveComparison;
- pTrigger->TriggerFired = SyncAlarmTriggerFired;
- pTrigger->CounterDestroyed = SyncAlarmCounterDestroyed;
- status = SyncInitTrigger(client, pTrigger, None, RTCounter,
- XSyncCAAllTrigger);
- if (status != Success)
- {
- free(pAlarm);
- return status;
- }
-
- pAlarm->client = client;
- pAlarm->alarm_id = stuff->id;
- XSyncIntToValue(&pAlarm->delta, 1L);
- pAlarm->events = TRUE;
- pAlarm->state = XSyncAlarmInactive;
- pAlarm->pEventClients = NULL;
- status = SyncChangeAlarmAttributes(client, pAlarm, vmask,
- (CARD32 *)&stuff[1]);
- if (status != Success)
- {
- free(pAlarm);
- return status;
- }
-
- if (!AddResource(stuff->id, RTAlarm, pAlarm))
- {
- free(pAlarm);
- return BadAlloc;
- }
-
- /* see if alarm already triggered. NULL counter will not trigger
- * in CreateAlarm and sets alarm state to Inactive.
- */
-
- if (!pTrigger->pSync)
- {
- pAlarm->state = XSyncAlarmInactive; /* XXX protocol change */
- }
- else
- {
- SyncCounter *pCounter;
-
- assert(SYNC_COUNTER == pTrigger->pSync->type);
- pCounter = (SyncCounter *)pTrigger->pSync;
-
- if ((*pTrigger->CheckTrigger)(pTrigger, pCounter->value))
- (*pTrigger->TriggerFired)(pTrigger);
- }
-
- return Success;
-}
-
-/*
- * ** Change Alarm
- */
-static int
-ProcSyncChangeAlarm(ClientPtr client)
-{
- REQUEST(xSyncChangeAlarmReq);
- SyncAlarm *pAlarm;
- SyncCounter *pCounter = NULL;
- long vmask;
- int len, status;
-
- REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
-
- status = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
- client, DixWriteAccess);
- if (status != Success)
- return status;
-
- vmask = stuff->valueMask;
- len = client->req_len - bytes_to_int32(sizeof(xSyncChangeAlarmReq));
- /* the "extra" call to Ones accounts for the presence of 64 bit values */
- if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta))))
- return BadLength;
-
- if ((status = SyncChangeAlarmAttributes(client, pAlarm, vmask,
- (CARD32 *)&stuff[1])) != Success)
- return status;
-
- if (pAlarm->trigger.pSync)
- {
- assert(SYNC_COUNTER == pAlarm->trigger.pSync->type);
- pCounter = (SyncCounter *)pAlarm->trigger.pSync;
- }
-
- /* see if alarm already triggered. NULL counter WILL trigger
- * in ChangeAlarm.
- */
-
- if (!pCounter ||
- (*pAlarm->trigger.CheckTrigger)(&pAlarm->trigger, pCounter->value))
- {
- (*pAlarm->trigger.TriggerFired)(&pAlarm->trigger);
- }
- return Success;
-}
-
-static int
-ProcSyncQueryAlarm(ClientPtr client)
-{
- REQUEST(xSyncQueryAlarmReq);
- SyncAlarm *pAlarm;
- xSyncQueryAlarmReply rep;
- SyncTrigger *pTrigger;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncQueryAlarmReq);
-
- rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
- client, DixReadAccess);
- if (rc != Success)
- return rc;
-
- rep.type = X_Reply;
- rep.length = bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply));
- rep.sequenceNumber = client->sequence;
-
- pTrigger = &pAlarm->trigger;
- rep.counter = (pTrigger->pSync) ? pTrigger->pSync->id : None;
-
-#if 0 /* XXX unclear what to do, depends on whether relative value-types
- * are "consumed" immediately and are considered absolute from then
- * on.
- */
- rep.value_type = pTrigger->value_type;
- rep.wait_value_hi = XSyncValueHigh32(pTrigger->wait_value);
- rep.wait_value_lo = XSyncValueLow32(pTrigger->wait_value);
-#else
- rep.value_type = XSyncAbsolute;
- rep.wait_value_hi = XSyncValueHigh32(pTrigger->test_value);
- rep.wait_value_lo = XSyncValueLow32(pTrigger->test_value);
-#endif
-
- rep.test_type = pTrigger->test_type;
- rep.delta_hi = XSyncValueHigh32(pAlarm->delta);
- rep.delta_lo = XSyncValueLow32(pAlarm->delta);
- rep.events = pAlarm->events;
- rep.state = pAlarm->state;
-
- if (client->swapped)
- {
- char n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.counter, n);
- swapl(&rep.wait_value_hi, n);
- swapl(&rep.wait_value_lo, n);
- swapl(&rep.test_type, n);
- swapl(&rep.delta_hi, n);
- swapl(&rep.delta_lo, n);
- }
-
- WriteToClient(client, sizeof(xSyncQueryAlarmReply), (char *) &rep);
- return Success;
-}
-
-static int
-ProcSyncDestroyAlarm(ClientPtr client)
-{
- SyncAlarm *pAlarm;
- int rc;
- REQUEST(xSyncDestroyAlarmReq);
-
- REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq);
-
- rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm,
- client, DixDestroyAccess);
- if (rc != Success)
- return rc;
-
- FreeResource(stuff->alarm, RT_NONE);
- return Success;
-}
-
-static int
-ProcSyncCreateFence(ClientPtr client)
-{
- REQUEST(xSyncCreateFenceReq);
- DrawablePtr pDraw;
- SyncFence *pFence;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncCreateFenceReq);
-
- rc = dixLookupDrawable(&pDraw, stuff->d, client, M_ANY, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- LEGAL_NEW_RESOURCE(stuff->fid, client);
-
- if (!(pFence = (SyncFence *)SyncCreate(client,
- stuff->fid,
- SYNC_FENCE)))
- return BadAlloc;
-
- miSyncInitFence(pDraw->pScreen, pFence, stuff->initially_triggered);
-
- return client->noClientException;
-}
-
-static int
-FreeFence(void *obj, XID id)
-{
- SyncFence *pFence = (SyncFence *) obj;
-
- miSyncDestroyFence(pFence);
-
- return Success;
-}
-
-int SyncVerifyFence(SyncFence **ppSyncFence, XID fid,
- ClientPtr client, Mask mode)
-{
- int rc = dixLookupResourceByType((pointer *)ppSyncFence, fid, RTFence,
- client, mode);
-
- if (rc != Success)
- client->errorValue = fid;
-
- return rc;
-}
-
-static int
-ProcSyncTriggerFence(ClientPtr client)
-{
- REQUEST(xSyncTriggerFenceReq);
- SyncFence *pFence;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncTriggerFenceReq);
-
- rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence,
- client, DixWriteAccess);
- if (rc != Success)
- return rc;
-
- miSyncTriggerFence(pFence);
-
- return client->noClientException;
-}
-
-static int
-ProcSyncResetFence(ClientPtr client)
-{
- REQUEST(xSyncResetFenceReq);
- SyncFence *pFence;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncResetFenceReq);
-
- rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence,
- client, DixWriteAccess);
- if (rc != Success)
- return rc;
-
- if (pFence->funcs.CheckTriggered(pFence) != TRUE)
- return BadMatch;
-
- pFence->funcs.Reset(pFence);
-
- return client->noClientException;
-}
-
-static int
-ProcSyncDestroyFence(ClientPtr client)
-{
- REQUEST(xSyncDestroyFenceReq);
- SyncFence *pFence;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncDestroyFenceReq);
-
- rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence,
- client, DixDestroyAccess);
- if (rc != Success)
- return rc;
-
- FreeResource(stuff->fid, RT_NONE);
- return client->noClientException;
-}
-
-static int
-ProcSyncQueryFence(ClientPtr client)
-{
- REQUEST(xSyncQueryFenceReq);
- xSyncQueryFenceReply rep;
- SyncFence *pFence;
- int rc;
-
- REQUEST_SIZE_MATCH(xSyncQueryFenceReq);
-
- rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid,
- RTFence, client, DixReadAccess);
- if (rc != Success)
- return rc;
-
- rep.type = X_Reply;
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- rep.triggered = pFence->funcs.CheckTriggered(pFence);
-
- if (client->swapped)
- {
- char n;
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- }
-
- WriteToClient(client, sizeof(xSyncQueryFenceReply), (char *) &rep);
- return client->noClientException;
-}
-
-static int
-ProcSyncAwaitFence(ClientPtr client)
-{
- REQUEST(xSyncAwaitFenceReq);
- SyncAwaitUnion *pAwaitUnion;
- SyncAwait *pAwait;
- /* Use CARD32 rather than XSyncFence because XIDs are hard-coded to
- * CARD32 in protocol definitions */
- CARD32 *pProtocolFences;
- int status;
- int len;
- int items;
- int i;
-
- REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq);
-
- len = client->req_len << 2;
- len -= sz_xSyncAwaitFenceReq;
- items = len / sizeof(CARD32);
-
- if (items * sizeof(CARD32) != len)
- {
- return BadLength;
- }
- if (items == 0)
- {
- client->errorValue = items; /* XXX protocol change */
- return BadValue;
- }
-
- if (!(pAwaitUnion = SyncAwaitPrologue(client, items)))
- return BadAlloc;
-
- /* don't need to do any more memory allocation for this request! */
-
- pProtocolFences = (CARD32 *) & stuff[1];
-
- pAwait = &(pAwaitUnion+1)->await; /* skip over header */
- for (i = 0; i < items; i++, pProtocolFences++, pAwait++)
- {
- if (*pProtocolFences == None) /* XXX protocol change */
- {
- /* this should take care of removing any triggers created by
- * this request that have already been registered on sync objects
- */
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
- client->errorValue = *pProtocolFences;
- return SyncErrorBase + XSyncBadCounter;
- }
-
- pAwait->trigger.pSync = NULL;
- /* Provide acceptable values for these unused fields to
- * satisfy SyncInitTrigger's validation logic
- */
- pAwait->trigger.value_type = XSyncAbsolute;
- XSyncIntToValue(&pAwait->trigger.wait_value, 0);
- pAwait->trigger.test_type = 0;
-
- status = SyncInitTrigger(client, &pAwait->trigger,
- *pProtocolFences, RTFence,
- XSyncCAAllTrigger);
- if (status != Success)
- {
- /* this should take care of removing any triggers created by
- * this request that have already been registered on sync objects
- */
- FreeResource(pAwaitUnion->header.delete_id, RT_NONE);
- return status;
- }
- /* this is not a mistake -- same function works for both cases */
- pAwait->trigger.TriggerFired = SyncAwaitTriggerFired;
- pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired;
- /* event_threshold is unused for fence syncs */
- XSyncIntToValue(&pAwait->event_threshold, 0);
- pAwait->pHeader = &pAwaitUnion->header;
- pAwaitUnion->header.num_waitconditions++;
- }
-
- SyncAwaitEpilogue(client, items, pAwaitUnion);
-
- return client->noClientException;
-}
-
-/*
- * ** Given an extension request, call the appropriate request procedure
- */
-static int
-ProcSyncDispatch(ClientPtr client)
-{
- REQUEST(xReq);
-
- switch (stuff->data)
- {
- case X_SyncInitialize:
- return ProcSyncInitialize(client);
- case X_SyncListSystemCounters:
- return ProcSyncListSystemCounters(client);
- case X_SyncCreateCounter:
- return ProcSyncCreateCounter(client);
- case X_SyncSetCounter:
- return ProcSyncSetCounter(client);
- case X_SyncChangeCounter:
- return ProcSyncChangeCounter(client);
- case X_SyncQueryCounter:
- return ProcSyncQueryCounter(client);
- case X_SyncDestroyCounter:
- return ProcSyncDestroyCounter(client);
- case X_SyncAwait:
- return ProcSyncAwait(client);
- case X_SyncCreateAlarm:
- return ProcSyncCreateAlarm(client);
- case X_SyncChangeAlarm:
- return ProcSyncChangeAlarm(client);
- case X_SyncQueryAlarm:
- return ProcSyncQueryAlarm(client);
- case X_SyncDestroyAlarm:
- return ProcSyncDestroyAlarm(client);
- case X_SyncSetPriority:
- return ProcSyncSetPriority(client);
- case X_SyncGetPriority:
- return ProcSyncGetPriority(client);
- case X_SyncCreateFence:
- return ProcSyncCreateFence(client);
- case X_SyncTriggerFence:
- return ProcSyncTriggerFence(client);
- case X_SyncResetFence:
- return ProcSyncResetFence(client);
- case X_SyncDestroyFence:
- return ProcSyncDestroyFence(client);
- case X_SyncQueryFence:
- return ProcSyncQueryFence(client);
- case X_SyncAwaitFence:
- return ProcSyncAwaitFence(client);
- default:
- return BadRequest;
- }
-}
-
-/*
- * Boring Swapping stuff ...
- */
-
-static int
-SProcSyncInitialize(ClientPtr client)
-{
- REQUEST(xSyncInitializeReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncInitializeReq);
-
- return ProcSyncInitialize(client);
-}
-
-static int
-SProcSyncListSystemCounters(ClientPtr client)
-{
- REQUEST(xSyncListSystemCountersReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncListSystemCountersReq);
-
- return ProcSyncListSystemCounters(client);
-}
-
-static int
-SProcSyncCreateCounter(ClientPtr client)
-{
- REQUEST(xSyncCreateCounterReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncCreateCounterReq);
- swapl(&stuff->cid, n);
- swapl(&stuff->initial_value_lo, n);
- swapl(&stuff->initial_value_hi, n);
-
- return ProcSyncCreateCounter(client);
-}
-
-static int
-SProcSyncSetCounter(ClientPtr client)
-{
- REQUEST(xSyncSetCounterReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncSetCounterReq);
- swapl(&stuff->cid, n);
- swapl(&stuff->value_lo, n);
- swapl(&stuff->value_hi, n);
-
- return ProcSyncSetCounter(client);
-}
-
-static int
-SProcSyncChangeCounter(ClientPtr client)
-{
- REQUEST(xSyncChangeCounterReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncChangeCounterReq);
- swapl(&stuff->cid, n);
- swapl(&stuff->value_lo, n);
- swapl(&stuff->value_hi, n);
-
- return ProcSyncChangeCounter(client);
-}
-
-static int
-SProcSyncQueryCounter(ClientPtr client)
-{
- REQUEST(xSyncQueryCounterReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncQueryCounterReq);
- swapl(&stuff->counter, n);
-
- return ProcSyncQueryCounter(client);
-}
-
-static int
-SProcSyncDestroyCounter(ClientPtr client)
-{
- REQUEST(xSyncDestroyCounterReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncDestroyCounterReq);
- swapl(&stuff->counter, n);
-
- return ProcSyncDestroyCounter(client);
-}
-
-static int
-SProcSyncAwait(ClientPtr client)
-{
- REQUEST(xSyncAwaitReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xSyncAwaitReq);
- SwapRestL(stuff);
-
- return ProcSyncAwait(client);
-}
-
-static int
-SProcSyncCreateAlarm(ClientPtr client)
-{
- REQUEST(xSyncCreateAlarmReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq);
- swapl(&stuff->id, n);
- swapl(&stuff->valueMask, n);
- SwapRestL(stuff);
-
- return ProcSyncCreateAlarm(client);
-}
-
-static int
-SProcSyncChangeAlarm(ClientPtr client)
-{
- REQUEST(xSyncChangeAlarmReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq);
- swapl(&stuff->alarm, n);
- swapl(&stuff->valueMask, n);
- SwapRestL(stuff);
- return ProcSyncChangeAlarm(client);
-}
-
-static int
-SProcSyncQueryAlarm(ClientPtr client)
-{
- REQUEST(xSyncQueryAlarmReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncQueryAlarmReq);
- swapl(&stuff->alarm, n);
-
- return ProcSyncQueryAlarm(client);
-}
-
-static int
-SProcSyncDestroyAlarm(ClientPtr client)
-{
- REQUEST(xSyncDestroyAlarmReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncDestroyAlarmReq);
- swapl(&stuff->alarm, n);
-
- return ProcSyncDestroyAlarm(client);
-}
-
-static int
-SProcSyncSetPriority(ClientPtr client)
-{
- REQUEST(xSyncSetPriorityReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncSetPriorityReq);
- swapl(&stuff->id, n);
- swapl(&stuff->priority, n);
-
- return ProcSyncSetPriority(client);
-}
-
-static int
-SProcSyncGetPriority(ClientPtr client)
-{
- REQUEST(xSyncGetPriorityReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncGetPriorityReq);
- swapl(&stuff->id, n);
-
- return ProcSyncGetPriority(client);
-}
-
-static int
-SProcSyncCreateFence(ClientPtr client)
-{
- REQUEST(xSyncCreateFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncCreateFenceReq);
- swapl(&stuff->fid, n);
-
- return ProcSyncCreateFence(client);
-}
-
-static int
-SProcSyncTriggerFence(ClientPtr client)
-{
- REQUEST(xSyncTriggerFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncTriggerFenceReq);
- swapl(&stuff->fid, n);
-
- return ProcSyncTriggerFence(client);
-}
-
-static int
-SProcSyncResetFence(ClientPtr client)
-{
- REQUEST(xSyncResetFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncResetFenceReq);
- swapl(&stuff->fid, n);
-
- return ProcSyncResetFence(client);
-}
-
-static int
-SProcSyncDestroyFence(ClientPtr client)
-{
- REQUEST(xSyncDestroyFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncDestroyFenceReq);
- swapl(&stuff->fid, n);
-
- return ProcSyncDestroyFence(client);
-}
-
-static int
-SProcSyncQueryFence(ClientPtr client)
-{
- REQUEST(xSyncQueryFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_SIZE_MATCH (xSyncQueryFenceReq);
- swapl(&stuff->fid, n);
-
- return ProcSyncQueryFence(client);
-}
-
-static int
-SProcSyncAwaitFence(ClientPtr client)
-{
- REQUEST(xSyncAwaitFenceReq);
- char n;
-
- swaps(&stuff->length, n);
- REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq);
- SwapRestL(stuff);
-
- return ProcSyncAwaitFence(client);
-}
-
-static int
-SProcSyncDispatch(ClientPtr client)
-{
- REQUEST(xReq);
-
- switch (stuff->data)
- {
- case X_SyncInitialize:
- return SProcSyncInitialize(client);
- case X_SyncListSystemCounters:
- return SProcSyncListSystemCounters(client);
- case X_SyncCreateCounter:
- return SProcSyncCreateCounter(client);
- case X_SyncSetCounter:
- return SProcSyncSetCounter(client);
- case X_SyncChangeCounter:
- return SProcSyncChangeCounter(client);
- case X_SyncQueryCounter:
- return SProcSyncQueryCounter(client);
- case X_SyncDestroyCounter:
- return SProcSyncDestroyCounter(client);
- case X_SyncAwait:
- return SProcSyncAwait(client);
- case X_SyncCreateAlarm:
- return SProcSyncCreateAlarm(client);
- case X_SyncChangeAlarm:
- return SProcSyncChangeAlarm(client);
- case X_SyncQueryAlarm:
- return SProcSyncQueryAlarm(client);
- case X_SyncDestroyAlarm:
- return SProcSyncDestroyAlarm(client);
- case X_SyncSetPriority:
- return SProcSyncSetPriority(client);
- case X_SyncGetPriority:
- return SProcSyncGetPriority(client);
- case X_SyncCreateFence:
- return SProcSyncCreateFence(client);
- case X_SyncTriggerFence:
- return SProcSyncTriggerFence(client);
- case X_SyncResetFence:
- return SProcSyncResetFence(client);
- case X_SyncDestroyFence:
- return SProcSyncDestroyFence(client);
- case X_SyncQueryFence:
- return SProcSyncQueryFence(client);
- case X_SyncAwaitFence:
- return SProcSyncAwaitFence(client);
- default:
- return BadRequest;
- }
-}
-
-/*
- * Event Swapping
- */
-
-static void
-SCounterNotifyEvent(xSyncCounterNotifyEvent *from, xSyncCounterNotifyEvent *to)
-{
- to->type = from->type;
- to->kind = from->kind;
- cpswaps(from->sequenceNumber, to->sequenceNumber);
- cpswapl(from->counter, to->counter);
- cpswapl(from->wait_value_lo, to->wait_value_lo);
- cpswapl(from->wait_value_hi, to->wait_value_hi);
- cpswapl(from->counter_value_lo, to->counter_value_lo);
- cpswapl(from->counter_value_hi, to->counter_value_hi);
- cpswapl(from->time, to->time);
- cpswaps(from->count, to->count);
- to->destroyed = from->destroyed;
-}
-
-
-static void
-SAlarmNotifyEvent(xSyncAlarmNotifyEvent *from, xSyncAlarmNotifyEvent *to)
-{
- to->type = from->type;
- to->kind = from->kind;
- cpswaps(from->sequenceNumber, to->sequenceNumber);
- cpswapl(from->alarm, to->alarm);
- cpswapl(from->counter_value_lo, to->counter_value_lo);
- cpswapl(from->counter_value_hi, to->counter_value_hi);
- cpswapl(from->alarm_value_lo, to->alarm_value_lo);
- cpswapl(from->alarm_value_hi, to->alarm_value_hi);
- cpswapl(from->time, to->time);
- to->state = from->state;
-}
-
-/*
- * ** Close everything down. ** This is fairly simple for now.
- */
-/* ARGSUSED */
-static void
-SyncResetProc(ExtensionEntry *extEntry)
-{
- free(SysCounterList);
- SysCounterList = NULL;
- RTCounter = 0;
-}
-
-/*
- * ** Initialise the extension.
- */
-void
-SyncExtensionInit(void)
-{
- ExtensionEntry *extEntry;
- int s;
-
- for (s = 0; s < screenInfo.numScreens; s++)
- miSyncSetup(screenInfo.screens[s]);
-
- if (RTCounter == 0)
- {
- RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter");
- }
- RTAlarm = CreateNewResourceType(FreeAlarm, "SyncAlarm");
- RTAwait = CreateNewResourceType(FreeAwait, "SyncAwait");
- RTFence = CreateNewResourceType(FreeFence, "SyncFence");
- if (RTAwait)
- RTAwait |= RC_NEVERRETAIN;
- RTAlarmClient = CreateNewResourceType(FreeAlarmClient, "SyncAlarmClient");
- if (RTAlarmClient)
- RTAlarmClient |= RC_NEVERRETAIN;
-
- if (RTCounter == 0 || RTAwait == 0 || RTAlarm == 0 ||
- RTAlarmClient == 0 ||
- (extEntry = AddExtension(SYNC_NAME,
- XSyncNumberEvents, XSyncNumberErrors,
- ProcSyncDispatch, SProcSyncDispatch,
- SyncResetProc,
- StandardMinorOpcode)) == NULL)
- {
- ErrorF("Sync Extension %d.%d failed to Initialise\n",
- SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION);
- return;
- }
-
- SyncEventBase = extEntry->eventBase;
- SyncErrorBase = extEntry->errorBase;
- EventSwapVector[SyncEventBase + XSyncCounterNotify] = (EventSwapPtr) SCounterNotifyEvent;
- EventSwapVector[SyncEventBase + XSyncAlarmNotify] = (EventSwapPtr) SAlarmNotifyEvent;
-
- SetResourceTypeErrorValue(RTCounter, SyncErrorBase + XSyncBadCounter);
- SetResourceTypeErrorValue(RTAlarm, SyncErrorBase + XSyncBadAlarm);
- SetResourceTypeErrorValue(RTFence, SyncErrorBase + XSyncBadFence);
-
- /*
- * Although SERVERTIME is implemented by the OS layer, we initialise it
- * here because doing it in OsInit() is too early. The resource database
- * is not initialised when OsInit() is called. This is just about OK
- * because there is always a servertime counter.
- */
- SyncInitServerTime();
- SyncInitIdleTime();
-
-#ifdef DEBUG
- fprintf(stderr, "Sync Extension %d.%d\n",
- SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION);
-#endif
-}
-
-
-/*
- * ***** SERVERTIME implementation - should go in its own file in OS directory?
- */
-
-
-
-static pointer ServertimeCounter;
-static XSyncValue Now;
-static XSyncValue *pnext_time;
-
-#define GetTime()\
-{\
- unsigned long millis = GetTimeInMillis();\
- unsigned long maxis = XSyncValueHigh32(Now);\
- if (millis < XSyncValueLow32(Now)) maxis++;\
- XSyncIntsToValue(&Now, millis, maxis);\
-}
-
-/*
-*** Server Block Handler
-*** code inspired by multibuffer extension (now deprecated)
- */
-/*ARGSUSED*/
-static void
-ServertimeBlockHandler(void *env, struct timeval **wt, void *LastSelectMask)
-{
- XSyncValue delay;
- unsigned long timeout;
-
- if (pnext_time)
- {
- GetTime();
-
- if (XSyncValueGreaterOrEqual(Now, *pnext_time))
- {
- timeout = 0;
- }
- else
- {
- Bool overflow;
- XSyncValueSubtract(&delay, *pnext_time, Now, &overflow);
- (void)overflow;
- timeout = XSyncValueLow32(delay);
- }
- AdjustWaitForDelay(wt, timeout); /* os/utils.c */
- }
-}
-
-/*
-*** Wakeup Handler
- */
-/*ARGSUSED*/
-static void
-ServertimeWakeupHandler(void *env, int rc, void *LastSelectMask)
-{
- if (pnext_time)
- {
- GetTime();
-
- if (XSyncValueGreaterOrEqual(Now, *pnext_time))
- {
- SyncChangeCounter(ServertimeCounter, Now);
- }
- }
-}
-
-static void
-ServertimeQueryValue(void *pCounter, CARD64 *pValue_return)
-{
- GetTime();
- *pValue_return = Now;
-}
-
-static void
-ServertimeBracketValues(void *pCounter, CARD64 *pbracket_less,
- CARD64 *pbracket_greater)
-{
- if (!pnext_time && pbracket_greater)
- {
- RegisterBlockAndWakeupHandlers(ServertimeBlockHandler,
- ServertimeWakeupHandler,
- NULL);
- }
- else if (pnext_time && !pbracket_greater)
- {
- RemoveBlockAndWakeupHandlers(ServertimeBlockHandler,
- ServertimeWakeupHandler,
- NULL);
- }
- pnext_time = pbracket_greater;
-}
-
-static void
-SyncInitServerTime(void)
-{
- CARD64 resolution;
-
- XSyncIntsToValue(&Now, GetTimeInMillis(), 0);
- XSyncIntToValue(&resolution, 4);
- ServertimeCounter = SyncCreateSystemCounter("SERVERTIME", Now, resolution,
- XSyncCounterNeverDecreases,
- ServertimeQueryValue, ServertimeBracketValues);
- pnext_time = NULL;
-}
-
-
-
-/*
- * IDLETIME implementation
- */
-
-static SyncCounter *IdleTimeCounter;
-static XSyncValue *pIdleTimeValueLess;
-static XSyncValue *pIdleTimeValueGreater;
-
-static void
-IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return)
-{
- CARD32 idle = GetTimeInMillis() - lastDeviceEventTime.milliseconds;
- XSyncIntsToValue (pValue_return, idle, 0);
-}
-
-static void
-IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask)
-{
- XSyncValue idle, old_idle;
- SyncTriggerList *list = IdleTimeCounter->sync.pTriglist;
- SyncTrigger *trig;
-
- if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
- return;
-
- old_idle = IdleTimeCounter->value;
- IdleTimeQueryValue (NULL, &idle);
- IdleTimeCounter->value = idle; /* push, so CheckTrigger works */
-
- if (pIdleTimeValueLess &&
- XSyncValueLessOrEqual (idle, *pIdleTimeValueLess))
- {
- /*
- * We've been idle for less than the threshold value, and someone
- * wants to know about that, but now we need to know whether they
- * want level or edge trigger. Check the trigger list against the
- * current idle time, and if any succeed, bomb out of select()
- * immediately so we can reschedule.
- */
-
- for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) {
- trig = list->pTrigger;
- if (trig->CheckTrigger(trig, old_idle)) {
- AdjustWaitForDelay(wt, 0);
- break;
- }
- }
- }
- else if (pIdleTimeValueGreater)
- {
- /*
- * There's a threshold in the positive direction. If we've been
- * idle less than it, schedule a wakeup for sometime in the future.
- * If we've been idle more than it, and someone wants to know about
- * that level-triggered, schedule an immediate wakeup.
- */
- unsigned long timeout = -1;
-
- if (XSyncValueLessThan (idle, *pIdleTimeValueGreater)) {
- XSyncValue value;
- Bool overflow;
-
- XSyncValueSubtract (&value, *pIdleTimeValueGreater,
- idle, &overflow);
- timeout = min(timeout, XSyncValueLow32 (value));
- } else {
- for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) {
- trig = list->pTrigger;
- if (trig->CheckTrigger(trig, old_idle)) {
- timeout = min(timeout, 0);
- break;
- }
- }
- }
-
- AdjustWaitForDelay (wt, timeout);
- }
-
- IdleTimeCounter->value = old_idle; /* pop */
-}
-
-static void
-IdleTimeWakeupHandler (pointer env, int rc, pointer LastSelectMask)
-{
- XSyncValue idle;
-
- if (!pIdleTimeValueLess && !pIdleTimeValueGreater)
- return;
-
- IdleTimeQueryValue (NULL, &idle);
-
- if ((pIdleTimeValueGreater &&
- XSyncValueGreaterOrEqual (idle, *pIdleTimeValueGreater)) ||
- (pIdleTimeValueLess &&
- XSyncValueLessOrEqual (idle, *pIdleTimeValueLess)))
- {
- SyncChangeCounter (IdleTimeCounter, idle);
- }
-}
-
-static void
-IdleTimeBracketValues (pointer pCounter, CARD64 *pbracket_less,
- CARD64 *pbracket_greater)
-{
- Bool registered = (pIdleTimeValueLess || pIdleTimeValueGreater);
-
- if (registered && !pbracket_less && !pbracket_greater)
- {
- RemoveBlockAndWakeupHandlers(IdleTimeBlockHandler,
- IdleTimeWakeupHandler,
- NULL);
- }
- else if (!registered && (pbracket_less || pbracket_greater))
- {
- RegisterBlockAndWakeupHandlers(IdleTimeBlockHandler,
- IdleTimeWakeupHandler,
- NULL);
- }
-
- pIdleTimeValueGreater = pbracket_greater;
- pIdleTimeValueLess = pbracket_less;
-}
-
-static void
-SyncInitIdleTime (void)
-{
- CARD64 resolution;
- XSyncValue idle;
-
- IdleTimeQueryValue (NULL, &idle);
- XSyncIntToValue (&resolution, 4);
-
- IdleTimeCounter = SyncCreateSystemCounter ("IDLETIME", idle, resolution,
- XSyncCounterUnrestricted,
- IdleTimeQueryValue,
- IdleTimeBracketValues);
-
- pIdleTimeValueLess = pIdleTimeValueGreater = NULL;
-}
+/* + +Copyright 1991, 1993, 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 1991, 1993 by Digital Equipment Corporation, Maynard, Massachusetts, +and Olivetti Research Limited, Cambridge, England. + + 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 names of Digital or Olivetti +not be used in advertising or publicity pertaining to distribution of the +software without specific, written prior permission. Digital and Olivetti +make no representations about the suitability of this software +for any purpose. It is provided "as is" without express or implied warranty. + +DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS +SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL THEY 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 <string.h> + +#include <X11/X.h> +#include <X11/Xproto.h> +#include <X11/Xmd.h> +#include "scrnintstr.h" +#include "os.h" +#include "extnsionst.h" +#include "dixstruct.h" +#include "pixmapstr.h" +#include "resource.h" +#include "opaque.h" +#include <X11/extensions/syncproto.h> +#include "syncsrv.h" +#include "syncsdk.h" +#include "protocol-versions.h" + +#include <stdio.h> +#if !defined(WIN32) +#include <sys/time.h> +#endif + +#include "modinit.h" + +/* + * Local Global Variables + */ +static int SyncEventBase; +static int SyncErrorBase; +static RESTYPE RTCounter = 0; +static RESTYPE RTAwait; +static RESTYPE RTAlarm; +static RESTYPE RTAlarmClient; +static RESTYPE RTFence; +static int SyncNumSystemCounters = 0; +static SyncCounter **SysCounterList = NULL; + +#define IsSystemCounter(pCounter) \ + (pCounter && (pCounter->sync.client == NULL)) + +/* these are all the alarm attributes that pertain to the alarm's trigger */ +#define XSyncCAAllTrigger \ + (XSyncCACounter | XSyncCAValueType | XSyncCAValue | XSyncCATestType) + +static void SyncComputeBracketValues(SyncCounter *); + +static void SyncInitServerTime(void); + +static void SyncInitIdleTime(void); + + +/* Each counter maintains a simple linked list of triggers that are + * interested in the counter. The two functions below are used to + * delete and add triggers on this list. + */ +static void +SyncDeleteTriggerFromSyncObject(SyncTrigger *pTrigger) +{ + SyncTriggerList *pCur; + SyncTriggerList *pPrev; + SyncCounter *pCounter; + + /* pSync needs to be stored in pTrigger before calling here. */ + + if (!pTrigger->pSync) + return; + + pPrev = NULL; + pCur = pTrigger->pSync->pTriglist; + + while (pCur) + { + if (pCur->pTrigger == pTrigger) + { + if (pPrev) + pPrev->next = pCur->next; + else + pTrigger->pSync->pTriglist = pCur->next; + + free(pCur); + break; + } + + pPrev = pCur; + pCur = pCur->next; + } + + if (SYNC_COUNTER == pTrigger->pSync->type) + { + pCounter = (SyncCounter *)pTrigger->pSync; + + if (IsSystemCounter(pCounter)) + SyncComputeBracketValues(pCounter); + } else if (SYNC_FENCE == pTrigger->pSync->type) { + SyncFence* pFence = (SyncFence*) pTrigger->pSync; + pFence->funcs.DeleteTrigger(pTrigger); + } +} + + +static int +SyncAddTriggerToSyncObject(SyncTrigger *pTrigger) +{ + SyncTriggerList *pCur; + SyncCounter *pCounter; + + if (!pTrigger->pSync) + return Success; + + /* don't do anything if it's already there */ + for (pCur = pTrigger->pSync->pTriglist; pCur; pCur = pCur->next) + { + if (pCur->pTrigger == pTrigger) + return Success; + } + + if (!(pCur = malloc(sizeof(SyncTriggerList)))) + return BadAlloc; + + pCur->pTrigger = pTrigger; + pCur->next = pTrigger->pSync->pTriglist; + pTrigger->pSync->pTriglist = pCur; + + if (SYNC_COUNTER == pTrigger->pSync->type) + { + pCounter = (SyncCounter *)pTrigger->pSync; + + if (IsSystemCounter(pCounter)) + SyncComputeBracketValues(pCounter); + } else if (SYNC_FENCE == pTrigger->pSync->type) { + SyncFence* pFence = (SyncFence*) pTrigger->pSync; + pFence->funcs.AddTrigger(pTrigger); + } + + return Success; +} + + +/* Below are five possible functions that can be plugged into + * pTrigger->CheckTrigger for counter sync objects, corresponding to + * the four possible test-types, and the one possible function that + * can be plugged into pTrigger->CheckTrigger for fence sync objects. + * These functions are called after the sync object's state changes + * but are also passed the old state so they can inspect both the old + * and new values. (PositiveTransition and NegativeTransition need to + * see both pieces of information.) These functions return the truth + * value of the trigger. + * + * All of them include the condition pTrigger->pSync == NULL. + * This is because the spec says that a trigger with a sync value + * of None is always TRUE. + */ + +static Bool +SyncCheckTriggerPositiveComparison(SyncTrigger *pTrigger, CARD64 oldval) +{ + SyncCounter *pCounter; + + assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); + pCounter = (SyncCounter *)pTrigger->pSync; + + return (pCounter == NULL || + XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value)); +} + +static Bool +SyncCheckTriggerNegativeComparison(SyncTrigger *pTrigger, CARD64 oldval) +{ + SyncCounter *pCounter; + + assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); + pCounter = (SyncCounter *)pTrigger->pSync; + + return (pCounter == NULL || + XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value)); +} + +static Bool +SyncCheckTriggerPositiveTransition(SyncTrigger *pTrigger, CARD64 oldval) +{ + SyncCounter *pCounter; + + assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); + pCounter = (SyncCounter *)pTrigger->pSync; + + return (pCounter == NULL || + (XSyncValueLessThan(oldval, pTrigger->test_value) && + XSyncValueGreaterOrEqual(pCounter->value, pTrigger->test_value))); +} + +static Bool +SyncCheckTriggerNegativeTransition(SyncTrigger *pTrigger, CARD64 oldval) +{ + SyncCounter *pCounter; + + assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); + pCounter = (SyncCounter *)pTrigger->pSync; + + return (pCounter == NULL || + (XSyncValueGreaterThan(oldval, pTrigger->test_value) && + XSyncValueLessOrEqual(pCounter->value, pTrigger->test_value))); +} + +static Bool +SyncCheckTriggerFence(SyncTrigger *pTrigger, CARD64 unused) +{ + SyncFence* pFence = (SyncFence*) pTrigger->pSync; + (void)unused; + + return (pFence == NULL || + pFence->funcs.CheckTriggered(pFence)); +} + +static int +SyncInitTrigger(ClientPtr client, SyncTrigger *pTrigger, XID syncObject, + RESTYPE resType, Mask changes) +{ + SyncObject *pSync = pTrigger->pSync; + SyncCounter *pCounter = NULL; + int rc; + Bool newSyncObject = FALSE; + + if (changes & XSyncCACounter) + { + if (syncObject == None) + pSync = NULL; + else if (Success != (rc = dixLookupResourceByType ((pointer *)&pSync, + syncObject, resType, client, DixReadAccess))) + { + client->errorValue = syncObject; + return rc; + } + if (pSync != pTrigger->pSync) + { /* new counter for trigger */ + SyncDeleteTriggerFromSyncObject(pTrigger); + pTrigger->pSync = pSync; + newSyncObject = TRUE; + } + } + + /* if system counter, ask it what the current value is */ + + if (pSync && SYNC_COUNTER == pSync->type) + { + pCounter = (SyncCounter *)pSync; + + if (IsSystemCounter(pCounter)) + { + (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter, + &pCounter->value); + } + } + + if (changes & XSyncCAValueType) + { + if (pTrigger->value_type != XSyncRelative && + pTrigger->value_type != XSyncAbsolute) + { + client->errorValue = pTrigger->value_type; + return BadValue; + } + } + + if (changes & XSyncCATestType) + { + + if (pSync && SYNC_FENCE == pSync->type) + { + pTrigger->CheckTrigger = SyncCheckTriggerFence; + } + else + { + if (pTrigger->test_type != XSyncPositiveTransition && + pTrigger->test_type != XSyncNegativeTransition && + pTrigger->test_type != XSyncPositiveComparison && + pTrigger->test_type != XSyncNegativeComparison) + { + client->errorValue = pTrigger->test_type; + return BadValue; + } + /* select appropriate CheckTrigger function */ + + switch (pTrigger->test_type) + { + case XSyncPositiveTransition: + pTrigger->CheckTrigger = SyncCheckTriggerPositiveTransition; + break; + case XSyncNegativeTransition: + pTrigger->CheckTrigger = SyncCheckTriggerNegativeTransition; + break; + case XSyncPositiveComparison: + pTrigger->CheckTrigger = SyncCheckTriggerPositiveComparison; + break; + case XSyncNegativeComparison: + pTrigger->CheckTrigger = SyncCheckTriggerNegativeComparison; + break; + } + } + } + + if (changes & (XSyncCAValueType | XSyncCAValue)) + { + if (pTrigger->value_type == XSyncAbsolute) + pTrigger->test_value = pTrigger->wait_value; + else /* relative */ + { + Bool overflow; + if (pCounter == NULL) + return BadMatch; + + XSyncValueAdd(&pTrigger->test_value, pCounter->value, + pTrigger->wait_value, &overflow); + if (overflow) + { + client->errorValue = XSyncValueHigh32(pTrigger->wait_value); + return BadValue; + } + } + } + + /* we wait until we're sure there are no errors before registering + * a new counter on a trigger + */ + if (newSyncObject) + { + if ((rc = SyncAddTriggerToSyncObject(pTrigger)) != Success) + return rc; + } + else if (pCounter && IsSystemCounter(pCounter)) + { + SyncComputeBracketValues(pCounter); + } + + return Success; +} + +/* AlarmNotify events happen in response to actions taken on an Alarm or + * the counter used by the alarm. AlarmNotify may be sent to multiple + * clients. The alarm maintains a list of clients interested in events. + */ +static void +SyncSendAlarmNotifyEvents(SyncAlarm *pAlarm) +{ + SyncAlarmClientList *pcl; + xSyncAlarmNotifyEvent ane; + SyncTrigger *pTrigger = &pAlarm->trigger; + SyncCounter *pCounter; + + assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); + + pCounter = (SyncCounter *)pTrigger->pSync; + + UpdateCurrentTime(); + + ane.type = SyncEventBase + XSyncAlarmNotify; + ane.kind = XSyncAlarmNotify; + ane.alarm = pAlarm->alarm_id; + if (pTrigger->pSync && SYNC_COUNTER == pTrigger->pSync->type) + { + ane.counter_value_hi = XSyncValueHigh32(pCounter->value); + ane.counter_value_lo = XSyncValueLow32(pCounter->value); + } + else + { /* XXX what else can we do if there's no counter? */ + ane.counter_value_hi = ane.counter_value_lo = 0; + } + + ane.alarm_value_hi = XSyncValueHigh32(pTrigger->test_value); + ane.alarm_value_lo = XSyncValueLow32(pTrigger->test_value); + ane.time = currentTime.milliseconds; + ane.state = pAlarm->state; + + /* send to owner */ + if (pAlarm->events) + WriteEventsToClient(pAlarm->client, 1, (xEvent *) &ane); + + /* send to other interested clients */ + for (pcl = pAlarm->pEventClients; pcl; pcl = pcl->next) + WriteEventsToClient(pcl->client, 1, (xEvent *) &ane); +} + + +/* CounterNotify events only occur in response to an Await. The events + * go only to the Awaiting client. + */ +static void +SyncSendCounterNotifyEvents(ClientPtr client, SyncAwait **ppAwait, + int num_events) +{ + xSyncCounterNotifyEvent *pEvents, *pev; + int i; + + if (client->clientGone) + return; + pev = pEvents = malloc(num_events * sizeof(xSyncCounterNotifyEvent)); + if (!pEvents) + return; + UpdateCurrentTime(); + for (i = 0; i < num_events; i++, ppAwait++, pev++) + { + SyncTrigger *pTrigger = &(*ppAwait)->trigger; + pev->type = SyncEventBase + XSyncCounterNotify; + pev->kind = XSyncCounterNotify; + pev->counter = pTrigger->pSync->id; + pev->wait_value_lo = XSyncValueLow32(pTrigger->test_value); + pev->wait_value_hi = XSyncValueHigh32(pTrigger->test_value); + if (SYNC_COUNTER == pTrigger->pSync->type) + { + SyncCounter *pCounter = (SyncCounter *)pTrigger->pSync; + + pev->counter_value_lo = XSyncValueLow32(pCounter->value); + pev->counter_value_hi = XSyncValueHigh32(pCounter->value); + } + else + { + pev->counter_value_lo = 0; + pev->counter_value_hi = 0; + } + + pev->time = currentTime.milliseconds; + pev->count = num_events - i - 1; /* events remaining */ + pev->destroyed = pTrigger->pSync->beingDestroyed; + } + /* swapping will be taken care of by this */ + WriteEventsToClient(client, num_events, (xEvent *)pEvents); + free(pEvents); +} + + +/* This function is called when an alarm's counter is destroyed. + * It is plugged into pTrigger->CounterDestroyed (for alarm triggers). + */ +static void +SyncAlarmCounterDestroyed(SyncTrigger *pTrigger) +{ + SyncAlarm *pAlarm = (SyncAlarm *)pTrigger; + + pAlarm->state = XSyncAlarmInactive; + SyncSendAlarmNotifyEvents(pAlarm); + pTrigger->pSync = NULL; +} + + +/* This function is called when an alarm "goes off." + * It is plugged into pTrigger->TriggerFired (for alarm triggers). + */ +static void +SyncAlarmTriggerFired(SyncTrigger *pTrigger) +{ + SyncAlarm *pAlarm = (SyncAlarm *)pTrigger; + SyncCounter *pCounter; + CARD64 new_test_value; + + assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); + pCounter = (SyncCounter *)pTrigger->pSync; + + /* no need to check alarm unless it's active */ + if (pAlarm->state != XSyncAlarmActive) + return; + + /* " if the counter value is None, or if the delta is 0 and + * the test-type is PositiveComparison or NegativeComparison, + * no change is made to value (test-value) and the alarm + * state is changed to Inactive before the event is generated." + */ + if (pCounter == NULL + || (XSyncValueIsZero(pAlarm->delta) + && (pAlarm->trigger.test_type == XSyncPositiveComparison + || pAlarm->trigger.test_type == XSyncNegativeComparison))) + pAlarm->state = XSyncAlarmInactive; + + new_test_value = pAlarm->trigger.test_value; + + if (pAlarm->state == XSyncAlarmActive) + { + Bool overflow; + CARD64 oldvalue; + SyncTrigger *paTrigger = &pAlarm->trigger; + SyncCounter *paCounter; + + assert(!paTrigger->pSync || (SYNC_COUNTER == paTrigger->pSync->type)); + paCounter = (SyncCounter *)pTrigger->pSync; + + /* "The alarm is updated by repeatedly adding delta to the + * value of the trigger and re-initializing it until it + * becomes FALSE." + */ + oldvalue = paTrigger->test_value; + + /* XXX really should do something smarter here */ + + do + { + XSyncValueAdd(&paTrigger->test_value, paTrigger->test_value, + pAlarm->delta, &overflow); + } while (!overflow && + (*paTrigger->CheckTrigger)(paTrigger, + paCounter->value)); + + new_test_value = paTrigger->test_value; + paTrigger->test_value = oldvalue; + + /* "If this update would cause value to fall outside the range + * for an INT64...no change is made to value (test-value) and + * the alarm state is changed to Inactive before the event is + * generated." + */ + if (overflow) + { + new_test_value = oldvalue; + pAlarm->state = XSyncAlarmInactive; + } + } + /* The AlarmNotify event has to have the "new state of the alarm" + * which we can't be sure of until this point. However, it has + * to have the "old" trigger test value. That's the reason for + * all the newvalue/oldvalue shuffling above. After we send the + * events, give the trigger its new test value. + */ + SyncSendAlarmNotifyEvents(pAlarm); + pTrigger->test_value = new_test_value; +} + + +/* This function is called when an Await unblocks, either as a result + * of the trigger firing OR the counter being destroyed. + * It goes into pTrigger->TriggerFired AND pTrigger->CounterDestroyed + * (for Await triggers). + */ +static void +SyncAwaitTriggerFired(SyncTrigger *pTrigger) +{ + SyncAwait *pAwait = (SyncAwait *)pTrigger; + int numwaits; + SyncAwaitUnion *pAwaitUnion; + SyncAwait **ppAwait; + int num_events = 0; + + pAwaitUnion = (SyncAwaitUnion *)pAwait->pHeader; + numwaits = pAwaitUnion->header.num_waitconditions; + ppAwait = malloc(numwaits * sizeof(SyncAwait *)); + if (!ppAwait) + goto bail; + + pAwait = &(pAwaitUnion+1)->await; + + /* "When a client is unblocked, all the CounterNotify events for + * the Await request are generated contiguously. If count is 0 + * there are no more events to follow for this request. If + * count is n, there are at least n more events to follow." + * + * Thus, it is best to find all the counters for which events + * need to be sent first, so that an accurate count field can + * be stored in the events. + */ + for ( ; numwaits; numwaits--, pAwait++) + { + CARD64 diff; + Bool overflow, diffgreater, diffequal; + + /* "A CounterNotify event with the destroyed flag set to TRUE is + * always generated if the counter for one of the triggers is + * destroyed." + */ + if (pAwait->trigger.pSync->beingDestroyed) + { + ppAwait[num_events++] = pAwait; + continue; + } + + if (SYNC_COUNTER == pAwait->trigger.pSync->type) + { + SyncCounter *pCounter = (SyncCounter *) pAwait->trigger.pSync; + + /* "The difference between the counter and the test value is + * calculated by subtracting the test value from the value of + * the counter." + */ + XSyncValueSubtract(&diff, pCounter->value, + pAwait->trigger.test_value, &overflow); + + /* "If the difference lies outside the range for an INT64, an + * event is not generated." + */ + if (overflow) + continue; + diffgreater = XSyncValueGreaterThan(diff, pAwait->event_threshold); + diffequal = XSyncValueEqual(diff, pAwait->event_threshold); + + /* "If the test-type is PositiveTransition or + * PositiveComparison, a CounterNotify event is generated if + * the difference is at least event-threshold. If the test-type + * is NegativeTransition or NegativeComparison, a CounterNotify + * event is generated if the difference is at most + * event-threshold." + */ + + if ( ((pAwait->trigger.test_type == XSyncPositiveComparison || + pAwait->trigger.test_type == XSyncPositiveTransition) + && (diffgreater || diffequal)) + || + ((pAwait->trigger.test_type == XSyncNegativeComparison || + pAwait->trigger.test_type == XSyncNegativeTransition) + && (!diffgreater) /* less or equal */ + ) + ) + { + ppAwait[num_events++] = pAwait; + } + } + } + if (num_events) + SyncSendCounterNotifyEvents(pAwaitUnion->header.client, ppAwait, + num_events); + free(ppAwait); + +bail: + /* unblock the client */ + AttendClient(pAwaitUnion->header.client); + /* delete the await */ + FreeResource(pAwaitUnion->header.delete_id, RT_NONE); +} + + +/* This function should always be used to change a counter's value so that + * any triggers depending on the counter will be checked. + */ +void +SyncChangeCounter(SyncCounter *pCounter, CARD64 newval) +{ + SyncTriggerList *ptl, *pnext; + CARD64 oldval; + + oldval = pCounter->value; + pCounter->value = newval; + + /* run through triggers to see if any become true */ + for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext) + { + pnext = ptl->next; + if ((*ptl->pTrigger->CheckTrigger)(ptl->pTrigger, oldval)) + (*ptl->pTrigger->TriggerFired)(ptl->pTrigger); + } + + if (IsSystemCounter(pCounter)) + { + SyncComputeBracketValues(pCounter); + } +} + + +/* loosely based on dix/events.c/EventSelectForWindow */ +static Bool +SyncEventSelectForAlarm(SyncAlarm *pAlarm, ClientPtr client, Bool wantevents) +{ + SyncAlarmClientList *pClients; + + if (client == pAlarm->client) /* alarm owner */ + { + pAlarm->events = wantevents; + return Success; + } + + /* see if the client is already on the list (has events selected) */ + + for (pClients = pAlarm->pEventClients; pClients; + pClients = pClients->next) + { + if (pClients->client == client) + { + /* client's presence on the list indicates desire for + * events. If the client doesn't want events, remove it + * from the list. If the client does want events, do + * nothing, since it's already got them. + */ + if (!wantevents) + { + FreeResource(pClients->delete_id, RT_NONE); + } + return Success; + } + } + + /* if we get here, this client does not currently have + * events selected on the alarm + */ + + if (!wantevents) + /* client doesn't want events, and we just discovered that it + * doesn't have them, so there's nothing to do. + */ + return Success; + + /* add new client to pAlarm->pEventClients */ + + pClients = malloc(sizeof(SyncAlarmClientList)); + if (!pClients) + return BadAlloc; + + /* register it as a resource so it will be cleaned up + * if the client dies + */ + + pClients->delete_id = FakeClientID(client->index); + if (!AddResource(pClients->delete_id, RTAlarmClient, pAlarm)) + { + free(pClients); + return BadAlloc; + } + + /* link it into list after we know all the allocations succeed */ + + pClients->next = pAlarm->pEventClients; + pAlarm->pEventClients = pClients; + pClients->client = client; + return Success; +} + +/* + * ** SyncChangeAlarmAttributes ** This is used by CreateAlarm and ChangeAlarm + */ +static int +SyncChangeAlarmAttributes(ClientPtr client, SyncAlarm *pAlarm, Mask mask, + CARD32 *values) +{ + int status; + XSyncCounter counter; + Mask origmask = mask; + + counter = + pAlarm->trigger.pSync ? pAlarm->trigger.pSync->id : None; + + while (mask) + { + int index2 = lowbit(mask); + mask &= ~index2; + switch (index2) + { + case XSyncCACounter: + mask &= ~XSyncCACounter; + /* sanity check in SyncInitTrigger */ + counter = *values++; + break; + + case XSyncCAValueType: + mask &= ~XSyncCAValueType; + /* sanity check in SyncInitTrigger */ + pAlarm->trigger.value_type = *values++; + break; + + case XSyncCAValue: + mask &= ~XSyncCAValue; + XSyncIntsToValue(&pAlarm->trigger.wait_value, values[1], values[0]); + values += 2; + break; + + case XSyncCATestType: + mask &= ~XSyncCATestType; + /* sanity check in SyncInitTrigger */ + pAlarm->trigger.test_type = *values++; + break; + + case XSyncCADelta: + mask &= ~XSyncCADelta; + XSyncIntsToValue(&pAlarm->delta, values[1], values[0]); + values += 2; + break; + + case XSyncCAEvents: + mask &= ~XSyncCAEvents; + if ((*values != xTrue) && (*values != xFalse)) + { + client->errorValue = *values; + return BadValue; + } + status = SyncEventSelectForAlarm(pAlarm, client, + (Bool)(*values++)); + if (status != Success) + return status; + break; + + default: + client->errorValue = mask; + return BadValue; + } + } + + /* "If the test-type is PositiveComparison or PositiveTransition + * and delta is less than zero, or if the test-type is + * NegativeComparison or NegativeTransition and delta is + * greater than zero, a Match error is generated." + */ + if (origmask & (XSyncCADelta|XSyncCATestType)) + { + CARD64 zero; + XSyncIntToValue(&zero, 0); + if ((((pAlarm->trigger.test_type == XSyncPositiveComparison) || + (pAlarm->trigger.test_type == XSyncPositiveTransition)) + && XSyncValueLessThan(pAlarm->delta, zero)) + || + (((pAlarm->trigger.test_type == XSyncNegativeComparison) || + (pAlarm->trigger.test_type == XSyncNegativeTransition)) + && XSyncValueGreaterThan(pAlarm->delta, zero)) + ) + { + return BadMatch; + } + } + + /* postpone this until now, when we're sure nothing else can go wrong */ + if ((status = SyncInitTrigger(client, &pAlarm->trigger, counter, RTCounter, + origmask & XSyncCAAllTrigger)) != Success) + return status; + + /* XXX spec does not really say to do this - needs clarification */ + pAlarm->state = XSyncAlarmActive; + return Success; +} + +static SyncObject * +SyncCreate(ClientPtr client, XID id, unsigned char type) +{ + SyncObject *pSync; + RESTYPE resType; + + switch (type) { + case SYNC_COUNTER: + resType = RTCounter; + pSync = malloc(sizeof(SyncCounter)); + break; + case SYNC_FENCE: + resType = RTFence; + pSync = dixAllocateObjectWithPrivates(SyncFence, + PRIVATE_SYNC_FENCE); + break; + default: + return NULL; + } + + if (!pSync) + return NULL; + + if (!AddResource(id, resType, (pointer) pSync)) + { + switch (type) { + case SYNC_FENCE: + dixFreeObjectWithPrivates((SyncFence *)pSync, PRIVATE_SYNC_FENCE); + break; + default: + free(pSync); + } + + return NULL; + } + + pSync->client = client; + pSync->id = id; + pSync->pTriglist = NULL; + pSync->beingDestroyed = FALSE; + pSync->type = type; + + return pSync; +} + + +static SyncCounter * +SyncCreateCounter(ClientPtr client, XSyncCounter id, CARD64 initialvalue) +{ + SyncCounter *pCounter; + + if (!(pCounter = (SyncCounter *)SyncCreate(client, + id, + SYNC_COUNTER))) + return NULL; + + pCounter->value = initialvalue; + pCounter->pSysCounterInfo = NULL; + return pCounter; +} + +static int FreeCounter(void *, XID); + +/* + * ***** System Counter utilities + */ + +pointer +SyncCreateSystemCounter( + char *name, + CARD64 initial, + CARD64 resolution, + SyncCounterType counterType, + void (*QueryValue)(pointer /* pCounter */, + CARD64 * /* pValue_return */), + void (*BracketValues)(pointer /* pCounter */, + CARD64 * /* pbracket_less */, + CARD64 * /* pbracket_greater */) + ) +{ + SyncCounter *pCounter; + + SysCounterList = realloc(SysCounterList, + (SyncNumSystemCounters+1)*sizeof(SyncCounter *)); + if (!SysCounterList) + return NULL; + + /* this function may be called before SYNC has been initialized, so we + * have to make sure RTCounter is created. + */ + if (RTCounter == 0) + { + RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter"); + if (RTCounter == 0) + { + return NULL; + } + } + + pCounter = SyncCreateCounter(NULL, FakeClientID(0), initial); + + if (pCounter) + { + SysCounterInfo *psci; + + psci = malloc(sizeof(SysCounterInfo)); + if (!psci) + { + FreeResource(pCounter->sync.id, RT_NONE); + return pCounter; + } + pCounter->pSysCounterInfo = psci; + psci->name = name; + psci->resolution = resolution; + psci->counterType = counterType; + psci->QueryValue = QueryValue; + psci->BracketValues = BracketValues; + XSyncMaxValue(&psci->bracket_greater); + XSyncMinValue(&psci->bracket_less); + SysCounterList[SyncNumSystemCounters++] = pCounter; + } + return pCounter; +} + +void +SyncDestroySystemCounter(pointer pSysCounter) +{ + SyncCounter *pCounter = (SyncCounter *)pSysCounter; + FreeResource(pCounter->sync.id, RT_NONE); +} + +static void +SyncComputeBracketValues(SyncCounter *pCounter) +{ + SyncTriggerList *pCur; + SyncTrigger *pTrigger; + SysCounterInfo *psci; + CARD64 *pnewgtval = NULL; + CARD64 *pnewltval = NULL; + SyncCounterType ct; + + if (!pCounter) + return; + + psci = pCounter->pSysCounterInfo; + ct = pCounter->pSysCounterInfo->counterType; + if (ct == XSyncCounterNeverChanges) + return; + + XSyncMaxValue(&psci->bracket_greater); + XSyncMinValue(&psci->bracket_less); + + for (pCur = pCounter->sync.pTriglist; pCur; pCur = pCur->next) + { + pTrigger = pCur->pTrigger; + + if (pTrigger->test_type == XSyncPositiveComparison && + ct != XSyncCounterNeverIncreases) + { + if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) && + XSyncValueLessThan(pTrigger->test_value, + psci->bracket_greater)) + { + psci->bracket_greater = pTrigger->test_value; + pnewgtval = &psci->bracket_greater; + } + } + else if (pTrigger->test_type == XSyncNegativeComparison && + ct != XSyncCounterNeverDecreases) + { + if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) && + XSyncValueGreaterThan(pTrigger->test_value, + psci->bracket_less)) + { + psci->bracket_less = pTrigger->test_value; + pnewltval = &psci->bracket_less; + } + } + else if (pTrigger->test_type == XSyncNegativeTransition && + ct != XSyncCounterNeverIncreases) + { + if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) && + XSyncValueGreaterThan(pTrigger->test_value, psci->bracket_less)) + { + psci->bracket_less = pTrigger->test_value; + pnewltval = &psci->bracket_less; + } else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) && + XSyncValueLessThan(pTrigger->test_value, + psci->bracket_greater)) + { + /* + * The value is exactly equal to our threshold. We want one + * more event in the positive direction to ensure we pick up + * when the value *exceeds* this threshold. + */ + psci->bracket_greater = pTrigger->test_value; + pnewgtval = &psci->bracket_greater; + } + } + else if (pTrigger->test_type == XSyncPositiveTransition && + ct != XSyncCounterNeverDecreases) + { + if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) && + XSyncValueLessThan(pTrigger->test_value, psci->bracket_greater)) + { + psci->bracket_greater = pTrigger->test_value; + pnewgtval = &psci->bracket_greater; + } else if (XSyncValueEqual(pCounter->value, pTrigger->test_value) && + XSyncValueGreaterThan(pTrigger->test_value, + psci->bracket_less)) + { + /* + * The value is exactly equal to our threshold. We want one + * more event in the negative direction to ensure we pick up + * when the value is less than this threshold. + */ + psci->bracket_less = pTrigger->test_value; + pnewltval = &psci->bracket_less; + } + } + } /* end for each trigger */ + + if (pnewgtval || pnewltval) + { + (*psci->BracketValues)((pointer)pCounter, pnewltval, pnewgtval); + } +} + +/* + * ***** Resource delete functions + */ + +/* ARGSUSED */ +static int +FreeAlarm(void *addr, XID id) +{ + SyncAlarm *pAlarm = (SyncAlarm *) addr; + + pAlarm->state = XSyncAlarmDestroyed; + + SyncSendAlarmNotifyEvents(pAlarm); + + /* delete event selections */ + + while (pAlarm->pEventClients) + FreeResource(pAlarm->pEventClients->delete_id, RT_NONE); + + SyncDeleteTriggerFromSyncObject(&pAlarm->trigger); + + free(pAlarm); + return Success; +} + + +/* + * ** Cleanup after the destruction of a Counter + */ +/* ARGSUSED */ +static int +FreeCounter(void *env, XID id) +{ + SyncCounter *pCounter = (SyncCounter *) env; + SyncTriggerList *ptl, *pnext; + + pCounter->sync.beingDestroyed = TRUE; + /* tell all the counter's triggers that the counter has been destroyed */ + for (ptl = pCounter->sync.pTriglist; ptl; ptl = pnext) + { + (*ptl->pTrigger->CounterDestroyed)(ptl->pTrigger); + pnext = ptl->next; + free(ptl); /* destroy the trigger list as we go */ + } + if (IsSystemCounter(pCounter)) + { + int i, found = 0; + + free(pCounter->pSysCounterInfo); + + /* find the counter in the list of system counters and remove it */ + + if (SysCounterList) + { + for (i = 0; i < SyncNumSystemCounters; i++) + { + if (SysCounterList[i] == pCounter) + { + found = i; + break; + } + } + if (found < (SyncNumSystemCounters-1)) + { + for (i = found; i < SyncNumSystemCounters-1; i++) + { + SysCounterList[i] = SysCounterList[i+1]; + } + } + } + SyncNumSystemCounters--; + } + free(pCounter); + return Success; +} + +/* + * ** Cleanup after Await + */ +/* ARGSUSED */ +static int +FreeAwait(void *addr, XID id) +{ + SyncAwaitUnion *pAwaitUnion = (SyncAwaitUnion *) addr; + SyncAwait *pAwait; + int numwaits; + + pAwait = &(pAwaitUnion+1)->await; /* first await on list */ + + /* remove triggers from counters */ + + for (numwaits = pAwaitUnion->header.num_waitconditions; numwaits; + numwaits--, pAwait++) + { + /* If the counter is being destroyed, FreeCounter will delete + * the trigger list itself, so don't do it here. + */ + SyncObject *pSync = pAwait->trigger.pSync; + if (pSync && !pSync->beingDestroyed) + SyncDeleteTriggerFromSyncObject(&pAwait->trigger); + } + free(pAwaitUnion); + return Success; +} + +#ifdef _MSC_VER +#pragma warning(disable:4715) /* Not all control paths return a value */ +#endif + +/* loosely based on dix/events.c/OtherClientGone */ +static int +FreeAlarmClient(void *value, XID id) +{ + SyncAlarm *pAlarm = (SyncAlarm *)value; + SyncAlarmClientList *pCur, *pPrev; + + for (pPrev = NULL, pCur = pAlarm->pEventClients; + pCur; + pPrev = pCur, pCur = pCur->next) + { + if (pCur->delete_id == id) + { + if (pPrev) + pPrev->next = pCur->next; + else + pAlarm->pEventClients = pCur->next; + free(pCur); + return Success; + } + } + FatalError("alarm client not on event list"); + /*NOTREACHED*/ +} + + +/* + * ***** Proc functions + */ + + +/* + * ** Initialize the extension + */ +static int +ProcSyncInitialize(ClientPtr client) +{ + xSyncInitializeReply rep; + int n; + + REQUEST_SIZE_MATCH(xSyncInitializeReq); + + memset(&rep, 0, sizeof(xSyncInitializeReply)); + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.majorVersion = SERVER_SYNC_MAJOR_VERSION; + rep.minorVersion = SERVER_SYNC_MINOR_VERSION; + rep.length = 0; + + if (client->swapped) + { + swaps(&rep.sequenceNumber, n); + } + WriteToClient(client, sizeof(rep), (char *) &rep); + return Success; +} + +/* + * ** Get list of system counters available through the extension + */ +static int +ProcSyncListSystemCounters(ClientPtr client) +{ + xSyncListSystemCountersReply rep; + int i, len; + xSyncSystemCounter *list = NULL, *walklist = NULL; + + REQUEST_SIZE_MATCH(xSyncListSystemCountersReq); + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.nCounters = SyncNumSystemCounters; + + for (i = len = 0; i < SyncNumSystemCounters; i++) + { + char *name = SysCounterList[i]->pSysCounterInfo->name; + /* pad to 4 byte boundary */ + len += pad_to_int32(sz_xSyncSystemCounter + strlen(name)); + } + + if (len) + { + walklist = list = malloc(len); + if (!list) + return BadAlloc; + } + + rep.length = bytes_to_int32(len); + + if (client->swapped) + { + char n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.nCounters, n); + } + + for (i = 0; i < SyncNumSystemCounters; i++) + { + int namelen; + char *pname_in_reply; + SysCounterInfo *psci = SysCounterList[i]->pSysCounterInfo; + + walklist->counter = SysCounterList[i]->sync.id; + walklist->resolution_hi = XSyncValueHigh32(psci->resolution); + walklist->resolution_lo = XSyncValueLow32(psci->resolution); + namelen = strlen(psci->name); + walklist->name_length = namelen; + + if (client->swapped) + { + char n; + swapl(&walklist->counter, n); + swapl(&walklist->resolution_hi, n); + swapl(&walklist->resolution_lo, n); + swaps(&walklist->name_length, n); + } + + pname_in_reply = ((char *)walklist) + sz_xSyncSystemCounter; + strncpy(pname_in_reply, psci->name, namelen); + walklist = (xSyncSystemCounter *) (((char *)walklist) + + pad_to_int32(sz_xSyncSystemCounter + namelen)); + } + + WriteToClient(client, sizeof(rep), (char *) &rep); + if (len) + { + WriteToClient(client, len, (char *) list); + free(list); + } + + return Success; +} + +/* + * ** Set client Priority + */ +static int +ProcSyncSetPriority(ClientPtr client) +{ + REQUEST(xSyncSetPriorityReq); + ClientPtr priorityclient; + int rc; + + REQUEST_SIZE_MATCH(xSyncSetPriorityReq); + + if (stuff->id == None) + priorityclient = client; + else { + rc = dixLookupClient(&priorityclient, stuff->id, client, + DixSetAttrAccess); + if (rc != Success) + return rc; + } + + if (priorityclient->priority != stuff->priority) + { + priorityclient->priority = stuff->priority; + + /* The following will force the server back into WaitForSomething + * so that the change in this client's priority is immediately + * reflected. + */ + isItTimeToYield = TRUE; + dispatchException |= DE_PRIORITYCHANGE; + } + return Success; +} + +/* + * ** Get client Priority + */ +static int +ProcSyncGetPriority(ClientPtr client) +{ + REQUEST(xSyncGetPriorityReq); + xSyncGetPriorityReply rep; + ClientPtr priorityclient; + int rc; + + REQUEST_SIZE_MATCH(xSyncGetPriorityReq); + + if (stuff->id == None) + priorityclient = client; + else { + rc = dixLookupClient(&priorityclient, stuff->id, client, + DixGetAttrAccess); + if (rc != Success) + return rc; + } + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.priority = priorityclient->priority; + + if (client->swapped) + { + char n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.priority, n); + } + + WriteToClient(client, sizeof(xSyncGetPriorityReply), (char *) &rep); + + return Success; +} + +/* + * ** Create a new counter + */ +static int +ProcSyncCreateCounter(ClientPtr client) +{ + REQUEST(xSyncCreateCounterReq); + CARD64 initial; + + REQUEST_SIZE_MATCH(xSyncCreateCounterReq); + + LEGAL_NEW_RESOURCE(stuff->cid, client); + + XSyncIntsToValue(&initial, stuff->initial_value_lo, stuff->initial_value_hi); + if (!SyncCreateCounter(client, stuff->cid, initial)) + return BadAlloc; + + return Success; +} + +/* + * ** Set Counter value + */ +static int +ProcSyncSetCounter(ClientPtr client) +{ + REQUEST(xSyncSetCounterReq); + SyncCounter *pCounter; + CARD64 newvalue; + int rc; + + REQUEST_SIZE_MATCH(xSyncSetCounterReq); + + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter, + client, DixWriteAccess); + if (rc != Success) + return rc; + + if (IsSystemCounter(pCounter)) + { + client->errorValue = stuff->cid; + return BadAccess; + } + + XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi); + SyncChangeCounter(pCounter, newvalue); + return Success; +} + +/* + * ** Change Counter value + */ +static int +ProcSyncChangeCounter(ClientPtr client) +{ + REQUEST(xSyncChangeCounterReq); + SyncCounter *pCounter; + CARD64 newvalue; + Bool overflow; + int rc; + + REQUEST_SIZE_MATCH(xSyncChangeCounterReq); + + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->cid, RTCounter, + client, DixWriteAccess); + if (rc != Success) + return rc; + + if (IsSystemCounter(pCounter)) + { + client->errorValue = stuff->cid; + return BadAccess; + } + + XSyncIntsToValue(&newvalue, stuff->value_lo, stuff->value_hi); + XSyncValueAdd(&newvalue, pCounter->value, newvalue, &overflow); + if (overflow) + { + /* XXX 64 bit value can't fit in 32 bits; do the best we can */ + client->errorValue = stuff->value_hi; + return BadValue; + } + SyncChangeCounter(pCounter, newvalue); + return Success; +} + +/* + * ** Destroy a counter + */ +static int +ProcSyncDestroyCounter(ClientPtr client) +{ + REQUEST(xSyncDestroyCounterReq); + SyncCounter *pCounter; + int rc; + + REQUEST_SIZE_MATCH(xSyncDestroyCounterReq); + + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, RTCounter, + client, DixDestroyAccess); + if (rc != Success) + return rc; + + if (IsSystemCounter(pCounter)) + { + client->errorValue = stuff->counter; + return BadAccess; + } + FreeResource(pCounter->sync.id, RT_NONE); + return Success; +} + +static SyncAwaitUnion* +SyncAwaitPrologue(ClientPtr client, int items) +{ + SyncAwaitUnion *pAwaitUnion; + + /* all the memory for the entire await list is allocated + * here in one chunk + */ + pAwaitUnion = malloc((items+1) * sizeof(SyncAwaitUnion)); + if (!pAwaitUnion) + return NULL; + + /* first item is the header, remainder are real wait conditions */ + + pAwaitUnion->header.delete_id = FakeClientID(client->index); + if (!AddResource(pAwaitUnion->header.delete_id, RTAwait, pAwaitUnion)) + { + free(pAwaitUnion); + return NULL; + } + + pAwaitUnion->header.client = client; + pAwaitUnion->header.num_waitconditions = 0; + + return pAwaitUnion; +} + +static void +SyncAwaitEpilogue(ClientPtr client, int items, SyncAwaitUnion *pAwaitUnion) +{ + SyncAwait *pAwait; + int i; + + IgnoreClient(client); + + /* see if any of the triggers are already true */ + + pAwait = &(pAwaitUnion+1)->await; /* skip over header */ + for (i = 0; i < items; i++, pAwait++) + { + CARD64 value; + + /* don't have to worry about NULL counters because the request + * errors before we get here out if they occur + */ + switch (pAwait->trigger.pSync->type) { + case SYNC_COUNTER: + value = ((SyncCounter *)pAwait->trigger.pSync)->value; + break; + default: + XSyncIntToValue(&value, 0); + } + + if ((*pAwait->trigger.CheckTrigger)(&pAwait->trigger, value)) + { + (*pAwait->trigger.TriggerFired)(&pAwait->trigger); + break; /* once is enough */ + } + } +} + +/* + * ** Await + */ +static int +ProcSyncAwait(ClientPtr client) +{ + REQUEST(xSyncAwaitReq); + int len, items; + int i; + xSyncWaitCondition *pProtocolWaitConds; + SyncAwaitUnion *pAwaitUnion; + SyncAwait *pAwait; + int status; + + REQUEST_AT_LEAST_SIZE(xSyncAwaitReq); + + len = client->req_len << 2; + len -= sz_xSyncAwaitReq; + items = len / sz_xSyncWaitCondition; + + if (items * sz_xSyncWaitCondition != len) + { + return BadLength; + } + if (items == 0) + { + client->errorValue = items; /* XXX protocol change */ + return BadValue; + } + + if (!(pAwaitUnion = SyncAwaitPrologue(client, items))) + return BadAlloc; + + /* don't need to do any more memory allocation for this request! */ + + pProtocolWaitConds = (xSyncWaitCondition *) & stuff[1]; + + pAwait = &(pAwaitUnion+1)->await; /* skip over header */ + for (i = 0; i < items; i++, pProtocolWaitConds++, pAwait++) + { + if (pProtocolWaitConds->counter == None) /* XXX protocol change */ + { + /* this should take care of removing any triggers created by + * this request that have already been registered on sync objects + */ + FreeResource(pAwaitUnion->header.delete_id, RT_NONE); + client->errorValue = pProtocolWaitConds->counter; + return SyncErrorBase + XSyncBadCounter; + } + + /* sanity checks are in SyncInitTrigger */ + pAwait->trigger.pSync = NULL; + pAwait->trigger.value_type = pProtocolWaitConds->value_type; + XSyncIntsToValue(&pAwait->trigger.wait_value, + pProtocolWaitConds->wait_value_lo, + pProtocolWaitConds->wait_value_hi); + pAwait->trigger.test_type = pProtocolWaitConds->test_type; + + status = SyncInitTrigger(client, &pAwait->trigger, + pProtocolWaitConds->counter, RTCounter, + XSyncCAAllTrigger); + if (status != Success) + { + /* this should take care of removing any triggers created by + * this request that have already been registered on sync objects + */ + FreeResource(pAwaitUnion->header.delete_id, RT_NONE); + return status; + } + /* this is not a mistake -- same function works for both cases */ + pAwait->trigger.TriggerFired = SyncAwaitTriggerFired; + pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired; + XSyncIntsToValue(&pAwait->event_threshold, + pProtocolWaitConds->event_threshold_lo, + pProtocolWaitConds->event_threshold_hi); + pAwait->pHeader = &pAwaitUnion->header; + pAwaitUnion->header.num_waitconditions++; + } + + SyncAwaitEpilogue(client, items, pAwaitUnion); + + return Success; +} + + +/* + * ** Query a counter + */ +static int +ProcSyncQueryCounter(ClientPtr client) +{ + REQUEST(xSyncQueryCounterReq); + xSyncQueryCounterReply rep; + SyncCounter *pCounter; + int rc; + + REQUEST_SIZE_MATCH(xSyncQueryCounterReq); + + rc = dixLookupResourceByType((pointer *)&pCounter, stuff->counter, + RTCounter, client, DixReadAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + /* if system counter, ask it what the current value is */ + + if (IsSystemCounter(pCounter)) + { + (*pCounter->pSysCounterInfo->QueryValue) ((pointer) pCounter, + &pCounter->value); + } + + rep.value_hi = XSyncValueHigh32(pCounter->value); + rep.value_lo = XSyncValueLow32(pCounter->value); + if (client->swapped) + { + char n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.value_hi, n); + swapl(&rep.value_lo, n); + } + WriteToClient(client, sizeof(xSyncQueryCounterReply), (char *) &rep); + return Success; +} + + +/* + * ** Create Alarm + */ +static int +ProcSyncCreateAlarm(ClientPtr client) +{ + REQUEST(xSyncCreateAlarmReq); + SyncAlarm *pAlarm; + int status; + unsigned long len, vmask; + SyncTrigger *pTrigger; + + REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq); + + LEGAL_NEW_RESOURCE(stuff->id, client); + + vmask = stuff->valueMask; + len = client->req_len - bytes_to_int32(sizeof(xSyncCreateAlarmReq)); + /* the "extra" call to Ones accounts for the presence of 64 bit values */ + if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta)))) + return BadLength; + + if (!(pAlarm = malloc(sizeof(SyncAlarm)))) + { + return BadAlloc; + } + + /* set up defaults */ + + pTrigger = &pAlarm->trigger; + pTrigger->pSync = NULL; + pTrigger->value_type = XSyncAbsolute; + XSyncIntToValue(&pTrigger->wait_value, 0L); + pTrigger->test_type = XSyncPositiveComparison; + pTrigger->TriggerFired = SyncAlarmTriggerFired; + pTrigger->CounterDestroyed = SyncAlarmCounterDestroyed; + status = SyncInitTrigger(client, pTrigger, None, RTCounter, + XSyncCAAllTrigger); + if (status != Success) + { + free(pAlarm); + return status; + } + + pAlarm->client = client; + pAlarm->alarm_id = stuff->id; + XSyncIntToValue(&pAlarm->delta, 1L); + pAlarm->events = TRUE; + pAlarm->state = XSyncAlarmInactive; + pAlarm->pEventClients = NULL; + status = SyncChangeAlarmAttributes(client, pAlarm, vmask, + (CARD32 *)&stuff[1]); + if (status != Success) + { + free(pAlarm); + return status; + } + + if (!AddResource(stuff->id, RTAlarm, pAlarm)) + { + free(pAlarm); + return BadAlloc; + } + + /* see if alarm already triggered. NULL counter will not trigger + * in CreateAlarm and sets alarm state to Inactive. + */ + + if (!pTrigger->pSync) + { + pAlarm->state = XSyncAlarmInactive; /* XXX protocol change */ + } + else + { + SyncCounter *pCounter; + + assert(SYNC_COUNTER == pTrigger->pSync->type); + pCounter = (SyncCounter *)pTrigger->pSync; + + if ((*pTrigger->CheckTrigger)(pTrigger, pCounter->value)) + (*pTrigger->TriggerFired)(pTrigger); + } + + return Success; +} + +/* + * ** Change Alarm + */ +static int +ProcSyncChangeAlarm(ClientPtr client) +{ + REQUEST(xSyncChangeAlarmReq); + SyncAlarm *pAlarm; + SyncCounter *pCounter = NULL; + long vmask; + int len, status; + + REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); + + status = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, + client, DixWriteAccess); + if (status != Success) + return status; + + vmask = stuff->valueMask; + len = client->req_len - bytes_to_int32(sizeof(xSyncChangeAlarmReq)); + /* the "extra" call to Ones accounts for the presence of 64 bit values */ + if (len != (Ones(vmask) + Ones(vmask & (XSyncCAValue|XSyncCADelta)))) + return BadLength; + + if ((status = SyncChangeAlarmAttributes(client, pAlarm, vmask, + (CARD32 *)&stuff[1])) != Success) + return status; + + if (pAlarm->trigger.pSync) + { + assert(SYNC_COUNTER == pAlarm->trigger.pSync->type); + pCounter = (SyncCounter *)pAlarm->trigger.pSync; + } + + /* see if alarm already triggered. NULL counter WILL trigger + * in ChangeAlarm. + */ + + if (!pCounter || + (*pAlarm->trigger.CheckTrigger)(&pAlarm->trigger, pCounter->value)) + { + (*pAlarm->trigger.TriggerFired)(&pAlarm->trigger); + } + return Success; +} + +static int +ProcSyncQueryAlarm(ClientPtr client) +{ + REQUEST(xSyncQueryAlarmReq); + SyncAlarm *pAlarm; + xSyncQueryAlarmReply rep; + SyncTrigger *pTrigger; + int rc; + + REQUEST_SIZE_MATCH(xSyncQueryAlarmReq); + + rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, + client, DixReadAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = bytes_to_int32(sizeof(xSyncQueryAlarmReply) - sizeof(xGenericReply)); + rep.sequenceNumber = client->sequence; + + pTrigger = &pAlarm->trigger; + rep.counter = (pTrigger->pSync) ? pTrigger->pSync->id : None; + +#if 0 /* XXX unclear what to do, depends on whether relative value-types + * are "consumed" immediately and are considered absolute from then + * on. + */ + rep.value_type = pTrigger->value_type; + rep.wait_value_hi = XSyncValueHigh32(pTrigger->wait_value); + rep.wait_value_lo = XSyncValueLow32(pTrigger->wait_value); +#else + rep.value_type = XSyncAbsolute; + rep.wait_value_hi = XSyncValueHigh32(pTrigger->test_value); + rep.wait_value_lo = XSyncValueLow32(pTrigger->test_value); +#endif + + rep.test_type = pTrigger->test_type; + rep.delta_hi = XSyncValueHigh32(pAlarm->delta); + rep.delta_lo = XSyncValueLow32(pAlarm->delta); + rep.events = pAlarm->events; + rep.state = pAlarm->state; + + if (client->swapped) + { + char n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.counter, n); + swapl(&rep.wait_value_hi, n); + swapl(&rep.wait_value_lo, n); + swapl(&rep.test_type, n); + swapl(&rep.delta_hi, n); + swapl(&rep.delta_lo, n); + } + + WriteToClient(client, sizeof(xSyncQueryAlarmReply), (char *) &rep); + return Success; +} + +static int +ProcSyncDestroyAlarm(ClientPtr client) +{ + SyncAlarm *pAlarm; + int rc; + REQUEST(xSyncDestroyAlarmReq); + + REQUEST_SIZE_MATCH(xSyncDestroyAlarmReq); + + rc = dixLookupResourceByType((pointer *)&pAlarm, stuff->alarm, RTAlarm, + client, DixDestroyAccess); + if (rc != Success) + return rc; + + FreeResource(stuff->alarm, RT_NONE); + return Success; +} + +static int +ProcSyncCreateFence(ClientPtr client) +{ + REQUEST(xSyncCreateFenceReq); + DrawablePtr pDraw; + SyncFence *pFence; + int rc; + + REQUEST_SIZE_MATCH(xSyncCreateFenceReq); + + rc = dixLookupDrawable(&pDraw, stuff->d, client, M_ANY, DixGetAttrAccess); + if (rc != Success) + return rc; + + LEGAL_NEW_RESOURCE(stuff->fid, client); + + if (!(pFence = (SyncFence *)SyncCreate(client, + stuff->fid, + SYNC_FENCE))) + return BadAlloc; + + miSyncInitFence(pDraw->pScreen, pFence, stuff->initially_triggered); + + return client->noClientException; +} + +static int +FreeFence(void *obj, XID id) +{ + SyncFence *pFence = (SyncFence *) obj; + + miSyncDestroyFence(pFence); + + return Success; +} + +int SyncVerifyFence(SyncFence **ppSyncFence, XID fid, + ClientPtr client, Mask mode) +{ + int rc = dixLookupResourceByType((pointer *)ppSyncFence, fid, RTFence, + client, mode); + + if (rc != Success) + client->errorValue = fid; + + return rc; +} + +static int +ProcSyncTriggerFence(ClientPtr client) +{ + REQUEST(xSyncTriggerFenceReq); + SyncFence *pFence; + int rc; + + REQUEST_SIZE_MATCH(xSyncTriggerFenceReq); + + rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence, + client, DixWriteAccess); + if (rc != Success) + return rc; + + miSyncTriggerFence(pFence); + + return client->noClientException; +} + +static int +ProcSyncResetFence(ClientPtr client) +{ + REQUEST(xSyncResetFenceReq); + SyncFence *pFence; + int rc; + + REQUEST_SIZE_MATCH(xSyncResetFenceReq); + + rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence, + client, DixWriteAccess); + if (rc != Success) + return rc; + + if (pFence->funcs.CheckTriggered(pFence) != TRUE) + return BadMatch; + + pFence->funcs.Reset(pFence); + + return client->noClientException; +} + +static int +ProcSyncDestroyFence(ClientPtr client) +{ + REQUEST(xSyncDestroyFenceReq); + SyncFence *pFence; + int rc; + + REQUEST_SIZE_MATCH(xSyncDestroyFenceReq); + + rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, RTFence, + client, DixDestroyAccess); + if (rc != Success) + return rc; + + FreeResource(stuff->fid, RT_NONE); + return client->noClientException; +} + +static int +ProcSyncQueryFence(ClientPtr client) +{ + REQUEST(xSyncQueryFenceReq); + xSyncQueryFenceReply rep; + SyncFence *pFence; + int rc; + + REQUEST_SIZE_MATCH(xSyncQueryFenceReq); + + rc = dixLookupResourceByType((pointer *)&pFence, stuff->fid, + RTFence, client, DixReadAccess); + if (rc != Success) + return rc; + + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rep.triggered = pFence->funcs.CheckTriggered(pFence); + + if (client->swapped) + { + char n; + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + } + + WriteToClient(client, sizeof(xSyncQueryFenceReply), (char *) &rep); + return client->noClientException; +} + +static int +ProcSyncAwaitFence(ClientPtr client) +{ + REQUEST(xSyncAwaitFenceReq); + SyncAwaitUnion *pAwaitUnion; + SyncAwait *pAwait; + /* Use CARD32 rather than XSyncFence because XIDs are hard-coded to + * CARD32 in protocol definitions */ + CARD32 *pProtocolFences; + int status; + int len; + int items; + int i; + + REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq); + + len = client->req_len << 2; + len -= sz_xSyncAwaitFenceReq; + items = len / sizeof(CARD32); + + if (items * sizeof(CARD32) != len) + { + return BadLength; + } + if (items == 0) + { + client->errorValue = items; /* XXX protocol change */ + return BadValue; + } + + if (!(pAwaitUnion = SyncAwaitPrologue(client, items))) + return BadAlloc; + + /* don't need to do any more memory allocation for this request! */ + + pProtocolFences = (CARD32 *) & stuff[1]; + + pAwait = &(pAwaitUnion+1)->await; /* skip over header */ + for (i = 0; i < items; i++, pProtocolFences++, pAwait++) + { + if (*pProtocolFences == None) /* XXX protocol change */ + { + /* this should take care of removing any triggers created by + * this request that have already been registered on sync objects + */ + FreeResource(pAwaitUnion->header.delete_id, RT_NONE); + client->errorValue = *pProtocolFences; + return SyncErrorBase + XSyncBadCounter; + } + + pAwait->trigger.pSync = NULL; + /* Provide acceptable values for these unused fields to + * satisfy SyncInitTrigger's validation logic + */ + pAwait->trigger.value_type = XSyncAbsolute; + XSyncIntToValue(&pAwait->trigger.wait_value, 0); + pAwait->trigger.test_type = 0; + + status = SyncInitTrigger(client, &pAwait->trigger, + *pProtocolFences, RTFence, + XSyncCAAllTrigger); + if (status != Success) + { + /* this should take care of removing any triggers created by + * this request that have already been registered on sync objects + */ + FreeResource(pAwaitUnion->header.delete_id, RT_NONE); + return status; + } + /* this is not a mistake -- same function works for both cases */ + pAwait->trigger.TriggerFired = SyncAwaitTriggerFired; + pAwait->trigger.CounterDestroyed = SyncAwaitTriggerFired; + /* event_threshold is unused for fence syncs */ + XSyncIntToValue(&pAwait->event_threshold, 0); + pAwait->pHeader = &pAwaitUnion->header; + pAwaitUnion->header.num_waitconditions++; + } + + SyncAwaitEpilogue(client, items, pAwaitUnion); + + return client->noClientException; +} + +/* + * ** Given an extension request, call the appropriate request procedure + */ +static int +ProcSyncDispatch(ClientPtr client) +{ + REQUEST(xReq); + + switch (stuff->data) + { + case X_SyncInitialize: + return ProcSyncInitialize(client); + case X_SyncListSystemCounters: + return ProcSyncListSystemCounters(client); + case X_SyncCreateCounter: + return ProcSyncCreateCounter(client); + case X_SyncSetCounter: + return ProcSyncSetCounter(client); + case X_SyncChangeCounter: + return ProcSyncChangeCounter(client); + case X_SyncQueryCounter: + return ProcSyncQueryCounter(client); + case X_SyncDestroyCounter: + return ProcSyncDestroyCounter(client); + case X_SyncAwait: + return ProcSyncAwait(client); + case X_SyncCreateAlarm: + return ProcSyncCreateAlarm(client); + case X_SyncChangeAlarm: + return ProcSyncChangeAlarm(client); + case X_SyncQueryAlarm: + return ProcSyncQueryAlarm(client); + case X_SyncDestroyAlarm: + return ProcSyncDestroyAlarm(client); + case X_SyncSetPriority: + return ProcSyncSetPriority(client); + case X_SyncGetPriority: + return ProcSyncGetPriority(client); + case X_SyncCreateFence: + return ProcSyncCreateFence(client); + case X_SyncTriggerFence: + return ProcSyncTriggerFence(client); + case X_SyncResetFence: + return ProcSyncResetFence(client); + case X_SyncDestroyFence: + return ProcSyncDestroyFence(client); + case X_SyncQueryFence: + return ProcSyncQueryFence(client); + case X_SyncAwaitFence: + return ProcSyncAwaitFence(client); + default: + return BadRequest; + } +} + +/* + * Boring Swapping stuff ... + */ + +static int +SProcSyncInitialize(ClientPtr client) +{ + REQUEST(xSyncInitializeReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncInitializeReq); + + return ProcSyncInitialize(client); +} + +static int +SProcSyncListSystemCounters(ClientPtr client) +{ + REQUEST(xSyncListSystemCountersReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncListSystemCountersReq); + + return ProcSyncListSystemCounters(client); +} + +static int +SProcSyncCreateCounter(ClientPtr client) +{ + REQUEST(xSyncCreateCounterReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncCreateCounterReq); + swapl(&stuff->cid, n); + swapl(&stuff->initial_value_lo, n); + swapl(&stuff->initial_value_hi, n); + + return ProcSyncCreateCounter(client); +} + +static int +SProcSyncSetCounter(ClientPtr client) +{ + REQUEST(xSyncSetCounterReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncSetCounterReq); + swapl(&stuff->cid, n); + swapl(&stuff->value_lo, n); + swapl(&stuff->value_hi, n); + + return ProcSyncSetCounter(client); +} + +static int +SProcSyncChangeCounter(ClientPtr client) +{ + REQUEST(xSyncChangeCounterReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncChangeCounterReq); + swapl(&stuff->cid, n); + swapl(&stuff->value_lo, n); + swapl(&stuff->value_hi, n); + + return ProcSyncChangeCounter(client); +} + +static int +SProcSyncQueryCounter(ClientPtr client) +{ + REQUEST(xSyncQueryCounterReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncQueryCounterReq); + swapl(&stuff->counter, n); + + return ProcSyncQueryCounter(client); +} + +static int +SProcSyncDestroyCounter(ClientPtr client) +{ + REQUEST(xSyncDestroyCounterReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncDestroyCounterReq); + swapl(&stuff->counter, n); + + return ProcSyncDestroyCounter(client); +} + +static int +SProcSyncAwait(ClientPtr client) +{ + REQUEST(xSyncAwaitReq); + char n; + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xSyncAwaitReq); + SwapRestL(stuff); + + return ProcSyncAwait(client); +} + +static int +SProcSyncCreateAlarm(ClientPtr client) +{ + REQUEST(xSyncCreateAlarmReq); + char n; + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xSyncCreateAlarmReq); + swapl(&stuff->id, n); + swapl(&stuff->valueMask, n); + SwapRestL(stuff); + + return ProcSyncCreateAlarm(client); +} + +static int +SProcSyncChangeAlarm(ClientPtr client) +{ + REQUEST(xSyncChangeAlarmReq); + char n; + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xSyncChangeAlarmReq); + swapl(&stuff->alarm, n); + swapl(&stuff->valueMask, n); + SwapRestL(stuff); + return ProcSyncChangeAlarm(client); +} + +static int +SProcSyncQueryAlarm(ClientPtr client) +{ + REQUEST(xSyncQueryAlarmReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncQueryAlarmReq); + swapl(&stuff->alarm, n); + + return ProcSyncQueryAlarm(client); +} + +static int +SProcSyncDestroyAlarm(ClientPtr client) +{ + REQUEST(xSyncDestroyAlarmReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncDestroyAlarmReq); + swapl(&stuff->alarm, n); + + return ProcSyncDestroyAlarm(client); +} + +static int +SProcSyncSetPriority(ClientPtr client) +{ + REQUEST(xSyncSetPriorityReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncSetPriorityReq); + swapl(&stuff->id, n); + swapl(&stuff->priority, n); + + return ProcSyncSetPriority(client); +} + +static int +SProcSyncGetPriority(ClientPtr client) +{ + REQUEST(xSyncGetPriorityReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncGetPriorityReq); + swapl(&stuff->id, n); + + return ProcSyncGetPriority(client); +} + +static int +SProcSyncCreateFence(ClientPtr client) +{ + REQUEST(xSyncCreateFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncCreateFenceReq); + swapl(&stuff->fid, n); + + return ProcSyncCreateFence(client); +} + +static int +SProcSyncTriggerFence(ClientPtr client) +{ + REQUEST(xSyncTriggerFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncTriggerFenceReq); + swapl(&stuff->fid, n); + + return ProcSyncTriggerFence(client); +} + +static int +SProcSyncResetFence(ClientPtr client) +{ + REQUEST(xSyncResetFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncResetFenceReq); + swapl(&stuff->fid, n); + + return ProcSyncResetFence(client); +} + +static int +SProcSyncDestroyFence(ClientPtr client) +{ + REQUEST(xSyncDestroyFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncDestroyFenceReq); + swapl(&stuff->fid, n); + + return ProcSyncDestroyFence(client); +} + +static int +SProcSyncQueryFence(ClientPtr client) +{ + REQUEST(xSyncQueryFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_SIZE_MATCH (xSyncQueryFenceReq); + swapl(&stuff->fid, n); + + return ProcSyncQueryFence(client); +} + +static int +SProcSyncAwaitFence(ClientPtr client) +{ + REQUEST(xSyncAwaitFenceReq); + char n; + + swaps(&stuff->length, n); + REQUEST_AT_LEAST_SIZE(xSyncAwaitFenceReq); + SwapRestL(stuff); + + return ProcSyncAwaitFence(client); +} + +static int +SProcSyncDispatch(ClientPtr client) +{ + REQUEST(xReq); + + switch (stuff->data) + { + case X_SyncInitialize: + return SProcSyncInitialize(client); + case X_SyncListSystemCounters: + return SProcSyncListSystemCounters(client); + case X_SyncCreateCounter: + return SProcSyncCreateCounter(client); + case X_SyncSetCounter: + return SProcSyncSetCounter(client); + case X_SyncChangeCounter: + return SProcSyncChangeCounter(client); + case X_SyncQueryCounter: + return SProcSyncQueryCounter(client); + case X_SyncDestroyCounter: + return SProcSyncDestroyCounter(client); + case X_SyncAwait: + return SProcSyncAwait(client); + case X_SyncCreateAlarm: + return SProcSyncCreateAlarm(client); + case X_SyncChangeAlarm: + return SProcSyncChangeAlarm(client); + case X_SyncQueryAlarm: + return SProcSyncQueryAlarm(client); + case X_SyncDestroyAlarm: + return SProcSyncDestroyAlarm(client); + case X_SyncSetPriority: + return SProcSyncSetPriority(client); + case X_SyncGetPriority: + return SProcSyncGetPriority(client); + case X_SyncCreateFence: + return SProcSyncCreateFence(client); + case X_SyncTriggerFence: + return SProcSyncTriggerFence(client); + case X_SyncResetFence: + return SProcSyncResetFence(client); + case X_SyncDestroyFence: + return SProcSyncDestroyFence(client); + case X_SyncQueryFence: + return SProcSyncQueryFence(client); + case X_SyncAwaitFence: + return SProcSyncAwaitFence(client); + default: + return BadRequest; + } +} + +/* + * Event Swapping + */ + +static void +SCounterNotifyEvent(xSyncCounterNotifyEvent *from, xSyncCounterNotifyEvent *to) +{ + to->type = from->type; + to->kind = from->kind; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->counter, to->counter); + cpswapl(from->wait_value_lo, to->wait_value_lo); + cpswapl(from->wait_value_hi, to->wait_value_hi); + cpswapl(from->counter_value_lo, to->counter_value_lo); + cpswapl(from->counter_value_hi, to->counter_value_hi); + cpswapl(from->time, to->time); + cpswaps(from->count, to->count); + to->destroyed = from->destroyed; +} + + +static void +SAlarmNotifyEvent(xSyncAlarmNotifyEvent *from, xSyncAlarmNotifyEvent *to) +{ + to->type = from->type; + to->kind = from->kind; + cpswaps(from->sequenceNumber, to->sequenceNumber); + cpswapl(from->alarm, to->alarm); + cpswapl(from->counter_value_lo, to->counter_value_lo); + cpswapl(from->counter_value_hi, to->counter_value_hi); + cpswapl(from->alarm_value_lo, to->alarm_value_lo); + cpswapl(from->alarm_value_hi, to->alarm_value_hi); + cpswapl(from->time, to->time); + to->state = from->state; +} + +/* + * ** Close everything down. ** This is fairly simple for now. + */ +/* ARGSUSED */ +static void +SyncResetProc(ExtensionEntry *extEntry) +{ + free(SysCounterList); + SysCounterList = NULL; + RTCounter = 0; +} + +/* + * ** Initialise the extension. + */ +void +SyncExtensionInit(void) +{ + ExtensionEntry *extEntry; + int s; + + for (s = 0; s < screenInfo.numScreens; s++) + miSyncSetup(screenInfo.screens[s]); + + if (RTCounter == 0) + { + RTCounter = CreateNewResourceType(FreeCounter, "SyncCounter"); + } + RTAlarm = CreateNewResourceType(FreeAlarm, "SyncAlarm"); + RTAwait = CreateNewResourceType(FreeAwait, "SyncAwait"); + RTFence = CreateNewResourceType(FreeFence, "SyncFence"); + if (RTAwait) + RTAwait |= RC_NEVERRETAIN; + RTAlarmClient = CreateNewResourceType(FreeAlarmClient, "SyncAlarmClient"); + if (RTAlarmClient) + RTAlarmClient |= RC_NEVERRETAIN; + + if (RTCounter == 0 || RTAwait == 0 || RTAlarm == 0 || + RTAlarmClient == 0 || + (extEntry = AddExtension(SYNC_NAME, + XSyncNumberEvents, XSyncNumberErrors, + ProcSyncDispatch, SProcSyncDispatch, + SyncResetProc, + StandardMinorOpcode)) == NULL) + { + ErrorF("Sync Extension %d.%d failed to Initialise\n", + SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION); + return; + } + + SyncEventBase = extEntry->eventBase; + SyncErrorBase = extEntry->errorBase; + EventSwapVector[SyncEventBase + XSyncCounterNotify] = (EventSwapPtr) SCounterNotifyEvent; + EventSwapVector[SyncEventBase + XSyncAlarmNotify] = (EventSwapPtr) SAlarmNotifyEvent; + + SetResourceTypeErrorValue(RTCounter, SyncErrorBase + XSyncBadCounter); + SetResourceTypeErrorValue(RTAlarm, SyncErrorBase + XSyncBadAlarm); + SetResourceTypeErrorValue(RTFence, SyncErrorBase + XSyncBadFence); + + /* + * Although SERVERTIME is implemented by the OS layer, we initialise it + * here because doing it in OsInit() is too early. The resource database + * is not initialised when OsInit() is called. This is just about OK + * because there is always a servertime counter. + */ + SyncInitServerTime(); + SyncInitIdleTime(); + +#ifdef DEBUG + fprintf(stderr, "Sync Extension %d.%d\n", + SYNC_MAJOR_VERSION, SYNC_MINOR_VERSION); +#endif +} + + +/* + * ***** SERVERTIME implementation - should go in its own file in OS directory? + */ + + + +static pointer ServertimeCounter; +static XSyncValue Now; +static XSyncValue *pnext_time; + +#define GetTime()\ +{\ + unsigned long millis = GetTimeInMillis();\ + unsigned long maxis = XSyncValueHigh32(Now);\ + if (millis < XSyncValueLow32(Now)) maxis++;\ + XSyncIntsToValue(&Now, millis, maxis);\ +} + +/* +*** Server Block Handler +*** code inspired by multibuffer extension (now deprecated) + */ +/*ARGSUSED*/ +static void +ServertimeBlockHandler(void *env, struct timeval **wt, void *LastSelectMask) +{ + XSyncValue delay; + unsigned long timeout; + + if (pnext_time) + { + GetTime(); + + if (XSyncValueGreaterOrEqual(Now, *pnext_time)) + { + timeout = 0; + } + else + { + Bool overflow; + XSyncValueSubtract(&delay, *pnext_time, Now, &overflow); + (void)overflow; + timeout = XSyncValueLow32(delay); + } + AdjustWaitForDelay(wt, timeout); /* os/utils.c */ + } +} + +/* +*** Wakeup Handler + */ +/*ARGSUSED*/ +static void +ServertimeWakeupHandler(void *env, int rc, void *LastSelectMask) +{ + if (pnext_time) + { + GetTime(); + + if (XSyncValueGreaterOrEqual(Now, *pnext_time)) + { + SyncChangeCounter(ServertimeCounter, Now); + } + } +} + +static void +ServertimeQueryValue(void *pCounter, CARD64 *pValue_return) +{ + GetTime(); + *pValue_return = Now; +} + +static void +ServertimeBracketValues(void *pCounter, CARD64 *pbracket_less, + CARD64 *pbracket_greater) +{ + if (!pnext_time && pbracket_greater) + { + RegisterBlockAndWakeupHandlers(ServertimeBlockHandler, + ServertimeWakeupHandler, + NULL); + } + else if (pnext_time && !pbracket_greater) + { + RemoveBlockAndWakeupHandlers(ServertimeBlockHandler, + ServertimeWakeupHandler, + NULL); + } + pnext_time = pbracket_greater; +} + +static void +SyncInitServerTime(void) +{ + CARD64 resolution; + + XSyncIntsToValue(&Now, GetTimeInMillis(), 0); + XSyncIntToValue(&resolution, 4); + ServertimeCounter = SyncCreateSystemCounter("SERVERTIME", Now, resolution, + XSyncCounterNeverDecreases, + ServertimeQueryValue, ServertimeBracketValues); + pnext_time = NULL; +} + + + +/* + * IDLETIME implementation + */ + +static SyncCounter *IdleTimeCounter; +static XSyncValue *pIdleTimeValueLess; +static XSyncValue *pIdleTimeValueGreater; + +static void +IdleTimeQueryValue (pointer pCounter, CARD64 *pValue_return) +{ + CARD32 idle = GetTimeInMillis() - lastDeviceEventTime.milliseconds; + XSyncIntsToValue (pValue_return, idle, 0); +} + +static void +IdleTimeBlockHandler(pointer env, struct timeval **wt, pointer LastSelectMask) +{ + XSyncValue idle, old_idle; + SyncTriggerList *list = IdleTimeCounter->sync.pTriglist; + SyncTrigger *trig; + + if (!pIdleTimeValueLess && !pIdleTimeValueGreater) + return; + + old_idle = IdleTimeCounter->value; + IdleTimeQueryValue (NULL, &idle); + IdleTimeCounter->value = idle; /* push, so CheckTrigger works */ + + if (pIdleTimeValueLess && + XSyncValueLessOrEqual (idle, *pIdleTimeValueLess)) + { + /* + * We've been idle for less than the threshold value, and someone + * wants to know about that, but now we need to know whether they + * want level or edge trigger. Check the trigger list against the + * current idle time, and if any succeed, bomb out of select() + * immediately so we can reschedule. + */ + + for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) { + trig = list->pTrigger; + if (trig->CheckTrigger(trig, old_idle)) { + AdjustWaitForDelay(wt, 0); + break; + } + } + /* + * We've been called exactly on the idle time, but we have a + * NegativeTransition trigger which requires a transition from an + * idle time greater than this. Schedule a wakeup for the next + * millisecond so we won't miss a transition. + */ + if (XSyncValueEqual (idle, *pIdleTimeValueLess)) + AdjustWaitForDelay(wt, 1); + } + else if (pIdleTimeValueGreater) + { + /* + * There's a threshold in the positive direction. If we've been + * idle less than it, schedule a wakeup for sometime in the future. + * If we've been idle more than it, and someone wants to know about + * that level-triggered, schedule an immediate wakeup. + */ + unsigned long timeout = -1; + + if (XSyncValueLessThan (idle, *pIdleTimeValueGreater)) { + XSyncValue value; + Bool overflow; + + XSyncValueSubtract (&value, *pIdleTimeValueGreater, + idle, &overflow); + timeout = min(timeout, XSyncValueLow32 (value)); + } else { + for (list = IdleTimeCounter->sync.pTriglist; list; list = list->next) { + trig = list->pTrigger; + if (trig->CheckTrigger(trig, old_idle)) { + timeout = min(timeout, 0); + break; + } + } + } + + AdjustWaitForDelay (wt, timeout); + } + + IdleTimeCounter->value = old_idle; /* pop */ +} + +static void +IdleTimeWakeupHandler (pointer env, int rc, pointer LastSelectMask) +{ + XSyncValue idle; + + if (!pIdleTimeValueLess && !pIdleTimeValueGreater) + return; + + IdleTimeQueryValue (NULL, &idle); + + if ((pIdleTimeValueGreater && + XSyncValueGreaterOrEqual (idle, *pIdleTimeValueGreater)) || + (pIdleTimeValueLess && + XSyncValueLessOrEqual (idle, *pIdleTimeValueLess))) + { + SyncChangeCounter (IdleTimeCounter, idle); + } +} + +static void +IdleTimeBracketValues (pointer pCounter, CARD64 *pbracket_less, + CARD64 *pbracket_greater) +{ + Bool registered = (pIdleTimeValueLess || pIdleTimeValueGreater); + + if (registered && !pbracket_less && !pbracket_greater) + { + RemoveBlockAndWakeupHandlers(IdleTimeBlockHandler, + IdleTimeWakeupHandler, + NULL); + } + else if (!registered && (pbracket_less || pbracket_greater)) + { + RegisterBlockAndWakeupHandlers(IdleTimeBlockHandler, + IdleTimeWakeupHandler, + NULL); + } + + pIdleTimeValueGreater = pbracket_greater; + pIdleTimeValueLess = pbracket_less; +} + +static void +SyncInitIdleTime (void) +{ + CARD64 resolution; + XSyncValue idle; + + IdleTimeQueryValue (NULL, &idle); + XSyncIntToValue (&resolution, 4); + + IdleTimeCounter = SyncCreateSystemCounter ("IDLETIME", idle, resolution, + XSyncCounterUnrestricted, + IdleTimeQueryValue, + IdleTimeBracketValues); + + pIdleTimeValueLess = pIdleTimeValueGreater = NULL; +} diff --git a/xorg-server/Xext/xf86bigfont.c b/xorg-server/Xext/xf86bigfont.c index 356a6152b..da3528783 100644 --- a/xorg-server/Xext/xf86bigfont.c +++ b/xorg-server/Xext/xf86bigfont.c @@ -1,751 +1,751 @@ -/*
- * BIGFONT extension for sharing font metrics between clients (if possible)
- * and for transmitting font metrics to clients in a compressed form.
- *
- * Copyright (c) 1999-2000 Bruno Haible
- * Copyright (c) 1999-2000 The XFree86 Project, Inc.
- */
-
-/* THIS IS NOT AN X CONSORTIUM STANDARD */
-
-/*
- * Big fonts suffer from the following: All clients that have opened a
- * font can access the complete glyph metrics array (the XFontStruct member
- * `per_char') directly, without going through a macro. Moreover these
- * glyph metrics are ink metrics, i.e. are not redundant even for a
- * fixed-width font. For a Unicode font, the size of this array is 768 KB.
- *
- * Problems: 1. It eats a lot of memory in each client. 2. All this glyph
- * metrics data is piped through the socket when the font is opened.
- *
- * This extension addresses these two problems for local clients, by using
- * shared memory. It also addresses the second problem for non-local clients,
- * by compressing the data before transmit by a factor of nearly 6.
- *
- * If you use this extension, your OS ought to nicely support shared memory.
- * This means: Shared memory should be swappable to the swap, and the limits
- * should be high enough (SHMMNI at least 64, SHMMAX at least 768 KB,
- * SHMALL at least 48 MB). It is a plus if your OS allows shmat() calls
- * on segments that have already been marked "removed", because it permits
- * these segments to be cleaned up by the OS if the X server is killed with
- * signal SIGKILL.
- *
- * This extension is transparently exploited by Xlib (functions XQueryFont,
- * XLoadQueryFont).
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <sys/types.h>
-#ifdef HAS_SHM
-#if defined(linux) && (!defined(__GNU_LIBRARY__) || __GNU_LIBRARY__ < 2)
-/* libc4 does not define __GNU_LIBRARY__, libc5 defines __GNU_LIBRARY__ as 1 */
-/* Linux libc4 and libc5 only (because glibc doesn't include kernel headers):
- Linux 2.0.x and 2.2.x define SHMLBA as PAGE_SIZE, but forget to define
- PAGE_SIZE. It is defined in <asm/page.h>. */
-#include <asm/page.h>
-#endif
-#ifdef SVR4
-#include <sys/sysmacros.h>
-#endif
-#if defined(__CYGWIN__) || defined(__SCO__)
-#include <sys/param.h>
-#include <sys/sysmacros.h>
-#endif
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <time.h>
-#include <errno.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "os.h"
-#include "dixstruct.h"
-#include "gcstruct.h"
-#include "dixfontstr.h"
-#include "extnsionst.h"
-#include "protocol-versions.h"
-
-#include <X11/extensions/xf86bigfproto.h>
-#include "xf86bigfontsrv.h"
-
-static void XF86BigfontResetProc(
- ExtensionEntry * /* extEntry */
- );
-
-
-#ifdef HAS_SHM
-
-/* A random signature, transmitted to the clients so they can verify that the
- shared memory segment they are attaching to was really established by the
- X server they are talking to. */
-static CARD32 signature;
-
-/* Index for additional information stored in a FontRec's devPrivates array. */
-static int FontShmdescIndex;
-
-static unsigned int pagesize;
-
-static Bool badSysCall = FALSE;
-
-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__)
-
-#include <sys/signal.h>
-
-static void
-SigSysHandler(
- int signo)
-{
- badSysCall = TRUE;
-}
-
-static Bool
-CheckForShmSyscall(void)
-{
- void (*oldHandler)(int);
- int shmid = -1;
-
- /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
- oldHandler = signal(SIGSYS, SigSysHandler);
-
- badSysCall = FALSE;
- shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
- if (shmid != -1)
- {
- /* Successful allocation - clean up */
- shmctl(shmid, IPC_RMID, NULL);
- }
- else
- {
- /* Allocation failed */
- badSysCall = TRUE;
- }
- signal(SIGSYS, oldHandler);
- return !badSysCall;
-}
-
-#define MUST_CHECK_FOR_SHM_SYSCALL
-
-#endif
-
-#endif
-
-void
-XFree86BigfontExtensionInit(void)
-{
- if (AddExtension(XF86BIGFONTNAME,
- XF86BigfontNumberEvents,
- XF86BigfontNumberErrors,
- ProcXF86BigfontDispatch,
- SProcXF86BigfontDispatch,
- XF86BigfontResetProc,
- StandardMinorOpcode)) {
-#ifdef HAS_SHM
-#ifdef MUST_CHECK_FOR_SHM_SYSCALL
- /*
- * Note: Local-clients will not be optimized without shared memory
- * support. Remote-client optimization does not depend on shared
- * memory support. Thus, the extension is still registered even
- * when shared memory support is not functional.
- */
- if (!CheckForShmSyscall()) {
- ErrorF(XF86BIGFONTNAME " extension local-client optimization disabled due to lack of shared memory support in the kernel\n");
- return;
- }
-#endif
-
- srand((unsigned int) time(NULL));
- signature = ((unsigned int) (65536.0/(RAND_MAX+1.0) * rand()) << 16)
- + (unsigned int) (65536.0/(RAND_MAX+1.0) * rand());
- /* fprintf(stderr, "signature = 0x%08X\n", signature); */
-
- FontShmdescIndex = AllocateFontPrivateIndex();
-
-#if !defined(CSRG_BASED) && !defined(__CYGWIN__)
- pagesize = SHMLBA;
-#else
-# ifdef _SC_PAGESIZE
- pagesize = sysconf(_SC_PAGESIZE);
-# else
- pagesize = getpagesize();
-# endif
-#endif
-#endif
- }
-}
-
-
-/* ========== Management of shared memory segments ========== */
-
-#ifdef HAS_SHM
-
-#ifdef __linux__
-/* On Linux, shared memory marked as "removed" can still be attached.
- Nice feature, because the kernel will automatically free the associated
- storage when the server and all clients are gone. */
-#define EARLY_REMOVE
-#endif
-
-typedef struct _ShmDesc {
- struct _ShmDesc *next;
- struct _ShmDesc **prev;
- int shmid;
- char *attach_addr;
-} ShmDescRec, *ShmDescPtr;
-
-static ShmDescPtr ShmList = (ShmDescPtr) NULL;
-
-static ShmDescPtr
-shmalloc(
- unsigned int size)
-{
- ShmDescPtr pDesc;
- int shmid;
- char *addr;
-
-#ifdef MUST_CHECK_FOR_SHM_SYSCALL
- if (pagesize == 0)
- return (ShmDescPtr) NULL;
-#endif
-
- /* On some older Linux systems, the number of shared memory segments
- system-wide is 127. In Linux 2.4, it is 4095.
- Therefore there is a tradeoff to be made between allocating a
- shared memory segment on one hand, and allocating memory and piping
- the glyph metrics on the other hand. If the glyph metrics size is
- small, we prefer the traditional way. */
- if (size < 3500)
- return (ShmDescPtr) NULL;
-
- pDesc = malloc(sizeof(ShmDescRec));
- if (!pDesc)
- return (ShmDescPtr) NULL;
-
- size = (size + pagesize-1) & -pagesize;
- shmid = shmget(IPC_PRIVATE, size, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH);
- if (shmid == -1) {
- ErrorF(XF86BIGFONTNAME " extension: shmget() failed, size = %u, %s\n",
- size, strerror(errno));
- free(pDesc);
- return (ShmDescPtr) NULL;
- }
-
- if ((addr = shmat(shmid, 0, 0)) == (char *)-1) {
- ErrorF(XF86BIGFONTNAME " extension: shmat() failed, size = %u, %s\n",
- size, strerror(errno));
- shmctl(shmid, IPC_RMID, (void *) 0);
- free(pDesc);
- return (ShmDescPtr) NULL;
- }
-
-#ifdef EARLY_REMOVE
- shmctl(shmid, IPC_RMID, (void *) 0);
-#endif
-
- pDesc->shmid = shmid;
- pDesc->attach_addr = addr;
- if (ShmList) ShmList->prev = &pDesc->next;
- pDesc->next = ShmList;
- pDesc->prev = &ShmList;
- ShmList = pDesc;
-
- return pDesc;
-}
-
-static void
-shmdealloc(
- ShmDescPtr pDesc)
-{
-#ifndef EARLY_REMOVE
- shmctl(pDesc->shmid, IPC_RMID, (void *) 0);
-#endif
- shmdt(pDesc->attach_addr);
-
- if (pDesc->next) pDesc->next->prev = pDesc->prev;
- *pDesc->prev = pDesc->next;
- free(pDesc);
-}
-
-#endif
-
-/* Called when a font is closed. */
-void
-XF86BigfontFreeFontShm(
- FontPtr pFont)
-{
-#ifdef HAS_SHM
- ShmDescPtr pDesc;
-
- /* If during shutdown of the server, XF86BigfontCleanup() has already
- * called shmdealloc() for all segments, we don't need to do it here.
- */
- if (!ShmList)
- return;
-
- pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
- if (pDesc)
- shmdealloc(pDesc);
-#endif
-}
-
-/* Called upon fatal signal. */
-void
-XF86BigfontCleanup(void)
-{
-#ifdef HAS_SHM
- while (ShmList)
- shmdealloc(ShmList);
-#endif
-}
-
-/* Called when a server generation dies. */
-static void
-XF86BigfontResetProc(
- ExtensionEntry* extEntry)
-{
- /* This function is normally called from CloseDownExtensions(), called
- * from main(). It will be followed by a call to FreeAllResources(),
- * which will call XF86BigfontFreeFontShm() for each font. Thus it
- * appears that we do not need to do anything in this function. --
- * But I prefer to write robust code, and not keep shared memory lying
- * around when it's not needed any more. (Someone might close down the
- * extension without calling FreeAllResources()...)
- */
- XF86BigfontCleanup();
-}
-
-
-/* ========== Handling of extension specific requests ========== */
-
-static int
-ProcXF86BigfontQueryVersion(
- ClientPtr client)
-{
- xXF86BigfontQueryVersionReply reply;
-
- REQUEST_SIZE_MATCH(xXF86BigfontQueryVersionReq);
- reply.type = X_Reply;
- reply.length = 0;
- reply.sequenceNumber = client->sequence;
- reply.majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION;
- reply.minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION;
- reply.uid = geteuid();
- reply.gid = getegid();
-#ifdef HAS_SHM
- reply.signature = signature;
-#else
- reply.signature = 0; /* This is redundant. Avoids uninitialized memory. */
-#endif
- reply.capabilities =
-#ifdef HAS_SHM
- (LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0)
-#else
- 0
-#endif
- ; /* may add more bits here in future versions */
- if (client->swapped) {
- char tmp;
- swaps(&reply.sequenceNumber, tmp);
- swapl(&reply.length, tmp);
- swaps(&reply.majorVersion, tmp);
- swaps(&reply.minorVersion, tmp);
- swapl(&reply.uid, tmp);
- swapl(&reply.gid, tmp);
- swapl(&reply.signature, tmp);
- }
- WriteToClient(client,
- sizeof(xXF86BigfontQueryVersionReply), (char *)&reply);
- return Success;
-}
-
-static void
-swapCharInfo(
- xCharInfo *pCI)
-{
- char tmp;
-
- swaps(&pCI->leftSideBearing, tmp);
- swaps(&pCI->rightSideBearing, tmp);
- swaps(&pCI->characterWidth, tmp);
- swaps(&pCI->ascent, tmp);
- swaps(&pCI->descent, tmp);
- swaps(&pCI->attributes, tmp);
-}
-
-/* static CARD32 hashCI (xCharInfo *p); */
-#define hashCI(p) \
- (CARD32)(((p->leftSideBearing << 27) + (p->leftSideBearing >> 5) + \
- (p->rightSideBearing << 23) + (p->rightSideBearing >> 9) + \
- (p->characterWidth << 16) + \
- (p->ascent << 11) + (p->descent << 6)) ^ p->attributes)
-
-static int
-ProcXF86BigfontQueryFont(
- ClientPtr client)
-{
- FontPtr pFont;
- REQUEST(xXF86BigfontQueryFontReq);
- CARD32 stuff_flags;
- xCharInfo* pmax;
- xCharInfo* pmin;
- int nCharInfos;
- int shmid;
-#ifdef HAS_SHM
- ShmDescPtr pDesc = NULL;
-#else
-#define pDesc 0
-#endif
- xCharInfo* pCI;
- CARD16* pIndex2UniqIndex;
- CARD16* pUniqIndex2Index;
- CARD32 nUniqCharInfos;
-
-#if 0
- REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
-#else
- switch (client->req_len) {
- case 2: /* client with version 1.0 libX11 */
- stuff_flags = (LocalClient(client) && !client->swapped ? XF86Bigfont_FLAGS_Shm : 0);
- break;
- case 3: /* client with version 1.1 libX11 */
- stuff_flags = stuff->flags;
- break;
- default:
- return BadLength;
- }
-#endif
- if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) != Success)
- return BadFont; /* procotol spec says only error is BadFont */
-
- pmax = FONTINKMAX(pFont);
- pmin = FONTINKMIN(pFont);
- nCharInfos =
- (pmax->rightSideBearing == pmin->rightSideBearing
- && pmax->leftSideBearing == pmin->leftSideBearing
- && pmax->descent == pmin->descent
- && pmax->ascent == pmin->ascent
- && pmax->characterWidth == pmin->characterWidth)
- ? 0 : N2dChars(pFont);
- shmid = -1;
- pCI = NULL;
- pIndex2UniqIndex = NULL;
- pUniqIndex2Index = NULL;
- nUniqCharInfos = 0;
-
- if (nCharInfos > 0) {
-#ifdef HAS_SHM
- if (!badSysCall)
- pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex);
- if (pDesc) {
- pCI = (xCharInfo *) pDesc->attach_addr;
- if (stuff_flags & XF86Bigfont_FLAGS_Shm)
- shmid = pDesc->shmid;
- } else {
- if (stuff_flags & XF86Bigfont_FLAGS_Shm && !badSysCall)
- pDesc = shmalloc(nCharInfos * sizeof(xCharInfo)
- + sizeof(CARD32));
- if (pDesc) {
- pCI = (xCharInfo *) pDesc->attach_addr;
- shmid = pDesc->shmid;
- } else {
-#endif
- pCI = malloc(nCharInfos * sizeof(xCharInfo));
- if (!pCI)
- return BadAlloc;
-#ifdef HAS_SHM
- }
-#endif
- /* Fill nCharInfos starting at pCI. */
- {
- xCharInfo* prCI = pCI;
- int ninfos = 0;
- int ncols = pFont->info.lastCol - pFont->info.firstCol + 1;
- int row;
- for (row = pFont->info.firstRow;
- row <= pFont->info.lastRow && ninfos < nCharInfos;
- row++) {
- unsigned char chars[512];
- xCharInfo* tmpCharInfos[256];
- unsigned long count;
- int col;
- unsigned long i;
- i = 0;
- for (col = pFont->info.firstCol;
- col <= pFont->info.lastCol;
- col++) {
- chars[i++] = row;
- chars[i++] = col;
- }
- (*pFont->get_metrics) (pFont, ncols, chars, TwoD16Bit,
- &count, tmpCharInfos);
- for (i = 0; i < count && ninfos < nCharInfos; i++) {
- *prCI++ = *tmpCharInfos[i];
- ninfos++;
- }
- }
- }
-#ifdef HAS_SHM
- if (pDesc && !badSysCall) {
- *(CARD32 *)(pCI + nCharInfos) = signature;
- if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) {
- shmdealloc(pDesc);
- return BadAlloc;
- }
- }
- }
-#endif
- if (shmid == -1) {
- /* Cannot use shared memory, so remove-duplicates the xCharInfos
- using a temporary hash table. */
- /* Note that CARD16 is suitable as index type, because
- nCharInfos <= 0x10000. */
- CARD32 hashModulus;
- CARD16* pHash2UniqIndex;
- CARD16* pUniqIndex2NextUniqIndex;
- CARD32 NextIndex;
- CARD32 NextUniqIndex;
- CARD16* tmp;
- CARD32 i, j;
-
- hashModulus = 67;
- if (hashModulus > nCharInfos+1)
- hashModulus = nCharInfos+1;
-
- tmp = malloc((4*nCharInfos+1) * sizeof(CARD16));
- if (!tmp) {
- if (!pDesc) free(pCI);
- return BadAlloc;
- }
- pIndex2UniqIndex = tmp;
- /* nCharInfos elements */
- pUniqIndex2Index = tmp + nCharInfos;
- /* max. nCharInfos elements */
- pUniqIndex2NextUniqIndex = tmp + 2*nCharInfos;
- /* max. nCharInfos elements */
- pHash2UniqIndex = tmp + 3*nCharInfos;
- /* hashModulus (<= nCharInfos+1) elements */
-
- /* Note that we can use 0xffff as end-of-list indicator, because
- even if nCharInfos = 0x10000, 0xffff can not occur as valid
- entry before the last element has been inserted. And once the
- last element has been inserted, we don't need the hash table
- any more. */
- for (j = 0; j < hashModulus; j++)
- pHash2UniqIndex[j] = (CARD16)(-1);
-
- NextUniqIndex = 0;
- for (NextIndex = 0; NextIndex < nCharInfos; NextIndex++) {
- xCharInfo* p = &pCI[NextIndex];
- CARD32 hashCode = hashCI(p) % hashModulus;
- for (i = pHash2UniqIndex[hashCode];
- i != (CARD16)(-1);
- i = pUniqIndex2NextUniqIndex[i]) {
- j = pUniqIndex2Index[i];
- if (pCI[j].leftSideBearing == p->leftSideBearing
- && pCI[j].rightSideBearing == p->rightSideBearing
- && pCI[j].characterWidth == p->characterWidth
- && pCI[j].ascent == p->ascent
- && pCI[j].descent == p->descent
- && pCI[j].attributes == p->attributes)
- break;
- }
- if (i != (CARD16)(-1)) {
- /* Found *p at Index j, UniqIndex i */
- pIndex2UniqIndex[NextIndex] = i;
- } else {
- /* Allocate a new entry in the Uniq table */
- if (hashModulus <= 2*NextUniqIndex
- && hashModulus < nCharInfos+1) {
- /* Time to increate hash table size */
- hashModulus = 2*hashModulus+1;
- if (hashModulus > nCharInfos+1)
- hashModulus = nCharInfos+1;
- for (j = 0; j < hashModulus; j++)
- pHash2UniqIndex[j] = (CARD16)(-1);
- for (i = 0; i < NextUniqIndex; i++)
- pUniqIndex2NextUniqIndex[i] = (CARD16)(-1);
- for (i = 0; i < NextUniqIndex; i++) {
- j = pUniqIndex2Index[i];
- p = &pCI[j];
- hashCode = hashCI(p) % hashModulus;
- pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode];
- pHash2UniqIndex[hashCode] = i;
- }
- p = &pCI[NextIndex];
- hashCode = hashCI(p) % hashModulus;
- }
- i = NextUniqIndex++;
- pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode];
- pHash2UniqIndex[hashCode] = i;
- pUniqIndex2Index[i] = NextIndex;
- pIndex2UniqIndex[NextIndex] = i;
- }
- }
- nUniqCharInfos = NextUniqIndex;
- /* fprintf(stderr, "font metrics: nCharInfos = %d, nUniqCharInfos = %d, hashModulus = %d\n", nCharInfos, nUniqCharInfos, hashModulus); */
- }
- }
-
- {
- int nfontprops = pFont->info.nprops;
- int rlength =
- sizeof(xXF86BigfontQueryFontReply)
- + nfontprops * sizeof(xFontProp)
- + (nCharInfos > 0 && shmid == -1
- ? nUniqCharInfos * sizeof(xCharInfo)
- + (nCharInfos+1)/2 * 2 * sizeof(CARD16)
- : 0);
- xXF86BigfontQueryFontReply* reply = malloc(rlength);
- char* p;
- if (!reply) {
- if (nCharInfos > 0) {
- if (shmid == -1) free(pIndex2UniqIndex);
- if (!pDesc) free(pCI);
- }
- return BadAlloc;
- }
- reply->type = X_Reply;
- reply->length = bytes_to_int32(rlength - sizeof(xGenericReply));
- reply->sequenceNumber = client->sequence;
- reply->minBounds = pFont->info.ink_minbounds;
- reply->maxBounds = pFont->info.ink_maxbounds;
- reply->minCharOrByte2 = pFont->info.firstCol;
- reply->maxCharOrByte2 = pFont->info.lastCol;
- reply->defaultChar = pFont->info.defaultCh;
- reply->nFontProps = pFont->info.nprops;
- reply->drawDirection = pFont->info.drawDirection;
- reply->minByte1 = pFont->info.firstRow;
- reply->maxByte1 = pFont->info.lastRow;
- reply->allCharsExist = pFont->info.allExist;
- reply->fontAscent = pFont->info.fontAscent;
- reply->fontDescent = pFont->info.fontDescent;
- reply->nCharInfos = nCharInfos;
- reply->nUniqCharInfos = nUniqCharInfos;
- reply->shmid = shmid;
- reply->shmsegoffset = 0;
- if (client->swapped) {
- char tmp;
- swaps(&reply->sequenceNumber, tmp);
- swapl(&reply->length, tmp);
- swapCharInfo(&reply->minBounds);
- swapCharInfo(&reply->maxBounds);
- swaps(&reply->minCharOrByte2, tmp);
- swaps(&reply->maxCharOrByte2, tmp);
- swaps(&reply->defaultChar, tmp);
- swaps(&reply->nFontProps, tmp);
- swaps(&reply->fontAscent, tmp);
- swaps(&reply->fontDescent, tmp);
- swapl(&reply->nCharInfos, tmp);
- swapl(&reply->nUniqCharInfos, tmp);
- swapl(&reply->shmid, tmp);
- swapl(&reply->shmsegoffset, tmp);
- }
- p = (char*) &reply[1];
- {
- FontPropPtr pFP;
- xFontProp* prFP;
- int i;
- for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) p;
- i < nfontprops;
- i++, pFP++, prFP++) {
- prFP->name = pFP->name;
- prFP->value = pFP->value;
- if (client->swapped) {
- char tmp;
- swapl(&prFP->name, tmp);
- swapl(&prFP->value, tmp);
- }
- }
- p = (char*) prFP;
- }
- if (nCharInfos > 0 && shmid == -1) {
- xCharInfo* pci;
- CARD16* ps;
- int i, j;
- pci = (xCharInfo*) p;
- for (i = 0; i < nUniqCharInfos; i++, pci++) {
- *pci = pCI[pUniqIndex2Index[i]];
- if (client->swapped)
- swapCharInfo(pci);
- }
- ps = (CARD16*) pci;
- for (j = 0; j < nCharInfos; j++, ps++) {
- *ps = pIndex2UniqIndex[j];
- if (client->swapped) {
- char tmp;
- swaps(ps, tmp);
- }
- }
- }
- WriteToClient(client, rlength, (char *)reply);
- free(reply);
- if (nCharInfos > 0) {
- if (shmid == -1) free(pIndex2UniqIndex);
- if (!pDesc) free(pCI);
- }
- return Success;
- }
-}
-
-static int
-ProcXF86BigfontDispatch(
- ClientPtr client)
-{
- REQUEST(xReq);
-
- switch (stuff->data) {
- case X_XF86BigfontQueryVersion:
- return ProcXF86BigfontQueryVersion(client);
- case X_XF86BigfontQueryFont:
- return ProcXF86BigfontQueryFont(client);
- default:
- return BadRequest;
- }
-}
-
-static int
-SProcXF86BigfontQueryVersion(
- ClientPtr client)
-{
- REQUEST(xXF86BigfontQueryVersionReq);
- char tmp;
-
- swaps(&stuff->length, tmp);
- return ProcXF86BigfontQueryVersion(client);
-}
-
-static int
-SProcXF86BigfontQueryFont(
- ClientPtr client)
-{
- REQUEST(xXF86BigfontQueryFontReq);
- char tmp;
-
- swaps(&stuff->length, tmp);
- REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq);
- swapl(&stuff->id, tmp);
- return ProcXF86BigfontQueryFont(client);
-}
-
-static int
-SProcXF86BigfontDispatch(
- ClientPtr client)
-{
- REQUEST(xReq);
-
- switch (stuff->data) {
- case X_XF86BigfontQueryVersion:
- return SProcXF86BigfontQueryVersion(client);
- case X_XF86BigfontQueryFont:
- return SProcXF86BigfontQueryFont(client);
- default:
- return BadRequest;
- }
-}
+/* + * BIGFONT extension for sharing font metrics between clients (if possible) + * and for transmitting font metrics to clients in a compressed form. + * + * Copyright (c) 1999-2000 Bruno Haible + * Copyright (c) 1999-2000 The XFree86 Project, Inc. + */ + +/* THIS IS NOT AN X CONSORTIUM STANDARD */ + +/* + * Big fonts suffer from the following: All clients that have opened a + * font can access the complete glyph metrics array (the XFontStruct member + * `per_char') directly, without going through a macro. Moreover these + * glyph metrics are ink metrics, i.e. are not redundant even for a + * fixed-width font. For a Unicode font, the size of this array is 768 KB. + * + * Problems: 1. It eats a lot of memory in each client. 2. All this glyph + * metrics data is piped through the socket when the font is opened. + * + * This extension addresses these two problems for local clients, by using + * shared memory. It also addresses the second problem for non-local clients, + * by compressing the data before transmit by a factor of nearly 6. + * + * If you use this extension, your OS ought to nicely support shared memory. + * This means: Shared memory should be swappable to the swap, and the limits + * should be high enough (SHMMNI at least 64, SHMMAX at least 768 KB, + * SHMALL at least 48 MB). It is a plus if your OS allows shmat() calls + * on segments that have already been marked "removed", because it permits + * these segments to be cleaned up by the OS if the X server is killed with + * signal SIGKILL. + * + * This extension is transparently exploited by Xlib (functions XQueryFont, + * XLoadQueryFont). + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <sys/types.h> +#ifdef HAS_SHM +#if defined(linux) && (!defined(__GNU_LIBRARY__) || __GNU_LIBRARY__ < 2) +/* libc4 does not define __GNU_LIBRARY__, libc5 defines __GNU_LIBRARY__ as 1 */ +/* Linux libc4 and libc5 only (because glibc doesn't include kernel headers): + Linux 2.0.x and 2.2.x define SHMLBA as PAGE_SIZE, but forget to define + PAGE_SIZE. It is defined in <asm/page.h>. */ +#include <asm/page.h> +#endif +#ifdef SVR4 +#include <sys/sysmacros.h> +#endif +#if defined(__CYGWIN__) +#include <sys/param.h> +#include <sys/sysmacros.h> +#endif +#include <sys/ipc.h> +#include <sys/shm.h> +#include <sys/stat.h> +#include <stdlib.h> +#include <unistd.h> +#include <time.h> +#include <errno.h> +#endif + +#include <X11/X.h> +#include <X11/Xproto.h> +#include "misc.h" +#include "os.h" +#include "dixstruct.h" +#include "gcstruct.h" +#include "dixfontstr.h" +#include "extnsionst.h" +#include "protocol-versions.h" + +#include <X11/extensions/xf86bigfproto.h> +#include "xf86bigfontsrv.h" + +static void XF86BigfontResetProc( + ExtensionEntry * /* extEntry */ + ); + + +#ifdef HAS_SHM + +/* A random signature, transmitted to the clients so they can verify that the + shared memory segment they are attaching to was really established by the + X server they are talking to. */ +static CARD32 signature; + +/* Index for additional information stored in a FontRec's devPrivates array. */ +static int FontShmdescIndex; + +static unsigned int pagesize; + +static Bool badSysCall = FALSE; + +#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__DragonFly__) + +#include <sys/signal.h> + +static void +SigSysHandler( + int signo) +{ + badSysCall = TRUE; +} + +static Bool +CheckForShmSyscall(void) +{ + void (*oldHandler)(int); + int shmid = -1; + + /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */ + oldHandler = signal(SIGSYS, SigSysHandler); + + badSysCall = FALSE; + shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT); + if (shmid != -1) + { + /* Successful allocation - clean up */ + shmctl(shmid, IPC_RMID, NULL); + } + else + { + /* Allocation failed */ + badSysCall = TRUE; + } + signal(SIGSYS, oldHandler); + return !badSysCall; +} + +#define MUST_CHECK_FOR_SHM_SYSCALL + +#endif + +#endif + +void +XFree86BigfontExtensionInit(void) +{ + if (AddExtension(XF86BIGFONTNAME, + XF86BigfontNumberEvents, + XF86BigfontNumberErrors, + ProcXF86BigfontDispatch, + SProcXF86BigfontDispatch, + XF86BigfontResetProc, + StandardMinorOpcode)) { +#ifdef HAS_SHM +#ifdef MUST_CHECK_FOR_SHM_SYSCALL + /* + * Note: Local-clients will not be optimized without shared memory + * support. Remote-client optimization does not depend on shared + * memory support. Thus, the extension is still registered even + * when shared memory support is not functional. + */ + if (!CheckForShmSyscall()) { + ErrorF(XF86BIGFONTNAME " extension local-client optimization disabled due to lack of shared memory support in the kernel\n"); + return; + } +#endif + + srand((unsigned int) time(NULL)); + signature = ((unsigned int) (65536.0/(RAND_MAX+1.0) * rand()) << 16) + + (unsigned int) (65536.0/(RAND_MAX+1.0) * rand()); + /* fprintf(stderr, "signature = 0x%08X\n", signature); */ + + FontShmdescIndex = AllocateFontPrivateIndex(); + +#if !defined(CSRG_BASED) && !defined(__CYGWIN__) + pagesize = SHMLBA; +#else +# ifdef _SC_PAGESIZE + pagesize = sysconf(_SC_PAGESIZE); +# else + pagesize = getpagesize(); +# endif +#endif +#endif + } +} + + +/* ========== Management of shared memory segments ========== */ + +#ifdef HAS_SHM + +#ifdef __linux__ +/* On Linux, shared memory marked as "removed" can still be attached. + Nice feature, because the kernel will automatically free the associated + storage when the server and all clients are gone. */ +#define EARLY_REMOVE +#endif + +typedef struct _ShmDesc { + struct _ShmDesc *next; + struct _ShmDesc **prev; + int shmid; + char *attach_addr; +} ShmDescRec, *ShmDescPtr; + +static ShmDescPtr ShmList = (ShmDescPtr) NULL; + +static ShmDescPtr +shmalloc( + unsigned int size) +{ + ShmDescPtr pDesc; + int shmid; + char *addr; + +#ifdef MUST_CHECK_FOR_SHM_SYSCALL + if (pagesize == 0) + return (ShmDescPtr) NULL; +#endif + + /* On some older Linux systems, the number of shared memory segments + system-wide is 127. In Linux 2.4, it is 4095. + Therefore there is a tradeoff to be made between allocating a + shared memory segment on one hand, and allocating memory and piping + the glyph metrics on the other hand. If the glyph metrics size is + small, we prefer the traditional way. */ + if (size < 3500) + return (ShmDescPtr) NULL; + + pDesc = malloc(sizeof(ShmDescRec)); + if (!pDesc) + return (ShmDescPtr) NULL; + + size = (size + pagesize-1) & -pagesize; + shmid = shmget(IPC_PRIVATE, size, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); + if (shmid == -1) { + ErrorF(XF86BIGFONTNAME " extension: shmget() failed, size = %u, %s\n", + size, strerror(errno)); + free(pDesc); + return (ShmDescPtr) NULL; + } + + if ((addr = shmat(shmid, 0, 0)) == (char *)-1) { + ErrorF(XF86BIGFONTNAME " extension: shmat() failed, size = %u, %s\n", + size, strerror(errno)); + shmctl(shmid, IPC_RMID, (void *) 0); + free(pDesc); + return (ShmDescPtr) NULL; + } + +#ifdef EARLY_REMOVE + shmctl(shmid, IPC_RMID, (void *) 0); +#endif + + pDesc->shmid = shmid; + pDesc->attach_addr = addr; + if (ShmList) ShmList->prev = &pDesc->next; + pDesc->next = ShmList; + pDesc->prev = &ShmList; + ShmList = pDesc; + + return pDesc; +} + +static void +shmdealloc( + ShmDescPtr pDesc) +{ +#ifndef EARLY_REMOVE + shmctl(pDesc->shmid, IPC_RMID, (void *) 0); +#endif + shmdt(pDesc->attach_addr); + + if (pDesc->next) pDesc->next->prev = pDesc->prev; + *pDesc->prev = pDesc->next; + free(pDesc); +} + +#endif + +/* Called when a font is closed. */ +void +XF86BigfontFreeFontShm( + FontPtr pFont) +{ +#ifdef HAS_SHM + ShmDescPtr pDesc; + + /* If during shutdown of the server, XF86BigfontCleanup() has already + * called shmdealloc() for all segments, we don't need to do it here. + */ + if (!ShmList) + return; + + pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex); + if (pDesc) + shmdealloc(pDesc); +#endif +} + +/* Called upon fatal signal. */ +void +XF86BigfontCleanup(void) +{ +#ifdef HAS_SHM + while (ShmList) + shmdealloc(ShmList); +#endif +} + +/* Called when a server generation dies. */ +static void +XF86BigfontResetProc( + ExtensionEntry* extEntry) +{ + /* This function is normally called from CloseDownExtensions(), called + * from main(). It will be followed by a call to FreeAllResources(), + * which will call XF86BigfontFreeFontShm() for each font. Thus it + * appears that we do not need to do anything in this function. -- + * But I prefer to write robust code, and not keep shared memory lying + * around when it's not needed any more. (Someone might close down the + * extension without calling FreeAllResources()...) + */ + XF86BigfontCleanup(); +} + + +/* ========== Handling of extension specific requests ========== */ + +static int +ProcXF86BigfontQueryVersion( + ClientPtr client) +{ + xXF86BigfontQueryVersionReply reply; + + REQUEST_SIZE_MATCH(xXF86BigfontQueryVersionReq); + reply.type = X_Reply; + reply.length = 0; + reply.sequenceNumber = client->sequence; + reply.majorVersion = SERVER_XF86BIGFONT_MAJOR_VERSION; + reply.minorVersion = SERVER_XF86BIGFONT_MINOR_VERSION; + reply.uid = geteuid(); + reply.gid = getegid(); +#ifdef HAS_SHM + reply.signature = signature; +#else + reply.signature = 0; /* This is redundant. Avoids uninitialized memory. */ +#endif + reply.capabilities = +#ifdef HAS_SHM + (LocalClient(client) && !client->swapped ? XF86Bigfont_CAP_LocalShm : 0) +#else + 0 +#endif + ; /* may add more bits here in future versions */ + if (client->swapped) { + char tmp; + swaps(&reply.sequenceNumber, tmp); + swapl(&reply.length, tmp); + swaps(&reply.majorVersion, tmp); + swaps(&reply.minorVersion, tmp); + swapl(&reply.uid, tmp); + swapl(&reply.gid, tmp); + swapl(&reply.signature, tmp); + } + WriteToClient(client, + sizeof(xXF86BigfontQueryVersionReply), (char *)&reply); + return Success; +} + +static void +swapCharInfo( + xCharInfo *pCI) +{ + char tmp; + + swaps(&pCI->leftSideBearing, tmp); + swaps(&pCI->rightSideBearing, tmp); + swaps(&pCI->characterWidth, tmp); + swaps(&pCI->ascent, tmp); + swaps(&pCI->descent, tmp); + swaps(&pCI->attributes, tmp); +} + +/* static CARD32 hashCI (xCharInfo *p); */ +#define hashCI(p) \ + (CARD32)(((p->leftSideBearing << 27) + (p->leftSideBearing >> 5) + \ + (p->rightSideBearing << 23) + (p->rightSideBearing >> 9) + \ + (p->characterWidth << 16) + \ + (p->ascent << 11) + (p->descent << 6)) ^ p->attributes) + +static int +ProcXF86BigfontQueryFont( + ClientPtr client) +{ + FontPtr pFont; + REQUEST(xXF86BigfontQueryFontReq); + CARD32 stuff_flags; + xCharInfo* pmax; + xCharInfo* pmin; + int nCharInfos; + int shmid; +#ifdef HAS_SHM + ShmDescPtr pDesc = NULL; +#else +#define pDesc 0 +#endif + xCharInfo* pCI; + CARD16* pIndex2UniqIndex; + CARD16* pUniqIndex2Index; + CARD32 nUniqCharInfos; + +#if 0 + REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq); +#else + switch (client->req_len) { + case 2: /* client with version 1.0 libX11 */ + stuff_flags = (LocalClient(client) && !client->swapped ? XF86Bigfont_FLAGS_Shm : 0); + break; + case 3: /* client with version 1.1 libX11 */ + stuff_flags = stuff->flags; + break; + default: + return BadLength; + } +#endif + if (dixLookupFontable(&pFont, stuff->id, client, DixGetAttrAccess) != Success) + return BadFont; /* procotol spec says only error is BadFont */ + + pmax = FONTINKMAX(pFont); + pmin = FONTINKMIN(pFont); + nCharInfos = + (pmax->rightSideBearing == pmin->rightSideBearing + && pmax->leftSideBearing == pmin->leftSideBearing + && pmax->descent == pmin->descent + && pmax->ascent == pmin->ascent + && pmax->characterWidth == pmin->characterWidth) + ? 0 : N2dChars(pFont); + shmid = -1; + pCI = NULL; + pIndex2UniqIndex = NULL; + pUniqIndex2Index = NULL; + nUniqCharInfos = 0; + + if (nCharInfos > 0) { +#ifdef HAS_SHM + if (!badSysCall) + pDesc = (ShmDescPtr) FontGetPrivate(pFont, FontShmdescIndex); + if (pDesc) { + pCI = (xCharInfo *) pDesc->attach_addr; + if (stuff_flags & XF86Bigfont_FLAGS_Shm) + shmid = pDesc->shmid; + } else { + if (stuff_flags & XF86Bigfont_FLAGS_Shm && !badSysCall) + pDesc = shmalloc(nCharInfos * sizeof(xCharInfo) + + sizeof(CARD32)); + if (pDesc) { + pCI = (xCharInfo *) pDesc->attach_addr; + shmid = pDesc->shmid; + } else { +#endif + pCI = malloc(nCharInfos * sizeof(xCharInfo)); + if (!pCI) + return BadAlloc; +#ifdef HAS_SHM + } +#endif + /* Fill nCharInfos starting at pCI. */ + { + xCharInfo* prCI = pCI; + int ninfos = 0; + int ncols = pFont->info.lastCol - pFont->info.firstCol + 1; + int row; + for (row = pFont->info.firstRow; + row <= pFont->info.lastRow && ninfos < nCharInfos; + row++) { + unsigned char chars[512]; + xCharInfo* tmpCharInfos[256]; + unsigned long count; + int col; + unsigned long i; + i = 0; + for (col = pFont->info.firstCol; + col <= pFont->info.lastCol; + col++) { + chars[i++] = row; + chars[i++] = col; + } + (*pFont->get_metrics) (pFont, ncols, chars, TwoD16Bit, + &count, tmpCharInfos); + for (i = 0; i < count && ninfos < nCharInfos; i++) { + *prCI++ = *tmpCharInfos[i]; + ninfos++; + } + } + } +#ifdef HAS_SHM + if (pDesc && !badSysCall) { + *(CARD32 *)(pCI + nCharInfos) = signature; + if (!FontSetPrivate(pFont, FontShmdescIndex, pDesc)) { + shmdealloc(pDesc); + return BadAlloc; + } + } + } +#endif + if (shmid == -1) { + /* Cannot use shared memory, so remove-duplicates the xCharInfos + using a temporary hash table. */ + /* Note that CARD16 is suitable as index type, because + nCharInfos <= 0x10000. */ + CARD32 hashModulus; + CARD16* pHash2UniqIndex; + CARD16* pUniqIndex2NextUniqIndex; + CARD32 NextIndex; + CARD32 NextUniqIndex; + CARD16* tmp; + CARD32 i, j; + + hashModulus = 67; + if (hashModulus > nCharInfos+1) + hashModulus = nCharInfos+1; + + tmp = malloc((4*nCharInfos+1) * sizeof(CARD16)); + if (!tmp) { + if (!pDesc) free(pCI); + return BadAlloc; + } + pIndex2UniqIndex = tmp; + /* nCharInfos elements */ + pUniqIndex2Index = tmp + nCharInfos; + /* max. nCharInfos elements */ + pUniqIndex2NextUniqIndex = tmp + 2*nCharInfos; + /* max. nCharInfos elements */ + pHash2UniqIndex = tmp + 3*nCharInfos; + /* hashModulus (<= nCharInfos+1) elements */ + + /* Note that we can use 0xffff as end-of-list indicator, because + even if nCharInfos = 0x10000, 0xffff can not occur as valid + entry before the last element has been inserted. And once the + last element has been inserted, we don't need the hash table + any more. */ + for (j = 0; j < hashModulus; j++) + pHash2UniqIndex[j] = (CARD16)(-1); + + NextUniqIndex = 0; + for (NextIndex = 0; NextIndex < nCharInfos; NextIndex++) { + xCharInfo* p = &pCI[NextIndex]; + CARD32 hashCode = hashCI(p) % hashModulus; + for (i = pHash2UniqIndex[hashCode]; + i != (CARD16)(-1); + i = pUniqIndex2NextUniqIndex[i]) { + j = pUniqIndex2Index[i]; + if (pCI[j].leftSideBearing == p->leftSideBearing + && pCI[j].rightSideBearing == p->rightSideBearing + && pCI[j].characterWidth == p->characterWidth + && pCI[j].ascent == p->ascent + && pCI[j].descent == p->descent + && pCI[j].attributes == p->attributes) + break; + } + if (i != (CARD16)(-1)) { + /* Found *p at Index j, UniqIndex i */ + pIndex2UniqIndex[NextIndex] = i; + } else { + /* Allocate a new entry in the Uniq table */ + if (hashModulus <= 2*NextUniqIndex + && hashModulus < nCharInfos+1) { + /* Time to increate hash table size */ + hashModulus = 2*hashModulus+1; + if (hashModulus > nCharInfos+1) + hashModulus = nCharInfos+1; + for (j = 0; j < hashModulus; j++) + pHash2UniqIndex[j] = (CARD16)(-1); + for (i = 0; i < NextUniqIndex; i++) + pUniqIndex2NextUniqIndex[i] = (CARD16)(-1); + for (i = 0; i < NextUniqIndex; i++) { + j = pUniqIndex2Index[i]; + p = &pCI[j]; + hashCode = hashCI(p) % hashModulus; + pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode]; + pHash2UniqIndex[hashCode] = i; + } + p = &pCI[NextIndex]; + hashCode = hashCI(p) % hashModulus; + } + i = NextUniqIndex++; + pUniqIndex2NextUniqIndex[i] = pHash2UniqIndex[hashCode]; + pHash2UniqIndex[hashCode] = i; + pUniqIndex2Index[i] = NextIndex; + pIndex2UniqIndex[NextIndex] = i; + } + } + nUniqCharInfos = NextUniqIndex; + /* fprintf(stderr, "font metrics: nCharInfos = %d, nUniqCharInfos = %d, hashModulus = %d\n", nCharInfos, nUniqCharInfos, hashModulus); */ + } + } + + { + int nfontprops = pFont->info.nprops; + int rlength = + sizeof(xXF86BigfontQueryFontReply) + + nfontprops * sizeof(xFontProp) + + (nCharInfos > 0 && shmid == -1 + ? nUniqCharInfos * sizeof(xCharInfo) + + (nCharInfos+1)/2 * 2 * sizeof(CARD16) + : 0); + xXF86BigfontQueryFontReply* reply = malloc(rlength); + char* p; + if (!reply) { + if (nCharInfos > 0) { + if (shmid == -1) free(pIndex2UniqIndex); + if (!pDesc) free(pCI); + } + return BadAlloc; + } + reply->type = X_Reply; + reply->length = bytes_to_int32(rlength - sizeof(xGenericReply)); + reply->sequenceNumber = client->sequence; + reply->minBounds = pFont->info.ink_minbounds; + reply->maxBounds = pFont->info.ink_maxbounds; + reply->minCharOrByte2 = pFont->info.firstCol; + reply->maxCharOrByte2 = pFont->info.lastCol; + reply->defaultChar = pFont->info.defaultCh; + reply->nFontProps = pFont->info.nprops; + reply->drawDirection = pFont->info.drawDirection; + reply->minByte1 = pFont->info.firstRow; + reply->maxByte1 = pFont->info.lastRow; + reply->allCharsExist = pFont->info.allExist; + reply->fontAscent = pFont->info.fontAscent; + reply->fontDescent = pFont->info.fontDescent; + reply->nCharInfos = nCharInfos; + reply->nUniqCharInfos = nUniqCharInfos; + reply->shmid = shmid; + reply->shmsegoffset = 0; + if (client->swapped) { + char tmp; + swaps(&reply->sequenceNumber, tmp); + swapl(&reply->length, tmp); + swapCharInfo(&reply->minBounds); + swapCharInfo(&reply->maxBounds); + swaps(&reply->minCharOrByte2, tmp); + swaps(&reply->maxCharOrByte2, tmp); + swaps(&reply->defaultChar, tmp); + swaps(&reply->nFontProps, tmp); + swaps(&reply->fontAscent, tmp); + swaps(&reply->fontDescent, tmp); + swapl(&reply->nCharInfos, tmp); + swapl(&reply->nUniqCharInfos, tmp); + swapl(&reply->shmid, tmp); + swapl(&reply->shmsegoffset, tmp); + } + p = (char*) &reply[1]; + { + FontPropPtr pFP; + xFontProp* prFP; + int i; + for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) p; + i < nfontprops; + i++, pFP++, prFP++) { + prFP->name = pFP->name; + prFP->value = pFP->value; + if (client->swapped) { + char tmp; + swapl(&prFP->name, tmp); + swapl(&prFP->value, tmp); + } + } + p = (char*) prFP; + } + if (nCharInfos > 0 && shmid == -1) { + xCharInfo* pci; + CARD16* ps; + int i, j; + pci = (xCharInfo*) p; + for (i = 0; i < nUniqCharInfos; i++, pci++) { + *pci = pCI[pUniqIndex2Index[i]]; + if (client->swapped) + swapCharInfo(pci); + } + ps = (CARD16*) pci; + for (j = 0; j < nCharInfos; j++, ps++) { + *ps = pIndex2UniqIndex[j]; + if (client->swapped) { + char tmp; + swaps(ps, tmp); + } + } + } + WriteToClient(client, rlength, (char *)reply); + free(reply); + if (nCharInfos > 0) { + if (shmid == -1) free(pIndex2UniqIndex); + if (!pDesc) free(pCI); + } + return Success; + } +} + +static int +ProcXF86BigfontDispatch( + ClientPtr client) +{ + REQUEST(xReq); + + switch (stuff->data) { + case X_XF86BigfontQueryVersion: + return ProcXF86BigfontQueryVersion(client); + case X_XF86BigfontQueryFont: + return ProcXF86BigfontQueryFont(client); + default: + return BadRequest; + } +} + +static int +SProcXF86BigfontQueryVersion( + ClientPtr client) +{ + REQUEST(xXF86BigfontQueryVersionReq); + char tmp; + + swaps(&stuff->length, tmp); + return ProcXF86BigfontQueryVersion(client); +} + +static int +SProcXF86BigfontQueryFont( + ClientPtr client) +{ + REQUEST(xXF86BigfontQueryFontReq); + char tmp; + + swaps(&stuff->length, tmp); + REQUEST_SIZE_MATCH(xXF86BigfontQueryFontReq); + swapl(&stuff->id, tmp); + return ProcXF86BigfontQueryFont(client); +} + +static int +SProcXF86BigfontDispatch( + ClientPtr client) +{ + REQUEST(xReq); + + switch (stuff->data) { + case X_XF86BigfontQueryVersion: + return SProcXF86BigfontQueryVersion(client); + case X_XF86BigfontQueryFont: + return SProcXF86BigfontQueryFont(client); + default: + return BadRequest; + } +} diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac index a5967ad03..1ceffe7cb 100644 --- a/xorg-server/configure.ac +++ b/xorg-server/configure.ac @@ -2224,7 +2224,6 @@ 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/sco/Makefile hw/xfree86/os-support/solaris/Makefile hw/xfree86/parser/Makefile hw/xfree86/ramdac/Makefile diff --git a/xorg-server/dix/dixfonts.c b/xorg-server/dix/dixfonts.c index ce9309f40..9cd8e3bbd 100644 --- a/xorg-server/dix/dixfonts.c +++ b/xorg-server/dix/dixfonts.c @@ -1,2086 +1,2086 @@ -/************************************************************************
-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.
-
-************************************************************************/
-/* The panoramix components contained the following notice */
-/*
-Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts.
-
-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.
-
-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
-DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING,
-BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation
-shall not be used in advertising or otherwise to promote the sale, use or other
-dealings in this Software without prior written authorization from Digital
-Equipment Corporation.
-
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include <X11/Xproto.h>
-#include "scrnintstr.h"
-#include "resource.h"
-#include "dixstruct.h"
-#include "cursorstr.h"
-#include "misc.h"
-#include "opaque.h"
-#include "dixfontstr.h"
-#include "closestr.h"
-#include "dixfont.h"
-#include "xace.h"
-
-#ifdef DEBUG
-#include <stdio.h>
-#endif
-
-#ifdef XF86BIGFONT
-#include "xf86bigfontsrv.h"
-#endif
-
-#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics
-
-extern pointer fosNaturalParams;
-extern FontPtr defaultFont;
-
-static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0;
-static int num_fpes = 0;
-static FPEFunctions *fpe_functions = (FPEFunctions *) 0;
-static int num_fpe_types = 0;
-
-static unsigned char *font_path_string;
-
-static int num_slept_fpes = 0;
-static int size_slept_fpes = 0;
-static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0;
-static FontPatternCachePtr patternCache;
-
-static int
-FontToXError(int err)
-{
- switch (err) {
- case Successful:
- return Success;
- case AllocError:
- return BadAlloc;
- case BadFontName:
- return BadName;
- case BadFontPath:
- case BadFontFormat: /* is there something better? */
- case BadCharRange:
- return BadValue;
- default:
- return err;
- }
-}
-
-static int
-LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size,
- unsigned char *data)
-{
- if (fpe_functions[pfont->fpe->type].load_glyphs)
- return (*fpe_functions[pfont->fpe->type].load_glyphs)
- (client, pfont, 0, nchars, item_size, data);
- else
- return Successful;
-}
-
-/*
- * adding RT_FONT prevents conflict with default cursor font
- */
-Bool
-SetDefaultFont(char *defaultfontname)
-{
- int err;
- FontPtr pf;
- XID fid;
- static FontPtr last_pf;
-
- fid = FakeClientID(0);
- err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync,
- (unsigned) strlen(defaultfontname), defaultfontname);
- if (err != Success)
- return FALSE;
- err = dixLookupResourceByType((pointer *)&pf, fid, RT_FONT, serverClient,
- DixReadAccess);
- if (err == Success) last_pf = pf;
- if (last_pf == (FontPtr) NULL)
- return FALSE;
- defaultFont = last_pf;
- return TRUE;
-}
-
-/*
- * note that the font wakeup queue is not refcounted. this is because
- * an fpe needs to be added when it's inited, and removed when it's finally
- * freed, in order to handle any data that isn't requested, like FS events.
- *
- * since the only thing that should call these routines is the renderer's
- * init_fpe() and free_fpe(), there shouldn't be any problem in using
- * freed data.
- */
-void
-QueueFontWakeup(FontPathElementPtr fpe)
-{
- int i;
- FontPathElementPtr *new;
-
- for (i = 0; i < num_slept_fpes; i++) {
- if (slept_fpes[i] == fpe) {
- return;
- }
- }
- if (num_slept_fpes == size_slept_fpes) {
- new = (FontPathElementPtr *)
- realloc(slept_fpes,
- sizeof(FontPathElementPtr) * (size_slept_fpes + 4));
- if (!new)
- return;
- slept_fpes = new;
- size_slept_fpes += 4;
- }
- slept_fpes[num_slept_fpes] = fpe;
- num_slept_fpes++;
-}
-
-void
-RemoveFontWakeup(FontPathElementPtr fpe)
-{
- int i,
- j;
-
- for (i = 0; i < num_slept_fpes; i++) {
- if (slept_fpes[i] == fpe) {
- for (j = i; j < num_slept_fpes; j++) {
- slept_fpes[j] = slept_fpes[j + 1];
- }
- num_slept_fpes--;
- return;
- }
- }
-}
-
-void
-FontWakeup(pointer data, int count, pointer LastSelectMask)
-{
- int i;
- FontPathElementPtr fpe;
-
- if (count < 0)
- return;
- /* wake up any fpe's that may be waiting for information */
- for (i = 0; i < num_slept_fpes; i++) {
- fpe = slept_fpes[i];
- (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask);
- }
-}
-
-/* XXX -- these two funcs may want to be broken into macros */
-static void
-UseFPE(FontPathElementPtr fpe)
-{
- fpe->refcount++;
-}
-
-static void
-FreeFPE (FontPathElementPtr fpe)
-{
- fpe->refcount--;
- if (fpe->refcount == 0) {
- (*fpe_functions[fpe->type].free_fpe) (fpe);
- free(fpe->name);
- free(fpe);
- }
-}
-
-static Bool
-doOpenFont(ClientPtr client, OFclosurePtr c)
-{
- FontPtr pfont = NullFont;
- FontPathElementPtr fpe = NULL;
- ScreenPtr pScr;
- int err = Successful;
- int i;
- char *alias,
- *newname;
- int newlen;
- int aliascount = 20;
- /*
- * Decide at runtime what FontFormat to use.
- */
- Mask FontFormat =
-
- ((screenInfo.imageByteOrder == LSBFirst) ?
- BitmapFormatByteOrderLSB : BitmapFormatByteOrderMSB) |
-
- ((screenInfo.bitmapBitOrder == LSBFirst) ?
- BitmapFormatBitOrderLSB : BitmapFormatBitOrderMSB) |
-
- BitmapFormatImageRectMin |
-
-#if GLYPHPADBYTES == 1
- BitmapFormatScanlinePad8 |
-#endif
-
-#if GLYPHPADBYTES == 2
- BitmapFormatScanlinePad16 |
-#endif
-
-#if GLYPHPADBYTES == 4
- BitmapFormatScanlinePad32 |
-#endif
-
-#if GLYPHPADBYTES == 8
- BitmapFormatScanlinePad64 |
-#endif
-
- BitmapFormatScanlineUnit8;
-
- if (client->clientGone)
- {
- if (c->current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current_fpe];
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
- err = Successful;
- goto bail;
- }
- while (c->current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current_fpe];
- err = (*fpe_functions[fpe->type].open_font)
- ((pointer) client, fpe, c->flags,
- c->fontname, c->fnamelen, FontFormat,
- BitmapFormatMaskByte |
- BitmapFormatMaskBit |
- BitmapFormatMaskImageRectangle |
- BitmapFormatMaskScanLinePad |
- BitmapFormatMaskScanLineUnit,
- c->fontid, &pfont, &alias,
- c->non_cachable_font && c->non_cachable_font->fpe == fpe ?
- c->non_cachable_font :
- (FontPtr)0);
-
- if (err == FontNameAlias && alias) {
- newlen = strlen(alias);
- newname = (char *) realloc(c->fontname, newlen);
- if (!newname) {
- err = AllocError;
- break;
- }
- memmove(newname, alias, newlen);
- c->fontname = newname;
- c->fnamelen = newlen;
- c->current_fpe = 0;
- if (--aliascount <= 0) {
- /* We've tried resolving this alias 20 times, we're
- * probably stuck in an infinite loop of aliases pointing
- * to each other - time to take emergency exit!
- */
- err = BadImplementation;
- break;
- }
- continue;
- }
- if (err == BadFontName) {
- c->current_fpe++;
- continue;
- }
- if (err == Suspended) {
- if (!ClientIsAsleep(client))
- ClientSleep(client, (ClientSleepProcPtr)doOpenFont, c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
- break;
- }
-
- if (err != Successful)
- goto bail;
- if (!pfont) {
- err = BadFontName;
- goto bail;
- }
- /* check values for firstCol, lastCol, firstRow, and lastRow */
- if (pfont->info.firstCol > pfont->info.lastCol ||
- pfont->info.firstRow > pfont->info.lastRow ||
- pfont->info.lastCol - pfont->info.firstCol > 255) {
- err = AllocError;
- goto bail;
- }
- if (!pfont->fpe)
- pfont->fpe = fpe;
- pfont->refcnt++;
- if (pfont->refcnt == 1) {
- UseFPE(pfont->fpe);
- for (i = 0; i < screenInfo.numScreens; i++) {
- pScr = screenInfo.screens[i];
- if (pScr->RealizeFont)
- {
- if (!(*pScr->RealizeFont) (pScr, pfont))
- {
- CloseFont (pfont, (Font) 0);
- err = AllocError;
- goto bail;
- }
- }
- }
- }
- if (!AddResource(c->fontid, RT_FONT, (pointer) pfont)) {
- err = AllocError;
- goto bail;
- }
- if (patternCache && pfont != c->non_cachable_font)
- CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen,
- pfont);
-bail:
- if (err != Successful && c->client != serverClient) {
- SendErrorToClient(c->client, X_OpenFont, 0,
- c->fontid, FontToXError(err));
- }
- ClientWakeup(c->client);
-xinerama_sleep:
- for (i = 0; i < c->num_fpes; i++) {
- FreeFPE(c->fpe_list[i]);
- }
- free(c->fpe_list);
- free(c->fontname);
- free(c);
- return TRUE;
-}
-
-int
-OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname)
-{
- OFclosurePtr c;
- int i;
- FontPtr cached = (FontPtr)0;
-
-#ifdef FONTDEBUG
- char *f;
- f = malloc(lenfname + 1);
- memmove(f, pfontname, lenfname);
- f[lenfname] = '\0';
- ErrorF("[dix] OpenFont: fontname is \"%s\"\n", f);
- free(f);
-#endif
- if (!lenfname || lenfname > XLFDMAXFONTNAMELEN)
- return BadName;
- if (patternCache)
- {
-
- /*
- ** Check name cache. If we find a cached version of this font that
- ** is cachable, immediately satisfy the request with it. If we find
- ** a cached version of this font that is non-cachable, we do not
- ** satisfy the request with it. Instead, we pass the FontPtr to the
- ** FPE's open_font code (the fontfile FPE in turn passes the
- ** information to the rasterizer; the fserve FPE ignores it).
- **
- ** Presumably, the font is marked non-cachable because the FPE has
- ** put some licensing restrictions on it. If the FPE, using
- ** whatever logic it relies on, determines that it is willing to
- ** share this existing font with the client, then it has the option
- ** to return the FontPtr we passed it as the newly-opened font.
- ** This allows the FPE to exercise its licensing logic without
- ** having to create another instance of a font that already exists.
- */
-
- cached = FindCachedFontPattern(patternCache, pfontname, lenfname);
- if (cached && cached->info.cachable)
- {
- if (!AddResource(fid, RT_FONT, (pointer) cached))
- return BadAlloc;
- cached->refcnt++;
- return Success;
- }
- }
- c = malloc(sizeof(OFclosureRec));
- if (!c)
- return BadAlloc;
- c->fontname = malloc(lenfname);
- c->origFontName = pfontname;
- c->origFontNameLen = lenfname;
- if (!c->fontname) {
- free(c);
- return BadAlloc;
- }
- /*
- * copy the current FPE list, so that if it gets changed by another client
- * while we're blocking, the request still appears atomic
- */
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
- if (!c->fpe_list) {
- free(c->fontname);
- free(c);
- return BadAlloc;
- }
- memmove(c->fontname, pfontname, lenfname);
- for (i = 0; i < num_fpes; i++) {
- c->fpe_list[i] = font_path_elements[i];
- UseFPE(c->fpe_list[i]);
- }
- c->client = client;
- c->fontid = fid;
- c->current_fpe = 0;
- c->num_fpes = num_fpes;
- c->fnamelen = lenfname;
- c->flags = flags;
- c->non_cachable_font = cached;
-
- (void) doOpenFont(client, c);
- return Success;
-}
-
-/**
- * Decrement font's ref count, and free storage if ref count equals zero
- *
- * \param value must conform to DeleteType
- */
-int
-CloseFont(pointer value, XID fid)
-{
- int nscr;
- ScreenPtr pscr;
- FontPathElementPtr fpe;
- FontPtr pfont = (FontPtr)value;
-
- if (pfont == NullFont)
- return Success;
- if (--pfont->refcnt == 0) {
- if (patternCache)
- RemoveCachedFontPattern (patternCache, pfont);
- /*
- * since the last reference is gone, ask each screen to free any
- * storage it may have allocated locally for it.
- */
- for (nscr = 0; nscr < screenInfo.numScreens; nscr++) {
- pscr = screenInfo.screens[nscr];
- if (pscr->UnrealizeFont)
- (*pscr->UnrealizeFont) (pscr, pfont);
- }
- if (pfont == defaultFont)
- defaultFont = NULL;
-#ifdef XF86BIGFONT
- XF86BigfontFreeFontShm(pfont);
-#endif
- fpe = pfont->fpe;
- (*fpe_functions[fpe->type].close_font) (fpe, pfont);
- FreeFPE(fpe);
- }
- return Success;
-}
-
-
-/***====================================================================***/
-
-/**
- * Sets up pReply as the correct QueryFontReply for pFont with the first
- * nProtoCCIStructs char infos.
- *
- * \param pReply caller must allocate this storage
- */
-void
-QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs)
-{
- FontPropPtr pFP;
- int r,
- c,
- i;
- xFontProp *prFP;
- xCharInfo *prCI;
- xCharInfo *charInfos[256];
- unsigned char chars[512];
- int ninfos;
- unsigned long ncols;
- unsigned long count;
-
- /* pr->length set in dispatch */
- pReply->minCharOrByte2 = pFont->info.firstCol;
- pReply->defaultChar = pFont->info.defaultCh;
- pReply->maxCharOrByte2 = pFont->info.lastCol;
- pReply->drawDirection = pFont->info.drawDirection;
- pReply->allCharsExist = pFont->info.allExist;
- pReply->minByte1 = pFont->info.firstRow;
- pReply->maxByte1 = pFont->info.lastRow;
- pReply->fontAscent = pFont->info.fontAscent;
- pReply->fontDescent = pFont->info.fontDescent;
-
- pReply->minBounds = pFont->info.ink_minbounds;
- pReply->maxBounds = pFont->info.ink_maxbounds;
-
- pReply->nFontProps = pFont->info.nprops;
- pReply->nCharInfos = nProtoCCIStructs;
-
- for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]);
- i < pFont->info.nprops;
- i++, pFP++, prFP++) {
- prFP->name = pFP->name;
- prFP->value = pFP->value;
- }
-
- ninfos = 0;
- ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1);
- prCI = (xCharInfo *) (prFP);
- for (r = pFont->info.firstRow;
- ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow;
- r++) {
- i = 0;
- for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) {
- chars[i++] = r;
- chars[i++] = c;
- }
- (*pFont->get_metrics) (pFont, ncols, chars,
- TwoD16Bit, &count, charInfos);
- i = 0;
- for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) {
- *prCI = *charInfos[i];
- prCI++;
- ninfos++;
- }
- }
- return;
-}
-
-static Bool
-doListFontsAndAliases(ClientPtr client, LFclosurePtr c)
-{
- FontPathElementPtr fpe;
- int err = Successful;
- FontNamesPtr names = NULL;
- char *name, *resolved=NULL;
- int namelen, resolvedlen;
- int nnames;
- int stringLens;
- int i;
- xListFontsReply reply;
- char *bufptr;
- char *bufferStart;
- int aliascount = 0;
-
- if (client->clientGone)
- {
- if (c->current.current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current.current_fpe];
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
- err = Successful;
- goto bail;
- }
-
- if (!c->current.patlen)
- goto finish;
-
- while (c->current.current_fpe < c->num_fpes) {
- fpe = c->fpe_list[c->current.current_fpe];
- err = Successful;
-
- if (!fpe_functions[fpe->type].start_list_fonts_and_aliases)
- {
- /* This FPE doesn't support/require list_fonts_and_aliases */
-
- err = (*fpe_functions[fpe->type].list_fonts)
- ((pointer) c->client, fpe, c->current.pattern,
- c->current.patlen, c->current.max_names - c->names->nnames,
- c->names);
-
- if (err == Suspended) {
- if (!ClientIsAsleep(client))
- ClientSleep(client,
- (ClientSleepProcPtr)doListFontsAndAliases,
- c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
-
- err = BadFontName;
- }
- else
- {
- /* Start of list_fonts_and_aliases functionality. Modeled
- after list_fonts_with_info in that it resolves aliases,
- except that the information collected from FPEs is just
- names, not font info. Each list_next_font_or_alias()
- returns either a name into name/namelen or an alias into
- name/namelen and its target name into resolved/resolvedlen.
- The code at this level then resolves the alias by polling
- the FPEs. */
-
- if (!c->current.list_started) {
- err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases)
- ((pointer) c->client, fpe, c->current.pattern,
- c->current.patlen, c->current.max_names - c->names->nnames,
- &c->current.private);
- if (err == Suspended) {
- if (!ClientIsAsleep(client))
- ClientSleep(client,
- (ClientSleepProcPtr)doListFontsAndAliases,
- c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
- if (err == Successful)
- c->current.list_started = TRUE;
- }
- if (err == Successful) {
- char *tmpname;
- name = 0;
- err = (*fpe_functions[fpe->type].list_next_font_or_alias)
- ((pointer) c->client, fpe, &name, &namelen, &tmpname,
- &resolvedlen, c->current.private);
- if (err == Suspended) {
- if (ClientIsAsleep(client))
- ClientSleep(client,
- (ClientSleepProcPtr)doListFontsAndAliases,
- c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
- if (err == FontNameAlias) {
- free(resolved);
- resolved = malloc(resolvedlen + 1);
- if (resolved)
- memmove(resolved, tmpname, resolvedlen + 1);
- }
- }
-
- if (err == Successful)
- {
- if (c->haveSaved)
- {
- if (c->savedName)
- (void)AddFontNamesName(c->names, c->savedName,
- c->savedNameLen);
- }
- else
- (void)AddFontNamesName(c->names, name, namelen);
- }
-
- /*
- * When we get an alias back, save our state and reset back to
- * the start of the FPE looking for the specified name. As
- * soon as a real font is found for the alias, pop back to the
- * old state
- */
- else if (err == FontNameAlias) {
- char tmp_pattern[XLFDMAXFONTNAMELEN];
- /*
- * when an alias recurses, we need to give
- * the last FPE a chance to clean up; so we call
- * it again, and assume that the error returned
- * is BadFontName, indicating the alias resolution
- * is complete.
- */
- memmove(tmp_pattern, resolved, resolvedlen);
- if (c->haveSaved)
- {
- char *tmpname;
- int tmpnamelen;
-
- tmpname = 0;
- (void) (*fpe_functions[fpe->type].list_next_font_or_alias)
- ((pointer) c->client, fpe, &tmpname, &tmpnamelen,
- &tmpname, &tmpnamelen, c->current.private);
- if (--aliascount <= 0)
- {
- err = BadFontName;
- goto ContBadFontName;
- }
- }
- else
- {
- c->saved = c->current;
- c->haveSaved = TRUE;
- free(c->savedName);
- c->savedName = malloc(namelen + 1);
- if (c->savedName)
- memmove(c->savedName, name, namelen + 1);
- c->savedNameLen = namelen;
- aliascount = 20;
- }
- memmove(c->current.pattern, tmp_pattern, resolvedlen);
- c->current.patlen = resolvedlen;
- c->current.max_names = c->names->nnames + 1;
- c->current.current_fpe = -1;
- c->current.private = 0;
- err = BadFontName;
- }
- }
- /*
- * At the end of this FPE, step to the next. If we've finished
- * processing an alias, pop state back. If we've collected enough
- * font names, quit.
- */
- if (err == BadFontName) {
- ContBadFontName: ;
- c->current.list_started = FALSE;
- c->current.current_fpe++;
- err = Successful;
- if (c->haveSaved)
- {
- if (c->names->nnames == c->current.max_names ||
- c->current.current_fpe == c->num_fpes) {
- c->haveSaved = FALSE;
- c->current = c->saved;
- /* Give the saved namelist a chance to clean itself up */
- continue;
- }
- }
- if (c->names->nnames == c->current.max_names)
- break;
- }
- }
-
- /*
- * send the reply
- */
- if (err != Successful) {
- SendErrorToClient(client, X_ListFonts, 0, 0, FontToXError(err));
- goto bail;
- }
-
-finish:
-
- names = c->names;
- nnames = names->nnames;
- client = c->client;
- stringLens = 0;
- for (i = 0; i < nnames; i++)
- stringLens += (names->length[i] <= 255) ? names->length[i] : 0;
-
- memset(&reply, 0, sizeof(xListFontsReply));
- reply.type = X_Reply;
- reply.length = bytes_to_int32(stringLens + nnames);
- reply.nFonts = nnames;
- reply.sequenceNumber = client->sequence;
-
- bufptr = bufferStart = malloc(reply.length << 2);
-
- if (!bufptr && reply.length) {
- SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc);
- goto bail;
- }
- /*
- * since WriteToClient long word aligns things, copy to temp buffer and
- * write all at once
- */
- for (i = 0; i < nnames; i++) {
- if (names->length[i] > 255)
- reply.nFonts--;
- else
- {
- *bufptr++ = names->length[i];
- memmove( bufptr, names->names[i], names->length[i]);
- bufptr += names->length[i];
- }
- }
- nnames = reply.nFonts;
- reply.length = bytes_to_int32(stringLens + nnames);
- client->pSwapReplyFunc = ReplySwapVector[X_ListFonts];
- WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply);
- (void) WriteToClient(client, stringLens + nnames, bufferStart);
- free(bufferStart);
-
-bail:
- ClientWakeup(client);
-xinerama_sleep:
- for (i = 0; i < c->num_fpes; i++)
- FreeFPE(c->fpe_list[i]);
- free(c->fpe_list);
- free(c->savedName);
- FreeFontNames(names);
- free(c);
- free(resolved);
- return TRUE;
-}
-
-int
-ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
- unsigned max_names)
-{
- int i;
- LFclosurePtr c;
-
- /*
- * The right error to return here would be BadName, however the
- * specification does not allow for a Name error on this request.
- * Perhaps a better solution would be to return a nil list, i.e.
- * a list containing zero fontnames.
- */
- if (length > XLFDMAXFONTNAMELEN)
- return BadAlloc;
-
- i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
- if (i != Success)
- return i;
-
- if (!(c = malloc(sizeof *c)))
- return BadAlloc;
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
- if (!c->fpe_list) {
- free(c);
- return BadAlloc;
- }
- c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100);
- if (!c->names)
- {
- free(c->fpe_list);
- free(c);
- return BadAlloc;
- }
- memmove( c->current.pattern, pattern, length);
- for (i = 0; i < num_fpes; i++) {
- c->fpe_list[i] = font_path_elements[i];
- UseFPE(c->fpe_list[i]);
- }
- c->client = client;
- c->num_fpes = num_fpes;
- c->current.patlen = length;
- c->current.current_fpe = 0;
- c->current.max_names = max_names;
- c->current.list_started = FALSE;
- c->current.private = 0;
- c->haveSaved = FALSE;
- c->savedName = 0;
- doListFontsAndAliases(client, c);
- return Success;
-}
-
-int
-doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c)
-{
- FontPathElementPtr fpe;
- int err = Successful;
- char *name;
- int namelen;
- int numFonts;
- FontInfoRec fontInfo,
- *pFontInfo;
- xListFontsWithInfoReply *reply;
- int length;
- xFontProp *pFP;
- int i;
- int aliascount = 0;
- xListFontsWithInfoReply finalReply;
-
- if (client->clientGone)
- {
- if (c->current.current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current.current_fpe];
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
- err = Successful;
- goto bail;
- }
- client->pSwapReplyFunc = ReplySwapVector[X_ListFontsWithInfo];
- if (!c->current.patlen)
- goto finish;
- while (c->current.current_fpe < c->num_fpes)
- {
- fpe = c->fpe_list[c->current.current_fpe];
- err = Successful;
- if (!c->current.list_started)
- {
- err = (*fpe_functions[fpe->type].start_list_fonts_with_info)
- (client, fpe, c->current.pattern, c->current.patlen,
- c->current.max_names, &c->current.private);
- if (err == Suspended)
- {
- if (!ClientIsAsleep(client))
- ClientSleep(client,
- (ClientSleepProcPtr)doListFontsWithInfo, c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
- if (err == Successful)
- c->current.list_started = TRUE;
- }
- if (err == Successful)
- {
- name = 0;
- pFontInfo = &fontInfo;
- err = (*fpe_functions[fpe->type].list_next_font_with_info)
- (client, fpe, &name, &namelen, &pFontInfo,
- &numFonts, c->current.private);
- if (err == Suspended)
- {
- if (!ClientIsAsleep(client))
- ClientSleep(client,
- (ClientSleepProcPtr)doListFontsWithInfo, c);
- else
- goto xinerama_sleep;
- return TRUE;
- }
- }
- /*
- * When we get an alias back, save our state and reset back to the
- * start of the FPE looking for the specified name. As soon as a real
- * font is found for the alias, pop back to the old state
- */
- if (err == FontNameAlias)
- {
- /*
- * when an alias recurses, we need to give
- * the last FPE a chance to clean up; so we call
- * it again, and assume that the error returned
- * is BadFontName, indicating the alias resolution
- * is complete.
- */
- if (c->haveSaved)
- {
- char *tmpname;
- int tmpnamelen;
- FontInfoPtr tmpFontInfo;
-
- tmpname = 0;
- tmpFontInfo = &fontInfo;
- (void) (*fpe_functions[fpe->type].list_next_font_with_info)
- (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo,
- &numFonts, c->current.private);
- if (--aliascount <= 0)
- {
- err = BadFontName;
- goto ContBadFontName;
- }
- }
- else
- {
- c->saved = c->current;
- c->haveSaved = TRUE;
- c->savedNumFonts = numFonts;
- free(c->savedName);
- c->savedName = malloc(namelen + 1);
- if (c->savedName)
- memmove(c->savedName, name, namelen + 1);
- aliascount = 20;
- }
- memmove(c->current.pattern, name, namelen);
- c->current.patlen = namelen;
- c->current.max_names = 1;
- c->current.current_fpe = 0;
- c->current.private = 0;
- c->current.list_started = FALSE;
- }
- /*
- * At the end of this FPE, step to the next. If we've finished
- * processing an alias, pop state back. If we've sent enough font
- * names, quit. Always wait for BadFontName to let the FPE
- * have a chance to clean up.
- */
- else if (err == BadFontName)
- {
- ContBadFontName: ;
- c->current.list_started = FALSE;
- c->current.current_fpe++;
- err = Successful;
- if (c->haveSaved)
- {
- if (c->current.max_names == 0 ||
- c->current.current_fpe == c->num_fpes)
- {
- c->haveSaved = FALSE;
- c->saved.max_names -= (1 - c->current.max_names);
- c->current = c->saved;
- }
- }
- else if (c->current.max_names == 0)
- break;
- }
- else if (err == Successful)
- {
- length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp);
- reply = c->reply;
- if (c->length < length)
- {
- reply = (xListFontsWithInfoReply *) realloc(c->reply, length);
- if (!reply)
- {
- err = AllocError;
- break;
- }
- memset((char*)reply + c->length, 0, length - c->length);
- c->reply = reply;
- c->length = length;
- }
- if (c->haveSaved)
- {
- numFonts = c->savedNumFonts;
- name = c->savedName;
- namelen = strlen(name);
- }
- reply->type = X_Reply;
- reply->length = bytes_to_int32(sizeof *reply - sizeof(xGenericReply) +
- pFontInfo->nprops * sizeof(xFontProp) +
- namelen);
- reply->sequenceNumber = client->sequence;
- reply->nameLength = namelen;
- reply->minBounds = pFontInfo->ink_minbounds;
- reply->maxBounds = pFontInfo->ink_maxbounds;
- reply->minCharOrByte2 = pFontInfo->firstCol;
- reply->maxCharOrByte2 = pFontInfo->lastCol;
- reply->defaultChar = pFontInfo->defaultCh;
- reply->nFontProps = pFontInfo->nprops;
- reply->drawDirection = pFontInfo->drawDirection;
- reply->minByte1 = pFontInfo->firstRow;
- reply->maxByte1 = pFontInfo->lastRow;
- reply->allCharsExist = pFontInfo->allExist;
- reply->fontAscent = pFontInfo->fontAscent;
- reply->fontDescent = pFontInfo->fontDescent;
- reply->nReplies = numFonts;
- pFP = (xFontProp *) (reply + 1);
- for (i = 0; i < pFontInfo->nprops; i++)
- {
- pFP->name = pFontInfo->props[i].name;
- pFP->value = pFontInfo->props[i].value;
- pFP++;
- }
- WriteSwappedDataToClient(client, length, reply);
- (void) WriteToClient(client, namelen, name);
- if (pFontInfo == &fontInfo)
- {
- free(fontInfo.props);
- free(fontInfo.isStringProp);
- }
- --c->current.max_names;
- }
- }
-finish:
- length = sizeof(xListFontsWithInfoReply);
- memset((char *) &finalReply, 0, sizeof(xListFontsWithInfoReply));
- finalReply.type = X_Reply;
- finalReply.sequenceNumber = client->sequence;
- finalReply.length = bytes_to_int32(sizeof(xListFontsWithInfoReply)
- - sizeof(xGenericReply));
- WriteSwappedDataToClient(client, length, &finalReply);
-bail:
- ClientWakeup(client);
-xinerama_sleep:
- for (i = 0; i < c->num_fpes; i++)
- FreeFPE(c->fpe_list[i]);
- free(c->reply);
- free(c->fpe_list);
- free(c->savedName);
- free(c);
- return TRUE;
-}
-
-int
-StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
- int max_names)
-{
- int i;
- LFWIclosurePtr c;
-
- /*
- * The right error to return here would be BadName, however the
- * specification does not allow for a Name error on this request.
- * Perhaps a better solution would be to return a nil list, i.e.
- * a list containing zero fontnames.
- */
- if (length > XLFDMAXFONTNAMELEN)
- return BadAlloc;
-
- i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
- if (i != Success)
- return i;
-
- if (!(c = malloc(sizeof *c)))
- goto badAlloc;
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
- if (!c->fpe_list)
- {
- free(c);
- goto badAlloc;
- }
- memmove(c->current.pattern, pattern, length);
- for (i = 0; i < num_fpes; i++)
- {
- c->fpe_list[i] = font_path_elements[i];
- UseFPE(c->fpe_list[i]);
- }
- c->client = client;
- c->num_fpes = num_fpes;
- c->reply = 0;
- c->length = 0;
- c->current.patlen = length;
- c->current.current_fpe = 0;
- c->current.max_names = max_names;
- c->current.list_started = FALSE;
- c->current.private = 0;
- c->savedNumFonts = 0;
- c->haveSaved = FALSE;
- c->savedName = 0;
- doListFontsWithInfo(client, c);
- return Success;
-badAlloc:
- return BadAlloc;
-}
-
-#define TextEltHeader 2
-#define FontShiftSize 5
-static ChangeGCVal clearGC[] = { NullPixmap };
-#define clearGCmask (GCClipMask)
-
-int
-doPolyText(ClientPtr client, PTclosurePtr c)
-{
- FontPtr pFont = c->pGC->font, oldpFont;
- int err = Success, lgerr; /* err is in X error, not font error, space */
- enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT;
- FontPathElementPtr fpe;
- GC *origGC = NULL;
- int itemSize = c->reqType == X_PolyText8 ? 1 : 2;
-
- if (client->clientGone)
- {
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
-
- if (ClientIsAsleep(client))
- {
- /* Client has died, but we cannot bail out right now. We
- need to clean up after the work we did when going to
- sleep. Setting the drawable pointer to 0 makes this
- happen without any attempts to render or perform other
- unnecessary activities. */
- c->pDraw = (DrawablePtr)0;
- }
- else
- {
- err = Success;
- goto bail;
- }
- }
-
- /* Make sure our drawable hasn't disappeared while we slept. */
- if (ClientIsAsleep(client) && c->pDraw)
- {
- DrawablePtr pDraw;
- dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
- if (c->pDraw != pDraw) {
- /* Our drawable has disappeared. Treat like client died... ask
- the FPE code to clean up after client and avoid further
- rendering while we clean up after ourself. */
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- c->pDraw = (DrawablePtr)0;
- }
- }
-
- client_state = ClientIsAsleep(client) ? SLEEPING : NEVER_SLEPT;
-
- while (c->endReq - c->pElt > TextEltHeader)
- {
- if (*c->pElt == FontChange)
- {
- Font fid;
- if (c->endReq - c->pElt < FontShiftSize)
- {
- err = BadLength;
- goto bail;
- }
-
- oldpFont = pFont;
-
- fid = ((Font)*(c->pElt+4)) /* big-endian */
- | ((Font)*(c->pElt+3)) << 8
- | ((Font)*(c->pElt+2)) << 16
- | ((Font)*(c->pElt+1)) << 24;
- err = dixLookupResourceByType((pointer *)&pFont, fid, RT_FONT,
- client, DixUseAccess);
- if (err != Success)
- {
- /* restore pFont for step 4 (described below) */
- pFont = oldpFont;
-
- /* If we're in START_SLEEP mode, the following step
- shortens the request... in the unlikely event that
- the fid somehow becomes valid before we come through
- again to actually execute the polytext, which would
- then mess up our refcounting scheme badly. */
- c->err = err;
- c->endReq = c->pElt;
-
- goto bail;
- }
-
- /* Step 3 (described below) on our new font */
- if (client_state == START_SLEEP)
- pFont->refcnt++;
- else
- {
- if (pFont != c->pGC->font && c->pDraw)
- {
- ChangeGCVal val;
- val.ptr = pFont;
- ChangeGC(NullClient, c->pGC, GCFont, &val);
- ValidateGC(c->pDraw, c->pGC);
- }
-
- /* Undo the refcnt++ we performed when going to sleep */
- if (client_state == SLEEPING)
- (void)CloseFont(c->pGC->font, (Font)0);
- }
- c->pElt += FontShiftSize;
- }
- else /* print a string */
- {
- unsigned char *pNextElt;
- pNextElt = c->pElt + TextEltHeader + (*c->pElt) * itemSize;
- if ( pNextElt > c->endReq)
- {
- err = BadLength;
- goto bail;
- }
- if (client_state == START_SLEEP)
- {
- c->pElt = pNextElt;
- continue;
- }
- if (c->pDraw)
- {
- lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, itemSize,
- c->pElt + TextEltHeader);
- }
- else lgerr = Successful;
-
- if (lgerr == Suspended)
- {
- if (!ClientIsAsleep(client)) {
- int len;
- GC *pGC;
- PTclosurePtr new_closure;
-
- /* We're putting the client to sleep. We need to do a few things
- to ensure successful and atomic-appearing execution of the
- remainder of the request. First, copy the remainder of the
- request into a safe malloc'd area. Second, create a scratch GC
- to use for the remainder of the request. Third, mark all fonts
- referenced in the remainder of the request to prevent their
- deallocation. Fourth, make the original GC look like the
- request has completed... set its font to the final font value
- from this request. These GC manipulations are for the unlikely
- (but possible) event that some other client is using the GC.
- Steps 3 and 4 are performed by running this procedure through
- the remainder of the request in a special no-render mode
- indicated by client_state = START_SLEEP. */
-
- /* Step 1 */
- /* Allocate a malloc'd closure structure to replace
- the local one we were passed */
- new_closure = malloc(sizeof(PTclosureRec));
- if (!new_closure)
- {
- err = BadAlloc;
- goto bail;
- }
- *new_closure = *c;
- c = new_closure;
-
- len = c->endReq - c->pElt;
- c->data = malloc(len);
- if (!c->data)
- {
- free(c);
- err = BadAlloc;
- goto bail;
- }
- memmove(c->data, c->pElt, len);
- c->pElt = c->data;
- c->endReq = c->pElt + len;
-
- /* Step 2 */
-
- pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
- if (!pGC)
- {
- free(c->data);
- free(c);
- err = BadAlloc;
- goto bail;
- }
- if ((err = CopyGC(c->pGC, pGC, GCFunction |
- GCPlaneMask | GCForeground |
- GCBackground | GCFillStyle |
- GCTile | GCStipple |
- GCTileStipXOrigin |
- GCTileStipYOrigin | GCFont |
- GCSubwindowMode | GCClipXOrigin |
- GCClipYOrigin | GCClipMask)) !=
- Success)
- {
- FreeScratchGC(pGC);
- free(c->data);
- free(c);
- err = BadAlloc;
- goto bail;
- }
- origGC = c->pGC;
- c->pGC = pGC;
- ValidateGC(c->pDraw, c->pGC);
-
- ClientSleep(client, (ClientSleepProcPtr)doPolyText, c);
-
- /* Set up to perform steps 3 and 4 */
- client_state = START_SLEEP;
- continue; /* on to steps 3 and 4 */
- }
- else
- goto xinerama_sleep;
- return TRUE;
- }
- else if (lgerr != Successful)
- {
- err = FontToXError(lgerr);
- goto bail;
- }
- if (c->pDraw)
- {
- c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */
- if (c->reqType == X_PolyText8)
- c->xorg = (* c->pGC->ops->PolyText8)(c->pDraw, c->pGC, c->xorg, c->yorg,
- *c->pElt, (char *) (c->pElt + TextEltHeader));
- else
- c->xorg = (* c->pGC->ops->PolyText16)(c->pDraw, c->pGC, c->xorg, c->yorg,
- *c->pElt, (unsigned short *) (c->pElt + TextEltHeader));
- }
- c->pElt = pNextElt;
- }
- }
-
-bail:
-
- if (client_state == START_SLEEP)
- {
- /* Step 4 */
- if (pFont != origGC->font)
- {
- ChangeGCVal val;
- val.ptr = pFont;
- ChangeGC(NullClient, origGC, GCFont, &val);
- ValidateGC(c->pDraw, origGC);
- }
-
- /* restore pElt pointer for execution of remainder of the request */
- c->pElt = c->data;
- return TRUE;
- }
-
- if (c->err != Success) err = c->err;
- if (err != Success && c->client != serverClient) {
-#ifdef PANORAMIX
- if (noPanoramiXExtension || !c->pGC->pScreen->myNum)
-#endif
- SendErrorToClient(c->client, c->reqType, 0, 0, err);
- }
- if (ClientIsAsleep(client))
- {
- ClientWakeup(c->client);
-xinerama_sleep:
- ChangeGC(NullClient, c->pGC, clearGCmask, clearGC);
-
- /* Unreference the font from the scratch GC */
- CloseFont(c->pGC->font, (Font)0);
- c->pGC->font = NullFont;
-
- FreeScratchGC(c->pGC);
- free(c->data);
- free(c);
- }
- return TRUE;
-}
-
-int
-PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt,
- unsigned char *endReq, int xorg, int yorg, int reqType, XID did)
-{
- PTclosureRec local_closure;
-
- local_closure.pElt = pElt;
- local_closure.endReq = endReq;
- local_closure.client = client;
- local_closure.pDraw = pDraw;
- local_closure.xorg = xorg;
- local_closure.yorg = yorg;
- local_closure.reqType = reqType;
- local_closure.pGC = pGC;
- local_closure.did = did;
- local_closure.err = Success;
-
- (void) doPolyText(client, &local_closure);
- return Success;
-}
-
-
-#undef TextEltHeader
-#undef FontShiftSize
-
-int
-doImageText(ClientPtr client, ITclosurePtr c)
-{
- int err = Success, lgerr; /* err is in X error, not font error, space */
- FontPathElementPtr fpe;
- int itemSize = c->reqType == X_ImageText8 ? 1 : 2;
-
- if (client->clientGone)
- {
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- err = Success;
- goto bail;
- }
-
- /* Make sure our drawable hasn't disappeared while we slept. */
- if (ClientIsAsleep(client) && c->pDraw)
- {
- DrawablePtr pDraw;
- dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess);
- if (c->pDraw != pDraw) {
- /* Our drawable has disappeared. Treat like client died... ask
- the FPE code to clean up after client. */
- fpe = c->pGC->font->fpe;
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- err = Success;
- goto bail;
- }
- }
-
- lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, itemSize, c->data);
- if (lgerr == Suspended)
- {
- if (!ClientIsAsleep(client)) {
- GC *pGC;
- unsigned char *data;
- ITclosurePtr new_closure;
-
- /* We're putting the client to sleep. We need to
- save some state. Similar problem to that handled
- in doPolyText, but much simpler because the
- request structure is much simpler. */
-
- new_closure = malloc(sizeof(ITclosureRec));
- if (!new_closure)
- {
- err = BadAlloc;
- goto bail;
- }
- *new_closure = *c;
- c = new_closure;
-
- data = malloc(c->nChars * itemSize);
- if (!data)
- {
- free(c);
- err = BadAlloc;
- goto bail;
- }
- memmove(data, c->data, c->nChars * itemSize);
- c->data = data;
-
- pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen);
- if (!pGC)
- {
- free(c->data);
- free(c);
- err = BadAlloc;
- goto bail;
- }
- if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask |
- GCForeground | GCBackground | GCFillStyle |
- GCTile | GCStipple | GCTileStipXOrigin |
- GCTileStipYOrigin | GCFont |
- GCSubwindowMode | GCClipXOrigin |
- GCClipYOrigin | GCClipMask)) != Success)
- {
- FreeScratchGC(pGC);
- free(c->data);
- free(c);
- err = BadAlloc;
- goto bail;
- }
- c->pGC = pGC;
- ValidateGC(c->pDraw, c->pGC);
-
- ClientSleep(client, (ClientSleepProcPtr)doImageText, c);
- }
- else
- goto xinerama_sleep;
- return TRUE;
- }
- else if (lgerr != Successful)
- {
- err = FontToXError(lgerr);
- goto bail;
- }
- if (c->pDraw)
- {
- if (c->reqType == X_ImageText8)
- (* c->pGC->ops->ImageText8)(c->pDraw, c->pGC, c->xorg, c->yorg,
- c->nChars, (char *) c->data);
- else
- (* c->pGC->ops->ImageText16)(c->pDraw, c->pGC, c->xorg, c->yorg,
- c->nChars, (unsigned short *) c->data);
- }
-
-bail:
-
- if (err != Success && c->client != serverClient) {
- SendErrorToClient(c->client, c->reqType, 0, 0, err);
- }
- if (ClientIsAsleep(client))
- {
- ClientWakeup(c->client);
-xinerama_sleep:
- ChangeGC(NullClient, c->pGC, clearGCmask, clearGC);
-
- /* Unreference the font from the scratch GC */
- CloseFont(c->pGC->font, (Font)0);
- c->pGC->font = NullFont;
-
- FreeScratchGC(c->pGC);
- free(c->data);
- free(c);
- }
- return TRUE;
-}
-
-int
-ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars,
- unsigned char *data, int xorg, int yorg, int reqType, XID did)
-{
- ITclosureRec local_closure;
-
- local_closure.client = client;
- local_closure.pDraw = pDraw;
- local_closure.pGC = pGC;
- local_closure.nChars = nChars;
- local_closure.data = data;
- local_closure.xorg = xorg;
- local_closure.yorg = yorg;
- local_closure.reqType = reqType;
- local_closure.did = did;
-
- (void) doImageText(client, &local_closure);
- return Success;
-}
-
-
-/* does the necessary magic to figure out the fpe type */
-static int
-DetermineFPEType(char *pathname)
-{
- int i;
-
- for (i = 0; i < num_fpe_types; i++) {
- if ((*fpe_functions[i].name_check) (pathname))
- return i;
- }
- return -1;
-}
-
-
-static void
-FreeFontPath(FontPathElementPtr *list, int n, Bool force)
-{
- int i;
-
- for (i = 0; i < n; i++) {
- if (force) {
- /* Sanity check that all refcounts will be 0 by the time
- we get to the end of the list. */
- int found = 1; /* the first reference is us */
- int j;
- for (j = i+1; j < n; j++) {
- if (list[j] == list[i])
- found++;
- }
- if (list[i]->refcount != found) {
- list[i]->refcount = found; /* ensure it will get freed */
- }
- }
- FreeFPE(list[i]);
- }
- free(list);
-}
-
-static FontPathElementPtr
-find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int len)
-{
- FontPathElementPtr fpe;
- int i;
-
- for (i = 0; i < num; i++) {
- fpe = list[i];
- if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0)
- return fpe;
- }
- return (FontPathElementPtr) 0;
-}
-
-
-static int
-SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
-{
- int i, err = 0;
- int valid_paths = 0;
- unsigned int len;
- unsigned char *cp = paths;
- FontPathElementPtr fpe = NULL, *fplist;
-
- fplist = malloc(sizeof(FontPathElementPtr) * npaths);
- if (!fplist) {
- *bad = 0;
- return BadAlloc;
- }
- for (i = 0; i < num_fpe_types; i++) {
- if (fpe_functions[i].set_path_hook)
- (*fpe_functions[i].set_path_hook) ();
- }
- for (i = 0; i < npaths; i++)
- {
- len = (unsigned int) (*cp++);
-
- if (len == 0)
- {
- if (persist)
- ErrorF("[dix] Removing empty element from the valid list of fontpaths\n");
- err = BadValue;
- }
- else
- {
- /* if it's already in our active list, just reset it */
- /*
- * note that this can miss FPE's in limbo -- may be worth catching
- * them, though it'd muck up refcounting
- */
- fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len);
- if (fpe)
- {
- err = (*fpe_functions[fpe->type].reset_fpe) (fpe);
- if (err == Successful)
- {
- UseFPE(fpe);/* since it'll be decref'd later when freed
- * from the old list */
- }
- else
- fpe = 0;
- }
- /* if error or can't do it, act like it's a new one */
- if (!fpe)
- {
- fpe = malloc(sizeof(FontPathElementRec));
- if (!fpe)
- {
- err = BadAlloc;
- goto bail;
- }
- fpe->name = malloc(len + 1);
- if (!fpe->name)
- {
- free(fpe);
- err = BadAlloc;
- goto bail;
- }
- fpe->refcount = 1;
-
- strncpy(fpe->name, (char *) cp, (int) len);
- fpe->name[len] = '\0';
- fpe->name_length = len;
- fpe->type = DetermineFPEType(fpe->name);
- if (fpe->type == -1)
- err = BadValue;
- else
- err = (*fpe_functions[fpe->type].init_fpe) (fpe);
- if (err != Successful)
- {
- if (persist)
- {
- ErrorF("[dix] Could not init font path element %s, removing from list!\n",
- fpe->name);
- }
- free(fpe->name);
- free(fpe);
- }
- }
- }
- if (err != Successful)
- {
- if (!persist)
- goto bail;
- }
- else
- {
- fplist[valid_paths++] = fpe;
- }
- cp += len;
- }
-
- FreeFontPath(font_path_elements, num_fpes, FALSE);
- font_path_elements = fplist;
- if (patternCache)
- EmptyFontPatternCache(patternCache);
- num_fpes = valid_paths;
-
- return Success;
-bail:
- *bad = i;
- while (--valid_paths >= 0)
- FreeFPE(fplist[valid_paths]);
- free(fplist);
- return FontToXError(err);
-}
-
-int
-SetFontPath(ClientPtr client, int npaths, unsigned char *paths)
-{
- int err = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess);
- if (err != Success)
- return err;
-
- if (npaths == 0) {
- if (SetDefaultFontPath(defaultFontPath) != Success)
- return BadValue;
- } else {
- int bad;
- err = SetFontPathElements(npaths, paths, &bad, FALSE);
- client->errorValue = bad;
- }
- return err;
-}
-
-int
-SetDefaultFontPath(char *path)
-{
- char *temp_path,
- *start,
- *end;
- unsigned char *cp,
- *pp,
- *nump,
- *newpath;
- int num = 1,
- len,
- err,
- size = 0,
- bad;
-
- /* ensure temp_path contains "built-ins" */
- start = path;
- while (1) {
- start = strstr(start, "built-ins");
- if (start == NULL)
- break;
- end = start + strlen("built-ins");
- if ((start == path || start[-1] == ',') && (!*end || *end == ','))
- break;
- start = end;
- }
- if (!start) {
- if (asprintf(&temp_path, "%s%sbuilt-ins", path, *path ? "," : "")
- == -1)
- temp_path = NULL;
- } else {
- temp_path = strdup(path);
- }
- if (!temp_path)
- return BadAlloc;
-
- /* get enough for string, plus values -- use up commas */
- len = strlen(temp_path) + 1;
- nump = cp = newpath = malloc(len);
- if (!newpath)
- return BadAlloc;
- pp = (unsigned char *) temp_path;
- cp++;
- while (*pp) {
- if (*pp == ',') {
- *nump = (unsigned char) size;
- nump = cp++;
- pp++;
- num++;
- size = 0;
- } else {
- *cp++ = *pp++;
- size++;
- }
- }
- *nump = (unsigned char) size;
-
- err = SetFontPathElements(num, newpath, &bad, TRUE);
-
- free(newpath);
- free(temp_path);
-
- return err;
-}
-
-int
-GetFontPath(ClientPtr client, int *count, int *length, unsigned char **result)
-{
- int i;
- unsigned char *c;
- int len;
- FontPathElementPtr fpe;
-
- i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess);
- if (i != Success)
- return i;
-
- len = 0;
- for (i = 0; i < num_fpes; i++) {
- fpe = font_path_elements[i];
- len += fpe->name_length + 1;
- }
- font_path_string = (unsigned char *) realloc(font_path_string, len);
- if (!font_path_string)
- return BadAlloc;
-
- c = font_path_string;
- *length = 0;
- for (i = 0; i < num_fpes; i++) {
- fpe = font_path_elements[i];
- *c = fpe->name_length;
- *length += *c++;
- memmove(c, fpe->name, fpe->name_length);
- c += fpe->name_length;
- }
- *count = num_fpes;
- *result = font_path_string;
- return Success;
-}
-
-void
-DeleteClientFontStuff(ClientPtr client)
-{
- int i;
- FontPathElementPtr fpe;
-
- for (i = 0; i < num_fpes; i++)
- {
- fpe = font_path_elements[i];
- if (fpe_functions[fpe->type].client_died)
- (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe);
- }
-}
-
-void
-InitFonts (void)
-{
- patternCache = MakeFontPatternCache();
-
- register_fpe_functions();
-}
-
-int
-GetDefaultPointSize (void)
-{
- return 120;
-}
-
-
-FontResolutionPtr
-GetClientResolutions (int *num)
-{
- static struct _FontResolution res;
- ScreenPtr pScreen;
-
- pScreen = screenInfo.screens[0];
- res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;
- /*
- * XXX - we'll want this as long as bitmap instances are prevalent
- so that we can match them from scalable fonts
- */
- if (res.x_resolution < 88)
- res.x_resolution = 75;
- else
- res.x_resolution = 100;
- res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight;
- if (res.y_resolution < 88)
- res.y_resolution = 75;
- else
- res.y_resolution = 100;
- res.point_size = 120;
- *num = 1;
- return &res;
-}
-
-/*
- * returns the type index of the new fpe
- *
- * should be called (only once!) by each type of fpe when initialized
- */
-
-int
-RegisterFPEFunctions(NameCheckFunc name_func,
- InitFpeFunc init_func,
- FreeFpeFunc free_func,
- ResetFpeFunc reset_func,
- OpenFontFunc open_func,
- CloseFontFunc close_func,
- ListFontsFunc list_func,
- StartLfwiFunc start_lfwi_func,
- NextLfwiFunc next_lfwi_func,
- WakeupFpeFunc wakeup_func,
- ClientDiedFunc client_died,
- LoadGlyphsFunc load_glyphs,
- StartLaFunc start_list_alias_func,
- NextLaFunc next_list_alias_func,
- SetPathFunc set_path_func)
-{
- FPEFunctions *new;
-
- /* grow the list */
- new = (FPEFunctions *) realloc(fpe_functions,
- (num_fpe_types + 1) * sizeof(FPEFunctions));
- if (!new)
- return -1;
- fpe_functions = new;
-
- fpe_functions[num_fpe_types].name_check = name_func;
- fpe_functions[num_fpe_types].open_font = open_func;
- fpe_functions[num_fpe_types].close_font = close_func;
- fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func;
- fpe_functions[num_fpe_types].list_fonts = list_func;
- fpe_functions[num_fpe_types].start_list_fonts_with_info =
- start_lfwi_func;
- fpe_functions[num_fpe_types].list_next_font_with_info =
- next_lfwi_func;
- fpe_functions[num_fpe_types].init_fpe = init_func;
- fpe_functions[num_fpe_types].free_fpe = free_func;
- fpe_functions[num_fpe_types].reset_fpe = reset_func;
- fpe_functions[num_fpe_types].client_died = client_died;
- fpe_functions[num_fpe_types].load_glyphs = load_glyphs;
- fpe_functions[num_fpe_types].start_list_fonts_and_aliases =
- start_list_alias_func;
- fpe_functions[num_fpe_types].list_next_font_or_alias =
- next_list_alias_func;
- fpe_functions[num_fpe_types].set_path_hook = set_path_func;
-
- return num_fpe_types++;
-}
-
-void
-FreeFonts(void)
-{
- if (patternCache) {
- FreeFontPatternCache(patternCache);
- patternCache = 0;
- }
- FreeFontPath(font_path_elements, num_fpes, TRUE);
- font_path_elements = 0;
- num_fpes = 0;
- free(fpe_functions);
- num_fpe_types = 0;
- fpe_functions = (FPEFunctions *) 0;
-}
-
-/* convenience functions for FS interface */
-
-FontPtr
-find_old_font(XID id)
-{
- pointer pFont;
- dixLookupResourceByType(&pFont, id, RT_NONE, serverClient, DixReadAccess);
- return (FontPtr)pFont;
-}
-
-Font
-GetNewFontClientID(void)
-{
- return FakeClientID(0);
-}
-
-int
-StoreFontClientFont(FontPtr pfont, Font id)
-{
- return AddResource(id, RT_NONE, (pointer) pfont);
-}
-
-void
-DeleteFontClientID(Font id)
-{
- FreeResource(id, RT_NONE);
-}
-
-int
-client_auth_generation(ClientPtr client)
-{
- return 0;
-}
-
-static int fs_handlers_installed = 0;
-static unsigned int last_server_gen;
-
-int
-init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler)
-{
- /* if server has reset, make sure the b&w handlers are reinstalled */
- if (last_server_gen < serverGeneration) {
- last_server_gen = serverGeneration;
- fs_handlers_installed = 0;
- }
- if (fs_handlers_installed == 0) {
- if (!RegisterBlockAndWakeupHandlers(block_handler,
- FontWakeup, (pointer) 0))
- return AllocError;
- fs_handlers_installed++;
- }
- QueueFontWakeup(fpe);
- return Successful;
-}
-
-void
-remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all)
-{
- if (all) {
- /* remove the handlers if no one else is using them */
- if (--fs_handlers_installed == 0) {
- RemoveBlockAndWakeupHandlers(block_handler, FontWakeup,
- (pointer) 0);
- }
- }
- RemoveFontWakeup(fpe);
-}
+/************************************************************************ +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. + +************************************************************************/ +/* The panoramix components contained the following notice */ +/* +Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. + +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. + +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 +DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, +BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL 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 Digital Equipment Corporation +shall not be used in advertising or otherwise to promote the sale, use or other +dealings in this Software without prior written authorization from Digital +Equipment Corporation. + +******************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> +#include <X11/Xproto.h> +#include "scrnintstr.h" +#include "resource.h" +#include "dixstruct.h" +#include "cursorstr.h" +#include "misc.h" +#include "opaque.h" +#include "dixfontstr.h" +#include "closestr.h" +#include "dixfont.h" +#include "xace.h" + +#ifdef DEBUG +#include <stdio.h> +#endif + +#ifdef XF86BIGFONT +#include "xf86bigfontsrv.h" +#endif + +#define QUERYCHARINFO(pci, pr) *(pr) = (pci)->metrics + +extern pointer fosNaturalParams; +extern FontPtr defaultFont; + +static FontPathElementPtr *font_path_elements = (FontPathElementPtr *) 0; +static int num_fpes = 0; +static FPEFunctions *fpe_functions = (FPEFunctions *) 0; +static int num_fpe_types = 0; + +static unsigned char *font_path_string; + +static int num_slept_fpes = 0; +static int size_slept_fpes = 0; +static FontPathElementPtr *slept_fpes = (FontPathElementPtr *) 0; +static FontPatternCachePtr patternCache; + +static int +FontToXError(int err) +{ + switch (err) { + case Successful: + return Success; + case AllocError: + return BadAlloc; + case BadFontName: + return BadName; + case BadFontPath: + case BadFontFormat: /* is there something better? */ + case BadCharRange: + return BadValue; + default: + return err; + } +} + +static int +LoadGlyphs(ClientPtr client, FontPtr pfont, unsigned nchars, int item_size, + unsigned char *data) +{ + if (fpe_functions[pfont->fpe->type].load_glyphs) + return (*fpe_functions[pfont->fpe->type].load_glyphs) + (client, pfont, 0, nchars, item_size, data); + else + return Successful; +} + +/* + * adding RT_FONT prevents conflict with default cursor font + */ +Bool +SetDefaultFont(char *defaultfontname) +{ + int err; + FontPtr pf; + XID fid; + static FontPtr last_pf; + + fid = FakeClientID(0); + err = OpenFont(serverClient, fid, FontLoadAll | FontOpenSync, + (unsigned) strlen(defaultfontname), defaultfontname); + if (err != Success) + return FALSE; + err = dixLookupResourceByType((pointer *)&pf, fid, RT_FONT, serverClient, + DixReadAccess); + if (err == Success) last_pf = pf; + if (last_pf == (FontPtr) NULL) + return FALSE; + defaultFont = last_pf; + return TRUE; +} + +/* + * note that the font wakeup queue is not refcounted. this is because + * an fpe needs to be added when it's inited, and removed when it's finally + * freed, in order to handle any data that isn't requested, like FS events. + * + * since the only thing that should call these routines is the renderer's + * init_fpe() and free_fpe(), there shouldn't be any problem in using + * freed data. + */ +void +QueueFontWakeup(FontPathElementPtr fpe) +{ + int i; + FontPathElementPtr *new; + + for (i = 0; i < num_slept_fpes; i++) { + if (slept_fpes[i] == fpe) { + return; + } + } + if (num_slept_fpes == size_slept_fpes) { + new = (FontPathElementPtr *) + realloc(slept_fpes, + sizeof(FontPathElementPtr) * (size_slept_fpes + 4)); + if (!new) + return; + slept_fpes = new; + size_slept_fpes += 4; + } + slept_fpes[num_slept_fpes] = fpe; + num_slept_fpes++; +} + +void +RemoveFontWakeup(FontPathElementPtr fpe) +{ + int i, + j; + + for (i = 0; i < num_slept_fpes; i++) { + if (slept_fpes[i] == fpe) { + for (j = i; j < num_slept_fpes; j++) { + slept_fpes[j] = slept_fpes[j + 1]; + } + num_slept_fpes--; + return; + } + } +} + +void +FontWakeup(pointer data, int count, pointer LastSelectMask) +{ + int i; + FontPathElementPtr fpe; + + if (count < 0) + return; + /* wake up any fpe's that may be waiting for information */ + for (i = 0; i < num_slept_fpes; i++) { + fpe = slept_fpes[i]; + (void) (*fpe_functions[fpe->type].wakeup_fpe) (fpe, LastSelectMask); + } +} + +/* XXX -- these two funcs may want to be broken into macros */ +static void +UseFPE(FontPathElementPtr fpe) +{ + fpe->refcount++; +} + +static void +FreeFPE (FontPathElementPtr fpe) +{ + fpe->refcount--; + if (fpe->refcount == 0) { + (*fpe_functions[fpe->type].free_fpe) (fpe); + free(fpe->name); + free(fpe); + } +} + +static Bool +doOpenFont(ClientPtr client, OFclosurePtr c) +{ + FontPtr pfont = NullFont; + FontPathElementPtr fpe = NULL; + ScreenPtr pScr; + int err = Successful; + int i; + char *alias, + *newname; + int newlen; + int aliascount = 20; + /* + * Decide at runtime what FontFormat to use. + */ + Mask FontFormat = + + ((screenInfo.imageByteOrder == LSBFirst) ? + BitmapFormatByteOrderLSB : BitmapFormatByteOrderMSB) | + + ((screenInfo.bitmapBitOrder == LSBFirst) ? + BitmapFormatBitOrderLSB : BitmapFormatBitOrderMSB) | + + BitmapFormatImageRectMin | + +#if GLYPHPADBYTES == 1 + BitmapFormatScanlinePad8 | +#endif + +#if GLYPHPADBYTES == 2 + BitmapFormatScanlinePad16 | +#endif + +#if GLYPHPADBYTES == 4 + BitmapFormatScanlinePad32 | +#endif + +#if GLYPHPADBYTES == 8 + BitmapFormatScanlinePad64 | +#endif + + BitmapFormatScanlineUnit8; + + if (client->clientGone) + { + if (c->current_fpe < c->num_fpes) + { + fpe = c->fpe_list[c->current_fpe]; + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); + } + err = Successful; + goto bail; + } + while (c->current_fpe < c->num_fpes) { + fpe = c->fpe_list[c->current_fpe]; + err = (*fpe_functions[fpe->type].open_font) + ((pointer) client, fpe, c->flags, + c->fontname, c->fnamelen, FontFormat, + BitmapFormatMaskByte | + BitmapFormatMaskBit | + BitmapFormatMaskImageRectangle | + BitmapFormatMaskScanLinePad | + BitmapFormatMaskScanLineUnit, + c->fontid, &pfont, &alias, + c->non_cachable_font && c->non_cachable_font->fpe == fpe ? + c->non_cachable_font : + (FontPtr)0); + + if (err == FontNameAlias && alias) { + newlen = strlen(alias); + newname = (char *) realloc(c->fontname, newlen); + if (!newname) { + err = AllocError; + break; + } + memmove(newname, alias, newlen); + c->fontname = newname; + c->fnamelen = newlen; + c->current_fpe = 0; + if (--aliascount <= 0) { + /* We've tried resolving this alias 20 times, we're + * probably stuck in an infinite loop of aliases pointing + * to each other - time to take emergency exit! + */ + err = BadImplementation; + break; + } + continue; + } + if (err == BadFontName) { + c->current_fpe++; + continue; + } + if (err == Suspended) { + if (!ClientIsAsleep(client)) + ClientSleep(client, (ClientSleepProcPtr)doOpenFont, c); + else + goto xinerama_sleep; + return TRUE; + } + break; + } + + if (err != Successful) + goto bail; + if (!pfont) { + err = BadFontName; + goto bail; + } + /* check values for firstCol, lastCol, firstRow, and lastRow */ + if (pfont->info.firstCol > pfont->info.lastCol || + pfont->info.firstRow > pfont->info.lastRow || + pfont->info.lastCol - pfont->info.firstCol > 255) { + err = AllocError; + goto bail; + } + if (!pfont->fpe) + pfont->fpe = fpe; + pfont->refcnt++; + if (pfont->refcnt == 1) { + UseFPE(pfont->fpe); + for (i = 0; i < screenInfo.numScreens; i++) { + pScr = screenInfo.screens[i]; + if (pScr->RealizeFont) + { + if (!(*pScr->RealizeFont) (pScr, pfont)) + { + CloseFont (pfont, (Font) 0); + err = AllocError; + goto bail; + } + } + } + } + if (!AddResource(c->fontid, RT_FONT, (pointer) pfont)) { + err = AllocError; + goto bail; + } + if (patternCache && pfont != c->non_cachable_font) + CacheFontPattern(patternCache, c->origFontName, c->origFontNameLen, + pfont); +bail: + if (err != Successful && c->client != serverClient) { + SendErrorToClient(c->client, X_OpenFont, 0, + c->fontid, FontToXError(err)); + } + ClientWakeup(c->client); +xinerama_sleep: + for (i = 0; i < c->num_fpes; i++) { + FreeFPE(c->fpe_list[i]); + } + free(c->fpe_list); + free(c->fontname); + free(c); + return TRUE; +} + +int +OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname, char *pfontname) +{ + OFclosurePtr c; + int i; + FontPtr cached = (FontPtr)0; + +#ifdef FONTDEBUG + char *f; + f = malloc(lenfname + 1); + memmove(f, pfontname, lenfname); + f[lenfname] = '\0'; + ErrorF("[dix] OpenFont: fontname is \"%s\"\n", f); + free(f); +#endif + if (!lenfname || lenfname > XLFDMAXFONTNAMELEN) + return BadName; + if (patternCache) + { + + /* + ** Check name cache. If we find a cached version of this font that + ** is cachable, immediately satisfy the request with it. If we find + ** a cached version of this font that is non-cachable, we do not + ** satisfy the request with it. Instead, we pass the FontPtr to the + ** FPE's open_font code (the fontfile FPE in turn passes the + ** information to the rasterizer; the fserve FPE ignores it). + ** + ** Presumably, the font is marked non-cachable because the FPE has + ** put some licensing restrictions on it. If the FPE, using + ** whatever logic it relies on, determines that it is willing to + ** share this existing font with the client, then it has the option + ** to return the FontPtr we passed it as the newly-opened font. + ** This allows the FPE to exercise its licensing logic without + ** having to create another instance of a font that already exists. + */ + + cached = FindCachedFontPattern(patternCache, pfontname, lenfname); + if (cached && cached->info.cachable) + { + if (!AddResource(fid, RT_FONT, (pointer) cached)) + return BadAlloc; + cached->refcnt++; + return Success; + } + } + c = malloc(sizeof(OFclosureRec)); + if (!c) + return BadAlloc; + c->fontname = malloc(lenfname); + c->origFontName = pfontname; + c->origFontNameLen = lenfname; + if (!c->fontname) { + free(c); + return BadAlloc; + } + /* + * copy the current FPE list, so that if it gets changed by another client + * while we're blocking, the request still appears atomic + */ + c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes); + if (!c->fpe_list) { + free(c->fontname); + free(c); + return BadAlloc; + } + memmove(c->fontname, pfontname, lenfname); + for (i = 0; i < num_fpes; i++) { + c->fpe_list[i] = font_path_elements[i]; + UseFPE(c->fpe_list[i]); + } + c->client = client; + c->fontid = fid; + c->current_fpe = 0; + c->num_fpes = num_fpes; + c->fnamelen = lenfname; + c->flags = flags; + c->non_cachable_font = cached; + + (void) doOpenFont(client, c); + return Success; +} + +/** + * Decrement font's ref count, and free storage if ref count equals zero + * + * \param value must conform to DeleteType + */ +int +CloseFont(pointer value, XID fid) +{ + int nscr; + ScreenPtr pscr; + FontPathElementPtr fpe; + FontPtr pfont = (FontPtr)value; + + if (pfont == NullFont) + return Success; + if (--pfont->refcnt == 0) { + if (patternCache) + RemoveCachedFontPattern (patternCache, pfont); + /* + * since the last reference is gone, ask each screen to free any + * storage it may have allocated locally for it. + */ + for (nscr = 0; nscr < screenInfo.numScreens; nscr++) { + pscr = screenInfo.screens[nscr]; + if (pscr->UnrealizeFont) + (*pscr->UnrealizeFont) (pscr, pfont); + } + if (pfont == defaultFont) + defaultFont = NULL; +#ifdef XF86BIGFONT + XF86BigfontFreeFontShm(pfont); +#endif + fpe = pfont->fpe; + (*fpe_functions[fpe->type].close_font) (fpe, pfont); + FreeFPE(fpe); + } + return Success; +} + + +/***====================================================================***/ + +/** + * Sets up pReply as the correct QueryFontReply for pFont with the first + * nProtoCCIStructs char infos. + * + * \param pReply caller must allocate this storage + */ +void +QueryFont(FontPtr pFont, xQueryFontReply *pReply, int nProtoCCIStructs) +{ + FontPropPtr pFP; + int r, + c, + i; + xFontProp *prFP; + xCharInfo *prCI; + xCharInfo *charInfos[256]; + unsigned char chars[512]; + int ninfos; + unsigned long ncols; + unsigned long count; + + /* pr->length set in dispatch */ + pReply->minCharOrByte2 = pFont->info.firstCol; + pReply->defaultChar = pFont->info.defaultCh; + pReply->maxCharOrByte2 = pFont->info.lastCol; + pReply->drawDirection = pFont->info.drawDirection; + pReply->allCharsExist = pFont->info.allExist; + pReply->minByte1 = pFont->info.firstRow; + pReply->maxByte1 = pFont->info.lastRow; + pReply->fontAscent = pFont->info.fontAscent; + pReply->fontDescent = pFont->info.fontDescent; + + pReply->minBounds = pFont->info.ink_minbounds; + pReply->maxBounds = pFont->info.ink_maxbounds; + + pReply->nFontProps = pFont->info.nprops; + pReply->nCharInfos = nProtoCCIStructs; + + for (i = 0, pFP = pFont->info.props, prFP = (xFontProp *) (&pReply[1]); + i < pFont->info.nprops; + i++, pFP++, prFP++) { + prFP->name = pFP->name; + prFP->value = pFP->value; + } + + ninfos = 0; + ncols = (unsigned long) (pFont->info.lastCol - pFont->info.firstCol + 1); + prCI = (xCharInfo *) (prFP); + for (r = pFont->info.firstRow; + ninfos < nProtoCCIStructs && r <= (int)pFont->info.lastRow; + r++) { + i = 0; + for (c = pFont->info.firstCol; c <= (int)pFont->info.lastCol; c++) { + chars[i++] = r; + chars[i++] = c; + } + (*pFont->get_metrics) (pFont, ncols, chars, + TwoD16Bit, &count, charInfos); + i = 0; + for (i = 0; i < (int) count && ninfos < nProtoCCIStructs; i++) { + *prCI = *charInfos[i]; + prCI++; + ninfos++; + } + } + return; +} + +static Bool +doListFontsAndAliases(ClientPtr client, LFclosurePtr c) +{ + FontPathElementPtr fpe; + int err = Successful; + FontNamesPtr names = NULL; + char *name, *resolved=NULL; + int namelen, resolvedlen; + int nnames; + int stringLens; + int i; + xListFontsReply reply; + char *bufptr; + char *bufferStart; + int aliascount = 0; + + if (client->clientGone) + { + if (c->current.current_fpe < c->num_fpes) + { + fpe = c->fpe_list[c->current.current_fpe]; + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); + } + err = Successful; + goto bail; + } + + if (!c->current.patlen) + goto finish; + + while (c->current.current_fpe < c->num_fpes) { + fpe = c->fpe_list[c->current.current_fpe]; + err = Successful; + + if (!fpe_functions[fpe->type].start_list_fonts_and_aliases) + { + /* This FPE doesn't support/require list_fonts_and_aliases */ + + err = (*fpe_functions[fpe->type].list_fonts) + ((pointer) c->client, fpe, c->current.pattern, + c->current.patlen, c->current.max_names - c->names->nnames, + c->names); + + if (err == Suspended) { + if (!ClientIsAsleep(client)) + ClientSleep(client, + (ClientSleepProcPtr)doListFontsAndAliases, + c); + else + goto xinerama_sleep; + return TRUE; + } + + err = BadFontName; + } + else + { + /* Start of list_fonts_and_aliases functionality. Modeled + after list_fonts_with_info in that it resolves aliases, + except that the information collected from FPEs is just + names, not font info. Each list_next_font_or_alias() + returns either a name into name/namelen or an alias into + name/namelen and its target name into resolved/resolvedlen. + The code at this level then resolves the alias by polling + the FPEs. */ + + if (!c->current.list_started) { + err = (*fpe_functions[fpe->type].start_list_fonts_and_aliases) + ((pointer) c->client, fpe, c->current.pattern, + c->current.patlen, c->current.max_names - c->names->nnames, + &c->current.private); + if (err == Suspended) { + if (!ClientIsAsleep(client)) + ClientSleep(client, + (ClientSleepProcPtr)doListFontsAndAliases, + c); + else + goto xinerama_sleep; + return TRUE; + } + if (err == Successful) + c->current.list_started = TRUE; + } + if (err == Successful) { + char *tmpname; + name = 0; + err = (*fpe_functions[fpe->type].list_next_font_or_alias) + ((pointer) c->client, fpe, &name, &namelen, &tmpname, + &resolvedlen, c->current.private); + if (err == Suspended) { + if (!ClientIsAsleep(client)) + ClientSleep(client, + (ClientSleepProcPtr)doListFontsAndAliases, + c); + else + goto xinerama_sleep; + return TRUE; + } + if (err == FontNameAlias) { + free(resolved); + resolved = malloc(resolvedlen + 1); + if (resolved) + memmove(resolved, tmpname, resolvedlen + 1); + } + } + + if (err == Successful) + { + if (c->haveSaved) + { + if (c->savedName) + (void)AddFontNamesName(c->names, c->savedName, + c->savedNameLen); + } + else + (void)AddFontNamesName(c->names, name, namelen); + } + + /* + * When we get an alias back, save our state and reset back to + * the start of the FPE looking for the specified name. As + * soon as a real font is found for the alias, pop back to the + * old state + */ + else if (err == FontNameAlias) { + char tmp_pattern[XLFDMAXFONTNAMELEN]; + /* + * when an alias recurses, we need to give + * the last FPE a chance to clean up; so we call + * it again, and assume that the error returned + * is BadFontName, indicating the alias resolution + * is complete. + */ + memmove(tmp_pattern, resolved, resolvedlen); + if (c->haveSaved) + { + char *tmpname; + int tmpnamelen; + + tmpname = 0; + (void) (*fpe_functions[fpe->type].list_next_font_or_alias) + ((pointer) c->client, fpe, &tmpname, &tmpnamelen, + &tmpname, &tmpnamelen, c->current.private); + if (--aliascount <= 0) + { + err = BadFontName; + goto ContBadFontName; + } + } + else + { + c->saved = c->current; + c->haveSaved = TRUE; + free(c->savedName); + c->savedName = malloc(namelen + 1); + if (c->savedName) + memmove(c->savedName, name, namelen + 1); + c->savedNameLen = namelen; + aliascount = 20; + } + memmove(c->current.pattern, tmp_pattern, resolvedlen); + c->current.patlen = resolvedlen; + c->current.max_names = c->names->nnames + 1; + c->current.current_fpe = -1; + c->current.private = 0; + err = BadFontName; + } + } + /* + * At the end of this FPE, step to the next. If we've finished + * processing an alias, pop state back. If we've collected enough + * font names, quit. + */ + if (err == BadFontName) { + ContBadFontName: ; + c->current.list_started = FALSE; + c->current.current_fpe++; + err = Successful; + if (c->haveSaved) + { + if (c->names->nnames == c->current.max_names || + c->current.current_fpe == c->num_fpes) { + c->haveSaved = FALSE; + c->current = c->saved; + /* Give the saved namelist a chance to clean itself up */ + continue; + } + } + if (c->names->nnames == c->current.max_names) + break; + } + } + + /* + * send the reply + */ + if (err != Successful) { + SendErrorToClient(client, X_ListFonts, 0, 0, FontToXError(err)); + goto bail; + } + +finish: + + names = c->names; + nnames = names->nnames; + client = c->client; + stringLens = 0; + for (i = 0; i < nnames; i++) + stringLens += (names->length[i] <= 255) ? names->length[i] : 0; + + memset(&reply, 0, sizeof(xListFontsReply)); + reply.type = X_Reply; + reply.length = bytes_to_int32(stringLens + nnames); + reply.nFonts = nnames; + reply.sequenceNumber = client->sequence; + + bufptr = bufferStart = malloc(reply.length << 2); + + if (!bufptr && reply.length) { + SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc); + goto bail; + } + /* + * since WriteToClient long word aligns things, copy to temp buffer and + * write all at once + */ + for (i = 0; i < nnames; i++) { + if (names->length[i] > 255) + reply.nFonts--; + else + { + *bufptr++ = names->length[i]; + memmove( bufptr, names->names[i], names->length[i]); + bufptr += names->length[i]; + } + } + nnames = reply.nFonts; + reply.length = bytes_to_int32(stringLens + nnames); + client->pSwapReplyFunc = ReplySwapVector[X_ListFonts]; + WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply); + (void) WriteToClient(client, stringLens + nnames, bufferStart); + free(bufferStart); + +bail: + ClientWakeup(client); +xinerama_sleep: + for (i = 0; i < c->num_fpes; i++) + FreeFPE(c->fpe_list[i]); + free(c->fpe_list); + free(c->savedName); + FreeFontNames(names); + free(c); + free(resolved); + return TRUE; +} + +int +ListFonts(ClientPtr client, unsigned char *pattern, unsigned length, + unsigned max_names) +{ + int i; + LFclosurePtr c; + + /* + * The right error to return here would be BadName, however the + * specification does not allow for a Name error on this request. + * Perhaps a better solution would be to return a nil list, i.e. + * a list containing zero fontnames. + */ + if (length > XLFDMAXFONTNAMELEN) + return BadAlloc; + + i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess); + if (i != Success) + return i; + + if (!(c = malloc(sizeof *c))) + return BadAlloc; + c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes); + if (!c->fpe_list) { + free(c); + return BadAlloc; + } + c->names = MakeFontNamesRecord(max_names < 100 ? max_names : 100); + if (!c->names) + { + free(c->fpe_list); + free(c); + return BadAlloc; + } + memmove( c->current.pattern, pattern, length); + for (i = 0; i < num_fpes; i++) { + c->fpe_list[i] = font_path_elements[i]; + UseFPE(c->fpe_list[i]); + } + c->client = client; + c->num_fpes = num_fpes; + c->current.patlen = length; + c->current.current_fpe = 0; + c->current.max_names = max_names; + c->current.list_started = FALSE; + c->current.private = 0; + c->haveSaved = FALSE; + c->savedName = 0; + doListFontsAndAliases(client, c); + return Success; +} + +int +doListFontsWithInfo(ClientPtr client, LFWIclosurePtr c) +{ + FontPathElementPtr fpe; + int err = Successful; + char *name; + int namelen; + int numFonts; + FontInfoRec fontInfo, + *pFontInfo; + xListFontsWithInfoReply *reply; + int length; + xFontProp *pFP; + int i; + int aliascount = 0; + xListFontsWithInfoReply finalReply; + + if (client->clientGone) + { + if (c->current.current_fpe < c->num_fpes) + { + fpe = c->fpe_list[c->current.current_fpe]; + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); + } + err = Successful; + goto bail; + } + client->pSwapReplyFunc = ReplySwapVector[X_ListFontsWithInfo]; + if (!c->current.patlen) + goto finish; + while (c->current.current_fpe < c->num_fpes) + { + fpe = c->fpe_list[c->current.current_fpe]; + err = Successful; + if (!c->current.list_started) + { + err = (*fpe_functions[fpe->type].start_list_fonts_with_info) + (client, fpe, c->current.pattern, c->current.patlen, + c->current.max_names, &c->current.private); + if (err == Suspended) + { + if (!ClientIsAsleep(client)) + ClientSleep(client, + (ClientSleepProcPtr)doListFontsWithInfo, c); + else + goto xinerama_sleep; + return TRUE; + } + if (err == Successful) + c->current.list_started = TRUE; + } + if (err == Successful) + { + name = 0; + pFontInfo = &fontInfo; + err = (*fpe_functions[fpe->type].list_next_font_with_info) + (client, fpe, &name, &namelen, &pFontInfo, + &numFonts, c->current.private); + if (err == Suspended) + { + if (!ClientIsAsleep(client)) + ClientSleep(client, + (ClientSleepProcPtr)doListFontsWithInfo, c); + else + goto xinerama_sleep; + return TRUE; + } + } + /* + * When we get an alias back, save our state and reset back to the + * start of the FPE looking for the specified name. As soon as a real + * font is found for the alias, pop back to the old state + */ + if (err == FontNameAlias) + { + /* + * when an alias recurses, we need to give + * the last FPE a chance to clean up; so we call + * it again, and assume that the error returned + * is BadFontName, indicating the alias resolution + * is complete. + */ + if (c->haveSaved) + { + char *tmpname; + int tmpnamelen; + FontInfoPtr tmpFontInfo; + + tmpname = 0; + tmpFontInfo = &fontInfo; + (void) (*fpe_functions[fpe->type].list_next_font_with_info) + (client, fpe, &tmpname, &tmpnamelen, &tmpFontInfo, + &numFonts, c->current.private); + if (--aliascount <= 0) + { + err = BadFontName; + goto ContBadFontName; + } + } + else + { + c->saved = c->current; + c->haveSaved = TRUE; + c->savedNumFonts = numFonts; + free(c->savedName); + c->savedName = malloc(namelen + 1); + if (c->savedName) + memmove(c->savedName, name, namelen + 1); + aliascount = 20; + } + memmove(c->current.pattern, name, namelen); + c->current.patlen = namelen; + c->current.max_names = 1; + c->current.current_fpe = 0; + c->current.private = 0; + c->current.list_started = FALSE; + } + /* + * At the end of this FPE, step to the next. If we've finished + * processing an alias, pop state back. If we've sent enough font + * names, quit. Always wait for BadFontName to let the FPE + * have a chance to clean up. + */ + else if (err == BadFontName) + { + ContBadFontName: ; + c->current.list_started = FALSE; + c->current.current_fpe++; + err = Successful; + if (c->haveSaved) + { + if (c->current.max_names == 0 || + c->current.current_fpe == c->num_fpes) + { + c->haveSaved = FALSE; + c->saved.max_names -= (1 - c->current.max_names); + c->current = c->saved; + } + } + else if (c->current.max_names == 0) + break; + } + else if (err == Successful) + { + length = sizeof(*reply) + pFontInfo->nprops * sizeof(xFontProp); + reply = c->reply; + if (c->length < length) + { + reply = (xListFontsWithInfoReply *) realloc(c->reply, length); + if (!reply) + { + err = AllocError; + break; + } + memset((char*)reply + c->length, 0, length - c->length); + c->reply = reply; + c->length = length; + } + if (c->haveSaved) + { + numFonts = c->savedNumFonts; + name = c->savedName; + namelen = strlen(name); + } + reply->type = X_Reply; + reply->length = bytes_to_int32(sizeof *reply - sizeof(xGenericReply) + + pFontInfo->nprops * sizeof(xFontProp) + + namelen); + reply->sequenceNumber = client->sequence; + reply->nameLength = namelen; + reply->minBounds = pFontInfo->ink_minbounds; + reply->maxBounds = pFontInfo->ink_maxbounds; + reply->minCharOrByte2 = pFontInfo->firstCol; + reply->maxCharOrByte2 = pFontInfo->lastCol; + reply->defaultChar = pFontInfo->defaultCh; + reply->nFontProps = pFontInfo->nprops; + reply->drawDirection = pFontInfo->drawDirection; + reply->minByte1 = pFontInfo->firstRow; + reply->maxByte1 = pFontInfo->lastRow; + reply->allCharsExist = pFontInfo->allExist; + reply->fontAscent = pFontInfo->fontAscent; + reply->fontDescent = pFontInfo->fontDescent; + reply->nReplies = numFonts; + pFP = (xFontProp *) (reply + 1); + for (i = 0; i < pFontInfo->nprops; i++) + { + pFP->name = pFontInfo->props[i].name; + pFP->value = pFontInfo->props[i].value; + pFP++; + } + WriteSwappedDataToClient(client, length, reply); + (void) WriteToClient(client, namelen, name); + if (pFontInfo == &fontInfo) + { + free(fontInfo.props); + free(fontInfo.isStringProp); + } + --c->current.max_names; + } + } +finish: + length = sizeof(xListFontsWithInfoReply); + memset((char *) &finalReply, 0, sizeof(xListFontsWithInfoReply)); + finalReply.type = X_Reply; + finalReply.sequenceNumber = client->sequence; + finalReply.length = bytes_to_int32(sizeof(xListFontsWithInfoReply) + - sizeof(xGenericReply)); + WriteSwappedDataToClient(client, length, &finalReply); +bail: + ClientWakeup(client); +xinerama_sleep: + for (i = 0; i < c->num_fpes; i++) + FreeFPE(c->fpe_list[i]); + free(c->reply); + free(c->fpe_list); + free(c->savedName); + free(c); + return TRUE; +} + +int +StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern, + int max_names) +{ + int i; + LFWIclosurePtr c; + + /* + * The right error to return here would be BadName, however the + * specification does not allow for a Name error on this request. + * Perhaps a better solution would be to return a nil list, i.e. + * a list containing zero fontnames. + */ + if (length > XLFDMAXFONTNAMELEN) + return BadAlloc; + + i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess); + if (i != Success) + return i; + + if (!(c = malloc(sizeof *c))) + goto badAlloc; + c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes); + if (!c->fpe_list) + { + free(c); + goto badAlloc; + } + memmove(c->current.pattern, pattern, length); + for (i = 0; i < num_fpes; i++) + { + c->fpe_list[i] = font_path_elements[i]; + UseFPE(c->fpe_list[i]); + } + c->client = client; + c->num_fpes = num_fpes; + c->reply = 0; + c->length = 0; + c->current.patlen = length; + c->current.current_fpe = 0; + c->current.max_names = max_names; + c->current.list_started = FALSE; + c->current.private = 0; + c->savedNumFonts = 0; + c->haveSaved = FALSE; + c->savedName = 0; + doListFontsWithInfo(client, c); + return Success; +badAlloc: + return BadAlloc; +} + +#define TextEltHeader 2 +#define FontShiftSize 5 +static ChangeGCVal clearGC[] = { NullPixmap }; +#define clearGCmask (GCClipMask) + +int +doPolyText(ClientPtr client, PTclosurePtr c) +{ + FontPtr pFont = c->pGC->font, oldpFont; + int err = Success, lgerr; /* err is in X error, not font error, space */ + enum { NEVER_SLEPT, START_SLEEP, SLEEPING } client_state = NEVER_SLEPT; + FontPathElementPtr fpe; + GC *origGC = NULL; + int itemSize = c->reqType == X_PolyText8 ? 1 : 2; + + if (client->clientGone) + { + fpe = c->pGC->font->fpe; + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); + + if (ClientIsAsleep(client)) + { + /* Client has died, but we cannot bail out right now. We + need to clean up after the work we did when going to + sleep. Setting the drawable pointer to 0 makes this + happen without any attempts to render or perform other + unnecessary activities. */ + c->pDraw = (DrawablePtr)0; + } + else + { + err = Success; + goto bail; + } + } + + /* Make sure our drawable hasn't disappeared while we slept. */ + if (ClientIsAsleep(client) && c->pDraw) + { + DrawablePtr pDraw; + dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess); + if (c->pDraw != pDraw) { + /* Our drawable has disappeared. Treat like client died... ask + the FPE code to clean up after client and avoid further + rendering while we clean up after ourself. */ + fpe = c->pGC->font->fpe; + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); + c->pDraw = (DrawablePtr)0; + } + } + + client_state = ClientIsAsleep(client) ? SLEEPING : NEVER_SLEPT; + + while (c->endReq - c->pElt > TextEltHeader) + { + if (*c->pElt == FontChange) + { + Font fid; + if (c->endReq - c->pElt < FontShiftSize) + { + err = BadLength; + goto bail; + } + + oldpFont = pFont; + + fid = ((Font)*(c->pElt+4)) /* big-endian */ + | ((Font)*(c->pElt+3)) << 8 + | ((Font)*(c->pElt+2)) << 16 + | ((Font)*(c->pElt+1)) << 24; + err = dixLookupResourceByType((pointer *)&pFont, fid, RT_FONT, + client, DixUseAccess); + if (err != Success) + { + /* restore pFont for step 4 (described below) */ + pFont = oldpFont; + + /* If we're in START_SLEEP mode, the following step + shortens the request... in the unlikely event that + the fid somehow becomes valid before we come through + again to actually execute the polytext, which would + then mess up our refcounting scheme badly. */ + c->err = err; + c->endReq = c->pElt; + + goto bail; + } + + /* Step 3 (described below) on our new font */ + if (client_state == START_SLEEP) + pFont->refcnt++; + else + { + if (pFont != c->pGC->font && c->pDraw) + { + ChangeGCVal val; + val.ptr = pFont; + ChangeGC(NullClient, c->pGC, GCFont, &val); + ValidateGC(c->pDraw, c->pGC); + } + + /* Undo the refcnt++ we performed when going to sleep */ + if (client_state == SLEEPING) + (void)CloseFont(c->pGC->font, (Font)0); + } + c->pElt += FontShiftSize; + } + else /* print a string */ + { + unsigned char *pNextElt; + pNextElt = c->pElt + TextEltHeader + (*c->pElt) * itemSize; + if ( pNextElt > c->endReq) + { + err = BadLength; + goto bail; + } + if (client_state == START_SLEEP) + { + c->pElt = pNextElt; + continue; + } + if (c->pDraw) + { + lgerr = LoadGlyphs(client, c->pGC->font, *c->pElt, itemSize, + c->pElt + TextEltHeader); + } + else lgerr = Successful; + + if (lgerr == Suspended) + { + if (!ClientIsAsleep(client)) { + int len; + GC *pGC; + PTclosurePtr new_closure; + + /* We're putting the client to sleep. We need to do a few things + to ensure successful and atomic-appearing execution of the + remainder of the request. First, copy the remainder of the + request into a safe malloc'd area. Second, create a scratch GC + to use for the remainder of the request. Third, mark all fonts + referenced in the remainder of the request to prevent their + deallocation. Fourth, make the original GC look like the + request has completed... set its font to the final font value + from this request. These GC manipulations are for the unlikely + (but possible) event that some other client is using the GC. + Steps 3 and 4 are performed by running this procedure through + the remainder of the request in a special no-render mode + indicated by client_state = START_SLEEP. */ + + /* Step 1 */ + /* Allocate a malloc'd closure structure to replace + the local one we were passed */ + new_closure = malloc(sizeof(PTclosureRec)); + if (!new_closure) + { + err = BadAlloc; + goto bail; + } + *new_closure = *c; + c = new_closure; + + len = c->endReq - c->pElt; + c->data = malloc(len); + if (!c->data) + { + free(c); + err = BadAlloc; + goto bail; + } + memmove(c->data, c->pElt, len); + c->pElt = c->data; + c->endReq = c->pElt + len; + + /* Step 2 */ + + pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); + if (!pGC) + { + free(c->data); + free(c); + err = BadAlloc; + goto bail; + } + if ((err = CopyGC(c->pGC, pGC, GCFunction | + GCPlaneMask | GCForeground | + GCBackground | GCFillStyle | + GCTile | GCStipple | + GCTileStipXOrigin | + GCTileStipYOrigin | GCFont | + GCSubwindowMode | GCClipXOrigin | + GCClipYOrigin | GCClipMask)) != + Success) + { + FreeScratchGC(pGC); + free(c->data); + free(c); + err = BadAlloc; + goto bail; + } + origGC = c->pGC; + c->pGC = pGC; + ValidateGC(c->pDraw, c->pGC); + + ClientSleep(client, (ClientSleepProcPtr)doPolyText, c); + + /* Set up to perform steps 3 and 4 */ + client_state = START_SLEEP; + continue; /* on to steps 3 and 4 */ + } + else + goto xinerama_sleep; + return TRUE; + } + else if (lgerr != Successful) + { + err = FontToXError(lgerr); + goto bail; + } + if (c->pDraw) + { + c->xorg += *((INT8 *)(c->pElt + 1)); /* must be signed */ + if (c->reqType == X_PolyText8) + c->xorg = (* c->pGC->ops->PolyText8)(c->pDraw, c->pGC, c->xorg, c->yorg, + *c->pElt, (char *) (c->pElt + TextEltHeader)); + else + c->xorg = (* c->pGC->ops->PolyText16)(c->pDraw, c->pGC, c->xorg, c->yorg, + *c->pElt, (unsigned short *) (c->pElt + TextEltHeader)); + } + c->pElt = pNextElt; + } + } + +bail: + + if (client_state == START_SLEEP) + { + /* Step 4 */ + if (pFont != origGC->font) + { + ChangeGCVal val; + val.ptr = pFont; + ChangeGC(NullClient, origGC, GCFont, &val); + ValidateGC(c->pDraw, origGC); + } + + /* restore pElt pointer for execution of remainder of the request */ + c->pElt = c->data; + return TRUE; + } + + if (c->err != Success) err = c->err; + if (err != Success && c->client != serverClient) { +#ifdef PANORAMIX + if (noPanoramiXExtension || !c->pGC->pScreen->myNum) +#endif + SendErrorToClient(c->client, c->reqType, 0, 0, err); + } + if (ClientIsAsleep(client)) + { + ClientWakeup(c->client); +xinerama_sleep: + ChangeGC(NullClient, c->pGC, clearGCmask, clearGC); + + /* Unreference the font from the scratch GC */ + CloseFont(c->pGC->font, (Font)0); + c->pGC->font = NullFont; + + FreeScratchGC(c->pGC); + free(c->data); + free(c); + } + return TRUE; +} + +int +PolyText(ClientPtr client, DrawablePtr pDraw, GC *pGC, unsigned char *pElt, + unsigned char *endReq, int xorg, int yorg, int reqType, XID did) +{ + PTclosureRec local_closure; + + local_closure.pElt = pElt; + local_closure.endReq = endReq; + local_closure.client = client; + local_closure.pDraw = pDraw; + local_closure.xorg = xorg; + local_closure.yorg = yorg; + local_closure.reqType = reqType; + local_closure.pGC = pGC; + local_closure.did = did; + local_closure.err = Success; + + (void) doPolyText(client, &local_closure); + return Success; +} + + +#undef TextEltHeader +#undef FontShiftSize + +int +doImageText(ClientPtr client, ITclosurePtr c) +{ + int err = Success, lgerr; /* err is in X error, not font error, space */ + FontPathElementPtr fpe; + int itemSize = c->reqType == X_ImageText8 ? 1 : 2; + + if (client->clientGone) + { + fpe = c->pGC->font->fpe; + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); + err = Success; + goto bail; + } + + /* Make sure our drawable hasn't disappeared while we slept. */ + if (ClientIsAsleep(client) && c->pDraw) + { + DrawablePtr pDraw; + dixLookupDrawable(&pDraw, c->did, client, 0, DixWriteAccess); + if (c->pDraw != pDraw) { + /* Our drawable has disappeared. Treat like client died... ask + the FPE code to clean up after client. */ + fpe = c->pGC->font->fpe; + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); + err = Success; + goto bail; + } + } + + lgerr = LoadGlyphs(client, c->pGC->font, c->nChars, itemSize, c->data); + if (lgerr == Suspended) + { + if (!ClientIsAsleep(client)) { + GC *pGC; + unsigned char *data; + ITclosurePtr new_closure; + + /* We're putting the client to sleep. We need to + save some state. Similar problem to that handled + in doPolyText, but much simpler because the + request structure is much simpler. */ + + new_closure = malloc(sizeof(ITclosureRec)); + if (!new_closure) + { + err = BadAlloc; + goto bail; + } + *new_closure = *c; + c = new_closure; + + data = malloc(c->nChars * itemSize); + if (!data) + { + free(c); + err = BadAlloc; + goto bail; + } + memmove(data, c->data, c->nChars * itemSize); + c->data = data; + + pGC = GetScratchGC(c->pGC->depth, c->pGC->pScreen); + if (!pGC) + { + free(c->data); + free(c); + err = BadAlloc; + goto bail; + } + if ((err = CopyGC(c->pGC, pGC, GCFunction | GCPlaneMask | + GCForeground | GCBackground | GCFillStyle | + GCTile | GCStipple | GCTileStipXOrigin | + GCTileStipYOrigin | GCFont | + GCSubwindowMode | GCClipXOrigin | + GCClipYOrigin | GCClipMask)) != Success) + { + FreeScratchGC(pGC); + free(c->data); + free(c); + err = BadAlloc; + goto bail; + } + c->pGC = pGC; + ValidateGC(c->pDraw, c->pGC); + + ClientSleep(client, (ClientSleepProcPtr)doImageText, c); + } + else + goto xinerama_sleep; + return TRUE; + } + else if (lgerr != Successful) + { + err = FontToXError(lgerr); + goto bail; + } + if (c->pDraw) + { + if (c->reqType == X_ImageText8) + (* c->pGC->ops->ImageText8)(c->pDraw, c->pGC, c->xorg, c->yorg, + c->nChars, (char *) c->data); + else + (* c->pGC->ops->ImageText16)(c->pDraw, c->pGC, c->xorg, c->yorg, + c->nChars, (unsigned short *) c->data); + } + +bail: + + if (err != Success && c->client != serverClient) { + SendErrorToClient(c->client, c->reqType, 0, 0, err); + } + if (ClientIsAsleep(client)) + { + ClientWakeup(c->client); +xinerama_sleep: + ChangeGC(NullClient, c->pGC, clearGCmask, clearGC); + + /* Unreference the font from the scratch GC */ + CloseFont(c->pGC->font, (Font)0); + c->pGC->font = NullFont; + + FreeScratchGC(c->pGC); + free(c->data); + free(c); + } + return TRUE; +} + +int +ImageText(ClientPtr client, DrawablePtr pDraw, GC *pGC, int nChars, + unsigned char *data, int xorg, int yorg, int reqType, XID did) +{ + ITclosureRec local_closure; + + local_closure.client = client; + local_closure.pDraw = pDraw; + local_closure.pGC = pGC; + local_closure.nChars = nChars; + local_closure.data = data; + local_closure.xorg = xorg; + local_closure.yorg = yorg; + local_closure.reqType = reqType; + local_closure.did = did; + + (void) doImageText(client, &local_closure); + return Success; +} + + +/* does the necessary magic to figure out the fpe type */ +static int +DetermineFPEType(char *pathname) +{ + int i; + + for (i = 0; i < num_fpe_types; i++) { + if ((*fpe_functions[i].name_check) (pathname)) + return i; + } + return -1; +} + + +static void +FreeFontPath(FontPathElementPtr *list, int n, Bool force) +{ + int i; + + for (i = 0; i < n; i++) { + if (force) { + /* Sanity check that all refcounts will be 0 by the time + we get to the end of the list. */ + int found = 1; /* the first reference is us */ + int j; + for (j = i+1; j < n; j++) { + if (list[j] == list[i]) + found++; + } + if (list[i]->refcount != found) { + list[i]->refcount = found; /* ensure it will get freed */ + } + } + FreeFPE(list[i]); + } + free(list); +} + +static FontPathElementPtr +find_existing_fpe(FontPathElementPtr *list, int num, unsigned char *name, int len) +{ + FontPathElementPtr fpe; + int i; + + for (i = 0; i < num; i++) { + fpe = list[i]; + if (fpe->name_length == len && memcmp(name, fpe->name, len) == 0) + return fpe; + } + return (FontPathElementPtr) 0; +} + + +static int +SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist) +{ + int i, err = 0; + int valid_paths = 0; + unsigned int len; + unsigned char *cp = paths; + FontPathElementPtr fpe = NULL, *fplist; + + fplist = malloc(sizeof(FontPathElementPtr) * npaths); + if (!fplist) { + *bad = 0; + return BadAlloc; + } + for (i = 0; i < num_fpe_types; i++) { + if (fpe_functions[i].set_path_hook) + (*fpe_functions[i].set_path_hook) (); + } + for (i = 0; i < npaths; i++) + { + len = (unsigned int) (*cp++); + + if (len == 0) + { + if (persist) + ErrorF("[dix] Removing empty element from the valid list of fontpaths\n"); + err = BadValue; + } + else + { + /* if it's already in our active list, just reset it */ + /* + * note that this can miss FPE's in limbo -- may be worth catching + * them, though it'd muck up refcounting + */ + fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len); + if (fpe) + { + err = (*fpe_functions[fpe->type].reset_fpe) (fpe); + if (err == Successful) + { + UseFPE(fpe);/* since it'll be decref'd later when freed + * from the old list */ + } + else + fpe = 0; + } + /* if error or can't do it, act like it's a new one */ + if (!fpe) + { + fpe = malloc(sizeof(FontPathElementRec)); + if (!fpe) + { + err = BadAlloc; + goto bail; + } + fpe->name = malloc(len + 1); + if (!fpe->name) + { + free(fpe); + err = BadAlloc; + goto bail; + } + fpe->refcount = 1; + + strncpy(fpe->name, (char *) cp, (int) len); + fpe->name[len] = '\0'; + fpe->name_length = len; + fpe->type = DetermineFPEType(fpe->name); + if (fpe->type == -1) + err = BadValue; + else + err = (*fpe_functions[fpe->type].init_fpe) (fpe); + if (err != Successful) + { + if (persist) + { + ErrorF("[dix] Could not init font path element %s, removing from list!\n", + fpe->name); + } + free(fpe->name); + free(fpe); + } + } + } + if (err != Successful) + { + if (!persist) + goto bail; + } + else + { + fplist[valid_paths++] = fpe; + } + cp += len; + } + + FreeFontPath(font_path_elements, num_fpes, FALSE); + font_path_elements = fplist; + if (patternCache) + EmptyFontPatternCache(patternCache); + num_fpes = valid_paths; + + return Success; +bail: + *bad = i; + while (--valid_paths >= 0) + FreeFPE(fplist[valid_paths]); + free(fplist); + return FontToXError(err); +} + +int +SetFontPath(ClientPtr client, int npaths, unsigned char *paths) +{ + int err = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); + if (err != Success) + return err; + + if (npaths == 0) { + if (SetDefaultFontPath(defaultFontPath) != Success) + return BadValue; + } else { + int bad; + err = SetFontPathElements(npaths, paths, &bad, FALSE); + client->errorValue = bad; + } + return err; +} + +int +SetDefaultFontPath(char *path) +{ + char *temp_path, + *start, + *end; + unsigned char *cp, + *pp, + *nump, + *newpath; + int num = 1, + len, + err, + size = 0, + bad; + + /* ensure temp_path contains "built-ins" */ + start = path; + while (1) { + start = strstr(start, "built-ins"); + if (start == NULL) + break; + end = start + strlen("built-ins"); + if ((start == path || start[-1] == ',') && (!*end || *end == ',')) + break; + start = end; + } + if (!start) { + if (asprintf(&temp_path, "%s%sbuilt-ins", path, *path ? "," : "") + == -1) + temp_path = NULL; + } else { + temp_path = strdup(path); + } + if (!temp_path) + return BadAlloc; + + /* get enough for string, plus values -- use up commas */ + len = strlen(temp_path) + 1; + nump = cp = newpath = malloc(len); + if (!newpath) + return BadAlloc; + pp = (unsigned char *) temp_path; + cp++; + while (*pp) { + if (*pp == ',') { + *nump = (unsigned char) size; + nump = cp++; + pp++; + num++; + size = 0; + } else { + *cp++ = *pp++; + size++; + } + } + *nump = (unsigned char) size; + + err = SetFontPathElements(num, newpath, &bad, TRUE); + + free(newpath); + free(temp_path); + + return err; +} + +int +GetFontPath(ClientPtr client, int *count, int *length, unsigned char **result) +{ + int i; + unsigned char *c; + int len; + FontPathElementPtr fpe; + + i = XaceHook(XACE_SERVER_ACCESS, client, DixGetAttrAccess); + if (i != Success) + return i; + + len = 0; + for (i = 0; i < num_fpes; i++) { + fpe = font_path_elements[i]; + len += fpe->name_length + 1; + } + font_path_string = (unsigned char *) realloc(font_path_string, len); + if (!font_path_string) + return BadAlloc; + + c = font_path_string; + *length = 0; + for (i = 0; i < num_fpes; i++) { + fpe = font_path_elements[i]; + *c = fpe->name_length; + *length += *c++; + memmove(c, fpe->name, fpe->name_length); + c += fpe->name_length; + } + *count = num_fpes; + *result = font_path_string; + return Success; +} + +void +DeleteClientFontStuff(ClientPtr client) +{ + int i; + FontPathElementPtr fpe; + + for (i = 0; i < num_fpes; i++) + { + fpe = font_path_elements[i]; + if (fpe_functions[fpe->type].client_died) + (*fpe_functions[fpe->type].client_died) ((pointer) client, fpe); + } +} + +void +InitFonts (void) +{ + patternCache = MakeFontPatternCache(); + + register_fpe_functions(); +} + +int +GetDefaultPointSize (void) +{ + return 120; +} + + +FontResolutionPtr +GetClientResolutions (int *num) +{ + static struct _FontResolution res; + ScreenPtr pScreen; + + pScreen = screenInfo.screens[0]; + res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth; + /* + * XXX - we'll want this as long as bitmap instances are prevalent + so that we can match them from scalable fonts + */ + if (res.x_resolution < 88) + res.x_resolution = 75; + else + res.x_resolution = 100; + res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight; + if (res.y_resolution < 88) + res.y_resolution = 75; + else + res.y_resolution = 100; + res.point_size = 120; + *num = 1; + return &res; +} + +/* + * returns the type index of the new fpe + * + * should be called (only once!) by each type of fpe when initialized + */ + +int +RegisterFPEFunctions(NameCheckFunc name_func, + InitFpeFunc init_func, + FreeFpeFunc free_func, + ResetFpeFunc reset_func, + OpenFontFunc open_func, + CloseFontFunc close_func, + ListFontsFunc list_func, + StartLfwiFunc start_lfwi_func, + NextLfwiFunc next_lfwi_func, + WakeupFpeFunc wakeup_func, + ClientDiedFunc client_died, + LoadGlyphsFunc load_glyphs, + StartLaFunc start_list_alias_func, + NextLaFunc next_list_alias_func, + SetPathFunc set_path_func) +{ + FPEFunctions *new; + + /* grow the list */ + new = (FPEFunctions *) realloc(fpe_functions, + (num_fpe_types + 1) * sizeof(FPEFunctions)); + if (!new) + return -1; + fpe_functions = new; + + fpe_functions[num_fpe_types].name_check = name_func; + fpe_functions[num_fpe_types].open_font = open_func; + fpe_functions[num_fpe_types].close_font = close_func; + fpe_functions[num_fpe_types].wakeup_fpe = wakeup_func; + fpe_functions[num_fpe_types].list_fonts = list_func; + fpe_functions[num_fpe_types].start_list_fonts_with_info = + start_lfwi_func; + fpe_functions[num_fpe_types].list_next_font_with_info = + next_lfwi_func; + fpe_functions[num_fpe_types].init_fpe = init_func; + fpe_functions[num_fpe_types].free_fpe = free_func; + fpe_functions[num_fpe_types].reset_fpe = reset_func; + fpe_functions[num_fpe_types].client_died = client_died; + fpe_functions[num_fpe_types].load_glyphs = load_glyphs; + fpe_functions[num_fpe_types].start_list_fonts_and_aliases = + start_list_alias_func; + fpe_functions[num_fpe_types].list_next_font_or_alias = + next_list_alias_func; + fpe_functions[num_fpe_types].set_path_hook = set_path_func; + + return num_fpe_types++; +} + +void +FreeFonts(void) +{ + if (patternCache) { + FreeFontPatternCache(patternCache); + patternCache = 0; + } + FreeFontPath(font_path_elements, num_fpes, TRUE); + font_path_elements = 0; + num_fpes = 0; + free(fpe_functions); + num_fpe_types = 0; + fpe_functions = (FPEFunctions *) 0; +} + +/* convenience functions for FS interface */ + +FontPtr +find_old_font(XID id) +{ + pointer pFont; + dixLookupResourceByType(&pFont, id, RT_NONE, serverClient, DixReadAccess); + return (FontPtr)pFont; +} + +Font +GetNewFontClientID(void) +{ + return FakeClientID(0); +} + +int +StoreFontClientFont(FontPtr pfont, Font id) +{ + return AddResource(id, RT_NONE, (pointer) pfont); +} + +void +DeleteFontClientID(Font id) +{ + FreeResource(id, RT_NONE); +} + +int +client_auth_generation(ClientPtr client) +{ + return 0; +} + +static int fs_handlers_installed = 0; +static unsigned int last_server_gen; + +int +init_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler) +{ + /* if server has reset, make sure the b&w handlers are reinstalled */ + if (last_server_gen < serverGeneration) { + last_server_gen = serverGeneration; + fs_handlers_installed = 0; + } + if (fs_handlers_installed == 0) { + if (!RegisterBlockAndWakeupHandlers(block_handler, + FontWakeup, (pointer) 0)) + return AllocError; + fs_handlers_installed++; + } + QueueFontWakeup(fpe); + return Successful; +} + +void +remove_fs_handlers(FontPathElementPtr fpe, BlockHandlerProcPtr block_handler, Bool all) +{ + if (all) { + /* remove the handlers if no one else is using them */ + if (--fs_handlers_installed == 0) { + RemoveBlockAndWakeupHandlers(block_handler, FontWakeup, + (pointer) 0); + } + } + RemoveFontWakeup(fpe); +} diff --git a/xorg-server/hw/xfree86/common/Makefile.am b/xorg-server/hw/xfree86/common/Makefile.am index 56caaa5ab..c031d4be3 100644 --- a/xorg-server/hw/xfree86/common/Makefile.am +++ b/xorg-server/hw/xfree86/common/Makefile.am @@ -1,93 +1,92 @@ -noinst_LTLIBRARIES = libcommon.la
-
-if XORG_BUS_SPARC
-SBUS_SOURCES = xf86sbusBus.c
-endif
-
-if XV
-XVSOURCES = xf86xv.c xf86xvmc.c
-XVSDKINCS = xf86xv.h xf86xvmc.h xf86xvpriv.h
-endif
-
-if XF86VIDMODE
-XF86VMODE_SDK = vidmodeproc.h
-endif
-
-if DGA
-DGASOURCES = xf86DGA.c
-endif
-
-RANDRSOURCES = xf86RandR.c
-
-BUSSOURCES = xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES)
-
-MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes
-
-xf86DefModeSet.c: $(srcdir)/modeline2c.awk $(MODEDEFSOURCES)
- $(AM_V_GEN)cat $(MODEDEFSOURCES) | LC_ALL=C $(AWK) -f $(srcdir)/modeline2c.awk > $@
- $(AM_V_GEN)echo >> $@
-
-BUILT_SOURCES = xf86DefModeSet.c
-
-AM_LDFLAGS = -r
-libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \
- xf86Cursor.c $(DGASOURCES) xf86DPMS.c \
- xf86Events.c xf86Globals.c xf86AutoConfig.c \
- xf86Option.c xf86Init.c xf86VGAarbiter.c \
- xf86VidMode.c xf86fbman.c xf86cmap.c \
- xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \
- xf86Mode.c xorgHelper.c \
- $(XVSOURCES) $(BUSSOURCES) $(RANDRSOURCES)
-nodist_libcommon_la_SOURCES = xf86DefModeSet.c xf86Build.h
-libcommon_la_LIBADD = $(top_builddir)/config/libconfig.la
-
-INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \
- -I$(srcdir)/../loader -I$(srcdir)/../parser \
- -I$(srcdir)/../vbe -I$(srcdir)/../int10 \
- -I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod \
- -I$(srcdir)/../modes -I$(srcdir)/../ramdac
-
-sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \
- xf86PciInfo.h xf86Priv.h xf86Privstr.h \
- xf86cmap.h xf86fbman.h xf86str.h xf86Xinput.h xisb.h \
- $(XVSDKINCS) $(XF86VMODE_SDK) xorgVersion.h \
- xf86sbusBus.h xf86VGAarbiter.h
-
-DISTCLEANFILES = xf86Build.h
-CLEANFILES = $(BUILT_SOURCES)
-
-EXTRA_DIST = \
- compiler.h \
- fourcc.h \
- scoasm.h \
- vidmodeproc.h \
- xf86.h \
- xf86Bus.h \
- xf86Config.h \
- xf86InPriv.h \
- xf86Module.h \
- xf86Opt.h \
- xf86PciInfo.h \
- xf86Priv.h \
- xf86Privstr.h \
- xf86Xinput.h \
- xf86cmap.h \
- xf86fbman.h \
- xf86pciBus.h \
- xf86str.h \
- xf86xv.h \
- xf86xvmc.h \
- xf86xvpriv.h \
- xisb.h \
- xorgVersion.h \
- $(MODEDEFSOURCES) \
- modeline2c.awk \
- xf86VGAarbiter.h \
- xf86VGAarbiterPriv.h \
- $(DISTKBDSOURCES)
-
-if LNXACPI
-XORG_CFLAGS += -DHAVE_ACPI
-endif
-
-AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS)
+noinst_LTLIBRARIES = libcommon.la + +if XORG_BUS_SPARC +SBUS_SOURCES = xf86sbusBus.c +endif + +if XV +XVSOURCES = xf86xv.c xf86xvmc.c +XVSDKINCS = xf86xv.h xf86xvmc.h xf86xvpriv.h +endif + +if XF86VIDMODE +XF86VMODE_SDK = vidmodeproc.h +endif + +if DGA +DGASOURCES = xf86DGA.c +endif + +RANDRSOURCES = xf86RandR.c + +BUSSOURCES = xf86pciBus.c xf86fbBus.c xf86noBus.c $(SBUS_SOURCES) + +MODEDEFSOURCES = $(srcdir)/vesamodes $(srcdir)/extramodes + +xf86DefModeSet.c: $(srcdir)/modeline2c.awk $(MODEDEFSOURCES) + $(AM_V_GEN)cat $(MODEDEFSOURCES) | LC_ALL=C $(AWK) -f $(srcdir)/modeline2c.awk > $@ + $(AM_V_GEN)echo >> $@ + +BUILT_SOURCES = xf86DefModeSet.c + +AM_LDFLAGS = -r +libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \ + xf86Cursor.c $(DGASOURCES) xf86DPMS.c \ + xf86Events.c xf86Globals.c xf86AutoConfig.c \ + xf86Option.c xf86Init.c xf86VGAarbiter.c \ + xf86VidMode.c xf86fbman.c xf86cmap.c \ + xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \ + xf86Mode.c xorgHelper.c \ + $(XVSOURCES) $(BUSSOURCES) $(RANDRSOURCES) +nodist_libcommon_la_SOURCES = xf86DefModeSet.c xf86Build.h +libcommon_la_LIBADD = $(top_builddir)/config/libconfig.la + +INCLUDES = $(XORG_INCS) -I$(srcdir)/../ddc -I$(srcdir)/../i2c \ + -I$(srcdir)/../loader -I$(srcdir)/../parser \ + -I$(srcdir)/../vbe -I$(srcdir)/../int10 \ + -I$(srcdir)/../vgahw -I$(srcdir)/../dixmods/extmod \ + -I$(srcdir)/../modes -I$(srcdir)/../ramdac + +sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \ + xf86PciInfo.h xf86Priv.h xf86Privstr.h \ + xf86cmap.h xf86fbman.h xf86str.h xf86Xinput.h xisb.h \ + $(XVSDKINCS) $(XF86VMODE_SDK) xorgVersion.h \ + xf86sbusBus.h xf86VGAarbiter.h + +DISTCLEANFILES = xf86Build.h +CLEANFILES = $(BUILT_SOURCES) + +EXTRA_DIST = \ + compiler.h \ + fourcc.h \ + vidmodeproc.h \ + xf86.h \ + xf86Bus.h \ + xf86Config.h \ + xf86InPriv.h \ + xf86Module.h \ + xf86Opt.h \ + xf86PciInfo.h \ + xf86Priv.h \ + xf86Privstr.h \ + xf86Xinput.h \ + xf86cmap.h \ + xf86fbman.h \ + xf86pciBus.h \ + xf86str.h \ + xf86xv.h \ + xf86xvmc.h \ + xf86xvpriv.h \ + xisb.h \ + xorgVersion.h \ + $(MODEDEFSOURCES) \ + modeline2c.awk \ + xf86VGAarbiter.h \ + xf86VGAarbiterPriv.h \ + $(DISTKBDSOURCES) + +if LNXACPI +XORG_CFLAGS += -DHAVE_ACPI +endif + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) diff --git a/xorg-server/hw/xfree86/common/compiler.h b/xorg-server/hw/xfree86/common/compiler.h index 617f6b788..9c9bac6ba 100644 --- a/xorg-server/hw/xfree86/common/compiler.h +++ b/xorg-server/hw/xfree86/common/compiler.h @@ -1,1786 +1,1773 @@ -/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * 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 Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Thomas Roell makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL 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 (c) 1994-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifndef _COMPILER_H
-
-# define _COMPILER_H
-
-#if defined(__SUNPRO_C)
-# define DO_PROTOTYPES
-#endif
-
-/* Map Sun compiler platform defines to gcc-style used in the code */
-#if defined(__amd64) && !defined(__amd64__)
-# define __amd64__
-#endif
-#if defined(__i386) && !defined(__i386__)
-# define __i386__
-#endif
-#if defined(__sparc) && !defined(__sparc__)
-# define __sparc__
-#endif
-#if defined(__sparcv9) && !defined(__sparc64__)
-# define __sparc64__
-#endif
-
-#ifndef _X_EXPORT
-# include <X11/Xfuncproto.h>
-#endif
-
-# include <pixman.h> /* for uint*_t types */
-
-/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */
-# ifndef __inline__
-# if defined(__GNUC__)
- /* gcc has __inline__ */
-# elif defined(__HIGHC__)
-# define __inline__ _Inline
-# else
-# define __inline__ /**/
-# endif
-# endif /* __inline__ */
-# ifndef __inline
-# if defined(__GNUC__) || defined(_MSC_VER)
- /* gcc has __inline */
-# elif defined(__HIGHC__)
-# define __inline _Inline
-# else
-# define __inline /**/
-# endif
-# endif /* __inline */
-
-/* Support gcc's __FUNCTION__ for people using other compilers */
-#if !defined(__GNUC__) && !defined(__FUNCTION__)
-# define __FUNCTION__ __func__ /* C99 */
-#endif
-
-# if defined(NO_INLINE) || defined(DO_PROTOTYPES)
-
-# if !defined(__arm__)
-# if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) && !defined(__nds32__) \
- && !(defined(__alpha__) && defined(linux)) \
- && !(defined(__ia64__) && defined(linux)) \
-
-extern _X_EXPORT void outb(unsigned short, unsigned char);
-extern _X_EXPORT void outw(unsigned short, unsigned short);
-extern _X_EXPORT void outl(unsigned short, unsigned int);
-extern _X_EXPORT unsigned int inb(unsigned short);
-extern _X_EXPORT unsigned int inw(unsigned short);
-extern _X_EXPORT unsigned int inl(unsigned short);
-
-# else /* __sparc__, __arm32__, __alpha__, __nds32__ */
-
-extern _X_EXPORT void outb(unsigned long, unsigned char);
-extern _X_EXPORT void outw(unsigned long, unsigned short);
-extern _X_EXPORT void outl(unsigned long, unsigned int);
-extern _X_EXPORT unsigned int inb(unsigned long);
-extern _X_EXPORT unsigned int inw(unsigned long);
-extern _X_EXPORT unsigned int inl(unsigned long);
-
-# endif /* __sparc__, __arm32__, __alpha__, __nds32__ */
-# endif /* __arm__ */
-
-# if defined(__powerpc__) && !defined(__OpenBSD__)
-extern unsigned long ldq_u(unsigned long *);
-extern unsigned long ldl_u(unsigned int *);
-extern unsigned long ldw_u(unsigned short *);
-extern void stq_u(unsigned long, unsigned long *);
-extern void stl_u(unsigned long, unsigned int *);
-extern void stw_u(unsigned long, unsigned short *);
-extern void mem_barrier(void);
-extern void write_mem_barrier(void);
-extern void stl_brx(unsigned long, volatile unsigned char *, int);
-extern void stw_brx(unsigned short, volatile unsigned char *, int);
-extern unsigned long ldl_brx(volatile unsigned char *, int);
-extern unsigned short ldw_brx(volatile unsigned char *, int);
-# endif /* __powerpc__ && !__OpenBSD */
-
-# endif /* NO_INLINE || DO_PROTOTYPES */
-
-# ifndef NO_INLINE
-# ifdef __GNUC__
-# ifdef __i386__
-
-# ifdef __SSE__
-# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
-# else
-# define write_mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
-# endif
-
-# ifdef __SSE2__
-# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
-# else
-# define mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory")
-# endif
-
-# elif defined __alpha__
-
-# define mem_barrier() __asm__ __volatile__ ("mb" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("wmb" : : : "memory")
-
-# elif defined __amd64__
-
-# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory")
-
-# elif defined __ia64__
-
-# ifndef __INTEL_COMPILER
-# define mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
-# define write_mem_barrier() __asm__ __volatile__ ("mf" : : : "memory")
-# else
-# include "ia64intrin.h"
-# define mem_barrier() __mf()
-# define write_mem_barrier() __mf()
-# endif
-
-# elif defined __mips__
- /* Note: sync instruction requires MIPS II instruction set */
-# define mem_barrier() \
- __asm__ __volatile__( \
- ".set push\n\t" \
- ".set noreorder\n\t" \
- ".set mips2\n\t" \
- "sync\n\t" \
- ".set pop" \
- : /* no output */ \
- : /* no input */ \
- : "memory")
-# define write_mem_barrier() mem_barrier()
-
-# elif defined __powerpc__
-
-# if defined(linux) && defined(__powerpc64__)
-# include <linux/version.h>
-# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
-# include <asm/memory.h>
-# endif
-# endif /* defined(linux) && defined(__powerpc64__) */
-
-# ifndef eieio /* We deal with arch-specific eieio() routines above... */
-# define eieio() __asm__ __volatile__ ("eieio" ::: "memory")
-# endif /* eieio */
-# define mem_barrier() eieio()
-# define write_mem_barrier() eieio()
-
-# elif defined __sparc__
-
-# define barrier() __asm__ __volatile__ (".word 0x8143e00a" : : : "memory")
-# define mem_barrier() /* XXX: nop for now */
-# define write_mem_barrier() /* XXX: nop for now */
-# endif
-# endif /* __GNUC__ */
-# endif /* NO_INLINE */
-
-# ifndef mem_barrier
-# define mem_barrier() /* NOP */
-# endif
-
-# ifndef write_mem_barrier
-# define write_mem_barrier() /* NOP */
-# endif
-
-
-# ifndef NO_INLINE
-# ifdef __GNUC__
-
-/* Define some packed structures to use with unaligned accesses */
-
-struct __una_u64 { uint64_t x __attribute__((packed)); };
-struct __una_u32 { uint32_t x __attribute__((packed)); };
-struct __una_u16 { uint16_t x __attribute__((packed)); };
-
-/* Elemental unaligned loads */
-
-static __inline__ uint64_t ldq_u(uint64_t *p)
-{
- const struct __una_u64 *ptr = (const struct __una_u64 *) p;
- return ptr->x;
-}
-
-static __inline__ uint32_t ldl_u(uint32_t *p)
-{
- const struct __una_u32 *ptr = (const struct __una_u32 *) p;
- return ptr->x;
-}
-
-static __inline__ uint16_t ldw_u(uint16_t *p)
-{
- const struct __una_u16 *ptr = (const struct __una_u16 *) p;
- return ptr->x;
-}
-
-/* Elemental unaligned stores */
-
-static __inline__ void stq_u(uint64_t val, uint64_t *p)
-{
- struct __una_u64 *ptr = (struct __una_u64 *) p;
- ptr->x = val;
-}
-
-static __inline__ void stl_u(uint32_t val, uint32_t *p)
-{
- struct __una_u32 *ptr = (struct __una_u32 *) p;
- ptr->x = val;
-}
-
-static __inline__ void stw_u(uint16_t val, uint16_t *p)
-{
- struct __una_u16 *ptr = (struct __una_u16 *) p;
- ptr->x = val;
-}
-# else /* !__GNUC__ */
-
-#include <string.h> /* needed for memmove */
-
-static __inline__ uint64_t ldq_u(uint64_t *p)
-{
- uint64_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ uint32_t ldl_u(uint32_t *p)
-{
- uint32_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ uint16_t ldw_u(uint16_t *p)
-{
- uint16_t ret;
- memmove(&ret, p, sizeof(*p));
- return ret;
-}
-
-static __inline__ void stq_u(uint64_t val, uint64_t *p)
-{
- uint64_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
-}
-
-static __inline__ void stl_u(uint32_t val, uint32_t *p)
-{
- uint32_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
-}
-
-static __inline__ void stw_u(uint16_t val, uint16_t *p)
-{
- uint16_t tmp = val;
- memmove(p, &tmp, sizeof(*p));
-}
-
-# endif /* __GNUC__ */
-# endif /* NO_INLINE */
-
-# ifndef NO_INLINE
-# ifdef __GNUC__
-# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__))
-
-# ifdef linux
-/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/* *before* any inx/outx is done. */
-
-extern _X_EXPORT void _outb(unsigned char val, unsigned long port);
-extern _X_EXPORT void _outw(unsigned short val, unsigned long port);
-extern _X_EXPORT void _outl(unsigned int val, unsigned long port);
-extern _X_EXPORT unsigned int _inb(unsigned long port);
-extern _X_EXPORT unsigned int _inw(unsigned long port);
-extern _X_EXPORT unsigned int _inl(unsigned long port);
-
-static __inline__ void
-outb(unsigned long port, unsigned char val)
-{
- _outb(val, port);
-}
-
-static __inline__ void
-outw(unsigned long port, unsigned short val)
-{
- _outw(val, port);
-}
-
-static __inline__ void
-outl(unsigned long port, unsigned int val)
-{
- _outl(val, port);
-}
-
-static __inline__ unsigned int
-inb(unsigned long port)
-{
- return _inb(port);
-}
-
-static __inline__ unsigned int
-inw(unsigned long port)
-{
- return _inw(port);
-}
-
-static __inline__ unsigned int
-inl(unsigned long port)
-{
- return _inl(port);
-}
-
-# endif /* linux */
-
-# if (defined(__FreeBSD__) || defined(__OpenBSD__)) \
- && !defined(DO_PROTOTYPES)
-
-/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */
-/* inx/outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/* *before* any inx/outx is done. */
-
-extern _X_EXPORT void outb(unsigned int port, unsigned char val);
-extern _X_EXPORT void outw(unsigned int port, unsigned short val);
-extern _X_EXPORT void outl(unsigned int port, unsigned int val);
-extern _X_EXPORT unsigned char inb(unsigned int port);
-extern _X_EXPORT unsigned short inw(unsigned int port);
-extern _X_EXPORT unsigned int inl(unsigned int port);
-
-# endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */
-
-
-#if defined(__NetBSD__)
-#include <machine/pio.h>
-#endif /* __NetBSD__ */
-
-# elif defined(linux) && defined(__ia64__)
-
-# include <inttypes.h>
-
-# include <sys/io.h>
-
-# undef outb
-# undef outw
-# undef outl
-# undef inb
-# undef inw
-# undef inl
-extern _X_EXPORT void outb(unsigned long port, unsigned char val);
-extern _X_EXPORT void outw(unsigned long port, unsigned short val);
-extern _X_EXPORT void outl(unsigned long port, unsigned int val);
-extern _X_EXPORT unsigned int inb(unsigned long port);
-extern _X_EXPORT unsigned int inw(unsigned long port);
-extern _X_EXPORT unsigned int inl(unsigned long port);
-
-# elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__)
-
-# include <inttypes.h>
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
- __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
-}
-
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
- __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
- __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- unsigned char ret;
- __asm__ __volatile__("inb %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- unsigned short ret;
- __asm__ __volatile__("inw %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- unsigned int ret;
- __asm__ __volatile__("inl %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-# elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__)
-
-# ifndef ASI_PL
-# define ASI_PL 0x88
-# endif
-
-static __inline__ void
-outb(unsigned long port, unsigned char val)
-{
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-outw(unsigned long port, unsigned short val)
-{
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-outl(unsigned long port, unsigned int val)
-{
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (port), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ unsigned int
-inb(unsigned long port)
-{
- unsigned int ret;
- __asm__ __volatile__("lduba [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned long port)
-{
- unsigned int ret;
- __asm__ __volatile__("lduha [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned long port)
-{
- unsigned int ret;
- __asm__ __volatile__("lda [%1] %2, %0"
- : "=r" (ret)
- : "r" (port), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned char
-xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned char ret;
-
- __asm__ __volatile__("lduba [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned short ret;
-
- __asm__ __volatile__("lduh [%1], %0"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned short ret;
-
- __asm__ __volatile__("lduha [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
-
- __asm__ __volatile__("ld [%1], %0"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
-
- __asm__ __volatile__("lda [%1] %2, %0"
- : "=r" (ret)
- : "r" (addr), "i" (ASI_PL));
- return ret;
-}
-
-static __inline__ void
-xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sth %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("st %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stba %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
-}
-
-static __inline__ void
-xf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sth %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void
-xf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("stha %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
-}
-
-static __inline__ void
-xf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("st %0, [%1]"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void
-xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sta %0, [%1] %2"
- : /* No outputs */
- : "r" (val), "r" (addr), "i" (ASI_PL));
-}
-
-# elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__))
-# ifdef __arm32__
-# define PORT_SIZE long
-# else
-# define PORT_SIZE short
-# endif
-
-_X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */
-
-static __inline__ void
-outb(unsigned PORT_SIZE port, unsigned char val)
-{
- *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
-}
-
-static __inline__ void
-outw(unsigned PORT_SIZE port, unsigned short val)
-{
- *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
-}
-
-static __inline__ void
-outl(unsigned PORT_SIZE port, unsigned int val)
-{
- *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
-}
-
-static __inline__ unsigned int
-inb(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase);
-}
-
-static __inline__ unsigned int
-inw(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase);
-}
-
-static __inline__ unsigned int
-inl(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase);
-}
-
-
-# if defined(__mips__)
-# ifdef linux /* don't mess with other OSs */
-# if X_BYTE_ORDER == X_BIG_ENDIAN
-static __inline__ unsigned int
-xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
-
- __asm__ __volatile__("lw %0, 0(%1)"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ void
-xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__("sw %0, 0(%1)"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-# endif
-# endif /* !linux */
-# endif /* __mips__ */
-
-# elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__)
-
-# ifndef MAP_FAILED
-# define MAP_FAILED ((void *)-1)
-# endif
-
-extern _X_EXPORT volatile unsigned char *ioBase;
-
-static __inline__ unsigned char
-xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned char val;
- __asm__ __volatile__(
- "lbzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned short val;
- __asm__ __volatile__(
- "lhzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned short val;
- __asm__ __volatile__(
- "lhbrx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned int val;
- __asm__ __volatile__(
- "lwzx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset)
-{
- register unsigned int val;
- __asm__ __volatile__(
- "lwbrx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (base), "r" (offset),
- "m" (*((volatile unsigned char *)base+offset)));
- return val;
-}
-
-static __inline__ void
-xf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset,
- const unsigned char val)
-{
- __asm__ __volatile__(
- "stbx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- __asm__ __volatile__(
- "sthbrx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- __asm__ __volatile__(
- "sthx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- __asm__ __volatile__(
- "stwbrx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- __asm__ __volatile__(
- "stwx %1,%2,%3\n\t"
- : "=m" (*((volatile unsigned char *)base+offset))
- : "r" (val), "b" (base), "r" (offset));
-}
-
-static __inline__ void
-xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
- const unsigned char val)
-{
- xf86WriteMmioNB8(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- xf86WriteMmioNB16Le(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset,
- const unsigned short val)
-{
- xf86WriteMmioNB16Be(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- xf86WriteMmioNB32Le(base, offset, val);
- eieio();
-}
-
-static __inline__ void
-xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- xf86WriteMmioNB32Be(base, offset, val);
- eieio();
-}
-
-
-static __inline__ void
-outb(unsigned short port, unsigned char value)
-{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio8((void *)ioBase, port, value);
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short value)
-{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio16Le((void *)ioBase, port, value);
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int value)
-{
- if(ioBase == MAP_FAILED) return;
- xf86WriteMmio32Le((void *)ioBase, port, value);
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio8((void *)ioBase, port);
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio16Le((void *)ioBase, port);
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- if(ioBase == MAP_FAILED) return 0;
- return xf86ReadMmio32Le((void *)ioBase, port);
-}
-
-#elif defined(__arm__) && defined(__linux__)
-
-/* for Linux on ARM, we use the LIBC inx/outx routines */
-/* note that the appropriate setup via "ioperm" needs to be done */
-/* *before* any inx/outx is done. */
-
-#include <sys/io.h>
-
-static __inline__ void
-xf_outb(unsigned short port, unsigned char val)
-{
- outb(val, port);
-}
-
-static __inline__ void
-xf_outw(unsigned short port, unsigned short val)
-{
- outw(val, port);
-}
-
-static __inline__ void
-xf_outl(unsigned short port, unsigned int val)
-{
- outl(val, port);
-}
-
-#define outb xf_outb
-#define outw xf_outw
-#define outl xf_outl
-
-# elif defined(__nds32__)
-
-/*
- * Assume all port access are aligned. We need to revise this implementation
- * if there is unaligned port access. For ldq_u, ldl_u, ldw_u, stq_u, stl_u and
- * stw_u, they are assumed unaligned.
- */
-
-#define barrier() /* no barrier */
-
-#define PORT_SIZE long
-
-static __inline__ unsigned char
-xf86ReadMmio8(__volatile__ void *base, const unsigned long offset)
-{
- return *(volatile unsigned char *)((unsigned char *)base + offset) ;
-}
-
-static __inline__ void
-xf86WriteMmio8(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned char *)((unsigned char *)base + offset) = val ;
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned char *)((unsigned char *)base + offset) = val ;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16Swap(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned short ret;
-
- __asm__ __volatile__(
- "lhi %0, [%1];\n\t"
- "wsbh %0, %0;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned short
-xf86ReadMmio16(__volatile__ void *base, const unsigned long offset)
-{
- return *(volatile unsigned short *)((char *)base + offset) ;
-}
-
-static __inline__ void
-xf86WriteMmio16Swap(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "shi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio16(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned short *)((unsigned char *)base + offset) = val ;
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio16SwapNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "shi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void
-xf86WriteMmio16NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned short *)((unsigned char *)base + offset) = val ;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32Swap(__volatile__ void *base, const unsigned long offset)
-{
- unsigned long addr = ((unsigned long)base) + offset;
- unsigned int ret;
-
- __asm__ __volatile__(
- "lwi %0, [%1];\n\t"
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned int
-xf86ReadMmio32(__volatile__ void *base, const unsigned long offset)
-{
- return *(volatile unsigned int *)((unsigned char *)base + offset) ;
-}
-
-static __inline__ void
-xf86WriteMmio32Swap(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "swi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio32(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned int *)((unsigned char *)base + offset) = val ;
- barrier();
-}
-
-static __inline__ void
-xf86WriteMmio32SwapNB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- unsigned long addr = ((unsigned long)base) + offset;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "swi %0, [%1];\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void
-xf86WriteMmio32NB(__volatile__ void *base, const unsigned long offset,
- const unsigned int val)
-{
- *(volatile unsigned int *)((unsigned char *)base + offset) = val ;
-}
-
-# if defined(NDS32_MMIO_SWAP)
-static __inline__ void
-outb(unsigned PORT_SIZE port, unsigned char val)
-{
- xf86WriteMmio8(IOPortBase, port, val);
-}
-
-static __inline__ void
-outw(unsigned PORT_SIZE port, unsigned short val)
-{
- xf86WriteMmio16Swap(IOPortBase, port, val);
-}
-
-static __inline__ void
-outl(unsigned PORT_SIZE port, unsigned int val)
-{
- xf86WriteMmio32Swap(IOPortBase, port, val);
-}
-
-static __inline__ unsigned int
-inb(unsigned PORT_SIZE port)
-{
- return xf86ReadMmio8(IOPortBase, port);
-}
-
-static __inline__ unsigned int
-inw(unsigned PORT_SIZE port)
-{
- return xf86ReadMmio16Swap(IOPortBase, port);
-}
-
-static __inline__ unsigned int
-inl(unsigned PORT_SIZE port)
-{
- return xf86ReadMmio32Swap(IOPortBase, port);
-}
-
-static __inline__ unsigned long ldq_u(unsigned long *p)
-{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
-
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned long ldl_u(unsigned int *p)
-{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
-
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ void stq_u(unsigned long val, unsigned long *p)
-{
- unsigned long addr = (unsigned long)p;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void stl_u(unsigned long val, unsigned int *p)
-{
- unsigned long addr = (unsigned long)p;
-
- __asm__ __volatile__(
- "wsbh %0, %0;\n\t"
- "rotri %0, %0, 16;\n\t"
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-# else /* !NDS32_MMIO_SWAP */
-static __inline__ void
-outb(unsigned PORT_SIZE port, unsigned char val)
-{
- *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))) = val;
- barrier();
-}
-
-static __inline__ void
-outw(unsigned PORT_SIZE port, unsigned short val)
-{
- *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))) = val;
- barrier();
-}
-
-static __inline__ void
-outl(unsigned PORT_SIZE port, unsigned int val)
-{
- *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))) = val;
- barrier();
-}
-static __inline__ unsigned int
-inb(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port)));
-}
-
-static __inline__ unsigned int
-inw(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port)));
-}
-
-static __inline__ unsigned int
-inl(unsigned PORT_SIZE port)
-{
- return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port)));
-}
-
-static __inline__ unsigned long ldq_u(unsigned long *p)
-{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
-
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-static __inline__ unsigned long ldl_u(unsigned int *p)
-{
- unsigned long addr = (unsigned long)p;
- unsigned int ret;
-
- __asm__ __volatile__(
- "lmw.bi %0, [%1], %0, 0;\n\t"
- : "=r" (ret)
- : "r" (addr));
- return ret;
-}
-
-
-static __inline__ void stq_u(unsigned long val, unsigned long *p)
-{
- unsigned long addr = (unsigned long)p;
-
- __asm__ __volatile__(
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-
-static __inline__ void stl_u(unsigned long val, unsigned int *p)
-{
- unsigned long addr = (unsigned long)p;
-
- __asm__ __volatile__(
- "smw.bi %0, [%1], %0, 0;\n\t"
- : /* No outputs */
- : "r" (val), "r" (addr));
-}
-# endif /* NDS32_MMIO_SWAP */
-
-# if (((X_BYTE_ORDER == X_BIG_ENDIAN) && !defined(NDS32_MMIO_SWAP)) || ((X_BYTE_ORDER != X_BIG_ENDIAN) && defined(NDS32_MMIO_SWAP)))
-# define ldw_u(p) ((*(unsigned char *)(p)) << 8 | \
- (*((unsigned char *)(p)+1)))
-# define stw_u(v,p) (*(unsigned char *)(p)) = ((v) >> 8); \
- (*((unsigned char *)(p)+1)) = (v)
-# else
-# define ldw_u(p) ((*(unsigned char *)(p)) | \
- (*((unsigned char *)(p)+1)<<8))
-# define stw_u(v,p) (*(unsigned char *)(p)) = (v); \
- (*((unsigned char *)(p)+1)) = ((v) >> 8)
-# endif
-
-# define mem_barrier() /* XXX: nop for now */
-# define write_mem_barrier() /* XXX: nop for now */
-
-# else /* ix86 */
-
-# if !defined(__SUNPRO_C)
-# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__)
-# ifdef GCCUSESGAS
-
-/*
- * If gcc uses gas rather than the native assembler, the syntax of these
- * inlines has to be different. DHD
- */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
- __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
-}
-
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
- __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
- __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- unsigned char ret;
- __asm__ __volatile__("inb %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- unsigned short ret;
- __asm__ __volatile__("inw %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- unsigned int ret;
- __asm__ __volatile__("inl %1,%0" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-# else /* GCCUSESGAS */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
- __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
- __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
- __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- unsigned char ret;
- __asm__ __volatile__("in%B0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- unsigned short ret;
- __asm__ __volatile__("in%W0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- unsigned int ret;
- __asm__ __volatile__("in%L0 (%1)" :
- "=a" (ret) :
- "d" (port));
- return ret;
-}
-
-# endif /* GCCUSESGAS */
-
-# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */
-
-static __inline__ void
-outb(unsigned short port, unsigned char val)
-{
-}
-
-static __inline__ void
-outw(unsigned short port, unsigned short val)
-{
-}
-
-static __inline__ void
-outl(unsigned short port, unsigned int val)
-{
-}
-
-static __inline__ unsigned int
-inb(unsigned short port)
-{
- return 0;
-}
-
-static __inline__ unsigned int
-inw(unsigned short port)
-{
- return 0;
-}
-
-static __inline__ unsigned int
-inl(unsigned short port)
-{
- return 0;
-}
-
-# endif /* FAKEIT */
-# endif /* __SUNPRO_C */
-
-# endif /* ix86 */
-
-# else /* !GNUC */
-# if defined(__STDC__) && (__STDC__ == 1)
-# ifndef asm
-# define asm __asm
-# endif
-# endif
-# ifndef SCO325
-# if defined(__UNIXWARE__)
-# /* avoid including <sys/types.h> for <sys/inline.h> on UnixWare */
-# define ushort unsigned short
-# define ushort_t unsigned short
-# define ulong unsigned long
-# define ulong_t unsigned long
-# define uint_t unsigned int
-# define uchar_t unsigned char
-# endif /* __UNIXWARE__ */
-# if !defined(__SUNPRO_C) && !defined(_MSC_VER)
-# include <sys/inline.h>
-# endif
-# else
-# include "scoasm.h"
-# endif
-# if (!defined(__HIGHC__) && !defined(__SUNPRO_C) && !defined(_MSC_VER)) || \
- defined(__USLC__)
-# pragma asm partial_optimization outl
-# pragma asm partial_optimization outw
-# pragma asm partial_optimization outb
-# pragma asm partial_optimization inl
-# pragma asm partial_optimization inw
-# pragma asm partial_optimization inb
-# endif
-# endif /* __GNUC__ */
-
-# endif /* NO_INLINE */
-
-# ifdef __alpha__
-/* entry points for Mmio memory access routines */
-extern _X_EXPORT int (*xf86ReadMmio8)(void *, unsigned long);
-extern _X_EXPORT int (*xf86ReadMmio16)(void *, unsigned long);
-# ifndef STANDALONE_MMIO
-extern _X_EXPORT int (*xf86ReadMmio32)(void *, unsigned long);
-# else
-/* Some DRI 3D drivers need MMIO_IN32. */
-static __inline__ int
-xf86ReadMmio32(void *Base, unsigned long Offset)
-{
- mem_barrier();
- return *(volatile unsigned int*)((unsigned long)Base+(Offset));
-}
-# endif
-extern _X_EXPORT void (*xf86WriteMmio8)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmio16)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmio32)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB8)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB16)(int, void *, unsigned long);
-extern _X_EXPORT void (*xf86WriteMmioNB32)(int, void *, unsigned long);
-extern _X_EXPORT void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int);
-extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int);
-
-/* Some macros to hide the system dependencies for MMIO accesses */
-/* Changed to kill noise generated by gcc's -Wcast-align */
-# define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
-# define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
-# ifndef STANDALONE_MMIO
-# define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset)
-# else
-# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
-# endif
-
-# define MMIO_OUT32(base, offset, val) \
- do { \
- write_mem_barrier(); \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \
- } while (0)
-# define MMIO_ONB32(base, offset, val) \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-
-# define MMIO_OUT8(base, offset, val) \
- (*xf86WriteMmio8)((CARD8)(val), base, offset)
-# define MMIO_OUT16(base, offset, val) \
- (*xf86WriteMmio16)((CARD16)(val), base, offset)
-# define MMIO_ONB8(base, offset, val) \
- (*xf86WriteMmioNB8)((CARD8)(val), base, offset)
-# define MMIO_ONB16(base, offset, val) \
- (*xf86WriteMmioNB16)((CARD16)(val), base, offset)
-# define MMIO_MOVE32(base, offset, val) \
- MMIO_OUT32(base, offset, val)
-
-# elif defined(__powerpc__)
- /*
- * we provide byteswapping and no byteswapping functions here
- * with byteswapping as default,
- * drivers that don't need byteswapping should define PPC_MMIO_IS_BE
- */
-# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
-# define MMIO_OUT8(base, offset, val) \
- xf86WriteMmio8(base, offset, (CARD8)(val))
-# define MMIO_ONB8(base, offset, val) \
- xf86WriteMmioNB8(base, offset, (CARD8)(val))
-
-# if defined(PPC_MMIO_IS_BE) /* No byteswapping */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Be(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16Be(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32Be(base, offset, (CARD32)(val))
-# else /* byteswapping is the default */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Le(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Le(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16Le(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32Le(base, offset, (CARD32)(val))
-# endif
-
-# define MMIO_MOVE32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-
-# elif defined(__sparc__) || defined(sparc) || defined(__sparc)
- /*
- * Like powerpc, we provide byteswapping and no byteswapping functions
- * here with byteswapping as default, drivers that don't need byteswapping
- * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we
- * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places
- * of drivers?).
- */
-# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
-# define MMIO_OUT8(base, offset, val) \
- xf86WriteMmio8(base, offset, (CARD8)(val))
-# define MMIO_ONB8(base, offset, val) \
- xf86WriteMmio8NB(base, offset, (CARD8)(val))
-
-# if defined(SPARC_MMIO_IS_BE) /* No byteswapping */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Be(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmio16BeNB(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmio32BeNB(base, offset, (CARD32)(val))
-# else /* byteswapping is the default */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Le(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Le(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmio16LeNB(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmio32LeNB(base, offset, (CARD32)(val))
-# endif
-
-# define MMIO_MOVE32(base, offset, val) \
- xf86WriteMmio32Be(base, offset, (CARD32)(val))
-
-# elif defined(__nds32__)
- /*
- * we provide byteswapping and no byteswapping functions here
- * with no byteswapping as default; when endianness of CPU core
- * and I/O devices don't match, byte swapping is necessary
- * drivers that need byteswapping should define NDS32_MMIO_SWAP
- */
-# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset)
-# define MMIO_OUT8(base, offset, val) \
- xf86WriteMmio8(base, offset, (CARD8)(val))
-# define MMIO_ONB8(base, offset, val) \
- xf86WriteMmioNB8(base, offset, (CARD8)(val))
-
-# if defined(NDS32_MMIO_SWAP) /* byteswapping */
-# define MMIO_IN16(base, offset) xf86ReadMmio16Swap(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32Swap(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16Swap(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32Swap(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16Swap(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32Swap(base, offset, (CARD32)(val))
-# else /* no byteswapping is the default */
-# define MMIO_IN16(base, offset) xf86ReadMmio16(base, offset)
-# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset)
-# define MMIO_OUT16(base, offset, val) \
- xf86WriteMmio16(base, offset, (CARD16)(val))
-# define MMIO_OUT32(base, offset, val) \
- xf86WriteMmio32(base, offset, (CARD32)(val))
-# define MMIO_ONB16(base, offset, val) \
- xf86WriteMmioNB16(base, offset, (CARD16)(val))
-# define MMIO_ONB32(base, offset, val) \
- xf86WriteMmioNB32(base, offset, (CARD32)(val))
-# endif
-
-# define MMIO_MOVE32(base, offset, val) \
- xf86WriteMmio32(base, offset, (CARD32)(val))
-
-#ifdef N1213_HC /* for NDS32 N1213 hardcore */
-static __inline__ void nds32_flush_icache(char *addr)
-{
- __asm__ volatile (
- "isync %0;"
- "msync;"
- "isb;"
- "cctl %0,L1I_VA_INVAL;"
- "isb;"
- : : "r"(addr) : "memory");
-}
-#else
-static __inline__ void nds32_flush_icache(char *addr)
-{
- __asm__ volatile (
- "isync %0;"
- "isb;"
- : : "r"(addr) : "memory");
-}
-#endif
-
-# else /* !__alpha__ && !__powerpc__ && !__sparc__ */
-
-# define MMIO_IN8(base, offset) \
- *(volatile CARD8 *)(((CARD8*)(base)) + (offset))
-# define MMIO_IN16(base, offset) \
- *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset))
-# define MMIO_IN32(base, offset) \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset))
-# define MMIO_OUT8(base, offset, val) \
- *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_OUT16(base, offset, val) \
- *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_OUT32(base, offset, val) \
- *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val)
-# define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val)
-# define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val)
-# define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val)
-
-# define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val)
-
-# endif /* __alpha__ */
-
-/*
- * With Intel, the version in os-support/misc/SlowBcopy.s is used.
- * This avoids port I/O during the copy (which causes problems with
- * some hardware).
- */
-# ifdef __alpha__
-# define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count)
-# define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count)
-# else /* __alpha__ */
-# define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count)
-# define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count)
-# endif /* __alpha__ */
-
-#endif /* _COMPILER_H */
+/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * 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 Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL 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 (c) 1994-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifndef _COMPILER_H + +# define _COMPILER_H + +#if defined(__SUNPRO_C) +# define DO_PROTOTYPES +#endif + +/* Map Sun compiler platform defines to gcc-style used in the code */ +#if defined(__amd64) && !defined(__amd64__) +# define __amd64__ +#endif +#if defined(__i386) && !defined(__i386__) +# define __i386__ +#endif +#if defined(__sparc) && !defined(__sparc__) +# define __sparc__ +#endif +#if defined(__sparcv9) && !defined(__sparc64__) +# define __sparc64__ +#endif + +#ifndef _X_EXPORT +# include <X11/Xfuncproto.h> +#endif + +# include <pixman.h> /* for uint*_t types */ + +/* Allow drivers to use the GCC-supported __inline__ and/or __inline. */ +# ifndef __inline__ +# if defined(__GNUC__) + /* gcc has __inline__ */ +# elif defined(__HIGHC__) +# define __inline__ _Inline +# else +# define __inline__ /**/ +# endif +# endif /* __inline__ */ +# ifndef __inline +# if defined(__GNUC__) || defined(_MSC_VER) + /* gcc has __inline */ +# elif defined(__HIGHC__) +# define __inline _Inline +# else +# define __inline /**/ +# endif +# endif /* __inline */ + +/* Support gcc's __FUNCTION__ for people using other compilers */ +#if !defined(__GNUC__) && !defined(__FUNCTION__) +# define __FUNCTION__ __func__ /* C99 */ +#endif + +# if defined(NO_INLINE) || defined(DO_PROTOTYPES) + +# if !defined(__arm__) +# if !defined(__sparc__) && !defined(__sparc) && !defined(__arm32__) && !defined(__nds32__) \ + && !(defined(__alpha__) && defined(linux)) \ + && !(defined(__ia64__) && defined(linux)) \ + +extern _X_EXPORT void outb(unsigned short, unsigned char); +extern _X_EXPORT void outw(unsigned short, unsigned short); +extern _X_EXPORT void outl(unsigned short, unsigned int); +extern _X_EXPORT unsigned int inb(unsigned short); +extern _X_EXPORT unsigned int inw(unsigned short); +extern _X_EXPORT unsigned int inl(unsigned short); + +# else /* __sparc__, __arm32__, __alpha__, __nds32__ */ + +extern _X_EXPORT void outb(unsigned long, unsigned char); +extern _X_EXPORT void outw(unsigned long, unsigned short); +extern _X_EXPORT void outl(unsigned long, unsigned int); +extern _X_EXPORT unsigned int inb(unsigned long); +extern _X_EXPORT unsigned int inw(unsigned long); +extern _X_EXPORT unsigned int inl(unsigned long); + +# endif /* __sparc__, __arm32__, __alpha__, __nds32__ */ +# endif /* __arm__ */ + +# if defined(__powerpc__) && !defined(__OpenBSD__) +extern unsigned long ldq_u(unsigned long *); +extern unsigned long ldl_u(unsigned int *); +extern unsigned long ldw_u(unsigned short *); +extern void stq_u(unsigned long, unsigned long *); +extern void stl_u(unsigned long, unsigned int *); +extern void stw_u(unsigned long, unsigned short *); +extern void mem_barrier(void); +extern void write_mem_barrier(void); +extern void stl_brx(unsigned long, volatile unsigned char *, int); +extern void stw_brx(unsigned short, volatile unsigned char *, int); +extern unsigned long ldl_brx(volatile unsigned char *, int); +extern unsigned short ldw_brx(volatile unsigned char *, int); +# endif /* __powerpc__ && !__OpenBSD */ + +# endif /* NO_INLINE || DO_PROTOTYPES */ + +# ifndef NO_INLINE +# ifdef __GNUC__ +# ifdef __i386__ + +# ifdef __SSE__ +# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory") +# else +# define write_mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory") +# endif + +# ifdef __SSE2__ +# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory") +# else +# define mem_barrier() __asm__ __volatile__ ("lock; addl $0,0(%%esp)" : : : "memory") +# endif + +# elif defined __alpha__ + +# define mem_barrier() __asm__ __volatile__ ("mb" : : : "memory") +# define write_mem_barrier() __asm__ __volatile__ ("wmb" : : : "memory") + +# elif defined __amd64__ + +# define mem_barrier() __asm__ __volatile__ ("mfence" : : : "memory") +# define write_mem_barrier() __asm__ __volatile__ ("sfence" : : : "memory") + +# elif defined __ia64__ + +# ifndef __INTEL_COMPILER +# define mem_barrier() __asm__ __volatile__ ("mf" : : : "memory") +# define write_mem_barrier() __asm__ __volatile__ ("mf" : : : "memory") +# else +# include "ia64intrin.h" +# define mem_barrier() __mf() +# define write_mem_barrier() __mf() +# endif + +# elif defined __mips__ + /* Note: sync instruction requires MIPS II instruction set */ +# define mem_barrier() \ + __asm__ __volatile__( \ + ".set push\n\t" \ + ".set noreorder\n\t" \ + ".set mips2\n\t" \ + "sync\n\t" \ + ".set pop" \ + : /* no output */ \ + : /* no input */ \ + : "memory") +# define write_mem_barrier() mem_barrier() + +# elif defined __powerpc__ + +# if defined(linux) && defined(__powerpc64__) +# include <linux/version.h> +# if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0) +# include <asm/memory.h> +# endif +# endif /* defined(linux) && defined(__powerpc64__) */ + +# ifndef eieio /* We deal with arch-specific eieio() routines above... */ +# define eieio() __asm__ __volatile__ ("eieio" ::: "memory") +# endif /* eieio */ +# define mem_barrier() eieio() +# define write_mem_barrier() eieio() + +# elif defined __sparc__ + +# define barrier() __asm__ __volatile__ (".word 0x8143e00a" : : : "memory") +# define mem_barrier() /* XXX: nop for now */ +# define write_mem_barrier() /* XXX: nop for now */ +# endif +# endif /* __GNUC__ */ +# endif /* NO_INLINE */ + +# ifndef mem_barrier +# define mem_barrier() /* NOP */ +# endif + +# ifndef write_mem_barrier +# define write_mem_barrier() /* NOP */ +# endif + + +# ifndef NO_INLINE +# ifdef __GNUC__ + +/* Define some packed structures to use with unaligned accesses */ + +struct __una_u64 { uint64_t x __attribute__((packed)); }; +struct __una_u32 { uint32_t x __attribute__((packed)); }; +struct __una_u16 { uint16_t x __attribute__((packed)); }; + +/* Elemental unaligned loads */ + +static __inline__ uint64_t ldq_u(uint64_t *p) +{ + const struct __una_u64 *ptr = (const struct __una_u64 *) p; + return ptr->x; +} + +static __inline__ uint32_t ldl_u(uint32_t *p) +{ + const struct __una_u32 *ptr = (const struct __una_u32 *) p; + return ptr->x; +} + +static __inline__ uint16_t ldw_u(uint16_t *p) +{ + const struct __una_u16 *ptr = (const struct __una_u16 *) p; + return ptr->x; +} + +/* Elemental unaligned stores */ + +static __inline__ void stq_u(uint64_t val, uint64_t *p) +{ + struct __una_u64 *ptr = (struct __una_u64 *) p; + ptr->x = val; +} + +static __inline__ void stl_u(uint32_t val, uint32_t *p) +{ + struct __una_u32 *ptr = (struct __una_u32 *) p; + ptr->x = val; +} + +static __inline__ void stw_u(uint16_t val, uint16_t *p) +{ + struct __una_u16 *ptr = (struct __una_u16 *) p; + ptr->x = val; +} +# else /* !__GNUC__ */ + +#include <string.h> /* needed for memmove */ + +static __inline__ uint64_t ldq_u(uint64_t *p) +{ + uint64_t ret; + memmove(&ret, p, sizeof(*p)); + return ret; +} + +static __inline__ uint32_t ldl_u(uint32_t *p) +{ + uint32_t ret; + memmove(&ret, p, sizeof(*p)); + return ret; +} + +static __inline__ uint16_t ldw_u(uint16_t *p) +{ + uint16_t ret; + memmove(&ret, p, sizeof(*p)); + return ret; +} + +static __inline__ void stq_u(uint64_t val, uint64_t *p) +{ + uint64_t tmp = val; + memmove(p, &tmp, sizeof(*p)); +} + +static __inline__ void stl_u(uint32_t val, uint32_t *p) +{ + uint32_t tmp = val; + memmove(p, &tmp, sizeof(*p)); +} + +static __inline__ void stw_u(uint16_t val, uint16_t *p) +{ + uint16_t tmp = val; + memmove(p, &tmp, sizeof(*p)); +} + +# endif /* __GNUC__ */ +# endif /* NO_INLINE */ + +# ifndef NO_INLINE +# ifdef __GNUC__ +# if (defined(linux) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && (defined(__alpha__)) + +# ifdef linux +/* for Linux on Alpha, we use the LIBC _inx/_outx routines */ +/* note that the appropriate setup via "ioperm" needs to be done */ +/* *before* any inx/outx is done. */ + +extern _X_EXPORT void _outb(unsigned char val, unsigned long port); +extern _X_EXPORT void _outw(unsigned short val, unsigned long port); +extern _X_EXPORT void _outl(unsigned int val, unsigned long port); +extern _X_EXPORT unsigned int _inb(unsigned long port); +extern _X_EXPORT unsigned int _inw(unsigned long port); +extern _X_EXPORT unsigned int _inl(unsigned long port); + +static __inline__ void +outb(unsigned long port, unsigned char val) +{ + _outb(val, port); +} + +static __inline__ void +outw(unsigned long port, unsigned short val) +{ + _outw(val, port); +} + +static __inline__ void +outl(unsigned long port, unsigned int val) +{ + _outl(val, port); +} + +static __inline__ unsigned int +inb(unsigned long port) +{ + return _inb(port); +} + +static __inline__ unsigned int +inw(unsigned long port) +{ + return _inw(port); +} + +static __inline__ unsigned int +inl(unsigned long port) +{ + return _inl(port); +} + +# endif /* linux */ + +# if (defined(__FreeBSD__) || defined(__OpenBSD__)) \ + && !defined(DO_PROTOTYPES) + +/* for FreeBSD and OpenBSD on Alpha, we use the libio (resp. libalpha) */ +/* inx/outx routines */ +/* note that the appropriate setup via "ioperm" needs to be done */ +/* *before* any inx/outx is done. */ + +extern _X_EXPORT void outb(unsigned int port, unsigned char val); +extern _X_EXPORT void outw(unsigned int port, unsigned short val); +extern _X_EXPORT void outl(unsigned int port, unsigned int val); +extern _X_EXPORT unsigned char inb(unsigned int port); +extern _X_EXPORT unsigned short inw(unsigned int port); +extern _X_EXPORT unsigned int inl(unsigned int port); + +# endif /* (__FreeBSD__ || __OpenBSD__ ) && !DO_PROTOTYPES */ + + +#if defined(__NetBSD__) +#include <machine/pio.h> +#endif /* __NetBSD__ */ + +# elif defined(linux) && defined(__ia64__) + +# include <inttypes.h> + +# include <sys/io.h> + +# undef outb +# undef outw +# undef outl +# undef inb +# undef inw +# undef inl +extern _X_EXPORT void outb(unsigned long port, unsigned char val); +extern _X_EXPORT void outw(unsigned long port, unsigned short val); +extern _X_EXPORT void outl(unsigned long port, unsigned int val); +extern _X_EXPORT unsigned int inb(unsigned long port); +extern _X_EXPORT unsigned int inw(unsigned long port); +extern _X_EXPORT unsigned int inl(unsigned long port); + +# elif (defined(linux) || defined(__FreeBSD__)) && defined(__amd64__) + +# include <inttypes.h> + +static __inline__ void +outb(unsigned short port, unsigned char val) +{ + __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); +} + + +static __inline__ void +outw(unsigned short port, unsigned short val) +{ + __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); +} + +static __inline__ void +outl(unsigned short port, unsigned int val) +{ + __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); +} + +static __inline__ unsigned int +inb(unsigned short port) +{ + unsigned char ret; + __asm__ __volatile__("inb %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inw(unsigned short port) +{ + unsigned short ret; + __asm__ __volatile__("inw %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inl(unsigned short port) +{ + unsigned int ret; + __asm__ __volatile__("inl %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +# elif (defined(linux) || defined(sun) || defined(__OpenBSD__) || defined(__FreeBSD__)) && defined(__sparc__) + +# ifndef ASI_PL +# define ASI_PL 0x88 +# endif + +static __inline__ void +outb(unsigned long port, unsigned char val) +{ + __asm__ __volatile__("stba %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (port), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void +outw(unsigned long port, unsigned short val) +{ + __asm__ __volatile__("stha %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (port), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void +outl(unsigned long port, unsigned int val) +{ + __asm__ __volatile__("sta %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (port), "i" (ASI_PL)); + barrier(); +} + +static __inline__ unsigned int +inb(unsigned long port) +{ + unsigned int ret; + __asm__ __volatile__("lduba [%1] %2, %0" + : "=r" (ret) + : "r" (port), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned int +inw(unsigned long port) +{ + unsigned int ret; + __asm__ __volatile__("lduha [%1] %2, %0" + : "=r" (ret) + : "r" (port), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned int +inl(unsigned long port) +{ + unsigned int ret; + __asm__ __volatile__("lda [%1] %2, %0" + : "=r" (ret) + : "r" (port), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned char +xf86ReadMmio8(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned char ret; + + __asm__ __volatile__("lduba [%1] %2, %0" + : "=r" (ret) + : "r" (addr), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned short +xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned short ret; + + __asm__ __volatile__("lduh [%1], %0" + : "=r" (ret) + : "r" (addr)); + return ret; +} + +static __inline__ unsigned short +xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned short ret; + + __asm__ __volatile__("lduha [%1] %2, %0" + : "=r" (ret) + : "r" (addr), "i" (ASI_PL)); + return ret; +} + +static __inline__ unsigned int +xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned int ret; + + __asm__ __volatile__("ld [%1], %0" + : "=r" (ret) + : "r" (addr)); + return ret; +} + +static __inline__ unsigned int +xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned int ret; + + __asm__ __volatile__("lda [%1] %2, %0" + : "=r" (ret) + : "r" (addr), "i" (ASI_PL)); + return ret; +} + +static __inline__ void +xf86WriteMmio8(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stba %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void +xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sth %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); + barrier(); +} + +static __inline__ void +xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stha %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void +xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("st %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); + barrier(); +} + +static __inline__ void +xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sta %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); + barrier(); +} + +static __inline__ void +xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stba %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); +} + +static __inline__ void +xf86WriteMmio16BeNB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sth %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); +} + +static __inline__ void +xf86WriteMmio16LeNB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("stha %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); +} + +static __inline__ void +xf86WriteMmio32BeNB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("st %0, [%1]" + : /* No outputs */ + : "r" (val), "r" (addr)); +} + +static __inline__ void +xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sta %0, [%1] %2" + : /* No outputs */ + : "r" (val), "r" (addr), "i" (ASI_PL)); +} + +# elif defined(__mips__) || (defined(__arm32__) && !defined(__linux__)) +# ifdef __arm32__ +# define PORT_SIZE long +# else +# define PORT_SIZE short +# endif + +_X_EXPORT unsigned int IOPortBase; /* Memory mapped I/O port area */ + +static __inline__ void +outb(unsigned PORT_SIZE port, unsigned char val) +{ + *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val; +} + +static __inline__ void +outw(unsigned PORT_SIZE port, unsigned short val) +{ + *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val; +} + +static __inline__ void +outl(unsigned PORT_SIZE port, unsigned int val) +{ + *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val; +} + +static __inline__ unsigned int +inb(unsigned PORT_SIZE port) +{ + return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase); +} + +static __inline__ unsigned int +inw(unsigned PORT_SIZE port) +{ + return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase); +} + +static __inline__ unsigned int +inl(unsigned PORT_SIZE port) +{ + return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase); +} + + +# if defined(__mips__) +# ifdef linux /* don't mess with other OSs */ +# if X_BYTE_ORDER == X_BIG_ENDIAN +static __inline__ unsigned int +xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned int ret; + + __asm__ __volatile__("lw %0, 0(%1)" + : "=r" (ret) + : "r" (addr)); + return ret; +} + +static __inline__ void +xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__("sw %0, 0(%1)" + : /* No outputs */ + : "r" (val), "r" (addr)); +} +# endif +# endif /* !linux */ +# endif /* __mips__ */ + +# elif (defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__)) && defined(__powerpc__) + +# ifndef MAP_FAILED +# define MAP_FAILED ((void *)-1) +# endif + +extern _X_EXPORT volatile unsigned char *ioBase; + +static __inline__ unsigned char +xf86ReadMmio8(__volatile__ void *base, const unsigned long offset) +{ + register unsigned char val; + __asm__ __volatile__( + "lbzx %0,%1,%2\n\t" + "eieio" + : "=r" (val) + : "b" (base), "r" (offset), + "m" (*((volatile unsigned char *)base+offset))); + return val; +} + +static __inline__ unsigned short +xf86ReadMmio16Be(__volatile__ void *base, const unsigned long offset) +{ + register unsigned short val; + __asm__ __volatile__( + "lhzx %0,%1,%2\n\t" + "eieio" + : "=r" (val) + : "b" (base), "r" (offset), + "m" (*((volatile unsigned char *)base+offset))); + return val; +} + +static __inline__ unsigned short +xf86ReadMmio16Le(__volatile__ void *base, const unsigned long offset) +{ + register unsigned short val; + __asm__ __volatile__( + "lhbrx %0,%1,%2\n\t" + "eieio" + : "=r" (val) + : "b" (base), "r" (offset), + "m" (*((volatile unsigned char *)base+offset))); + return val; +} + +static __inline__ unsigned int +xf86ReadMmio32Be(__volatile__ void *base, const unsigned long offset) +{ + register unsigned int val; + __asm__ __volatile__( + "lwzx %0,%1,%2\n\t" + "eieio" + : "=r" (val) + : "b" (base), "r" (offset), + "m" (*((volatile unsigned char *)base+offset))); + return val; +} + +static __inline__ unsigned int +xf86ReadMmio32Le(__volatile__ void *base, const unsigned long offset) +{ + register unsigned int val; + __asm__ __volatile__( + "lwbrx %0,%1,%2\n\t" + "eieio" + : "=r" (val) + : "b" (base), "r" (offset), + "m" (*((volatile unsigned char *)base+offset))); + return val; +} + +static __inline__ void +xf86WriteMmioNB8(__volatile__ void *base, const unsigned long offset, + const unsigned char val) +{ + __asm__ __volatile__( + "stbx %1,%2,%3\n\t" + : "=m" (*((volatile unsigned char *)base+offset)) + : "r" (val), "b" (base), "r" (offset)); +} + +static __inline__ void +xf86WriteMmioNB16Le(__volatile__ void *base, const unsigned long offset, + const unsigned short val) +{ + __asm__ __volatile__( + "sthbrx %1,%2,%3\n\t" + : "=m" (*((volatile unsigned char *)base+offset)) + : "r" (val), "b" (base), "r" (offset)); +} + +static __inline__ void +xf86WriteMmioNB16Be(__volatile__ void *base, const unsigned long offset, + const unsigned short val) +{ + __asm__ __volatile__( + "sthx %1,%2,%3\n\t" + : "=m" (*((volatile unsigned char *)base+offset)) + : "r" (val), "b" (base), "r" (offset)); +} + +static __inline__ void +xf86WriteMmioNB32Le(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + __asm__ __volatile__( + "stwbrx %1,%2,%3\n\t" + : "=m" (*((volatile unsigned char *)base+offset)) + : "r" (val), "b" (base), "r" (offset)); +} + +static __inline__ void +xf86WriteMmioNB32Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + __asm__ __volatile__( + "stwx %1,%2,%3\n\t" + : "=m" (*((volatile unsigned char *)base+offset)) + : "r" (val), "b" (base), "r" (offset)); +} + +static __inline__ void +xf86WriteMmio8(__volatile__ void *base, const unsigned long offset, + const unsigned char val) +{ + xf86WriteMmioNB8(base, offset, val); + eieio(); +} + +static __inline__ void +xf86WriteMmio16Le(__volatile__ void *base, const unsigned long offset, + const unsigned short val) +{ + xf86WriteMmioNB16Le(base, offset, val); + eieio(); +} + +static __inline__ void +xf86WriteMmio16Be(__volatile__ void *base, const unsigned long offset, + const unsigned short val) +{ + xf86WriteMmioNB16Be(base, offset, val); + eieio(); +} + +static __inline__ void +xf86WriteMmio32Le(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + xf86WriteMmioNB32Le(base, offset, val); + eieio(); +} + +static __inline__ void +xf86WriteMmio32Be(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + xf86WriteMmioNB32Be(base, offset, val); + eieio(); +} + + +static __inline__ void +outb(unsigned short port, unsigned char value) +{ + if(ioBase == MAP_FAILED) return; + xf86WriteMmio8((void *)ioBase, port, value); +} + +static __inline__ void +outw(unsigned short port, unsigned short value) +{ + if(ioBase == MAP_FAILED) return; + xf86WriteMmio16Le((void *)ioBase, port, value); +} + +static __inline__ void +outl(unsigned short port, unsigned int value) +{ + if(ioBase == MAP_FAILED) return; + xf86WriteMmio32Le((void *)ioBase, port, value); +} + +static __inline__ unsigned int +inb(unsigned short port) +{ + if(ioBase == MAP_FAILED) return 0; + return xf86ReadMmio8((void *)ioBase, port); +} + +static __inline__ unsigned int +inw(unsigned short port) +{ + if(ioBase == MAP_FAILED) return 0; + return xf86ReadMmio16Le((void *)ioBase, port); +} + +static __inline__ unsigned int +inl(unsigned short port) +{ + if(ioBase == MAP_FAILED) return 0; + return xf86ReadMmio32Le((void *)ioBase, port); +} + +#elif defined(__arm__) && defined(__linux__) + +/* for Linux on ARM, we use the LIBC inx/outx routines */ +/* note that the appropriate setup via "ioperm" needs to be done */ +/* *before* any inx/outx is done. */ + +#include <sys/io.h> + +static __inline__ void +xf_outb(unsigned short port, unsigned char val) +{ + outb(val, port); +} + +static __inline__ void +xf_outw(unsigned short port, unsigned short val) +{ + outw(val, port); +} + +static __inline__ void +xf_outl(unsigned short port, unsigned int val) +{ + outl(val, port); +} + +#define outb xf_outb +#define outw xf_outw +#define outl xf_outl + +# elif defined(__nds32__) + +/* + * Assume all port access are aligned. We need to revise this implementation + * if there is unaligned port access. For ldq_u, ldl_u, ldw_u, stq_u, stl_u and + * stw_u, they are assumed unaligned. + */ + +#define barrier() /* no barrier */ + +#define PORT_SIZE long + +static __inline__ unsigned char +xf86ReadMmio8(__volatile__ void *base, const unsigned long offset) +{ + return *(volatile unsigned char *)((unsigned char *)base + offset) ; +} + +static __inline__ void +xf86WriteMmio8(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + *(volatile unsigned char *)((unsigned char *)base + offset) = val ; + barrier(); +} + +static __inline__ void +xf86WriteMmio8NB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + *(volatile unsigned char *)((unsigned char *)base + offset) = val ; +} + +static __inline__ unsigned short +xf86ReadMmio16Swap(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned short ret; + + __asm__ __volatile__( + "lhi %0, [%1];\n\t" + "wsbh %0, %0;\n\t" + : "=r" (ret) + : "r" (addr)); + return ret; +} + +static __inline__ unsigned short +xf86ReadMmio16(__volatile__ void *base, const unsigned long offset) +{ + return *(volatile unsigned short *)((char *)base + offset) ; +} + +static __inline__ void +xf86WriteMmio16Swap(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__( + "wsbh %0, %0;\n\t" + "shi %0, [%1];\n\t" + : /* No outputs */ + : "r" (val), "r" (addr)); + barrier(); +} + +static __inline__ void +xf86WriteMmio16(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + *(volatile unsigned short *)((unsigned char *)base + offset) = val ; + barrier(); +} + +static __inline__ void +xf86WriteMmio16SwapNB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__( + "wsbh %0, %0;\n\t" + "shi %0, [%1];\n\t" + : /* No outputs */ + : "r" (val), "r" (addr)); +} + +static __inline__ void +xf86WriteMmio16NB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + *(volatile unsigned short *)((unsigned char *)base + offset) = val ; +} + +static __inline__ unsigned int +xf86ReadMmio32Swap(__volatile__ void *base, const unsigned long offset) +{ + unsigned long addr = ((unsigned long)base) + offset; + unsigned int ret; + + __asm__ __volatile__( + "lwi %0, [%1];\n\t" + "wsbh %0, %0;\n\t" + "rotri %0, %0, 16;\n\t" + : "=r" (ret) + : "r" (addr)); + return ret; +} + +static __inline__ unsigned int +xf86ReadMmio32(__volatile__ void *base, const unsigned long offset) +{ + return *(volatile unsigned int *)((unsigned char *)base + offset) ; +} + +static __inline__ void +xf86WriteMmio32Swap(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__( + "wsbh %0, %0;\n\t" + "rotri %0, %0, 16;\n\t" + "swi %0, [%1];\n\t" + : /* No outputs */ + : "r" (val), "r" (addr)); + barrier(); +} + +static __inline__ void +xf86WriteMmio32(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + *(volatile unsigned int *)((unsigned char *)base + offset) = val ; + barrier(); +} + +static __inline__ void +xf86WriteMmio32SwapNB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + unsigned long addr = ((unsigned long)base) + offset; + + __asm__ __volatile__( + "wsbh %0, %0;\n\t" + "rotri %0, %0, 16;\n\t" + "swi %0, [%1];\n\t" + : /* No outputs */ + : "r" (val), "r" (addr)); +} + +static __inline__ void +xf86WriteMmio32NB(__volatile__ void *base, const unsigned long offset, + const unsigned int val) +{ + *(volatile unsigned int *)((unsigned char *)base + offset) = val ; +} + +# if defined(NDS32_MMIO_SWAP) +static __inline__ void +outb(unsigned PORT_SIZE port, unsigned char val) +{ + xf86WriteMmio8(IOPortBase, port, val); +} + +static __inline__ void +outw(unsigned PORT_SIZE port, unsigned short val) +{ + xf86WriteMmio16Swap(IOPortBase, port, val); +} + +static __inline__ void +outl(unsigned PORT_SIZE port, unsigned int val) +{ + xf86WriteMmio32Swap(IOPortBase, port, val); +} + +static __inline__ unsigned int +inb(unsigned PORT_SIZE port) +{ + return xf86ReadMmio8(IOPortBase, port); +} + +static __inline__ unsigned int +inw(unsigned PORT_SIZE port) +{ + return xf86ReadMmio16Swap(IOPortBase, port); +} + +static __inline__ unsigned int +inl(unsigned PORT_SIZE port) +{ + return xf86ReadMmio32Swap(IOPortBase, port); +} + +static __inline__ unsigned long ldq_u(unsigned long *p) +{ + unsigned long addr = (unsigned long)p; + unsigned int ret; + + __asm__ __volatile__( + "lmw.bi %0, [%1], %0, 0;\n\t" + "wsbh %0, %0;\n\t" + "rotri %0, %0, 16;\n\t" + : "=r" (ret) + : "r" (addr)); + return ret; +} + +static __inline__ unsigned long ldl_u(unsigned int *p) +{ + unsigned long addr = (unsigned long)p; + unsigned int ret; + + __asm__ __volatile__( + "lmw.bi %0, [%1], %0, 0;\n\t" + "wsbh %0, %0;\n\t" + "rotri %0, %0, 16;\n\t" + : "=r" (ret) + : "r" (addr)); + return ret; +} + +static __inline__ void stq_u(unsigned long val, unsigned long *p) +{ + unsigned long addr = (unsigned long)p; + + __asm__ __volatile__( + "wsbh %0, %0;\n\t" + "rotri %0, %0, 16;\n\t" + "smw.bi %0, [%1], %0, 0;\n\t" + : /* No outputs */ + : "r" (val), "r" (addr)); +} + +static __inline__ void stl_u(unsigned long val, unsigned int *p) +{ + unsigned long addr = (unsigned long)p; + + __asm__ __volatile__( + "wsbh %0, %0;\n\t" + "rotri %0, %0, 16;\n\t" + "smw.bi %0, [%1], %0, 0;\n\t" + : /* No outputs */ + : "r" (val), "r" (addr)); +} + +# else /* !NDS32_MMIO_SWAP */ +static __inline__ void +outb(unsigned PORT_SIZE port, unsigned char val) +{ + *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))) = val; + barrier(); +} + +static __inline__ void +outw(unsigned PORT_SIZE port, unsigned short val) +{ + *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))) = val; + barrier(); +} + +static __inline__ void +outl(unsigned PORT_SIZE port, unsigned int val) +{ + *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))) = val; + barrier(); +} +static __inline__ unsigned int +inb(unsigned PORT_SIZE port) +{ + return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))); +} + +static __inline__ unsigned int +inw(unsigned PORT_SIZE port) +{ + return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))); +} + +static __inline__ unsigned int +inl(unsigned PORT_SIZE port) +{ + return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))); +} + +static __inline__ unsigned long ldq_u(unsigned long *p) +{ + unsigned long addr = (unsigned long)p; + unsigned int ret; + + __asm__ __volatile__( + "lmw.bi %0, [%1], %0, 0;\n\t" + : "=r" (ret) + : "r" (addr)); + return ret; +} + +static __inline__ unsigned long ldl_u(unsigned int *p) +{ + unsigned long addr = (unsigned long)p; + unsigned int ret; + + __asm__ __volatile__( + "lmw.bi %0, [%1], %0, 0;\n\t" + : "=r" (ret) + : "r" (addr)); + return ret; +} + + +static __inline__ void stq_u(unsigned long val, unsigned long *p) +{ + unsigned long addr = (unsigned long)p; + + __asm__ __volatile__( + "smw.bi %0, [%1], %0, 0;\n\t" + : /* No outputs */ + : "r" (val), "r" (addr)); +} + +static __inline__ void stl_u(unsigned long val, unsigned int *p) +{ + unsigned long addr = (unsigned long)p; + + __asm__ __volatile__( + "smw.bi %0, [%1], %0, 0;\n\t" + : /* No outputs */ + : "r" (val), "r" (addr)); +} +# endif /* NDS32_MMIO_SWAP */ + +# if (((X_BYTE_ORDER == X_BIG_ENDIAN) && !defined(NDS32_MMIO_SWAP)) || ((X_BYTE_ORDER != X_BIG_ENDIAN) && defined(NDS32_MMIO_SWAP))) +# define ldw_u(p) ((*(unsigned char *)(p)) << 8 | \ + (*((unsigned char *)(p)+1))) +# define stw_u(v,p) (*(unsigned char *)(p)) = ((v) >> 8); \ + (*((unsigned char *)(p)+1)) = (v) +# else +# define ldw_u(p) ((*(unsigned char *)(p)) | \ + (*((unsigned char *)(p)+1)<<8)) +# define stw_u(v,p) (*(unsigned char *)(p)) = (v); \ + (*((unsigned char *)(p)+1)) = ((v) >> 8) +# endif + +# define mem_barrier() /* XXX: nop for now */ +# define write_mem_barrier() /* XXX: nop for now */ + +# else /* ix86 */ + +# if !defined(__SUNPRO_C) +# if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__m32r__) +# ifdef GCCUSESGAS + +/* + * If gcc uses gas rather than the native assembler, the syntax of these + * inlines has to be different. DHD + */ + +static __inline__ void +outb(unsigned short port, unsigned char val) +{ + __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port)); +} + + +static __inline__ void +outw(unsigned short port, unsigned short val) +{ + __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port)); +} + +static __inline__ void +outl(unsigned short port, unsigned int val) +{ + __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port)); +} + +static __inline__ unsigned int +inb(unsigned short port) +{ + unsigned char ret; + __asm__ __volatile__("inb %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inw(unsigned short port) +{ + unsigned short ret; + __asm__ __volatile__("inw %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inl(unsigned short port) +{ + unsigned int ret; + __asm__ __volatile__("inl %1,%0" : + "=a" (ret) : + "d" (port)); + return ret; +} + +# else /* GCCUSESGAS */ + +static __inline__ void +outb(unsigned short port, unsigned char val) +{ + __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port)); +} + +static __inline__ void +outw(unsigned short port, unsigned short val) +{ + __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port)); +} + +static __inline__ void +outl(unsigned short port, unsigned int val) +{ + __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port)); +} + +static __inline__ unsigned int +inb(unsigned short port) +{ + unsigned char ret; + __asm__ __volatile__("in%B0 (%1)" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inw(unsigned short port) +{ + unsigned short ret; + __asm__ __volatile__("in%W0 (%1)" : + "=a" (ret) : + "d" (port)); + return ret; +} + +static __inline__ unsigned int +inl(unsigned short port) +{ + unsigned int ret; + __asm__ __volatile__("in%L0 (%1)" : + "=a" (ret) : + "d" (port)); + return ret; +} + +# endif /* GCCUSESGAS */ + +# else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__arm__) && !defined(__sh__) && !defined(__hppa__) && !defined(__m32r__) */ + +static __inline__ void +outb(unsigned short port, unsigned char val) +{ +} + +static __inline__ void +outw(unsigned short port, unsigned short val) +{ +} + +static __inline__ void +outl(unsigned short port, unsigned int val) +{ +} + +static __inline__ unsigned int +inb(unsigned short port) +{ + return 0; +} + +static __inline__ unsigned int +inw(unsigned short port) +{ + return 0; +} + +static __inline__ unsigned int +inl(unsigned short port) +{ + return 0; +} + +# endif /* FAKEIT */ +# endif /* __SUNPRO_C */ + +# endif /* ix86 */ + +# else /* !GNUC */ +# if defined(__STDC__) && (__STDC__ == 1) +# ifndef asm +# define asm __asm +# endif +# endif +# if !defined(__SUNPRO_C) && !defined(_MSC_VER) +# include <sys/inline.h> +# endif +# if (!defined(__HIGHC__) && !defined(__SUNPRO_C) && !defined(_MSC_VER)) || \ + defined(__USLC__) +# pragma asm partial_optimization outl +# pragma asm partial_optimization outw +# pragma asm partial_optimization outb +# pragma asm partial_optimization inl +# pragma asm partial_optimization inw +# pragma asm partial_optimization inb +# endif +# endif /* __GNUC__ */ + +# endif /* NO_INLINE */ + +# ifdef __alpha__ +/* entry points for Mmio memory access routines */ +extern _X_EXPORT int (*xf86ReadMmio8)(void *, unsigned long); +extern _X_EXPORT int (*xf86ReadMmio16)(void *, unsigned long); +# ifndef STANDALONE_MMIO +extern _X_EXPORT int (*xf86ReadMmio32)(void *, unsigned long); +# else +/* Some DRI 3D drivers need MMIO_IN32. */ +static __inline__ int +xf86ReadMmio32(void *Base, unsigned long Offset) +{ + mem_barrier(); + return *(volatile unsigned int*)((unsigned long)Base+(Offset)); +} +# endif +extern _X_EXPORT void (*xf86WriteMmio8)(int, void *, unsigned long); +extern _X_EXPORT void (*xf86WriteMmio16)(int, void *, unsigned long); +extern _X_EXPORT void (*xf86WriteMmio32)(int, void *, unsigned long); +extern _X_EXPORT void (*xf86WriteMmioNB8)(int, void *, unsigned long); +extern _X_EXPORT void (*xf86WriteMmioNB16)(int, void *, unsigned long); +extern _X_EXPORT void (*xf86WriteMmioNB32)(int, void *, unsigned long); +extern _X_EXPORT void xf86SlowBCopyFromBus(unsigned char *, unsigned char *, int); +extern _X_EXPORT void xf86SlowBCopyToBus(unsigned char *, unsigned char *, int); + +/* Some macros to hide the system dependencies for MMIO accesses */ +/* Changed to kill noise generated by gcc's -Wcast-align */ +# define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset) +# define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset) +# ifndef STANDALONE_MMIO +# define MMIO_IN32(base, offset) (*xf86ReadMmio32)(base, offset) +# else +# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset) +# endif + +# define MMIO_OUT32(base, offset, val) \ + do { \ + write_mem_barrier(); \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val); \ + } while (0) +# define MMIO_ONB32(base, offset, val) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val) + +# define MMIO_OUT8(base, offset, val) \ + (*xf86WriteMmio8)((CARD8)(val), base, offset) +# define MMIO_OUT16(base, offset, val) \ + (*xf86WriteMmio16)((CARD16)(val), base, offset) +# define MMIO_ONB8(base, offset, val) \ + (*xf86WriteMmioNB8)((CARD8)(val), base, offset) +# define MMIO_ONB16(base, offset, val) \ + (*xf86WriteMmioNB16)((CARD16)(val), base, offset) +# define MMIO_MOVE32(base, offset, val) \ + MMIO_OUT32(base, offset, val) + +# elif defined(__powerpc__) + /* + * we provide byteswapping and no byteswapping functions here + * with byteswapping as default, + * drivers that don't need byteswapping should define PPC_MMIO_IS_BE + */ +# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset) +# define MMIO_OUT8(base, offset, val) \ + xf86WriteMmio8(base, offset, (CARD8)(val)) +# define MMIO_ONB8(base, offset, val) \ + xf86WriteMmioNB8(base, offset, (CARD8)(val)) + +# if defined(PPC_MMIO_IS_BE) /* No byteswapping */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Be(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Be(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmioNB16Be(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmioNB32Be(base, offset, (CARD32)(val)) +# else /* byteswapping is the default */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Le(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Le(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmioNB16Le(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmioNB32Le(base, offset, (CARD32)(val)) +# endif + +# define MMIO_MOVE32(base, offset, val) \ + xf86WriteMmio32Be(base, offset, (CARD32)(val)) + +# elif defined(__sparc__) || defined(sparc) || defined(__sparc) + /* + * Like powerpc, we provide byteswapping and no byteswapping functions + * here with byteswapping as default, drivers that don't need byteswapping + * should define SPARC_MMIO_IS_BE (perhaps create a generic macro so that we + * do not need to use PPC_MMIO_IS_BE and the sparc one in all the same places + * of drivers?). + */ +# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset) +# define MMIO_OUT8(base, offset, val) \ + xf86WriteMmio8(base, offset, (CARD8)(val)) +# define MMIO_ONB8(base, offset, val) \ + xf86WriteMmio8NB(base, offset, (CARD8)(val)) + +# if defined(SPARC_MMIO_IS_BE) /* No byteswapping */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Be(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Be(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Be(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Be(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmio16BeNB(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmio32BeNB(base, offset, (CARD32)(val)) +# else /* byteswapping is the default */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Le(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Le(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Le(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Le(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmio16LeNB(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmio32LeNB(base, offset, (CARD32)(val)) +# endif + +# define MMIO_MOVE32(base, offset, val) \ + xf86WriteMmio32Be(base, offset, (CARD32)(val)) + +# elif defined(__nds32__) + /* + * we provide byteswapping and no byteswapping functions here + * with no byteswapping as default; when endianness of CPU core + * and I/O devices don't match, byte swapping is necessary + * drivers that need byteswapping should define NDS32_MMIO_SWAP + */ +# define MMIO_IN8(base, offset) xf86ReadMmio8(base, offset) +# define MMIO_OUT8(base, offset, val) \ + xf86WriteMmio8(base, offset, (CARD8)(val)) +# define MMIO_ONB8(base, offset, val) \ + xf86WriteMmioNB8(base, offset, (CARD8)(val)) + +# if defined(NDS32_MMIO_SWAP) /* byteswapping */ +# define MMIO_IN16(base, offset) xf86ReadMmio16Swap(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32Swap(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16Swap(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32Swap(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmioNB16Swap(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmioNB32Swap(base, offset, (CARD32)(val)) +# else /* no byteswapping is the default */ +# define MMIO_IN16(base, offset) xf86ReadMmio16(base, offset) +# define MMIO_IN32(base, offset) xf86ReadMmio32(base, offset) +# define MMIO_OUT16(base, offset, val) \ + xf86WriteMmio16(base, offset, (CARD16)(val)) +# define MMIO_OUT32(base, offset, val) \ + xf86WriteMmio32(base, offset, (CARD32)(val)) +# define MMIO_ONB16(base, offset, val) \ + xf86WriteMmioNB16(base, offset, (CARD16)(val)) +# define MMIO_ONB32(base, offset, val) \ + xf86WriteMmioNB32(base, offset, (CARD32)(val)) +# endif + +# define MMIO_MOVE32(base, offset, val) \ + xf86WriteMmio32(base, offset, (CARD32)(val)) + +#ifdef N1213_HC /* for NDS32 N1213 hardcore */ +static __inline__ void nds32_flush_icache(char *addr) +{ + __asm__ volatile ( + "isync %0;" + "msync;" + "isb;" + "cctl %0,L1I_VA_INVAL;" + "isb;" + : : "r"(addr) : "memory"); +} +#else +static __inline__ void nds32_flush_icache(char *addr) +{ + __asm__ volatile ( + "isync %0;" + "isb;" + : : "r"(addr) : "memory"); +} +#endif + +# else /* !__alpha__ && !__powerpc__ && !__sparc__ */ + +# define MMIO_IN8(base, offset) \ + *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) +# define MMIO_IN16(base, offset) \ + *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) +# define MMIO_IN32(base, offset) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) +# define MMIO_OUT8(base, offset, val) \ + *(volatile CARD8 *)(((CARD8*)(base)) + (offset)) = (val) +# define MMIO_OUT16(base, offset, val) \ + *(volatile CARD16 *)(void *)(((CARD8*)(base)) + (offset)) = (val) +# define MMIO_OUT32(base, offset, val) \ + *(volatile CARD32 *)(void *)(((CARD8*)(base)) + (offset)) = (val) +# define MMIO_ONB8(base, offset, val) MMIO_OUT8(base, offset, val) +# define MMIO_ONB16(base, offset, val) MMIO_OUT16(base, offset, val) +# define MMIO_ONB32(base, offset, val) MMIO_OUT32(base, offset, val) + +# define MMIO_MOVE32(base, offset, val) MMIO_OUT32(base, offset, val) + +# endif /* __alpha__ */ + +/* + * With Intel, the version in os-support/misc/SlowBcopy.s is used. + * This avoids port I/O during the copy (which causes problems with + * some hardware). + */ +# ifdef __alpha__ +# define slowbcopy_tobus(src,dst,count) xf86SlowBCopyToBus(src,dst,count) +# define slowbcopy_frombus(src,dst,count) xf86SlowBCopyFromBus(src,dst,count) +# else /* __alpha__ */ +# define slowbcopy_tobus(src,dst,count) xf86SlowBcopy(src,dst,count) +# define slowbcopy_frombus(src,dst,count) xf86SlowBcopy(src,dst,count) +# endif /* __alpha__ */ + +#endif /* _COMPILER_H */ diff --git a/xorg-server/hw/xfree86/common/scoasm.h b/xorg-server/hw/xfree86/common/scoasm.h deleted file mode 100644 index 8f80e7b1e..000000000 --- a/xorg-server/hw/xfree86/common/scoasm.h +++ /dev/null @@ -1,142 +0,0 @@ - -/* - * Copyright (c) 1996 by The XFree86 Project, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the copyright holder(s) - * and author(s) shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from the copyright holder(s) and author(s). - */ - -/* - * scoasm.h - used to define inline versions of certain functions which - * do NOT appear in sys/inline.h. - */ -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#if defined(__SCO__) && defined(__USLC__) -#ifndef _SCOASM_HDR_INC -#define _SCOASM_HDR_INC - -asm void outl(port,val) -{ -%reg port,val; - movl port, %edx - movl val, %eax - outl (%dx) -%reg port; mem val; - movl port, %edx - movl val, %eax - outl (%dx) -%mem port; reg val; - movw port, %dx - movl val, %eax - outl (%dx) -%mem port,val; - movw port, %dx - movl val, %eax - outl (%dx) -} - -asm void outw(port,val) -{ -%reg port,val; - movl port, %edx - movl val, %eax - data16 - outl (%dx) -%reg port; mem val; - movl port, %edx - movw val, %ax - data16 - outl (%dx) -%mem port; reg val; - movw port, %dx - movl val, %eax - data16 - outl (%dx) -%mem port,val; - movw port, %dx - movw val, %ax - data16 - outl (%dx) -} - -asm void outb(port,val) -{ -%reg port,val; - movl port, %edx - movl val, %eax - outb (%dx) -%reg port; mem val; - movl port, %edx - movb val, %al - outb (%dx) -%mem port; reg val; - movw port, %dx - movl val, %eax - outb (%dx) -%mem port,val; - movw port, %dx - movb val, %al - outb (%dx) -} - -asm int inl(port) -{ -%reg port; - movl port, %edx - inl (%dx) -%mem port; - movw port, %dx - inl (%dx) -} - -asm int inw(port) -{ -%reg port; - subl %eax, %eax - movl port, %edx - data16 - inl (%dx) -%mem port; - subl %eax, %eax - movw port, %dx - data16 - inl (%dx) -} - -asm int inb(port) -{ -%reg port; - subl %eax, %eax - movl port, %edx - inb (%dx) -%mem port; - subl %eax, %eax - movw port, %dx - inb (%dx) -} - -#endif /* _SCOASM_HDR_INC */ -#endif /* __SCO__ && __USLC__ */ diff --git a/xorg-server/hw/xfree86/common/xf86.h b/xorg-server/hw/xfree86/common/xf86.h index c91020132..54332e381 100644 --- a/xorg-server/hw/xfree86/common/xf86.h +++ b/xorg-server/hw/xfree86/common/xf86.h @@ -1,355 +1,353 @@ -/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * This file contains declarations for public XFree86 functions and variables,
- * and definitions of public macros.
- *
- * "public" means available to video drivers.
- */
-
-#ifndef _XF86_H
-#define _XF86_H
-
-#if HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#elif HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "xf86str.h"
-#include "xf86Opt.h"
-#include <X11/Xfuncproto.h>
-#include <stdarg.h>
-#ifdef RANDR
-#include <X11/extensions/randr.h>
-#endif
-
-#include "propertyst.h"
-
-/* General parameters */
-extern _X_EXPORT int xf86DoConfigure;
-extern _X_EXPORT int xf86DoShowOptions;
-extern _X_EXPORT Bool xf86DoConfigurePass1;
-
-extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec;
-#define xf86ScreenKey (&xf86ScreenKeyRec)
-
-extern _X_EXPORT DevPrivateKeyRec xf86CreateRootWindowKeyRec;
-#define xf86CreateRootWindowKey (&xf86CreateRootWindowKeyRec)
-
-extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
-extern _X_EXPORT const unsigned char byte_reversed[256];
-extern _X_EXPORT Bool fbSlotClaimed;
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
-extern _X_EXPORT Bool sbusSlotClaimed;
-#endif
-extern _X_EXPORT confDRIRec xf86ConfigDRI;
-extern _X_EXPORT Bool xf86inSuspend;
-extern _X_EXPORT Bool xf86DRI2Enabled(void);
-
-extern _X_EXPORT Bool VTSwitchEnabled; /* kbd driver */
-
-#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \
- xf86ScreenKey))
-#define XF86FLIP_PIXELS() \
- do { \
- if (xf86GetFlipPixels()) { \
- pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \
- pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \
- } \
- while (0)
-
-#define BOOLTOSTRING(b) ((b) ? "TRUE" : "FALSE")
-
-#define PIX24TOBPP(p) (((p) == Pix24Use24) ? 24 : \
- (((p) == Pix24Use32) ? 32 : 0))
-
-/* Function Prototypes */
-#ifndef _NO_XF86_PROTOTYPES
-
-/* PCI related */
-#include <pciaccess.h>
-extern _X_EXPORT Bool pciSlotClaimed;
-
-extern _X_EXPORT Bool xf86CheckPciSlot(const struct pci_device *);
-extern _X_EXPORT int xf86ClaimPciSlot(struct pci_device *, DriverPtr drvp,
- int chipset, GDevPtr dev, Bool active);
-extern _X_EXPORT void xf86UnclaimPciSlot(struct pci_device *);
-extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus,
- int *device, int *func);
-extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus,
- int device, int func);
-extern _X_EXPORT void xf86FormatPciBusNumber(int busnum, char *buffer);
-extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device * pPci);
-extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device * pPci,
- memType base);
-extern _X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex);
-extern _X_EXPORT int xf86MatchPciInstances(const char *driverName,
- int vendorID, SymTabPtr chipsets, PciChipsets *PCIchipsets,
- GDevPtr *devList, int numDevs, DriverPtr drvp, int **foundEntities);
-extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn,
- int scrnFlag, int entityIndex,PciChipsets *p_chip, void *dummy,
- EntityProc init, EntityProc enter, EntityProc leave, pointer private);
-/* Obsolete! don't use */
-extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn,
- int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init,
- EntityProc enter, EntityProc leave, pointer private);
-
-/* xf86Bus.c */
-
-extern _X_EXPORT int xf86GetFbInfoForScreen(int scrnIndex);
-extern _X_EXPORT int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
-extern _X_EXPORT int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active);
-extern _X_EXPORT Bool xf86DriverHasEntities(DriverPtr drvp);
-extern _X_EXPORT void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex);
-extern _X_EXPORT void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex,
- int instance);
-extern _X_EXPORT int xf86GetNumEntityInstances(int entityIndex);
-extern _X_EXPORT GDevPtr xf86GetDevFromEntity(int entityIndex, int instance);
-extern _X_EXPORT void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex);
-extern _X_EXPORT EntityInfoPtr xf86GetEntityInfo(int entityIndex);
-extern _X_EXPORT Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
- EntityProc enter, EntityProc leave, pointer);
-extern _X_EXPORT Bool xf86IsEntityPrimary(int entityIndex);
-extern _X_EXPORT void xf86EnterServerState(xf86State state);
-extern _X_EXPORT ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
-
-extern _X_EXPORT int xf86GetLastScrnFlag(int entityIndex);
-extern _X_EXPORT void xf86SetLastScrnFlag(int entityIndex, int scrnIndex);
-extern _X_EXPORT Bool xf86IsEntityShared(int entityIndex);
-extern _X_EXPORT void xf86SetEntityShared(int entityIndex);
-extern _X_EXPORT Bool xf86IsEntitySharable(int entityIndex);
-extern _X_EXPORT void xf86SetEntitySharable(int entityIndex);
-extern _X_EXPORT Bool xf86IsPrimInitDone(int entityIndex);
-extern _X_EXPORT void xf86SetPrimInitDone(int entityIndex);
-extern _X_EXPORT void xf86ClearPrimInitDone(int entityIndex);
-extern _X_EXPORT int xf86AllocateEntityPrivateIndex(void);
-extern _X_EXPORT DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex);
-
-/* xf86Configure.c */
-extern _X_EXPORT GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus,
- void *busData, int chipset);
-
-/* xf86Cursor.c */
-
-extern _X_EXPORT void xf86LockZoom(ScreenPtr pScreen, int lock);
-extern _X_EXPORT void xf86InitViewport(ScrnInfoPtr pScr);
-extern _X_EXPORT void xf86SetViewport(ScreenPtr pScreen, int x, int y);
-extern _X_EXPORT void xf86ZoomViewport(ScreenPtr pScreen, int zoom);
-extern _X_EXPORT Bool xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode);
-extern _X_EXPORT void *xf86GetPointerScreenFuncs(void);
-extern _X_EXPORT void xf86InitOrigins(void);
-extern _X_EXPORT void xf86ReconfigureLayout(void);
-
-/* xf86cvt.c */
-extern _X_EXPORT DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh,
- Bool Reduced, Bool Interlaced);
-
-/* xf86DPMS.c */
-
-extern _X_EXPORT Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags);
-
-#ifdef DPMSExtension
-extern _X_EXPORT int DPMSSet(ClientPtr client, int level);
-extern _X_EXPORT Bool DPMSSupported(void);
-#endif
-
-
-/* xf86DGA.c */
-
-#ifdef XFreeXDGA
-extern _X_EXPORT Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes,
- int num);
-extern _X_EXPORT Bool DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes, int num);
-extern _X_EXPORT xf86SetDGAModeProc xf86SetDGAMode;
-#endif
-
-/* xf86Events.c */
-
-extern _X_EXPORT void SetTimeSinceLastInputEvent(void);
-extern _X_EXPORT pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data);
-extern _X_EXPORT int xf86RemoveInputHandler(pointer handler);
-extern _X_EXPORT void xf86DisableInputHandler(pointer handler);
-extern _X_EXPORT void xf86EnableInputHandler(pointer handler);
-extern _X_EXPORT pointer xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data);
-extern _X_EXPORT int xf86RemoveGeneralHandler(pointer handler);
-extern _X_EXPORT void xf86DisableGeneralHandler(pointer handler);
-extern _X_EXPORT void xf86EnableGeneralHandler(pointer handler);
-extern _X_EXPORT InputHandlerProc xf86SetConsoleHandler(InputHandlerProc handler, pointer data);
-extern _X_EXPORT void xf86InterceptSignals(int *signo);
-extern _X_EXPORT void xf86InterceptSigIll(void (*sigillhandler)(void));
-extern _X_EXPORT Bool xf86EnableVTSwitch(Bool new);
-extern _X_EXPORT void xf86ProcessActionEvent(ActionEvent action, void *arg);
-extern _X_EXPORT void xf86PrintBacktrace(void);
-
-/* xf86Helper.c */
-
-extern _X_EXPORT void xf86AddDriver(DriverPtr driver, pointer module, int flags);
-extern _X_EXPORT void xf86DeleteDriver(int drvIndex);
-extern _X_EXPORT ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags);
-extern _X_EXPORT void xf86DeleteScreen(int scrnIndex, int flags);
-extern _X_EXPORT int xf86AllocateScrnInfoPrivateIndex(void);
-extern _X_EXPORT Bool xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad);
-extern _X_EXPORT Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, int fbbpp,
- int depth24flags);
-extern _X_EXPORT void xf86PrintDepthBpp(ScrnInfoPtr scrp);
-extern _X_EXPORT Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
-extern _X_EXPORT Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
-extern _X_EXPORT Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma);
-extern _X_EXPORT void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
-extern _X_EXPORT void xf86SetBlackWhitePixels(ScreenPtr pScreen);
-extern _X_EXPORT void xf86EnableDisableFBAccess(int scrnIndex, Bool enable);
-extern _X_EXPORT void xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb,
- const char *format, va_list args);
-extern _X_EXPORT void xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb,
- const char *format, ...) _X_ATTRIBUTE_PRINTF(4,5);
-extern _X_EXPORT void xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...)
- _X_ATTRIBUTE_PRINTF(3,4);
-extern _X_EXPORT void xf86MsgVerb(MessageType type, int verb, const char *format, ...)
- _X_ATTRIBUTE_PRINTF(3,4);
-extern _X_EXPORT void xf86Msg(MessageType type, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3);
-extern _X_EXPORT void xf86ErrorFVerb(int verb, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3);
-extern _X_EXPORT void xf86ErrorF(const char *format, ...) _X_ATTRIBUTE_PRINTF(1,2);
-extern _X_EXPORT const char *xf86TokenToString(SymTabPtr table, int token);
-extern _X_EXPORT int xf86StringToToken(SymTabPtr table, const char *string);
-extern _X_EXPORT void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from);
-extern _X_EXPORT void xf86PrintChipsets(const char *drvname, const char *drvmsg,
- SymTabPtr chips);
-extern _X_EXPORT int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist);
-extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num,
- Bool (*ClockFunc)(ScrnInfoPtr, int),
- void (*ProtectRegs)(ScrnInfoPtr, Bool),
- void (*BlankScreen)(ScrnInfoPtr, Bool),
- IOADDRESS vertsyncreg, int maskval,
- int knownclkindex, int knownclkvalue);
-extern _X_EXPORT const char *xf86GetVisualName(int visual);
-extern _X_EXPORT int xf86GetVerbosity(void);
-extern _X_EXPORT Pix24Flags xf86GetPix24(void);
-extern _X_EXPORT int xf86GetDepth(void);
-extern _X_EXPORT rgb xf86GetWeight(void);
-extern _X_EXPORT Gamma xf86GetGamma(void);
-extern _X_EXPORT Bool xf86GetFlipPixels(void);
-extern _X_EXPORT const char *xf86GetServerName(void);
-extern _X_EXPORT Bool xf86ServerIsExiting(void);
-extern _X_EXPORT Bool xf86ServerIsResetting(void);
-extern _X_EXPORT Bool xf86ServerIsInitialising(void);
-extern _X_EXPORT Bool xf86ServerIsOnlyDetecting(void);
-extern _X_EXPORT Bool xf86CaughtSignal(void);
-extern _X_EXPORT Bool xf86GetVidModeAllowNonLocal(void);
-extern _X_EXPORT Bool xf86GetVidModeEnabled(void);
-extern _X_EXPORT Bool xf86GetModInDevAllowNonLocal(void);
-extern _X_EXPORT Bool xf86GetModInDevEnabled(void);
-extern _X_EXPORT Bool xf86GetAllowMouseOpenFail(void);
-extern _X_EXPORT Bool xf86IsPc98(void);
-extern _X_EXPORT void xf86DisableRandR(void);
-extern _X_EXPORT CARD32 xorgGetVersion(void);
-extern _X_EXPORT CARD32 xf86GetModuleVersion(pointer module);
-extern _X_EXPORT pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
-extern _X_EXPORT pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
-extern _X_EXPORT pointer xf86LoadOneModule(char *name, pointer optlist);
-extern _X_EXPORT void xf86UnloadSubModule(pointer mod);
-extern _X_EXPORT Bool xf86LoaderCheckSymbol(const char *name);
-extern _X_EXPORT void xf86SetBackingStore(ScreenPtr pScreen);
-extern _X_EXPORT void xf86SetSilkenMouse(ScreenPtr pScreen);
-extern _X_EXPORT pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name,
- char **adaptor_name, pointer *adaptor_options);
-extern _X_EXPORT void xf86GetOS(const char **name, int *major, int *minor, int *teeny);
-extern _X_EXPORT ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag,
- int entityIndex, EntityProc init,
- EntityProc enter, EntityProc leave,
- pointer private);
-
-extern _X_EXPORT Bool xf86IsScreenPrimary(int scrnIndex);
-extern _X_EXPORT int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type,
- int format, unsigned long len,
- pointer value);
-extern _X_EXPORT Bool xf86IsUnblank(int mode);
-
-/* xf86Init.c */
-
-extern _X_EXPORT PixmapFormatPtr xf86GetPixFormat(ScrnInfoPtr pScrn, int depth);
-extern _X_EXPORT int xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth);
-
-/* xf86Mode.c */
-
-extern _X_EXPORT int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2,
- int DivFactor, int MulFactor, int *divider);
-extern _X_EXPORT const char *xf86ModeStatusToString(ModeStatus status);
-extern _X_EXPORT ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
- ClockRangePtr clockRanges, LookupModeFlags strategy);
-extern _X_EXPORT ModeStatus xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor);
-extern _X_EXPORT ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
- ClockRangePtr clockRanges,
- LookupModeFlags strategy,
- int maxPitch, int virtualX,
- int virtualY);
-extern _X_EXPORT ModeStatus xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode,
- int flags);
-extern _X_EXPORT int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
- char **modeNames, ClockRangePtr clockRanges,
- int *linePitches, int minPitch, int maxPitch,
- int minHeight, int maxHeight, int pitchInc,
- int virtualX, int virtualY, int apertureSize,
- LookupModeFlags strategy);
-extern _X_EXPORT void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode);
-extern _X_EXPORT void xf86PruneDriverModes(ScrnInfoPtr scrp);
-extern _X_EXPORT void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags);
-extern _X_EXPORT void xf86PrintModes(ScrnInfoPtr scrp);
-extern _X_EXPORT void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges);
-extern _X_EXPORT double xf86ModeHSync(const DisplayModeRec *mode);
-extern _X_EXPORT double xf86ModeVRefresh(const DisplayModeRec *mode);
-extern _X_EXPORT void xf86SetModeDefaultName(DisplayModePtr mode);
-extern _X_EXPORT void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags);
-extern _X_EXPORT DisplayModePtr xf86DuplicateMode(const DisplayModeRec *pMode);
-extern _X_EXPORT DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList);
-extern _X_EXPORT Bool xf86ModesEqual(const DisplayModeRec *pMode1,
- const DisplayModeRec *pMode2);
-extern _X_EXPORT void xf86PrintModeline(int scrnIndex,DisplayModePtr mode);
-extern _X_EXPORT DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new);
-
-/* xf86Option.c */
-
-extern _X_EXPORT void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts);
-
-
-/* xf86RandR.c */
-#ifdef RANDR
-extern _X_EXPORT Bool xf86RandRInit (ScreenPtr pScreen);
-extern _X_EXPORT Rotation xf86GetRotation(ScreenPtr pScreen);
-extern _X_EXPORT Bool xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
- int newvirtX, int newvirtY,
- int newmmWidth, int newmmHeight, Bool resetMode);
-#endif
-
-/* xf86VidModeExtentionInit.c */
-
-extern _X_EXPORT Bool VidModeExtensionInit(ScreenPtr pScreen);
-
-#endif /* _NO_XF86_PROTOTYPES */
-
-#endif /* _XF86_H */
+/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains declarations for public XFree86 functions and variables, + * and definitions of public macros. + * + * "public" means available to video drivers. + */ + +#ifndef _XF86_H +#define _XF86_H + +#if HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#elif HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include "xf86str.h" +#include "xf86Opt.h" +#include <X11/Xfuncproto.h> +#include <stdarg.h> +#ifdef RANDR +#include <X11/extensions/randr.h> +#endif + +#include "propertyst.h" + +/* General parameters */ +extern _X_EXPORT int xf86DoConfigure; +extern _X_EXPORT int xf86DoShowOptions; +extern _X_EXPORT Bool xf86DoConfigurePass1; + +extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec; +#define xf86ScreenKey (&xf86ScreenKeyRec) + +extern _X_EXPORT DevPrivateKeyRec xf86CreateRootWindowKeyRec; +#define xf86CreateRootWindowKey (&xf86CreateRootWindowKeyRec) + +extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */ +extern _X_EXPORT const unsigned char byte_reversed[256]; +extern _X_EXPORT Bool fbSlotClaimed; +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) +extern _X_EXPORT Bool sbusSlotClaimed; +#endif +extern _X_EXPORT confDRIRec xf86ConfigDRI; +extern _X_EXPORT Bool xf86DRI2Enabled(void); + +extern _X_EXPORT Bool VTSwitchEnabled; /* kbd driver */ + +#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \ + xf86ScreenKey)) +#define XF86FLIP_PIXELS() \ + do { \ + if (xf86GetFlipPixels()) { \ + pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \ + pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \ + } \ + while (0) + +#define BOOLTOSTRING(b) ((b) ? "TRUE" : "FALSE") + +#define PIX24TOBPP(p) (((p) == Pix24Use24) ? 24 : \ + (((p) == Pix24Use32) ? 32 : 0)) + +/* Function Prototypes */ +#ifndef _NO_XF86_PROTOTYPES + +/* PCI related */ +#include <pciaccess.h> +extern _X_EXPORT Bool pciSlotClaimed; + +extern _X_EXPORT Bool xf86CheckPciSlot(const struct pci_device *); +extern _X_EXPORT int xf86ClaimPciSlot(struct pci_device *, DriverPtr drvp, + int chipset, GDevPtr dev, Bool active); +extern _X_EXPORT void xf86UnclaimPciSlot(struct pci_device *); +extern _X_EXPORT Bool xf86ParsePciBusString(const char *busID, int *bus, + int *device, int *func); +extern _X_EXPORT Bool xf86ComparePciBusString(const char *busID, int bus, + int device, int func); +extern _X_EXPORT void xf86FormatPciBusNumber(int busnum, char *buffer); +extern _X_EXPORT Bool xf86IsPrimaryPci(struct pci_device * pPci); +extern _X_EXPORT Bool xf86CheckPciMemBase(struct pci_device * pPci, + memType base); +extern _X_EXPORT struct pci_device * xf86GetPciInfoForEntity(int entityIndex); +extern _X_EXPORT int xf86MatchPciInstances(const char *driverName, + int vendorID, SymTabPtr chipsets, PciChipsets *PCIchipsets, + GDevPtr *devList, int numDevs, DriverPtr drvp, int **foundEntities); +extern _X_EXPORT ScrnInfoPtr xf86ConfigPciEntity(ScrnInfoPtr pScrn, + int scrnFlag, int entityIndex,PciChipsets *p_chip, void *dummy, + EntityProc init, EntityProc enter, EntityProc leave, pointer private); +/* Obsolete! don't use */ +extern _X_EXPORT Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, + int entityIndex,PciChipsets *p_chip, void *dummy, EntityProc init, + EntityProc enter, EntityProc leave, pointer private); + +/* xf86Bus.c */ + +extern _X_EXPORT int xf86GetFbInfoForScreen(int scrnIndex); +extern _X_EXPORT int xf86ClaimFbSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active); +extern _X_EXPORT int xf86ClaimNoSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active); +extern _X_EXPORT Bool xf86DriverHasEntities(DriverPtr drvp); +extern _X_EXPORT void xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex); +extern _X_EXPORT void xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, + int instance); +extern _X_EXPORT int xf86GetNumEntityInstances(int entityIndex); +extern _X_EXPORT GDevPtr xf86GetDevFromEntity(int entityIndex, int instance); +extern _X_EXPORT void xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex); +extern _X_EXPORT EntityInfoPtr xf86GetEntityInfo(int entityIndex); +extern _X_EXPORT Bool xf86SetEntityFuncs(int entityIndex, EntityProc init, + EntityProc enter, EntityProc leave, pointer); +extern _X_EXPORT Bool xf86IsEntityPrimary(int entityIndex); +extern _X_EXPORT ScrnInfoPtr xf86FindScreenForEntity(int entityIndex); + +extern _X_EXPORT int xf86GetLastScrnFlag(int entityIndex); +extern _X_EXPORT void xf86SetLastScrnFlag(int entityIndex, int scrnIndex); +extern _X_EXPORT Bool xf86IsEntityShared(int entityIndex); +extern _X_EXPORT void xf86SetEntityShared(int entityIndex); +extern _X_EXPORT Bool xf86IsEntitySharable(int entityIndex); +extern _X_EXPORT void xf86SetEntitySharable(int entityIndex); +extern _X_EXPORT Bool xf86IsPrimInitDone(int entityIndex); +extern _X_EXPORT void xf86SetPrimInitDone(int entityIndex); +extern _X_EXPORT void xf86ClearPrimInitDone(int entityIndex); +extern _X_EXPORT int xf86AllocateEntityPrivateIndex(void); +extern _X_EXPORT DevUnion *xf86GetEntityPrivate(int entityIndex, int privIndex); + +/* xf86Configure.c */ +extern _X_EXPORT GDevPtr xf86AddBusDeviceToConfigure(const char *driver, BusType bus, + void *busData, int chipset); + +/* xf86Cursor.c */ + +extern _X_EXPORT void xf86LockZoom(ScreenPtr pScreen, int lock); +extern _X_EXPORT void xf86InitViewport(ScrnInfoPtr pScr); +extern _X_EXPORT void xf86SetViewport(ScreenPtr pScreen, int x, int y); +extern _X_EXPORT void xf86ZoomViewport(ScreenPtr pScreen, int zoom); +extern _X_EXPORT Bool xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode); +extern _X_EXPORT void *xf86GetPointerScreenFuncs(void); +extern _X_EXPORT void xf86InitOrigins(void); +extern _X_EXPORT void xf86ReconfigureLayout(void); + +/* xf86cvt.c */ +extern _X_EXPORT DisplayModePtr xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, + Bool Reduced, Bool Interlaced); + +/* xf86DPMS.c */ + +extern _X_EXPORT Bool xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags); + +#ifdef DPMSExtension +extern _X_EXPORT int DPMSSet(ClientPtr client, int level); +extern _X_EXPORT Bool DPMSSupported(void); +#endif + + +/* xf86DGA.c */ + +#ifdef XFreeXDGA +extern _X_EXPORT Bool DGAInit(ScreenPtr pScreen, DGAFunctionPtr funcs, DGAModePtr modes, + int num); +extern _X_EXPORT Bool DGAReInitModes(ScreenPtr pScreen, DGAModePtr modes, int num); +extern _X_EXPORT xf86SetDGAModeProc xf86SetDGAMode; +#endif + +/* xf86Events.c */ + +extern _X_EXPORT void SetTimeSinceLastInputEvent(void); +extern _X_EXPORT pointer xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data); +extern _X_EXPORT int xf86RemoveInputHandler(pointer handler); +extern _X_EXPORT void xf86DisableInputHandler(pointer handler); +extern _X_EXPORT void xf86EnableInputHandler(pointer handler); +extern _X_EXPORT pointer xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data); +extern _X_EXPORT int xf86RemoveGeneralHandler(pointer handler); +extern _X_EXPORT void xf86DisableGeneralHandler(pointer handler); +extern _X_EXPORT void xf86EnableGeneralHandler(pointer handler); +extern _X_EXPORT InputHandlerProc xf86SetConsoleHandler(InputHandlerProc handler, pointer data); +extern _X_EXPORT void xf86InterceptSignals(int *signo); +extern _X_EXPORT void xf86InterceptSigIll(void (*sigillhandler)(void)); +extern _X_EXPORT Bool xf86EnableVTSwitch(Bool new); +extern _X_EXPORT void xf86ProcessActionEvent(ActionEvent action, void *arg); +extern _X_EXPORT void xf86PrintBacktrace(void); + +/* xf86Helper.c */ + +extern _X_EXPORT void xf86AddDriver(DriverPtr driver, pointer module, int flags); +extern _X_EXPORT void xf86DeleteDriver(int drvIndex); +extern _X_EXPORT ScrnInfoPtr xf86AllocateScreen(DriverPtr drv, int flags); +extern _X_EXPORT void xf86DeleteScreen(int scrnIndex, int flags); +extern _X_EXPORT int xf86AllocateScrnInfoPrivateIndex(void); +extern _X_EXPORT Bool xf86AddPixFormat(ScrnInfoPtr pScrn, int depth, int bpp, int pad); +extern _X_EXPORT Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, int fbbpp, + int depth24flags); +extern _X_EXPORT void xf86PrintDepthBpp(ScrnInfoPtr scrp); +extern _X_EXPORT Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask); +extern _X_EXPORT Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual); +extern _X_EXPORT Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma); +extern _X_EXPORT void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y); +extern _X_EXPORT void xf86SetBlackWhitePixels(ScreenPtr pScreen); +extern _X_EXPORT void xf86EnableDisableFBAccess(int scrnIndex, Bool enable); +extern _X_EXPORT void xf86VDrvMsgVerb(int scrnIndex, MessageType type, int verb, + const char *format, va_list args); +extern _X_EXPORT void xf86DrvMsgVerb(int scrnIndex, MessageType type, int verb, + const char *format, ...) _X_ATTRIBUTE_PRINTF(4,5); +extern _X_EXPORT void xf86DrvMsg(int scrnIndex, MessageType type, const char *format, ...) + _X_ATTRIBUTE_PRINTF(3,4); +extern _X_EXPORT void xf86MsgVerb(MessageType type, int verb, const char *format, ...) + _X_ATTRIBUTE_PRINTF(3,4); +extern _X_EXPORT void xf86Msg(MessageType type, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3); +extern _X_EXPORT void xf86ErrorFVerb(int verb, const char *format, ...) _X_ATTRIBUTE_PRINTF(2,3); +extern _X_EXPORT void xf86ErrorF(const char *format, ...) _X_ATTRIBUTE_PRINTF(1,2); +extern _X_EXPORT const char *xf86TokenToString(SymTabPtr table, int token); +extern _X_EXPORT int xf86StringToToken(SymTabPtr table, const char *string); +extern _X_EXPORT void xf86ShowClocks(ScrnInfoPtr scrp, MessageType from); +extern _X_EXPORT void xf86PrintChipsets(const char *drvname, const char *drvmsg, + SymTabPtr chips); +extern _X_EXPORT int xf86MatchDevice(const char *drivername, GDevPtr **driversectlist); +extern _X_EXPORT void xf86GetClocks(ScrnInfoPtr pScrn, int num, + Bool (*ClockFunc)(ScrnInfoPtr, int), + void (*ProtectRegs)(ScrnInfoPtr, Bool), + void (*BlankScreen)(ScrnInfoPtr, Bool), + IOADDRESS vertsyncreg, int maskval, + int knownclkindex, int knownclkvalue); +extern _X_EXPORT const char *xf86GetVisualName(int visual); +extern _X_EXPORT int xf86GetVerbosity(void); +extern _X_EXPORT Pix24Flags xf86GetPix24(void); +extern _X_EXPORT int xf86GetDepth(void); +extern _X_EXPORT rgb xf86GetWeight(void); +extern _X_EXPORT Gamma xf86GetGamma(void); +extern _X_EXPORT Bool xf86GetFlipPixels(void); +extern _X_EXPORT const char *xf86GetServerName(void); +extern _X_EXPORT Bool xf86ServerIsExiting(void); +extern _X_EXPORT Bool xf86ServerIsResetting(void); +extern _X_EXPORT Bool xf86ServerIsInitialising(void); +extern _X_EXPORT Bool xf86ServerIsOnlyDetecting(void); +extern _X_EXPORT Bool xf86CaughtSignal(void); +extern _X_EXPORT Bool xf86GetVidModeAllowNonLocal(void); +extern _X_EXPORT Bool xf86GetVidModeEnabled(void); +extern _X_EXPORT Bool xf86GetModInDevAllowNonLocal(void); +extern _X_EXPORT Bool xf86GetModInDevEnabled(void); +extern _X_EXPORT Bool xf86GetAllowMouseOpenFail(void); +extern _X_EXPORT Bool xf86IsPc98(void); +extern _X_EXPORT void xf86DisableRandR(void); +extern _X_EXPORT CARD32 xorgGetVersion(void); +extern _X_EXPORT CARD32 xf86GetModuleVersion(pointer module); +extern _X_EXPORT pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name); +extern _X_EXPORT pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name); +extern _X_EXPORT pointer xf86LoadOneModule(char *name, pointer optlist); +extern _X_EXPORT void xf86UnloadSubModule(pointer mod); +extern _X_EXPORT Bool xf86LoaderCheckSymbol(const char *name); +extern _X_EXPORT void xf86SetBackingStore(ScreenPtr pScreen); +extern _X_EXPORT void xf86SetSilkenMouse(ScreenPtr pScreen); +extern _X_EXPORT pointer xf86FindXvOptions(int scrnIndex, int adapt_index, char *port_name, + char **adaptor_name, pointer *adaptor_options); +extern _X_EXPORT void xf86GetOS(const char **name, int *major, int *minor, int *teeny); +extern _X_EXPORT ScrnInfoPtr xf86ConfigFbEntity(ScrnInfoPtr pScrn, int scrnFlag, + int entityIndex, EntityProc init, + EntityProc enter, EntityProc leave, + pointer private); + +extern _X_EXPORT Bool xf86IsScreenPrimary(int scrnIndex); +extern _X_EXPORT int xf86RegisterRootWindowProperty(int ScrnIndex, Atom property, Atom type, + int format, unsigned long len, + pointer value); +extern _X_EXPORT Bool xf86IsUnblank(int mode); + +/* xf86Init.c */ + +extern _X_EXPORT PixmapFormatPtr xf86GetPixFormat(ScrnInfoPtr pScrn, int depth); +extern _X_EXPORT int xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth); + +/* xf86Mode.c */ + +extern _X_EXPORT int xf86GetNearestClock(ScrnInfoPtr scrp, int freq, Bool allowDiv2, + int DivFactor, int MulFactor, int *divider); +extern _X_EXPORT const char *xf86ModeStatusToString(ModeStatus status); +extern _X_EXPORT ModeStatus xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep, + ClockRangePtr clockRanges, LookupModeFlags strategy); +extern _X_EXPORT ModeStatus xf86CheckModeForMonitor(DisplayModePtr mode, MonPtr monitor); +extern _X_EXPORT ModeStatus xf86InitialCheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, + ClockRangePtr clockRanges, + LookupModeFlags strategy, + int maxPitch, int virtualX, + int virtualY); +extern _X_EXPORT ModeStatus xf86CheckModeForDriver(ScrnInfoPtr scrp, DisplayModePtr mode, + int flags); +extern _X_EXPORT int xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes, + char **modeNames, ClockRangePtr clockRanges, + int *linePitches, int minPitch, int maxPitch, + int minHeight, int maxHeight, int pitchInc, + int virtualX, int virtualY, int apertureSize, + LookupModeFlags strategy); +extern _X_EXPORT void xf86DeleteMode(DisplayModePtr *modeList, DisplayModePtr mode); +extern _X_EXPORT void xf86PruneDriverModes(ScrnInfoPtr scrp); +extern _X_EXPORT void xf86SetCrtcForModes(ScrnInfoPtr scrp, int adjustFlags); +extern _X_EXPORT void xf86PrintModes(ScrnInfoPtr scrp); +extern _X_EXPORT void xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges); +extern _X_EXPORT double xf86ModeHSync(const DisplayModeRec *mode); +extern _X_EXPORT double xf86ModeVRefresh(const DisplayModeRec *mode); +extern _X_EXPORT void xf86SetModeDefaultName(DisplayModePtr mode); +extern _X_EXPORT void xf86SetModeCrtc(DisplayModePtr p, int adjustFlags); +extern _X_EXPORT DisplayModePtr xf86DuplicateMode(const DisplayModeRec *pMode); +extern _X_EXPORT DisplayModePtr xf86DuplicateModes(ScrnInfoPtr pScrn, DisplayModePtr modeList); +extern _X_EXPORT Bool xf86ModesEqual(const DisplayModeRec *pMode1, + const DisplayModeRec *pMode2); +extern _X_EXPORT void xf86PrintModeline(int scrnIndex,DisplayModePtr mode); +extern _X_EXPORT DisplayModePtr xf86ModesAdd(DisplayModePtr modes, DisplayModePtr new); + +/* xf86Option.c */ + +extern _X_EXPORT void xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts); + + +/* xf86RandR.c */ +#ifdef RANDR +extern _X_EXPORT Bool xf86RandRInit (ScreenPtr pScreen); +extern _X_EXPORT Rotation xf86GetRotation(ScreenPtr pScreen); +extern _X_EXPORT Bool xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen, + int newvirtX, int newvirtY, + int newmmWidth, int newmmHeight, Bool resetMode); +#endif + +/* xf86VidModeExtentionInit.c */ + +extern _X_EXPORT Bool VidModeExtensionInit(ScreenPtr pScreen); + +#endif /* _NO_XF86_PROTOTYPES */ + +#endif /* _XF86_H */ diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c index bec2343b2..3b0896863 100644 --- a/xorg-server/hw/xfree86/common/xf86Bus.c +++ b/xorg-server/hw/xfree86/common/xf86Bus.c @@ -1,671 +1,636 @@ -/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * This file contains the interfaces to the bus-specific code
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <X11/X.h>
-#include "os.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-
-/* Bus-specific headers */
-
-#include "xf86Bus.h"
-
-#define XF86_OS_PRIVS
-#include "xf86_OSproc.h"
-#include "xf86VGAarbiter.h"
-
-/* Entity data */
-EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */
-int xf86NumEntities = 0;
-static int xf86EntityPrivateCount = 0;
-
-BusRec primaryBus = { BUS_NONE, { 0 } };
-
-/**
- * Call the driver's correct probe function.
- *
- * If the driver implements the \c DriverRec::PciProbe entry-point and an
- * appropriate PCI device (with matching Device section in the xorg.conf file)
- * is found, it is called. If \c DriverRec::PciProbe or no devices can be
- * successfully probed with it (e.g., only non-PCI devices are available),
- * the driver's \c DriverRec::Probe function is called.
- *
- * \param drv Driver to probe
- *
- * \return
- * If a device can be successfully probed by the driver, \c TRUE is
- * returned. Otherwise, \c FALSE is returned.
- */
-Bool
-xf86CallDriverProbe( DriverPtr drv, Bool detect_only )
-{
- Bool foundScreen = FALSE;
-
- if (drv->PciProbe != NULL) {
- if (xf86DoConfigure && xf86DoConfigurePass1) {
- assert(detect_only);
- foundScreen = xf86PciAddMatchingDev(drv);
- }
- else {
- assert(! detect_only);
- foundScreen = xf86PciProbeDev(drv);
- }
- }
-
- if (!foundScreen && (drv->Probe != NULL)) {
- xf86Msg( X_WARNING, "Falling back to old probe method for %s\n",
- drv->driverName);
- foundScreen = (*drv->Probe)(drv, (detect_only) ? PROBE_DETECT
- : PROBE_DEFAULT);
- }
-
- return foundScreen;
-}
-
-/**
- * @return TRUE if all buses are configured and set up correctly and FALSE
- * otherwise.
- */
-Bool
-xf86BusConfig(void)
-{
- screenLayoutPtr layout;
- int i, j;
-
- /* Enable full I/O access */
- if (xorgHWAccess)
- xorgHWAccess = xf86EnableIO();
-
- /*
- * Now call each of the Probe functions. Each successful probe will
- * result in an extra entry added to the xf86Screens[] list for each
- * instance of the hardware found.
- */
- for (i = 0; i < xf86NumDrivers; i++) {
- xorgHWFlags flags;
- if (!xorgHWAccess) {
- if (!xf86DriverList[i]->driverFunc
- || !xf86DriverList[i]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags)
- || NEED_IO_ENABLED(flags))
- continue;
- }
-
- xf86CallDriverProbe(xf86DriverList[i], FALSE);
- }
-
- /* If nothing was detected, return now */
- if (xf86NumScreens == 0) {
- xf86Msg(X_ERROR, "No devices detected.\n");
- return FALSE;
- }
-
- xf86VGAarbiterInit();
-
- /*
- * Match up the screens found by the probes against those specified
- * in the config file. Remove the ones that won't be used. Sort
- * them in the order specified.
- *
- * What is the best way to do this?
- *
- * For now, go through the screens allocated by the probes, and
- * look for screen config entry which refers to the same device
- * section as picked out by the probe.
- *
- */
- for (i = 0; i < xf86NumScreens; i++) {
- for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
- layout++) {
- Bool found = FALSE;
- for (j = 0; j < xf86Screens[i]->numEntities; j++) {
-
- GDevPtr dev = xf86GetDevFromEntity(
- xf86Screens[i]->entityList[j],
- xf86Screens[i]->entityInstanceList[j]);
- if (dev == layout->screen->device) {
- /* A match has been found */
- xf86Screens[i]->confScreen = layout->screen;
- found = TRUE;
- break;
- }
- }
- if (found) break;
- }
- if (layout->screen == NULL) {
- /* No match found */
- xf86Msg(X_ERROR,
- "Screen %d deleted because of no matching config section.\n", i);
- xf86DeleteScreen(i--, 0);
- }
- }
-
- /* If no screens left, return now. */
- if (xf86NumScreens == 0) {
- xf86Msg(X_ERROR,
- "Device(s) detected, but none match those in the config file.\n");
- return FALSE;
- }
-
- return TRUE;
-}
-
-/*
- * Call the bus probes relevant to the architecture.
- *
- * The only one available so far is for PCI and SBUS.
- */
-
-void
-xf86BusProbe(void)
-{
- xf86PciProbe();
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- xf86SbusProbe();
-#endif
-}
-
-/*
- * Determine what bus type the busID string represents. The start of the
- * bus-dependent part of the string is returned as retID.
- */
-
-BusType
-StringToBusType(const char* busID, const char **retID)
-{
- char *p, *s;
- BusType ret = BUS_NONE;
-
- /* If no type field, Default to PCI */
- if (isdigit(busID[0])) {
- if (retID)
- *retID = busID;
- return BUS_PCI;
- }
-
- s = xstrdup(busID);
- p = strtok(s, ":");
- if (p == NULL || *p == 0) {
- free(s);
- return BUS_NONE;
- }
- if (!xf86NameCmp(p, "pci") || !xf86NameCmp(p, "agp"))
- ret = BUS_PCI;
- if (!xf86NameCmp(p, "sbus"))
- ret = BUS_SBUS;
- if (ret != BUS_NONE)
- if (retID)
- *retID = busID + strlen(p) + 1;
- free(s);
- return ret;
-}
-
-int
-xf86AllocateEntity(void)
-{
- xf86NumEntities++;
- xf86Entities = xnfrealloc(xf86Entities,
- sizeof(EntityPtr) * xf86NumEntities);
- xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec));
- xf86Entities[xf86NumEntities - 1]->entityPrivates =
- xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
- return xf86NumEntities - 1;
-}
-
-Bool
-xf86IsEntityPrimary(int entityIndex)
-{
- EntityPtr pEnt = xf86Entities[entityIndex];
-
- if (primaryBus.type != pEnt->bus.type) return FALSE;
-
- switch (pEnt->bus.type) {
- case BUS_PCI:
- return pEnt->bus.id.pci == primaryBus.id.pci;
- case BUS_SBUS:
- return pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum;
- default:
- return FALSE;
- }
-}
-
-Bool
-xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter,
- EntityProc leave, pointer private)
-{
- if (entityIndex >= xf86NumEntities)
- return FALSE;
- xf86Entities[entityIndex]->entityInit = init;
- xf86Entities[entityIndex]->entityEnter = enter;
- xf86Entities[entityIndex]->entityLeave = leave;
- xf86Entities[entityIndex]->private = private;
- return TRUE;
-}
-
-Bool
-xf86DriverHasEntities(DriverPtr drvp)
-{
- int i;
- for (i = 0; i < xf86NumEntities; i++) {
- if (xf86Entities[i]->driver == drvp)
- return TRUE;
- }
- return FALSE;
-}
-
-void
-xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
-{
- if (entityIndex == -1)
- return;
- if (xf86Entities[entityIndex]->inUse &&
- !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) {
- ErrorF("Requested Entity already in use!\n");
- return;
- }
-
- pScrn->numEntities++;
- pScrn->entityList = xnfrealloc(pScrn->entityList,
- pScrn->numEntities * sizeof(int));
- pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
- xf86Entities[entityIndex]->inUse = TRUE;
- pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList,
- pScrn->numEntities * sizeof(int));
- pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
- pScrn->domainIOBase = xf86Entities[entityIndex]->domainIO;
-}
-
-void
-xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, int instance)
-{
- int i;
-
- if (entityIndex == -1 || entityIndex >= xf86NumEntities)
- return;
-
- for (i = 0; i < pScrn->numEntities; i++) {
- if (pScrn->entityList[i] == entityIndex) {
- pScrn->entityInstanceList[i] = instance;
- break;
- }
- }
-}
-
-/*
- * XXX This needs to be updated for the case where a single entity may have
- * instances associated with more than one screen.
- */
-ScrnInfoPtr
-xf86FindScreenForEntity(int entityIndex)
-{
- int i,j;
-
- if (entityIndex == -1) return NULL;
-
- if (xf86Screens) {
- for (i = 0; i < xf86NumScreens; i++) {
- for (j = 0; j < xf86Screens[i]->numEntities; j++) {
- if ( xf86Screens[i]->entityList[j] == entityIndex )
- return xf86Screens[i];
- }
- }
- }
- return NULL;
-}
-
-void
-xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex)
-{
- int i;
-
- for (i = 0; i < pScrn->numEntities; i++) {
- if (pScrn->entityList[i] == entityIndex) {
- for (i++; i < pScrn->numEntities; i++)
- pScrn->entityList[i-1] = pScrn->entityList[i];
- pScrn->numEntities--;
- xf86Entities[entityIndex]->inUse = FALSE;
- break;
- }
- }
-}
-
-/*
- * xf86ClearEntitiesForScreen() - called when a screen is deleted
- * to mark it's entities unused. Called by xf86DeleteScreen().
- */
-void
-xf86ClearEntityListForScreen(int scrnIndex)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- int i, entityIndex;
-
- if (pScrn->entityList == NULL || pScrn->numEntities == 0) return;
-
- for (i = 0; i < pScrn->numEntities; i++) {
- entityIndex = pScrn->entityList[i];
- xf86Entities[entityIndex]->inUse = FALSE;
- /* disable resource: call the disable function */
- }
- free(pScrn->entityList);
- free(pScrn->entityInstanceList);
- pScrn->entityList = NULL;
- pScrn->entityInstanceList = NULL;
-}
-
-/*
- * Add an extra device section (GDevPtr) to an entity.
- */
-
-void
-xf86AddDevToEntity(int entityIndex, GDevPtr dev)
-{
- EntityPtr pEnt;
-
- if (entityIndex >= xf86NumEntities)
- return;
-
- pEnt = xf86Entities[entityIndex];
- pEnt->numInstances++;
- pEnt->devices = xnfrealloc(pEnt->devices,
- pEnt->numInstances * sizeof(GDevPtr));
- pEnt->devices[pEnt->numInstances - 1] = dev;
- dev->claimed = TRUE;
-}
-
-/*
- * xf86GetEntityInfo() -- This function hands information from the
- * EntityRec struct to the drivers. The EntityRec structure itself
- * remains invisible to the driver.
- */
-EntityInfoPtr
-xf86GetEntityInfo(int entityIndex)
-{
- EntityInfoPtr pEnt;
- int i;
-
- if (entityIndex == -1)
- return NULL;
-
- if (entityIndex >= xf86NumEntities)
- return NULL;
-
- pEnt = xnfcalloc(1,sizeof(EntityInfoRec));
- pEnt->index = entityIndex;
- pEnt->location = xf86Entities[entityIndex]->bus;
- pEnt->active = xf86Entities[entityIndex]->active;
- pEnt->chipset = xf86Entities[entityIndex]->chipset;
- pEnt->driver = xf86Entities[entityIndex]->driver;
- if ( (xf86Entities[entityIndex]->devices) &&
- (xf86Entities[entityIndex]->devices[0]) ) {
- for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
- if (xf86Entities[entityIndex]->devices[i]->screen == 0)
- break;
- pEnt->device = xf86Entities[entityIndex]->devices[i];
- } else
- pEnt->device = NULL;
-
- return pEnt;
-}
-
-int
-xf86GetNumEntityInstances(int entityIndex)
-{
- if (entityIndex >= xf86NumEntities)
- return -1;
-
- return xf86Entities[entityIndex]->numInstances;
-}
-
-GDevPtr
-xf86GetDevFromEntity(int entityIndex, int instance)
-{
- int i;
-
- /* We might not use AddDevtoEntity */
- if ( (!xf86Entities[entityIndex]->devices) ||
- (!xf86Entities[entityIndex]->devices[0]) )
- return NULL;
-
- if (entityIndex >= xf86NumEntities ||
- instance >= xf86Entities[entityIndex]->numInstances)
- return NULL;
-
- for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++)
- if (xf86Entities[entityIndex]->devices[i]->screen == instance)
- break;
- return xf86Entities[entityIndex]->devices[i];
-}
-
-/*
- * xf86AccessEnter() -- gets called to save the text mode VGA IO
- * resources when reentering the server after a VT switch.
- */
-void
-xf86AccessEnter(void)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++)
- if (xf86Entities[i]->entityEnter)
- xf86Entities[i]->entityEnter(i,xf86Entities[i]->private);
-
- xf86EnterServerState(SETUP);
-}
-
-void
-xf86AccessLeave(void)
-{
- int i;
-
- for (i = 0; i < xf86NumEntities; i++)
- if (xf86Entities[i]->entityLeave)
- xf86Entities[i]->entityLeave(i,xf86Entities[i]->private);
-}
-
-/*
- * xf86EnterServerState() -- set state the server is in.
- */
-
-typedef enum { TRI_UNSET, TRI_TRUE, TRI_FALSE } TriState;
-
-void
-xf86EnterServerState(xf86State state)
-{
- static int sigio_state;
- static TriState sigio_blocked = TRI_UNSET;
-
- /*
- * This is a good place to block SIGIO during SETUP state. SIGIO should be
- * blocked in SETUP state otherwise (u)sleep() might get interrupted
- * early. We take care not to call xf86BlockSIGIO() twice.
- */
- if ((state == SETUP) && (sigio_blocked != TRI_TRUE)) {
- sigio_state = xf86BlockSIGIO();
- sigio_blocked = TRI_TRUE;
- } else if ((state == OPERATING) && (sigio_blocked != TRI_UNSET)) {
- xf86UnblockSIGIO(sigio_state);
- sigio_blocked = TRI_FALSE;
- }
-}
-
-/*
- * xf86PostProbe() -- Allocate all non conflicting resources
- * This function gets called by xf86Init().
- */
-void
-xf86PostProbe(void)
-{
- int i;
-
- if (fbSlotClaimed && (pciSlotClaimed
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- || sbusSlotClaimed
-#endif
- ))
- FatalError("Cannot run in framebuffer mode. Please specify busIDs "
- " for all framebuffer devices\n");
-
- for (i = 0; i < xf86NumEntities; i++)
- if (xf86Entities[i]->entityInit)
- xf86Entities[i]->entityInit(i,xf86Entities[i]->private);
-}
-
-void
-xf86PostScreenInit(void)
-{
- xf86VGAarbiterWrapFunctions();
- xf86EnterServerState(OPERATING);
-}
-
-int
-xf86GetLastScrnFlag(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- return xf86Entities[entityIndex]->lastScrnFlag;
- } else {
- return -1;
- }
-}
-
-void
-xf86SetLastScrnFlag(int entityIndex, int scrnIndex)
-{
- if(entityIndex < xf86NumEntities) {
- xf86Entities[entityIndex]->lastScrnFlag = scrnIndex;
- }
-}
-
-Bool
-xf86IsEntityShared(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-void
-xf86SetEntityShared(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- xf86Entities[entityIndex]->entityProp |= IS_SHARED_ACCEL;
- }
-}
-
-Bool
-xf86IsEntitySharable(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-void
-xf86SetEntitySharable(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- xf86Entities[entityIndex]->entityProp |= ACCEL_IS_SHARABLE;
- }
-}
-
-Bool
-xf86IsPrimInitDone(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- if(xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) {
- return TRUE;
- }
- }
- return FALSE;
-}
-
-void
-xf86SetPrimInitDone(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- xf86Entities[entityIndex]->entityProp |= SA_PRIM_INIT_DONE;
- }
-}
-
-void
-xf86ClearPrimInitDone(int entityIndex)
-{
- if(entityIndex < xf86NumEntities) {
- xf86Entities[entityIndex]->entityProp &= ~SA_PRIM_INIT_DONE;
- }
-}
-
-
-/*
- * Allocate a private in the entities.
- */
-
-int
-xf86AllocateEntityPrivateIndex(void)
-{
- int idx, i;
- EntityPtr pEnt;
- DevUnion *nprivs;
-
- idx = xf86EntityPrivateCount++;
- for (i = 0; i < xf86NumEntities; i++) {
- pEnt = xf86Entities[i];
- nprivs = xnfrealloc(pEnt->entityPrivates,
- xf86EntityPrivateCount * sizeof(DevUnion));
- /* Zero the new private */
- memset(&nprivs[idx], 0, sizeof(DevUnion));
- pEnt->entityPrivates = nprivs;
- }
- return idx;
-}
-
-DevUnion *
-xf86GetEntityPrivate(int entityIndex, int privIndex)
-{
- if (entityIndex >= xf86NumEntities || privIndex >= xf86EntityPrivateCount)
- return NULL;
-
- return &(xf86Entities[entityIndex]->entityPrivates[privIndex]);
-}
-
+/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains the interfaces to the bus-specific code + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <ctype.h> +#include <stdlib.h> +#include <unistd.h> +#include <X11/X.h> +#include "os.h" +#include "xf86.h" +#include "xf86Priv.h" + +/* Bus-specific headers */ + +#include "xf86Bus.h" + +#define XF86_OS_PRIVS +#include "xf86_OSproc.h" +#include "xf86VGAarbiter.h" + +/* Entity data */ +EntityPtr *xf86Entities = NULL; /* Bus slots claimed by drivers */ +int xf86NumEntities = 0; +static int xf86EntityPrivateCount = 0; + +BusRec primaryBus = { BUS_NONE, { 0 } }; + +/** + * Call the driver's correct probe function. + * + * If the driver implements the \c DriverRec::PciProbe entry-point and an + * appropriate PCI device (with matching Device section in the xorg.conf file) + * is found, it is called. If \c DriverRec::PciProbe or no devices can be + * successfully probed with it (e.g., only non-PCI devices are available), + * the driver's \c DriverRec::Probe function is called. + * + * \param drv Driver to probe + * + * \return + * If a device can be successfully probed by the driver, \c TRUE is + * returned. Otherwise, \c FALSE is returned. + */ +Bool +xf86CallDriverProbe( DriverPtr drv, Bool detect_only ) +{ + Bool foundScreen = FALSE; + + if (drv->PciProbe != NULL) { + if (xf86DoConfigure && xf86DoConfigurePass1) { + assert(detect_only); + foundScreen = xf86PciAddMatchingDev(drv); + } + else { + assert(! detect_only); + foundScreen = xf86PciProbeDev(drv); + } + } + + if (!foundScreen && (drv->Probe != NULL)) { + xf86Msg( X_WARNING, "Falling back to old probe method for %s\n", + drv->driverName); + foundScreen = (*drv->Probe)(drv, (detect_only) ? PROBE_DETECT + : PROBE_DEFAULT); + } + + return foundScreen; +} + +/** + * @return TRUE if all buses are configured and set up correctly and FALSE + * otherwise. + */ +Bool +xf86BusConfig(void) +{ + screenLayoutPtr layout; + int i, j; + + /* Enable full I/O access */ + if (xorgHWAccess) + xorgHWAccess = xf86EnableIO(); + + /* + * Now call each of the Probe functions. Each successful probe will + * result in an extra entry added to the xf86Screens[] list for each + * instance of the hardware found. + */ + for (i = 0; i < xf86NumDrivers; i++) { + xorgHWFlags flags; + if (!xorgHWAccess) { + if (!xf86DriverList[i]->driverFunc + || !xf86DriverList[i]->driverFunc(NULL, + GET_REQUIRED_HW_INTERFACES, + &flags) + || NEED_IO_ENABLED(flags)) + continue; + } + + xf86CallDriverProbe(xf86DriverList[i], FALSE); + } + + /* If nothing was detected, return now */ + if (xf86NumScreens == 0) { + xf86Msg(X_ERROR, "No devices detected.\n"); + return FALSE; + } + + xf86VGAarbiterInit(); + + /* + * Match up the screens found by the probes against those specified + * in the config file. Remove the ones that won't be used. Sort + * them in the order specified. + * + * What is the best way to do this? + * + * For now, go through the screens allocated by the probes, and + * look for screen config entry which refers to the same device + * section as picked out by the probe. + * + */ + for (i = 0; i < xf86NumScreens; i++) { + for (layout = xf86ConfigLayout.screens; layout->screen != NULL; + layout++) { + Bool found = FALSE; + for (j = 0; j < xf86Screens[i]->numEntities; j++) { + + GDevPtr dev = xf86GetDevFromEntity( + xf86Screens[i]->entityList[j], + xf86Screens[i]->entityInstanceList[j]); + if (dev == layout->screen->device) { + /* A match has been found */ + xf86Screens[i]->confScreen = layout->screen; + found = TRUE; + break; + } + } + if (found) break; + } + if (layout->screen == NULL) { + /* No match found */ + xf86Msg(X_ERROR, + "Screen %d deleted because of no matching config section.\n", i); + xf86DeleteScreen(i--, 0); + } + } + + /* If no screens left, return now. */ + if (xf86NumScreens == 0) { + xf86Msg(X_ERROR, + "Device(s) detected, but none match those in the config file.\n"); + return FALSE; + } + + return TRUE; +} + +/* + * Call the bus probes relevant to the architecture. + * + * The only one available so far is for PCI and SBUS. + */ + +void +xf86BusProbe(void) +{ + xf86PciProbe(); +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) + xf86SbusProbe(); +#endif +} + +/* + * Determine what bus type the busID string represents. The start of the + * bus-dependent part of the string is returned as retID. + */ + +BusType +StringToBusType(const char* busID, const char **retID) +{ + char *p, *s; + BusType ret = BUS_NONE; + + /* If no type field, Default to PCI */ + if (isdigit(busID[0])) { + if (retID) + *retID = busID; + return BUS_PCI; + } + + s = xstrdup(busID); + p = strtok(s, ":"); + if (p == NULL || *p == 0) { + free(s); + return BUS_NONE; + } + if (!xf86NameCmp(p, "pci") || !xf86NameCmp(p, "agp")) + ret = BUS_PCI; + if (!xf86NameCmp(p, "sbus")) + ret = BUS_SBUS; + if (ret != BUS_NONE) + if (retID) + *retID = busID + strlen(p) + 1; + free(s); + return ret; +} + +int +xf86AllocateEntity(void) +{ + xf86NumEntities++; + xf86Entities = xnfrealloc(xf86Entities, + sizeof(EntityPtr) * xf86NumEntities); + xf86Entities[xf86NumEntities - 1] = xnfcalloc(1,sizeof(EntityRec)); + xf86Entities[xf86NumEntities - 1]->entityPrivates = + xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1); + return xf86NumEntities - 1; +} + +Bool +xf86IsEntityPrimary(int entityIndex) +{ + EntityPtr pEnt = xf86Entities[entityIndex]; + + if (primaryBus.type != pEnt->bus.type) return FALSE; + + switch (pEnt->bus.type) { + case BUS_PCI: + return pEnt->bus.id.pci == primaryBus.id.pci; + case BUS_SBUS: + return pEnt->bus.id.sbus.fbNum == primaryBus.id.sbus.fbNum; + default: + return FALSE; + } +} + +Bool +xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter, + EntityProc leave, pointer private) +{ + if (entityIndex >= xf86NumEntities) + return FALSE; + xf86Entities[entityIndex]->entityInit = init; + xf86Entities[entityIndex]->entityEnter = enter; + xf86Entities[entityIndex]->entityLeave = leave; + xf86Entities[entityIndex]->private = private; + return TRUE; +} + +Bool +xf86DriverHasEntities(DriverPtr drvp) +{ + int i; + for (i = 0; i < xf86NumEntities; i++) { + if (xf86Entities[i]->driver == drvp) + return TRUE; + } + return FALSE; +} + +void +xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex) +{ + if (entityIndex == -1) + return; + if (xf86Entities[entityIndex]->inUse && + !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL)) { + ErrorF("Requested Entity already in use!\n"); + return; + } + + pScrn->numEntities++; + pScrn->entityList = xnfrealloc(pScrn->entityList, + pScrn->numEntities * sizeof(int)); + pScrn->entityList[pScrn->numEntities - 1] = entityIndex; + xf86Entities[entityIndex]->inUse = TRUE; + pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList, + pScrn->numEntities * sizeof(int)); + pScrn->entityInstanceList[pScrn->numEntities - 1] = 0; + pScrn->domainIOBase = xf86Entities[entityIndex]->domainIO; +} + +void +xf86SetEntityInstanceForScreen(ScrnInfoPtr pScrn, int entityIndex, int instance) +{ + int i; + + if (entityIndex == -1 || entityIndex >= xf86NumEntities) + return; + + for (i = 0; i < pScrn->numEntities; i++) { + if (pScrn->entityList[i] == entityIndex) { + pScrn->entityInstanceList[i] = instance; + break; + } + } +} + +/* + * XXX This needs to be updated for the case where a single entity may have + * instances associated with more than one screen. + */ +ScrnInfoPtr +xf86FindScreenForEntity(int entityIndex) +{ + int i,j; + + if (entityIndex == -1) return NULL; + + if (xf86Screens) { + for (i = 0; i < xf86NumScreens; i++) { + for (j = 0; j < xf86Screens[i]->numEntities; j++) { + if ( xf86Screens[i]->entityList[j] == entityIndex ) + return xf86Screens[i]; + } + } + } + return NULL; +} + +void +xf86RemoveEntityFromScreen(ScrnInfoPtr pScrn, int entityIndex) +{ + int i; + + for (i = 0; i < pScrn->numEntities; i++) { + if (pScrn->entityList[i] == entityIndex) { + for (i++; i < pScrn->numEntities; i++) + pScrn->entityList[i-1] = pScrn->entityList[i]; + pScrn->numEntities--; + xf86Entities[entityIndex]->inUse = FALSE; + break; + } + } +} + +/* + * xf86ClearEntitiesForScreen() - called when a screen is deleted + * to mark it's entities unused. Called by xf86DeleteScreen(). + */ +void +xf86ClearEntityListForScreen(int scrnIndex) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + int i, entityIndex; + + if (pScrn->entityList == NULL || pScrn->numEntities == 0) return; + + for (i = 0; i < pScrn->numEntities; i++) { + entityIndex = pScrn->entityList[i]; + xf86Entities[entityIndex]->inUse = FALSE; + /* disable resource: call the disable function */ + } + free(pScrn->entityList); + free(pScrn->entityInstanceList); + pScrn->entityList = NULL; + pScrn->entityInstanceList = NULL; +} + +/* + * Add an extra device section (GDevPtr) to an entity. + */ + +void +xf86AddDevToEntity(int entityIndex, GDevPtr dev) +{ + EntityPtr pEnt; + + if (entityIndex >= xf86NumEntities) + return; + + pEnt = xf86Entities[entityIndex]; + pEnt->numInstances++; + pEnt->devices = xnfrealloc(pEnt->devices, + pEnt->numInstances * sizeof(GDevPtr)); + pEnt->devices[pEnt->numInstances - 1] = dev; + dev->claimed = TRUE; +} + +/* + * xf86GetEntityInfo() -- This function hands information from the + * EntityRec struct to the drivers. The EntityRec structure itself + * remains invisible to the driver. + */ +EntityInfoPtr +xf86GetEntityInfo(int entityIndex) +{ + EntityInfoPtr pEnt; + int i; + + if (entityIndex == -1) + return NULL; + + if (entityIndex >= xf86NumEntities) + return NULL; + + pEnt = xnfcalloc(1,sizeof(EntityInfoRec)); + pEnt->index = entityIndex; + pEnt->location = xf86Entities[entityIndex]->bus; + pEnt->active = xf86Entities[entityIndex]->active; + pEnt->chipset = xf86Entities[entityIndex]->chipset; + pEnt->driver = xf86Entities[entityIndex]->driver; + if ( (xf86Entities[entityIndex]->devices) && + (xf86Entities[entityIndex]->devices[0]) ) { + for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++) + if (xf86Entities[entityIndex]->devices[i]->screen == 0) + break; + pEnt->device = xf86Entities[entityIndex]->devices[i]; + } else + pEnt->device = NULL; + + return pEnt; +} + +int +xf86GetNumEntityInstances(int entityIndex) +{ + if (entityIndex >= xf86NumEntities) + return -1; + + return xf86Entities[entityIndex]->numInstances; +} + +GDevPtr +xf86GetDevFromEntity(int entityIndex, int instance) +{ + int i; + + /* We might not use AddDevtoEntity */ + if ( (!xf86Entities[entityIndex]->devices) || + (!xf86Entities[entityIndex]->devices[0]) ) + return NULL; + + if (entityIndex >= xf86NumEntities || + instance >= xf86Entities[entityIndex]->numInstances) + return NULL; + + for (i = 0; i < xf86Entities[entityIndex]->numInstances; i++) + if (xf86Entities[entityIndex]->devices[i]->screen == instance) + break; + return xf86Entities[entityIndex]->devices[i]; +} + +/* + * xf86AccessEnter() -- gets called to save the text mode VGA IO + * resources when reentering the server after a VT switch. + */ +void +xf86AccessEnter(void) +{ + int i; + + for (i = 0; i < xf86NumEntities; i++) + if (xf86Entities[i]->entityEnter) + xf86Entities[i]->entityEnter(i,xf86Entities[i]->private); +} + +void +xf86AccessLeave(void) +{ + int i; + + for (i = 0; i < xf86NumEntities; i++) + if (xf86Entities[i]->entityLeave) + xf86Entities[i]->entityLeave(i,xf86Entities[i]->private); +} + +/* + * xf86PostProbe() -- Allocate all non conflicting resources + * This function gets called by xf86Init(). + */ +void +xf86PostProbe(void) +{ + int i; + + if (fbSlotClaimed && (pciSlotClaimed +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) + || sbusSlotClaimed +#endif + )) + FatalError("Cannot run in framebuffer mode. Please specify busIDs " + " for all framebuffer devices\n"); + + for (i = 0; i < xf86NumEntities; i++) + if (xf86Entities[i]->entityInit) + xf86Entities[i]->entityInit(i,xf86Entities[i]->private); +} + +int +xf86GetLastScrnFlag(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + return xf86Entities[entityIndex]->lastScrnFlag; + } else { + return -1; + } +} + +void +xf86SetLastScrnFlag(int entityIndex, int scrnIndex) +{ + if(entityIndex < xf86NumEntities) { + xf86Entities[entityIndex]->lastScrnFlag = scrnIndex; + } +} + +Bool +xf86IsEntityShared(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + if(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) { + return TRUE; + } + } + return FALSE; +} + +void +xf86SetEntityShared(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + xf86Entities[entityIndex]->entityProp |= IS_SHARED_ACCEL; + } +} + +Bool +xf86IsEntitySharable(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + if(xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) { + return TRUE; + } + } + return FALSE; +} + +void +xf86SetEntitySharable(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + xf86Entities[entityIndex]->entityProp |= ACCEL_IS_SHARABLE; + } +} + +Bool +xf86IsPrimInitDone(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + if(xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) { + return TRUE; + } + } + return FALSE; +} + +void +xf86SetPrimInitDone(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + xf86Entities[entityIndex]->entityProp |= SA_PRIM_INIT_DONE; + } +} + +void +xf86ClearPrimInitDone(int entityIndex) +{ + if(entityIndex < xf86NumEntities) { + xf86Entities[entityIndex]->entityProp &= ~SA_PRIM_INIT_DONE; + } +} + + +/* + * Allocate a private in the entities. + */ + +int +xf86AllocateEntityPrivateIndex(void) +{ + int idx, i; + EntityPtr pEnt; + DevUnion *nprivs; + + idx = xf86EntityPrivateCount++; + for (i = 0; i < xf86NumEntities; i++) { + pEnt = xf86Entities[i]; + nprivs = xnfrealloc(pEnt->entityPrivates, + xf86EntityPrivateCount * sizeof(DevUnion)); + /* Zero the new private */ + memset(&nprivs[idx], 0, sizeof(DevUnion)); + pEnt->entityPrivates = nprivs; + } + return idx; +} + +DevUnion * +xf86GetEntityPrivate(int entityIndex, int privIndex) +{ + if (entityIndex >= xf86NumEntities || privIndex >= xf86EntityPrivateCount) + return NULL; + + return &(xf86Entities[entityIndex]->entityPrivates[privIndex]); +} + diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c index c106f3754..883c48cc0 100644 --- a/xorg-server/hw/xfree86/common/xf86Configure.c +++ b/xorg-server/hw/xfree86/common/xf86Configure.c @@ -1,784 +1,765 @@ -/*
- * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales.
- *
- * 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 Alan Hourihane not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Alan Hourihane makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Alan Hourihane, alanh@fairlite.demon.co.uk
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "xf86.h"
-#include "xf86Config.h"
-#include "xf86_OSlib.h"
-#include "xf86Priv.h"
-#define IN_XSERVER
-#include "Configint.h"
-#include "xf86DDC.h"
-#include "xf86pciBus.h"
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
-#include "xf86Bus.h"
-#include "xf86Sbus.h"
-#endif
-
-typedef struct _DevToConfig {
- GDevRec GDev;
- struct pci_device * pVideo;
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- sbusDevicePtr sVideo;
-#endif
- int iDriver;
-} DevToConfigRec, *DevToConfigPtr;
-
-static DevToConfigPtr DevToConfig = NULL;
-static int nDevToConfig = 0, CurrentDriver;
-
-xf86MonPtr ConfiguredMonitor;
-Bool xf86DoConfigurePass1 = TRUE;
-static Bool foundMouse = FALSE;
-
-#if defined(__SCO__)
-static char *DFLT_MOUSE_PROTO = "OSMouse";
-#elif defined(__UNIXWARE__)
-static char *DFLT_MOUSE_PROTO = "OSMouse";
-static char *DFLT_MOUSE_DEV = "/dev/mouse";
-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
-static char *DFLT_MOUSE_DEV = "/dev/sysmouse";
-static char *DFLT_MOUSE_PROTO = "auto";
-#elif defined(linux)
-static char DFLT_MOUSE_DEV[] = "/dev/input/mice";
-static char DFLT_MOUSE_PROTO[] = "auto";
-#else
-static char *DFLT_MOUSE_DEV = "/dev/mouse";
-static char *DFLT_MOUSE_PROTO = "auto";
-#endif
-
-/*
- * This is called by the driver, either through xf86Match???Instances() or
- * directly. We allocate a GDevRec and fill it in as much as we can, letting
- * the caller fill in the rest and/or change it as it sees fit.
- */
-GDevPtr
-xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset)
-{
- int ret, i, j;
-
- if (!xf86DoConfigure || !xf86DoConfigurePass1)
- return NULL;
-
- /* Check for duplicates */
- for (i = 0; i < nDevToConfig; i++) {
- switch (bus) {
- case BUS_PCI:
- ret = xf86PciConfigure(busData, DevToConfig[i].pVideo);
- break;
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- case BUS_SBUS:
- ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo);
- break;
-#endif
- default:
- return NULL;
- }
- if (ret == 0)
- goto out;
- }
-
- /* Allocate new structure occurrence */
- i = nDevToConfig++;
- DevToConfig =
- xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
- memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
-
- DevToConfig[i].GDev.chipID =
- DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1;
-
- DevToConfig[i].iDriver = CurrentDriver;
-
- /* Fill in what we know, converting the driver name to lower case */
- DevToConfig[i].GDev.driver = xnfalloc(strlen(driver) + 1);
- for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++);
-
- switch (bus) {
- case BUS_PCI:
- xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo,
- &DevToConfig[i].GDev, &chipset);
- break;
-#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__)
- case BUS_SBUS:
- xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo,
- &DevToConfig[i].GDev);
- break;
-#endif
- default:
- break;
- }
-
- /* Get driver's available options */
- if (xf86DriverList[CurrentDriver]->AvailableOptions)
- DevToConfig[i].GDev.options = (OptionInfoPtr)
- (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset,
- bus);
-
- return &DevToConfig[i].GDev;
-
-out:
- return NULL;
-}
-
-static XF86ConfInputPtr
-configureInputSection (void)
-{
- XF86ConfInputPtr mouse = NULL;
- parsePrologue (XF86ConfInputPtr, XF86ConfInputRec)
-
- ptr->inp_identifier = "Keyboard0";
- ptr->inp_driver = "kbd";
- ptr->list.next = NULL;
-
- /* Crude mechanism to auto-detect mouse (os dependent) */
- {
- int fd;
-#ifdef WSCONS_SUPPORT
- fd = open("/dev/wsmouse", 0);
- if (fd >= 0) {
- DFLT_MOUSE_DEV = "/dev/wsmouse";
- DFLT_MOUSE_PROTO = "wsmouse";
- close(fd);
- } else {
- ErrorF("cannot open /dev/wsmouse\n");
- }
-#endif
-
-#ifndef __SCO__
- fd = open(DFLT_MOUSE_DEV, 0);
- if (fd != -1) {
- foundMouse = TRUE;
- close(fd);
- }
-#else
- foundMouse = TRUE;
-#endif
- }
-
- mouse = calloc(1, sizeof(XF86ConfInputRec));
- mouse->inp_identifier = "Mouse0";
- mouse->inp_driver = "mouse";
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("Protocol"),
- strdup(DFLT_MOUSE_PROTO));
-#ifndef __SCO__
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("Device"),
- strdup(DFLT_MOUSE_DEV));
-#endif
- mouse->inp_option_lst =
- xf86addNewOption(mouse->inp_option_lst, strdup("ZAxisMapping"),
- strdup("4 5 6 7"));
- ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
- return ptr;
-}
-
-static XF86ConfScreenPtr
-configureScreenSection (int screennum)
-{
- int i;
- int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ };
- parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec)
-
- XNFasprintf(&ptr->scrn_identifier, "Screen%d", screennum);
- XNFasprintf(&ptr->scrn_monitor_str, "Monitor%d", screennum);
- XNFasprintf(&ptr->scrn_device_str, "Card%d", screennum);
-
- for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++)
- {
- XF86ConfDisplayPtr display;
-
- display = calloc(1, sizeof(XF86ConfDisplayRec));
- display->disp_depth = depths[i];
- display->disp_black.red = display->disp_white.red = -1;
- display->disp_black.green = display->disp_white.green = -1;
- display->disp_black.blue = display->disp_white.blue = -1;
- ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem(
- (glp)ptr->scrn_display_lst, (glp)display);
- }
-
- return ptr;
-}
-
-static const char*
-optionTypeToString(OptionValueType type)
-{
- switch (type) {
- case OPTV_NONE:
- return "";
- case OPTV_INTEGER:
- return "<i>";
- case OPTV_STRING:
- return "<str>";
- case OPTV_ANYSTR:
- return "[<str>]";
- case OPTV_REAL:
- return "<f>";
- case OPTV_BOOLEAN:
- return "[<bool>]";
- case OPTV_FREQ:
- return "<freq>";
- case OPTV_PERCENT:
- return "<percent>";
- default:
- return "";
- }
-}
-
-static XF86ConfDevicePtr
-configureDeviceSection (int screennum)
-{
- OptionInfoPtr p;
- int i = 0;
- parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
-
- /* Move device info to parser structure */
- if (asprintf(&ptr->dev_identifier, "Card%d", screennum) == -1)
- ptr->dev_identifier = NULL;
- ptr->dev_chipset = DevToConfig[screennum].GDev.chipset;
- ptr->dev_busid = DevToConfig[screennum].GDev.busID;
- ptr->dev_driver = DevToConfig[screennum].GDev.driver;
- ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac;
- for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++)
- ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i];
- ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam;
- ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq;
- ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase;
- ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase;
- ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase;
- ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip;
- for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks); i++)
- ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i];
- ptr->dev_clocks = i;
- ptr->dev_chipid = DevToConfig[screennum].GDev.chipID;
- ptr->dev_chiprev = DevToConfig[screennum].GDev.chipRev;
- ptr->dev_irq = DevToConfig[screennum].GDev.irq;
-
- /* Make sure older drivers don't segv */
- if (DevToConfig[screennum].GDev.options) {
- /* Fill in the available driver options for people to use */
- const char *descrip =
- " ### Available Driver options are:-\n"
- " ### Values: <i>: integer, <f>: float, "
- "<bool>: \"True\"/\"False\",\n"
- " ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n"
- " ### <percent>: \"<f>%\"\n"
- " ### [arg]: arg optional\n";
- ptr->dev_comment = strdup(descrip);
- if (ptr->dev_comment) {
- for (p = DevToConfig[screennum].GDev.options;
- p->name != NULL; p++) {
- char *p_e;
- const char *prefix = " #Option ";
- const char *middle = " \t# ";
- const char *suffix = "\n";
- const char *opttype = optionTypeToString(p->type);
- char *optname;
- int len = strlen(ptr->dev_comment) + strlen(prefix) +
- strlen(middle) + strlen(suffix) + 1;
-
- if (asprintf(&optname, "\"%s\"", p->name) == -1)
- break;
-
- len += max(20, strlen(optname));
- len += strlen(opttype);
-
- ptr->dev_comment = realloc(ptr->dev_comment, len);
- if (!ptr->dev_comment)
- break;
- p_e = ptr->dev_comment + strlen(ptr->dev_comment);
- sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle,
- opttype, suffix);
- free(optname);
- }
- }
- }
-
- return ptr;
-}
-
-static XF86ConfLayoutPtr
-configureLayoutSection (void)
-{
- int scrnum = 0;
- parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec)
-
- ptr->lay_identifier = "X.org Configured";
-
- {
- XF86ConfInputrefPtr iptr;
-
- iptr = malloc (sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- iptr->iref_inputdev_str = "Mouse0";
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, strdup("CorePointer"), NULL);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
- }
-
- {
- XF86ConfInputrefPtr iptr;
-
- iptr = malloc (sizeof (XF86ConfInputrefRec));
- iptr->list.next = NULL;
- iptr->iref_option_lst = NULL;
- iptr->iref_inputdev_str = "Keyboard0";
- iptr->iref_option_lst =
- xf86addNewOption (iptr->iref_option_lst, strdup("CoreKeyboard"), NULL);
- ptr->lay_input_lst = (XF86ConfInputrefPtr)
- xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
- }
-
- for (scrnum = 0; scrnum < nDevToConfig; scrnum++) {
- XF86ConfAdjacencyPtr aptr;
-
- aptr = malloc (sizeof (XF86ConfAdjacencyRec));
- aptr->list.next = NULL;
- aptr->adj_x = 0;
- aptr->adj_y = 0;
- aptr->adj_scrnum = scrnum;
- XNFasprintf(&aptr->adj_screen_str, "Screen%d", scrnum);
- if (scrnum == 0) {
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
- aptr->adj_refscreen = NULL;
- }
- else {
- aptr->adj_where = CONF_ADJ_RIGHTOF;
- XNFasprintf(&aptr->adj_refscreen, "Screen%d", scrnum - 1);
- }
- ptr->lay_adjacency_lst =
- (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst,
- (glp)aptr);
- }
-
- return ptr;
-}
-
-static XF86ConfFlagsPtr
-configureFlagsSection (void)
-{
- parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec)
-
- return ptr;
-}
-
-static XF86ConfModulePtr
-configureModuleSection (void)
-{
- char **elist, **el;
- /* Find the list of extension & font modules. */
- const char *esubdirs[] = {
- "extensions",
- "fonts",
- NULL
- };
- parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec)
-
- elist = LoaderListDirs(esubdirs, NULL);
- if (elist) {
- for (el = elist; *el; el++) {
- XF86LoadPtr module;
-
- module = calloc(1, sizeof(XF86LoadRec));
- module->load_name = *el;
- ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem(
- (glp)ptr->mod_load_lst, (glp)module);
- }
- free(elist);
- }
-
- return ptr;
-}
-
-static XF86ConfFilesPtr
-configureFilesSection (void)
-{
- parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
-
- if (xf86ModulePath)
- ptr->file_modulepath = strdup(xf86ModulePath);
- if (defaultFontPath)
- ptr->file_fontpath = strdup(defaultFontPath);
-
- return ptr;
-}
-
-static XF86ConfMonitorPtr
-configureMonitorSection (int screennum)
-{
- parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
-
- XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
- ptr->mon_vendor = strdup("Monitor Vendor");
- ptr->mon_modelname = strdup("Monitor Model");
-
- return ptr;
-}
-
-/* Initialize Configure Monitor from Detailed Timing Block */
-static void handle_detailed_input(struct detailed_monitor_section *det_mon,
- void *data)
-{
- XF86ConfMonitorPtr ptr = (XF86ConfMonitorPtr) data;
-
- switch (det_mon->type) {
- case DS_NAME:
- ptr->mon_modelname = realloc(ptr->mon_modelname,
- strlen((char*)(det_mon->section.name)) +
- 1);
- strcpy(ptr->mon_modelname,
- (char*)(det_mon->section.name));
- break;
- case DS_RANGES:
- ptr->mon_hsync[ptr->mon_n_hsync].lo =
- det_mon->section.ranges.min_h;
- ptr->mon_hsync[ptr->mon_n_hsync].hi =
- det_mon->section.ranges.max_h;
- ptr->mon_n_vrefresh = 1;
- ptr->mon_vrefresh[ptr->mon_n_hsync].lo =
- det_mon->section.ranges.min_v;
- ptr->mon_vrefresh[ptr->mon_n_hsync].hi =
- det_mon->section.ranges.max_v;
- ptr->mon_n_hsync++;
- default:
- break;
- }
-}
-
-static XF86ConfMonitorPtr
-configureDDCMonitorSection (int screennum)
-{
- int len, mon_width, mon_height;
-#define displaySizeMaxLen 80
- char displaySize_string[displaySizeMaxLen];
- int displaySizeLen;
-
- parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec)
-
- XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum);
- ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name);
- XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id);
-
- /* features in centimetres, we want millimetres */
- mon_width = 10 * ConfiguredMonitor->features.hsize ;
- mon_height = 10 * ConfiguredMonitor->features.vsize ;
-
-#ifdef CONFIGURE_DISPLAYSIZE
- ptr->mon_width = mon_width;
- ptr->mon_height = mon_height;
-#else
- if (mon_width && mon_height) {
- /* when values available add DisplaySize option AS A COMMENT */
-
- displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen,
- "\t#DisplaySize\t%5d %5d\t# mm\n",
- mon_width, mon_height);
-
- if (displaySizeLen>0 && displaySizeLen<displaySizeMaxLen) {
- if (ptr->mon_comment) {
- len = strlen(ptr->mon_comment);
- } else {
- len = 0;
- }
- if ((ptr->mon_comment =
- realloc(ptr->mon_comment, len + strlen(displaySize_string) + 1))) {
- strcpy(ptr->mon_comment + len, displaySize_string);
- }
- }
- }
-#endif /* def CONFIGURE_DISPLAYSIZE */
-
- xf86ForEachDetailedBlock(ConfiguredMonitor, handle_detailed_input,
- ptr);
-
- if (ConfiguredMonitor->features.dpms) {
- ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, strdup("DPMS"), NULL);
- }
-
- return ptr;
-}
-
-#if !defined(PATH_MAX)
-# define PATH_MAX 1024
-#endif
-
-void
-DoConfigure(void)
-{
- int i,j, screennum = -1;
- char *home = NULL;
- char filename[PATH_MAX];
- char *addslash = "";
- XF86ConfigPtr xf86config = NULL;
- char **vlist, **vl;
- int *dev2screen;
-
- vlist = xf86DriverlistFromCompile();
-
- if (!vlist) {
- ErrorF("Missing output drivers. Configuration failed.\n");
- goto bail;
- }
-
- ErrorF("List of video drivers:\n");
- for (vl = vlist; *vl; vl++)
- ErrorF("\t%s\n", *vl);
-
- /* Load all the drivers that were found. */
- xf86LoadModules(vlist, NULL);
-
- free(vlist);
-
- for (i = 0; i < xf86NumDrivers; i++) {
- xorgHWFlags flags;
- if (!xf86DriverList[i]->driverFunc
- || !xf86DriverList[i]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags)
- || NEED_IO_ENABLED(flags)) {
- xorgHWAccess = TRUE;
- break;
- }
- }
- /* Enable full I/O access */
- if (xorgHWAccess) {
- if(!xf86EnableIO())
- /* oops, we have failed */
- xorgHWAccess = FALSE;
- }
-
- /* Create XF86Config file structure */
- xf86config = calloc(1, sizeof(XF86ConfigRec));
-
- /* Call all of the probe functions, reporting the results. */
- for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) {
- xorgHWFlags flags;
- Bool found_screen;
- DriverRec * const drv = xf86DriverList[CurrentDriver];
-
- if (!xorgHWAccess) {
- if (!drv->driverFunc
- || !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags )
- || NEED_IO_ENABLED(flags))
- continue;
- }
-
- found_screen = xf86CallDriverProbe( drv, TRUE );
- if ( found_screen && drv->Identify ) {
- (*drv->Identify)(0);
- }
- }
-
- if (nDevToConfig <= 0) {
- ErrorF("No devices to configure. Configuration failed.\n");
- goto bail;
- }
-
- /* Add device, monitor and screen sections for detected devices */
- for (screennum = 0; screennum < nDevToConfig; screennum++) {
- XF86ConfDevicePtr DevicePtr;
- XF86ConfMonitorPtr MonitorPtr;
- XF86ConfScreenPtr ScreenPtr;
-
- DevicePtr = configureDeviceSection(screennum);
- xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem(
- (glp)xf86config->conf_device_lst, (glp)DevicePtr);
- MonitorPtr = configureMonitorSection(screennum);
- xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
- (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
- ScreenPtr = configureScreenSection(screennum);
- xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
- (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
- }
-
- xf86config->conf_files = configureFilesSection();
- xf86config->conf_modules = configureModuleSection();
- xf86config->conf_flags = configureFlagsSection();
- xf86config->conf_videoadaptor_lst = NULL;
- xf86config->conf_modes_lst = NULL;
- xf86config->conf_vendor_lst = NULL;
- xf86config->conf_dri = NULL;
- xf86config->conf_input_lst = configureInputSection();
- xf86config->conf_layout_lst = configureLayoutSection();
-
- home = getenv("HOME");
- if ((home == NULL) || (home[0] == '\0')) {
- home = "/";
- } else {
- /* Determine if trailing slash is present or needed */
- int l = strlen(home);
-
- if (home[l-1] != '/') {
- addslash = "/";
- }
- }
-
- snprintf(filename, sizeof(filename), "%s%s" XF86CONFIGFILE ".new",
- home, addslash);
-
- if (xf86writeConfigFile(filename, xf86config) == 0) {
- xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
- filename, strerror(errno));
- goto bail;
- }
-
- xf86DoConfigurePass1 = FALSE;
- /* Try to get DDC information filled in */
- xf86ConfigFile = filename;
- if (xf86HandleConfigFile(FALSE) != CONFIG_OK) {
- goto bail;
- }
-
- xf86DoConfigurePass1 = FALSE;
-
- dev2screen = xnfcalloc(1,xf86NumDrivers*sizeof(int));
-
- {
- Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool));
- for (screennum = 0; screennum < nDevToConfig; screennum++) {
- int k,l,n,oldNumScreens;
-
- i = DevToConfig[screennum].iDriver;
-
- if (driverProbed[i]) continue;
- driverProbed[i] = TRUE;
-
- oldNumScreens = xf86NumScreens;
-
- xf86CallDriverProbe( xf86DriverList[i], FALSE );
-
- /* reorder */
- k = screennum > 0 ? screennum : 1;
- for (l = oldNumScreens; l < xf86NumScreens; l++) {
- /* is screen primary? */
- Bool primary = FALSE;
- for (n = 0; n<xf86Screens[l]->numEntities; n++) {
- if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) {
- dev2screen[0] = l;
- primary = TRUE;
- break;
- }
- }
- if (primary) continue;
- /* not primary: assign it to next device of same driver */
- /*
- * NOTE: we assume that devices in DevToConfig
- * and xf86Screens[] have the same order except
- * for the primary device which always comes first.
- */
- for (; k < nDevToConfig; k++) {
- if (DevToConfig[k].iDriver == i) {
- dev2screen[k++] = l;
- break;
- }
- }
- }
- }
- free(driverProbed);
- }
-
-
- if (nDevToConfig != xf86NumScreens) {
- ErrorF("Number of created screens does not match number of detected"
- " devices.\n Configuration failed.\n");
- goto bail;
- }
-
- xf86PostProbe();
-
- for (j = 0; j < xf86NumScreens; j++) {
- xf86Screens[j]->scrnIndex = j;
- }
-
- xf86freeMonitorList(xf86config->conf_monitor_lst);
- xf86config->conf_monitor_lst = NULL;
- xf86freeScreenList(xf86config->conf_screen_lst);
- xf86config->conf_screen_lst = NULL;
- for (j = 0; j < xf86NumScreens; j++) {
- XF86ConfMonitorPtr MonitorPtr;
- XF86ConfScreenPtr ScreenPtr;
-
- ConfiguredMonitor = NULL;
-
- if ((*xf86Screens[dev2screen[j]]->PreInit)(xf86Screens[dev2screen[j]],
- PROBE_DETECT) &&
- ConfiguredMonitor) {
- MonitorPtr = configureDDCMonitorSection(j);
- } else {
- MonitorPtr = configureMonitorSection(j);
- }
- ScreenPtr = configureScreenSection(j);
- xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem(
- (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr);
- xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem(
- (glp)xf86config->conf_screen_lst, (glp)ScreenPtr);
- }
-
- if (xf86writeConfigFile(filename, xf86config) == 0) {
- xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n",
- filename, strerror(errno));
- goto bail;
- }
-
- ErrorF("\n");
-
-#ifdef __SCO__
- ErrorF("\n"__XSERVERNAME__
- " is using the kernel event driver to access the mouse.\n"
- "If you wish to use the internal "__XSERVERNAME__
- " mouse drivers, please\n"
- "edit the file and correct the Device.\n");
-#else /* !__SCO__ */
- if (!foundMouse) {
- ErrorF("\n"__XSERVERNAME__" is not able to detect your mouse.\n"
- "Edit the file and correct the Device.\n");
- } else {
- ErrorF("\n"__XSERVERNAME__" detected your mouse at device %s.\n"
- "Please check your config if the mouse is still not\n"
- "operational, as by default "__XSERVERNAME__
- " tries to autodetect\n"
- "the protocol.\n",DFLT_MOUSE_DEV);
- }
-#endif /* !__SCO__ */
-
- if (xf86NumScreens > 1) {
- ErrorF("\n"__XSERVERNAME__
- " has configured a multihead system, please check your config.\n");
- }
-
- ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename);
- ErrorF("To test the server, run 'X -config %s'\n\n", filename);
-
-bail:
- OsCleanup(TRUE);
- AbortDDX();
- fflush(stderr);
- exit(0);
-}
+/* + * Copyright 2000-2002 by Alan Hourihane, Flint Mountain, North Wales. + * + * 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 Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Author: Alan Hourihane, alanh@fairlite.demon.co.uk + * + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "xf86.h" +#include "xf86Config.h" +#include "xf86_OSlib.h" +#include "xf86Priv.h" +#define IN_XSERVER +#include "Configint.h" +#include "xf86DDC.h" +#include "xf86pciBus.h" +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) +#include "xf86Bus.h" +#include "xf86Sbus.h" +#endif + +typedef struct _DevToConfig { + GDevRec GDev; + struct pci_device * pVideo; +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) + sbusDevicePtr sVideo; +#endif + int iDriver; +} DevToConfigRec, *DevToConfigPtr; + +static DevToConfigPtr DevToConfig = NULL; +static int nDevToConfig = 0, CurrentDriver; + +xf86MonPtr ConfiguredMonitor; +Bool xf86DoConfigurePass1 = TRUE; +static Bool foundMouse = FALSE; + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) +static char *DFLT_MOUSE_DEV = "/dev/sysmouse"; +static char *DFLT_MOUSE_PROTO = "auto"; +#elif defined(linux) +static char DFLT_MOUSE_DEV[] = "/dev/input/mice"; +static char DFLT_MOUSE_PROTO[] = "auto"; +#else +static char *DFLT_MOUSE_DEV = "/dev/mouse"; +static char *DFLT_MOUSE_PROTO = "auto"; +#endif + +/* + * This is called by the driver, either through xf86Match???Instances() or + * directly. We allocate a GDevRec and fill it in as much as we can, letting + * the caller fill in the rest and/or change it as it sees fit. + */ +GDevPtr +xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset) +{ + int ret, i, j; + + if (!xf86DoConfigure || !xf86DoConfigurePass1) + return NULL; + + /* Check for duplicates */ + for (i = 0; i < nDevToConfig; i++) { + switch (bus) { + case BUS_PCI: + ret = xf86PciConfigure(busData, DevToConfig[i].pVideo); + break; +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) + case BUS_SBUS: + ret = xf86SbusConfigure(busData, DevToConfig[i].sVideo); + break; +#endif + default: + return NULL; + } + if (ret == 0) + goto out; + } + + /* Allocate new structure occurrence */ + i = nDevToConfig++; + DevToConfig = + xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec)); + memset(DevToConfig + i, 0, sizeof(DevToConfigRec)); + + DevToConfig[i].GDev.chipID = + DevToConfig[i].GDev.chipRev = DevToConfig[i].GDev.irq = -1; + + DevToConfig[i].iDriver = CurrentDriver; + + /* Fill in what we know, converting the driver name to lower case */ + DevToConfig[i].GDev.driver = xnfalloc(strlen(driver) + 1); + for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++); + + switch (bus) { + case BUS_PCI: + xf86PciConfigureNewDev(busData, DevToConfig[i].pVideo, + &DevToConfig[i].GDev, &chipset); + break; +#if (defined(__sparc__) || defined(__sparc)) && !defined(__OpenBSD__) + case BUS_SBUS: + xf86SbusConfigureNewDev(busData, DevToConfig[i].sVideo, + &DevToConfig[i].GDev); + break; +#endif + default: + break; + } + + /* Get driver's available options */ + if (xf86DriverList[CurrentDriver]->AvailableOptions) + DevToConfig[i].GDev.options = (OptionInfoPtr) + (*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset, + bus); + + return &DevToConfig[i].GDev; + +out: + return NULL; +} + +static XF86ConfInputPtr +configureInputSection (void) +{ + XF86ConfInputPtr mouse = NULL; + parsePrologue (XF86ConfInputPtr, XF86ConfInputRec) + + ptr->inp_identifier = "Keyboard0"; + ptr->inp_driver = "kbd"; + ptr->list.next = NULL; + + /* Crude mechanism to auto-detect mouse (os dependent) */ + { + int fd; +#ifdef WSCONS_SUPPORT + fd = open("/dev/wsmouse", 0); + if (fd >= 0) { + DFLT_MOUSE_DEV = "/dev/wsmouse"; + DFLT_MOUSE_PROTO = "wsmouse"; + close(fd); + } else { + ErrorF("cannot open /dev/wsmouse\n"); + } +#endif + + fd = open(DFLT_MOUSE_DEV, 0); + if (fd != -1) { + foundMouse = TRUE; + close(fd); + } + } + + mouse = calloc(1, sizeof(XF86ConfInputRec)); + mouse->inp_identifier = "Mouse0"; + mouse->inp_driver = "mouse"; + mouse->inp_option_lst = + xf86addNewOption(mouse->inp_option_lst, strdup("Protocol"), + strdup(DFLT_MOUSE_PROTO)); + mouse->inp_option_lst = + xf86addNewOption(mouse->inp_option_lst, strdup("Device"), + strdup(DFLT_MOUSE_DEV)); + mouse->inp_option_lst = + xf86addNewOption(mouse->inp_option_lst, strdup("ZAxisMapping"), + strdup("4 5 6 7")); + ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse); + return ptr; +} + +static XF86ConfScreenPtr +configureScreenSection (int screennum) +{ + int i; + int depths[] = { 1, 4, 8, 15, 16, 24/*, 32*/ }; + parsePrologue (XF86ConfScreenPtr, XF86ConfScreenRec) + + XNFasprintf(&ptr->scrn_identifier, "Screen%d", screennum); + XNFasprintf(&ptr->scrn_monitor_str, "Monitor%d", screennum); + XNFasprintf(&ptr->scrn_device_str, "Card%d", screennum); + + for (i=0; i<sizeof(depths)/sizeof(depths[0]); i++) + { + XF86ConfDisplayPtr display; + + display = calloc(1, sizeof(XF86ConfDisplayRec)); + display->disp_depth = depths[i]; + display->disp_black.red = display->disp_white.red = -1; + display->disp_black.green = display->disp_white.green = -1; + display->disp_black.blue = display->disp_white.blue = -1; + ptr->scrn_display_lst = (XF86ConfDisplayPtr)xf86addListItem( + (glp)ptr->scrn_display_lst, (glp)display); + } + + return ptr; +} + +static const char* +optionTypeToString(OptionValueType type) +{ + switch (type) { + case OPTV_NONE: + return ""; + case OPTV_INTEGER: + return "<i>"; + case OPTV_STRING: + return "<str>"; + case OPTV_ANYSTR: + return "[<str>]"; + case OPTV_REAL: + return "<f>"; + case OPTV_BOOLEAN: + return "[<bool>]"; + case OPTV_FREQ: + return "<freq>"; + case OPTV_PERCENT: + return "<percent>"; + default: + return ""; + } +} + +static XF86ConfDevicePtr +configureDeviceSection (int screennum) +{ + OptionInfoPtr p; + int i = 0; + parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec) + + /* Move device info to parser structure */ + if (asprintf(&ptr->dev_identifier, "Card%d", screennum) == -1) + ptr->dev_identifier = NULL; + ptr->dev_chipset = DevToConfig[screennum].GDev.chipset; + ptr->dev_busid = DevToConfig[screennum].GDev.busID; + ptr->dev_driver = DevToConfig[screennum].GDev.driver; + ptr->dev_ramdac = DevToConfig[screennum].GDev.ramdac; + for (i = 0; (i < MAXDACSPEEDS) && (i < CONF_MAXDACSPEEDS); i++) + ptr->dev_dacSpeeds[i] = DevToConfig[screennum].GDev.dacSpeeds[i]; + ptr->dev_videoram = DevToConfig[screennum].GDev.videoRam; + ptr->dev_textclockfreq = DevToConfig[screennum].GDev.textClockFreq; + ptr->dev_bios_base = DevToConfig[screennum].GDev.BiosBase; + ptr->dev_mem_base = DevToConfig[screennum].GDev.MemBase; + ptr->dev_io_base = DevToConfig[screennum].GDev.IOBase; + ptr->dev_clockchip = DevToConfig[screennum].GDev.clockchip; + for (i = 0; (i < MAXCLOCKS) && (i < DevToConfig[screennum].GDev.numclocks); i++) + ptr->dev_clock[i] = DevToConfig[screennum].GDev.clock[i]; + ptr->dev_clocks = i; + ptr->dev_chipid = DevToConfig[screennum].GDev.chipID; + ptr->dev_chiprev = DevToConfig[screennum].GDev.chipRev; + ptr->dev_irq = DevToConfig[screennum].GDev.irq; + + /* Make sure older drivers don't segv */ + if (DevToConfig[screennum].GDev.options) { + /* Fill in the available driver options for people to use */ + const char *descrip = + " ### Available Driver options are:-\n" + " ### Values: <i>: integer, <f>: float, " + "<bool>: \"True\"/\"False\",\n" + " ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n" + " ### <percent>: \"<f>%\"\n" + " ### [arg]: arg optional\n"; + ptr->dev_comment = strdup(descrip); + if (ptr->dev_comment) { + for (p = DevToConfig[screennum].GDev.options; + p->name != NULL; p++) { + char *p_e; + const char *prefix = " #Option "; + const char *middle = " \t# "; + const char *suffix = "\n"; + const char *opttype = optionTypeToString(p->type); + char *optname; + int len = strlen(ptr->dev_comment) + strlen(prefix) + + strlen(middle) + strlen(suffix) + 1; + + if (asprintf(&optname, "\"%s\"", p->name) == -1) + break; + + len += max(20, strlen(optname)); + len += strlen(opttype); + + ptr->dev_comment = realloc(ptr->dev_comment, len); + if (!ptr->dev_comment) + break; + p_e = ptr->dev_comment + strlen(ptr->dev_comment); + sprintf(p_e, "%s%-20s%s%s%s", prefix, optname, middle, + opttype, suffix); + free(optname); + } + } + } + + return ptr; +} + +static XF86ConfLayoutPtr +configureLayoutSection (void) +{ + int scrnum = 0; + parsePrologue (XF86ConfLayoutPtr, XF86ConfLayoutRec) + + ptr->lay_identifier = "X.org Configured"; + + { + XF86ConfInputrefPtr iptr; + + iptr = malloc (sizeof (XF86ConfInputrefRec)); + iptr->list.next = NULL; + iptr->iref_option_lst = NULL; + iptr->iref_inputdev_str = "Mouse0"; + iptr->iref_option_lst = + xf86addNewOption (iptr->iref_option_lst, strdup("CorePointer"), NULL); + ptr->lay_input_lst = (XF86ConfInputrefPtr) + xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); + } + + { + XF86ConfInputrefPtr iptr; + + iptr = malloc (sizeof (XF86ConfInputrefRec)); + iptr->list.next = NULL; + iptr->iref_option_lst = NULL; + iptr->iref_inputdev_str = "Keyboard0"; + iptr->iref_option_lst = + xf86addNewOption (iptr->iref_option_lst, strdup("CoreKeyboard"), NULL); + ptr->lay_input_lst = (XF86ConfInputrefPtr) + xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr); + } + + for (scrnum = 0; scrnum < nDevToConfig; scrnum++) { + XF86ConfAdjacencyPtr aptr; + + aptr = malloc (sizeof (XF86ConfAdjacencyRec)); + aptr->list.next = NULL; + aptr->adj_x = 0; + aptr->adj_y = 0; + aptr->adj_scrnum = scrnum; + XNFasprintf(&aptr->adj_screen_str, "Screen%d", scrnum); + if (scrnum == 0) { + aptr->adj_where = CONF_ADJ_ABSOLUTE; + aptr->adj_refscreen = NULL; + } + else { + aptr->adj_where = CONF_ADJ_RIGHTOF; + XNFasprintf(&aptr->adj_refscreen, "Screen%d", scrnum - 1); + } + ptr->lay_adjacency_lst = + (XF86ConfAdjacencyPtr)xf86addListItem((glp)ptr->lay_adjacency_lst, + (glp)aptr); + } + + return ptr; +} + +static XF86ConfFlagsPtr +configureFlagsSection (void) +{ + parsePrologue (XF86ConfFlagsPtr, XF86ConfFlagsRec) + + return ptr; +} + +static XF86ConfModulePtr +configureModuleSection (void) +{ + char **elist, **el; + /* Find the list of extension & font modules. */ + const char *esubdirs[] = { + "extensions", + "fonts", + NULL + }; + parsePrologue (XF86ConfModulePtr, XF86ConfModuleRec) + + elist = LoaderListDirs(esubdirs, NULL); + if (elist) { + for (el = elist; *el; el++) { + XF86LoadPtr module; + + module = calloc(1, sizeof(XF86LoadRec)); + module->load_name = *el; + ptr->mod_load_lst = (XF86LoadPtr)xf86addListItem( + (glp)ptr->mod_load_lst, (glp)module); + } + free(elist); + } + + return ptr; +} + +static XF86ConfFilesPtr +configureFilesSection (void) +{ + parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec) + + if (xf86ModulePath) + ptr->file_modulepath = strdup(xf86ModulePath); + if (defaultFontPath) + ptr->file_fontpath = strdup(defaultFontPath); + + return ptr; +} + +static XF86ConfMonitorPtr +configureMonitorSection (int screennum) +{ + parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec) + + XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum); + ptr->mon_vendor = strdup("Monitor Vendor"); + ptr->mon_modelname = strdup("Monitor Model"); + + return ptr; +} + +/* Initialize Configure Monitor from Detailed Timing Block */ +static void handle_detailed_input(struct detailed_monitor_section *det_mon, + void *data) +{ + XF86ConfMonitorPtr ptr = (XF86ConfMonitorPtr) data; + + switch (det_mon->type) { + case DS_NAME: + ptr->mon_modelname = realloc(ptr->mon_modelname, + strlen((char*)(det_mon->section.name)) + + 1); + strcpy(ptr->mon_modelname, + (char*)(det_mon->section.name)); + break; + case DS_RANGES: + ptr->mon_hsync[ptr->mon_n_hsync].lo = + det_mon->section.ranges.min_h; + ptr->mon_hsync[ptr->mon_n_hsync].hi = + det_mon->section.ranges.max_h; + ptr->mon_n_vrefresh = 1; + ptr->mon_vrefresh[ptr->mon_n_hsync].lo = + det_mon->section.ranges.min_v; + ptr->mon_vrefresh[ptr->mon_n_hsync].hi = + det_mon->section.ranges.max_v; + ptr->mon_n_hsync++; + default: + break; + } +} + +static XF86ConfMonitorPtr +configureDDCMonitorSection (int screennum) +{ + int len, mon_width, mon_height; +#define displaySizeMaxLen 80 + char displaySize_string[displaySizeMaxLen]; + int displaySizeLen; + + parsePrologue (XF86ConfMonitorPtr, XF86ConfMonitorRec) + + XNFasprintf(&ptr->mon_identifier, "Monitor%d", screennum); + ptr->mon_vendor = strdup(ConfiguredMonitor->vendor.name); + XNFasprintf(&ptr->mon_modelname, "%x", ConfiguredMonitor->vendor.prod_id); + + /* features in centimetres, we want millimetres */ + mon_width = 10 * ConfiguredMonitor->features.hsize ; + mon_height = 10 * ConfiguredMonitor->features.vsize ; + +#ifdef CONFIGURE_DISPLAYSIZE + ptr->mon_width = mon_width; + ptr->mon_height = mon_height; +#else + if (mon_width && mon_height) { + /* when values available add DisplaySize option AS A COMMENT */ + + displaySizeLen = snprintf(displaySize_string, displaySizeMaxLen, + "\t#DisplaySize\t%5d %5d\t# mm\n", + mon_width, mon_height); + + if (displaySizeLen>0 && displaySizeLen<displaySizeMaxLen) { + if (ptr->mon_comment) { + len = strlen(ptr->mon_comment); + } else { + len = 0; + } + if ((ptr->mon_comment = + realloc(ptr->mon_comment, len + strlen(displaySize_string) + 1))) { + strcpy(ptr->mon_comment + len, displaySize_string); + } + } + } +#endif /* def CONFIGURE_DISPLAYSIZE */ + + xf86ForEachDetailedBlock(ConfiguredMonitor, handle_detailed_input, + ptr); + + if (ConfiguredMonitor->features.dpms) { + ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, strdup("DPMS"), NULL); + } + + return ptr; +} + +#if !defined(PATH_MAX) +# define PATH_MAX 1024 +#endif + +void +DoConfigure(void) +{ + int i,j, screennum = -1; + char *home = NULL; + char filename[PATH_MAX]; + char *addslash = ""; + XF86ConfigPtr xf86config = NULL; + char **vlist, **vl; + int *dev2screen; + + vlist = xf86DriverlistFromCompile(); + + if (!vlist) { + ErrorF("Missing output drivers. Configuration failed.\n"); + goto bail; + } + + ErrorF("List of video drivers:\n"); + for (vl = vlist; *vl; vl++) + ErrorF("\t%s\n", *vl); + + /* Load all the drivers that were found. */ + xf86LoadModules(vlist, NULL); + + free(vlist); + + for (i = 0; i < xf86NumDrivers; i++) { + xorgHWFlags flags; + if (!xf86DriverList[i]->driverFunc + || !xf86DriverList[i]->driverFunc(NULL, + GET_REQUIRED_HW_INTERFACES, + &flags) + || NEED_IO_ENABLED(flags)) { + xorgHWAccess = TRUE; + break; + } + } + /* Enable full I/O access */ + if (xorgHWAccess) { + if(!xf86EnableIO()) + /* oops, we have failed */ + xorgHWAccess = FALSE; + } + + /* Create XF86Config file structure */ + xf86config = calloc(1, sizeof(XF86ConfigRec)); + + /* Call all of the probe functions, reporting the results. */ + for (CurrentDriver = 0; CurrentDriver < xf86NumDrivers; CurrentDriver++) { + xorgHWFlags flags; + Bool found_screen; + DriverRec * const drv = xf86DriverList[CurrentDriver]; + + if (!xorgHWAccess) { + if (!drv->driverFunc + || !drv->driverFunc( NULL, GET_REQUIRED_HW_INTERFACES, &flags ) + || NEED_IO_ENABLED(flags)) + continue; + } + + found_screen = xf86CallDriverProbe( drv, TRUE ); + if ( found_screen && drv->Identify ) { + (*drv->Identify)(0); + } + } + + if (nDevToConfig <= 0) { + ErrorF("No devices to configure. Configuration failed.\n"); + goto bail; + } + + /* Add device, monitor and screen sections for detected devices */ + for (screennum = 0; screennum < nDevToConfig; screennum++) { + XF86ConfDevicePtr DevicePtr; + XF86ConfMonitorPtr MonitorPtr; + XF86ConfScreenPtr ScreenPtr; + + DevicePtr = configureDeviceSection(screennum); + xf86config->conf_device_lst = (XF86ConfDevicePtr)xf86addListItem( + (glp)xf86config->conf_device_lst, (glp)DevicePtr); + MonitorPtr = configureMonitorSection(screennum); + xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem( + (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr); + ScreenPtr = configureScreenSection(screennum); + xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem( + (glp)xf86config->conf_screen_lst, (glp)ScreenPtr); + } + + xf86config->conf_files = configureFilesSection(); + xf86config->conf_modules = configureModuleSection(); + xf86config->conf_flags = configureFlagsSection(); + xf86config->conf_videoadaptor_lst = NULL; + xf86config->conf_modes_lst = NULL; + xf86config->conf_vendor_lst = NULL; + xf86config->conf_dri = NULL; + xf86config->conf_input_lst = configureInputSection(); + xf86config->conf_layout_lst = configureLayoutSection(); + + home = getenv("HOME"); + if ((home == NULL) || (home[0] == '\0')) { + home = "/"; + } else { + /* Determine if trailing slash is present or needed */ + int l = strlen(home); + + if (home[l-1] != '/') { + addslash = "/"; + } + } + + snprintf(filename, sizeof(filename), "%s%s" XF86CONFIGFILE ".new", + home, addslash); + + if (xf86writeConfigFile(filename, xf86config) == 0) { + xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n", + filename, strerror(errno)); + goto bail; + } + + xf86DoConfigurePass1 = FALSE; + /* Try to get DDC information filled in */ + xf86ConfigFile = filename; + if (xf86HandleConfigFile(FALSE) != CONFIG_OK) { + goto bail; + } + + xf86DoConfigurePass1 = FALSE; + + dev2screen = xnfcalloc(1,xf86NumDrivers*sizeof(int)); + + { + Bool *driverProbed = xnfcalloc(1,xf86NumDrivers*sizeof(Bool)); + for (screennum = 0; screennum < nDevToConfig; screennum++) { + int k,l,n,oldNumScreens; + + i = DevToConfig[screennum].iDriver; + + if (driverProbed[i]) continue; + driverProbed[i] = TRUE; + + oldNumScreens = xf86NumScreens; + + xf86CallDriverProbe( xf86DriverList[i], FALSE ); + + /* reorder */ + k = screennum > 0 ? screennum : 1; + for (l = oldNumScreens; l < xf86NumScreens; l++) { + /* is screen primary? */ + Bool primary = FALSE; + for (n = 0; n<xf86Screens[l]->numEntities; n++) { + if (xf86IsEntityPrimary(xf86Screens[l]->entityList[n])) { + dev2screen[0] = l; + primary = TRUE; + break; + } + } + if (primary) continue; + /* not primary: assign it to next device of same driver */ + /* + * NOTE: we assume that devices in DevToConfig + * and xf86Screens[] have the same order except + * for the primary device which always comes first. + */ + for (; k < nDevToConfig; k++) { + if (DevToConfig[k].iDriver == i) { + dev2screen[k++] = l; + break; + } + } + } + } + free(driverProbed); + } + + + if (nDevToConfig != xf86NumScreens) { + ErrorF("Number of created screens does not match number of detected" + " devices.\n Configuration failed.\n"); + goto bail; + } + + xf86PostProbe(); + + for (j = 0; j < xf86NumScreens; j++) { + xf86Screens[j]->scrnIndex = j; + } + + xf86freeMonitorList(xf86config->conf_monitor_lst); + xf86config->conf_monitor_lst = NULL; + xf86freeScreenList(xf86config->conf_screen_lst); + xf86config->conf_screen_lst = NULL; + for (j = 0; j < xf86NumScreens; j++) { + XF86ConfMonitorPtr MonitorPtr; + XF86ConfScreenPtr ScreenPtr; + + ConfiguredMonitor = NULL; + + if ((*xf86Screens[dev2screen[j]]->PreInit)(xf86Screens[dev2screen[j]], + PROBE_DETECT) && + ConfiguredMonitor) { + MonitorPtr = configureDDCMonitorSection(j); + } else { + MonitorPtr = configureMonitorSection(j); + } + ScreenPtr = configureScreenSection(j); + xf86config->conf_monitor_lst = (XF86ConfMonitorPtr)xf86addListItem( + (glp)xf86config->conf_monitor_lst, (glp)MonitorPtr); + xf86config->conf_screen_lst = (XF86ConfScreenPtr)xf86addListItem( + (glp)xf86config->conf_screen_lst, (glp)ScreenPtr); + } + + if (xf86writeConfigFile(filename, xf86config) == 0) { + xf86Msg(X_ERROR, "Unable to write config file: \"%s\": %s\n", + filename, strerror(errno)); + goto bail; + } + + ErrorF("\n"); + + if (!foundMouse) { + ErrorF("\n"__XSERVERNAME__" is not able to detect your mouse.\n" + "Edit the file and correct the Device.\n"); + } else { + ErrorF("\n"__XSERVERNAME__" detected your mouse at device %s.\n" + "Please check your config if the mouse is still not\n" + "operational, as by default "__XSERVERNAME__ + " tries to autodetect\n" + "the protocol.\n",DFLT_MOUSE_DEV); + } + + if (xf86NumScreens > 1) { + ErrorF("\n"__XSERVERNAME__ + " has configured a multihead system, please check your config.\n"); + } + + ErrorF("\nYour %s file is %s\n\n", XF86CONFIGFILE ,filename); + ErrorF("To test the server, run 'X -config %s'\n\n", filename); + +bail: + OsCleanup(TRUE); + AbortDDX(); + fflush(stderr); + exit(0); +} diff --git a/xorg-server/hw/xfree86/common/xf86Cursor.c b/xorg-server/hw/xfree86/common/xf86Cursor.c index acfa79f10..929f047cc 100644 --- a/xorg-server/hw/xfree86/common/xf86Cursor.c +++ b/xorg-server/hw/xfree86/common/xf86Cursor.c @@ -1,860 +1,860 @@ -/*
- * Copyright (c) 1994-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include "input.h"
-#include "cursor.h"
-#include "mipointer.h"
-#include "scrnintstr.h"
-#include "globals.h"
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSproc.h"
-
-#include <X11/extensions/XIproto.h>
-#include "xf86Xinput.h"
-
-#ifdef XFreeXDGA
-#include "dgaproc.h"
-#endif
-
-typedef struct _xf86EdgeRec {
- short screen;
- short start;
- short end;
- DDXPointRec offset;
- struct _xf86EdgeRec *next;
-} xf86EdgeRec, *xf86EdgePtr;
-
-typedef struct {
- xf86EdgePtr left, right, up, down;
-} xf86ScreenLayoutRec, *xf86ScreenLayoutPtr;
-
-static Bool xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y);
-static void xf86CrossScreen(ScreenPtr pScreen, Bool entering);
-static void xf86WarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y);
-
-static void xf86PointerMoved(int scrnIndex, int x, int y);
-
-static miPointerScreenFuncRec xf86PointerScreenFuncs = {
- xf86CursorOffScreen,
- xf86CrossScreen,
- xf86WarpCursor,
- /* let miPointerInitialize take care of these */
- NULL,
- NULL
-};
-
-static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS];
-
-static Bool HardEdges;
-
-/*
- * xf86InitViewport --
- * Initialize paning & zooming parameters, so that a driver must only
- * check what resolutions are possible and whether the virtual area
- * is valid if specified.
- */
-
-void
-xf86InitViewport(ScrnInfoPtr pScr)
-{
-
- pScr->PointerMoved = xf86PointerMoved;
-
- /*
- * Compute the initial Viewport if necessary
- */
- if (pScr->display) {
- if (pScr->display->frameX0 < 0) {
- pScr->frameX0 = (pScr->virtualX - pScr->modes->HDisplay) / 2;
- pScr->frameY0 = (pScr->virtualY - pScr->modes->VDisplay) / 2;
- } else {
- pScr->frameX0 = pScr->display->frameX0;
- pScr->frameY0 = pScr->display->frameY0;
- }
- }
-
- pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
- pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
-
- /*
- * Now adjust the initial Viewport, so it lies within the virtual area
- */
- if (pScr->frameX1 >= pScr->virtualX)
- {
- pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay;
- pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1;
- }
-
- if (pScr->frameY1 >= pScr->virtualY)
- {
- pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay;
- pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1;
- }
-}
-
-
-/*
- * xf86SetViewport --
- * Scroll the visual part of the screen so the pointer is visible.
- */
-
-void
-xf86SetViewport(ScreenPtr pScreen, int x, int y)
-{
- ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
-
- (*pScr->PointerMoved)(pScreen->myNum, x, y);
-}
-
-
-static void
-xf86PointerMoved(int scrnIndex, int x, int y)
-{
- Bool frameChanged = FALSE;
- ScrnInfoPtr pScr = xf86Screens[scrnIndex];
-
- /*
- * check wether (x,y) belongs to the visual part of the screen
- * if not, change the base of the displayed frame accoring
- */
- if ( pScr->frameX0 > x) {
- pScr->frameX0 = x;
- pScr->frameX1 = x + pScr->currentMode->HDisplay - 1;
- frameChanged = TRUE ;
- }
-
- if ( pScr->frameX1 < x) {
- pScr->frameX1 = x + 1;
- pScr->frameX0 = x - pScr->currentMode->HDisplay + 1;
- frameChanged = TRUE ;
- }
-
- if ( pScr->frameY0 > y) {
- pScr->frameY0 = y;
- pScr->frameY1 = y + pScr->currentMode->VDisplay - 1;
- frameChanged = TRUE;
- }
-
- if ( pScr->frameY1 < y) {
- pScr->frameY1 = y;
- pScr->frameY0 = y - pScr->currentMode->VDisplay + 1;
- frameChanged = TRUE;
- }
-
- if (frameChanged && pScr->AdjustFrame != NULL)
- pScr->AdjustFrame(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
-}
-
-/*
- * xf86LockZoom --
- * Enable/disable ZoomViewport
- */
-
-void
-xf86LockZoom(ScreenPtr pScreen, Bool lock)
-{
- XF86SCRNINFO(pScreen)->zoomLocked = lock;
-}
-
-/*
- * xf86SwitchMode --
- * This is called by both keyboard processing and the VidMode extension to
- * set a new mode.
- */
-
-Bool
-xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode)
-{
- ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
- ScreenPtr pCursorScreen;
- Bool Switched;
- int px, py;
- DeviceIntPtr dev, it;
-
- if (!pScr->vtSema || !mode || !pScr->SwitchMode)
- return FALSE;
-
-#ifdef XFreeXDGA
- if (DGAActive(pScr->scrnIndex))
- return FALSE;
-#endif
-
- if (mode == pScr->currentMode)
- return TRUE;
-
- if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY)
- return FALSE;
-
- /* Let's take an educated guess for which pointer to take here. And about as
- educated as it gets is to take the first pointer we find.
- */
- for (dev = inputInfo.devices; dev; dev = dev->next)
- {
- if (IsPointerDevice(dev) && dev->spriteInfo->spriteOwner)
- break;
- }
-
- pCursorScreen = miPointerGetScreen(dev);
- if (pScreen == pCursorScreen)
- miPointerGetPosition(dev, &px, &py);
-
- xf86EnterServerState(SETUP);
- Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0);
- if (Switched) {
- pScr->currentMode = mode;
-
- /*
- * Adjust frame for new display size.
- * Frame is centered around cursor position if cursor is on same screen.
- */
- if (pScreen == pCursorScreen)
- pScr->frameX0 = px - (mode->HDisplay / 2) + 1;
- else
- pScr->frameX0 = (pScr->frameX0 + pScr->frameX1 + 1 - mode->HDisplay) / 2;
-
- if (pScr->frameX0 < 0)
- pScr->frameX0 = 0;
-
- pScr->frameX1 = pScr->frameX0 + mode->HDisplay - 1;
- if (pScr->frameX1 >= pScr->virtualX) {
- pScr->frameX0 = pScr->virtualX - mode->HDisplay;
- pScr->frameX1 = pScr->virtualX - 1;
- }
-
- if (pScreen == pCursorScreen)
- pScr->frameY0 = py - (mode->VDisplay / 2) + 1;
- else
- pScr->frameY0 = (pScr->frameY0 + pScr->frameY1 + 1 - mode->VDisplay) / 2;
-
- if (pScr->frameY0 < 0)
- pScr->frameY0 = 0;
-
- pScr->frameY1 = pScr->frameY0 + mode->VDisplay - 1;
- if (pScr->frameY1 >= pScr->virtualY) {
- pScr->frameY0 = pScr->virtualY - mode->VDisplay;
- pScr->frameY1 = pScr->virtualY - 1;
- }
- }
- xf86EnterServerState(OPERATING);
-
- if (pScr->AdjustFrame)
- (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
-
- /* The original code centered the frame around the cursor if possible.
- * Since this is hard to achieve with multiple cursors, we do the following:
- * - center around the first pointer
- * - move all other pointers to the nearest edge on the screen (or leave
- * them unmodified if they are within the boundaries).
- */
- if (pScreen == pCursorScreen)
- {
- xf86WarpCursor(dev, pScreen, px, py);
- }
-
- for (it = inputInfo.devices; it; it = it->next)
- {
- if (it == dev)
- continue;
-
- if (IsPointerDevice(it) && it->spriteInfo->spriteOwner)
- {
- pCursorScreen = miPointerGetScreen(it);
- if (pScreen == pCursorScreen)
- {
- miPointerGetPosition(it, &px, &py);
- if (px < pScr->frameX0)
- px = pScr->frameX0;
- else if (px > pScr->frameX1)
- px = pScr->frameX1;
-
- if(py < pScr->frameY0)
- py = pScr->frameY0;
- else if(py > pScr->frameY1)
- py = pScr->frameY1;
-
- xf86WarpCursor(it, pScreen, px, py);
- }
- }
- }
-
- return Switched;
-}
-
-/*
- * xf86ZoomViewport --
- * Reinitialize the visual part of the screen for another mode.
- */
-
-void
-xf86ZoomViewport(ScreenPtr pScreen, int zoom)
-{
- ScrnInfoPtr pScr = XF86SCRNINFO(pScreen);
- DisplayModePtr mode;
-
- if (pScr->zoomLocked || !(mode = pScr->currentMode))
- return;
-
- do {
- if (zoom > 0)
- mode = mode->next;
- else
- mode = mode->prev;
- } while (mode != pScr->currentMode && !(mode->type & M_T_USERDEF));
-
- (void)xf86SwitchMode(pScreen, mode);
-}
-
-
-static xf86EdgePtr
-FindEdge(xf86EdgePtr edge, int val)
-{
- while(edge && (edge->end <= val))
- edge = edge->next;
-
- if(edge && (edge->start <= val))
- return edge;
-
- return NULL;
-}
-
-/*
- * xf86CursorOffScreen --
- * Check whether it is necessary to switch to another screen
- */
-
-static Bool
-xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
-{
- xf86EdgePtr edge;
- int tmp;
-
- if(screenInfo.numScreens == 1)
- return FALSE;
-
- if(*x < 0) {
- tmp = *y;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].left))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *x = 0;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- *pScreen = xf86Screens[edge->screen]->pScreen;
- }
- }
-
- if(*x >= (*pScreen)->width) {
- tmp = *y;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].right))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *x = (*pScreen)->width - 1;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- *pScreen = xf86Screens[edge->screen]->pScreen;
- }
- }
-
- if(*y < 0) {
- tmp = *x;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].up))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *y = 0;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- *pScreen = xf86Screens[edge->screen]->pScreen;
- }
- }
-
- if(*y >= (*pScreen)->height) {
- tmp = *x;
- if(tmp < 0) tmp = 0;
- if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1;
-
- if((edge = xf86ScreenLayout[(*pScreen)->myNum].down))
- edge = FindEdge(edge, tmp);
-
- if(!edge) *y = (*pScreen)->height - 1;
- else {
- *x += edge->offset.x;
- *y += edge->offset.y;
- (*pScreen) = xf86Screens[edge->screen]->pScreen;
- }
- }
-
-
-#if 0
- /* This presents problems for overlapping screens when
- HardEdges is used. Have to think about the logic more */
- if((*x < 0) || (*x >= (*pScreen)->width) ||
- (*y < 0) || (*y >= (*pScreen)->height)) {
- /* We may have crossed more than one screen */
- xf86CursorOffScreen(pScreen, x, y);
- }
-#endif
-
- return TRUE;
-}
-
-
-
-/*
- * xf86CrossScreen --
- * Switch to another screen
- *
- * Currently nothing special happens, but mi assumes the CrossScreen
- * method exists.
- */
-
-static void
-xf86CrossScreen (ScreenPtr pScreen, Bool entering)
-{
-}
-
-
-/*
- * xf86WarpCursor --
- * Warp possible to another screen
- */
-
-/* ARGSUSED */
-static void
-xf86WarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
-{
- int sigstate;
- sigstate = xf86BlockSIGIO ();
- miPointerWarpCursor(pDev, pScreen, x, y);
-
- xf86Info.currentScreen = pScreen;
- xf86UnblockSIGIO (sigstate);
-}
-
-
-void *
-xf86GetPointerScreenFuncs(void)
-{
- return (void *)&xf86PointerScreenFuncs;
-}
-
-
-static xf86EdgePtr
-AddEdge(
- xf86EdgePtr edge,
- short min,
- short max,
- short dx,
- short dy,
- short screen
-){
- xf86EdgePtr pEdge = edge, pPrev = NULL, pNew;
-
- while(1) {
- while(pEdge && (min >= pEdge->end)) {
- pPrev = pEdge;
- pEdge = pEdge->next;
- }
-
- if(!pEdge) {
- if(!(pNew = malloc(sizeof(xf86EdgeRec))))
- break;
-
- pNew->screen = screen;
- pNew->start = min;
- pNew->end = max;
- pNew->offset.x = dx;
- pNew->offset.y = dy;
- pNew->next = NULL;
-
- if(pPrev)
- pPrev->next = pNew;
- else
- edge = pNew;
-
- break;
- } else if (min < pEdge->start) {
- if(!(pNew = malloc(sizeof(xf86EdgeRec))))
- break;
-
- pNew->screen = screen;
- pNew->start = min;
- pNew->offset.x = dx;
- pNew->offset.y = dy;
- pNew->next = pEdge;
-
- if(pPrev) pPrev->next = pNew;
- else edge = pNew;
-
- if(max <= pEdge->start) {
- pNew->end = max;
- break;
- } else {
- pNew->end = pEdge->start;
- min = pEdge->end;
- }
- } else
- min = pEdge->end;
-
- pPrev = pEdge;
- pEdge = pEdge->next;
-
- if(max <= min) break;
- }
-
- return edge;
-}
-
-static void
-FillOutEdge(xf86EdgePtr pEdge, int limit)
-{
- xf86EdgePtr pNext;
- int diff;
-
- if(pEdge->start > 0) pEdge->start = 0;
-
- while((pNext = pEdge->next)) {
- diff = pNext->start - pEdge->end;
- if(diff > 0) {
- pEdge->end += diff >> 1;
- pNext->start -= diff - (diff >> 1);
- }
- pEdge = pNext;
- }
-
- if(pEdge->end < limit)
- pEdge->end = limit;
-}
-
-/*
- * xf86InitOrigins() can deal with a maximum of 32 screens
- * on 32 bit architectures, 64 on 64 bit architectures.
- */
-
-void
-xf86InitOrigins(void)
-{
- unsigned long screensLeft, prevScreensLeft, mask;
- screenLayoutPtr screen;
- ScreenPtr pScreen, refScreen;
- int x1, x2, y1, y2, left, right, top, bottom;
- int i, j, ref, minX, minY, min, max;
- xf86ScreenLayoutPtr pLayout;
- Bool OldStyleConfig = FALSE;
-
- /* need to have this set up with a config file option */
- HardEdges = FALSE;
-
- memset(xf86ScreenLayout, 0, MAXSCREENS * sizeof(xf86ScreenLayoutRec));
-
- screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1;
-
- while(1) {
- for(mask = screensLeft, i = 0; mask; mask >>= 1, i++) {
- if(!(mask & 1L)) continue;
-
- screen = &xf86ConfigLayout.screens[i];
-
- if (screen->refscreen != NULL &&
- screen->refscreen->screennum >= xf86NumScreens) {
- screensLeft &= ~(1 << i);
- xf86Msg(X_WARNING, "Not including screen \"%s\" in origins calculation.\n",
- screen->screen->id);
- continue;
- }
-
- pScreen = xf86Screens[i]->pScreen;
- switch(screen->where) {
- case PosObsolete:
- OldStyleConfig = TRUE;
- pLayout = &xf86ScreenLayout[i];
- /* force edge lists */
- if(screen->left) {
- ref = screen->left->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->left = AddEdge(pLayout->left,
- 0, pScreen->height,
- xf86Screens[ref]->pScreen->width, 0, ref);
- }
- if(screen->right) {
- ref = screen->right->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->right = AddEdge(pLayout->right,
- 0, pScreen->height, -pScreen->width, 0, ref);
- }
- if(screen->top) {
- ref = screen->top->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->up = AddEdge(pLayout->up,
- 0, pScreen->width,
- 0, xf86Screens[ref]->pScreen->height, ref);
- }
- if(screen->bottom) {
- ref = screen->bottom->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- pLayout->down = AddEdge(pLayout->down,
- 0, pScreen->width, 0, -pScreen->height, ref);
- }
- /* we could also try to place it based on those
- relative locations if we wanted to */
- screen->x = screen->y = 0;
- /* FALLTHROUGH */
- case PosAbsolute:
- pScreen->x = screen->x;
- pScreen->y = screen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosRelative:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x + screen->x;
- pScreen->y = refScreen->y + screen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosRightOf:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x + refScreen->width;
- pScreen->y = refScreen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosLeftOf:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x - pScreen->width;
- pScreen->y = refScreen->y;
- screensLeft &= ~(1 << i);
- break;
- case PosBelow:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x;
- pScreen->y = refScreen->y + refScreen->height;
- screensLeft &= ~(1 << i);
- break;
- case PosAbove:
- ref = screen->refscreen->screennum;
- if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) {
- ErrorF("Referenced uninitialized screen in Layout!\n");
- break;
- }
- if(screensLeft & (1 << ref)) break;
- refScreen = xf86Screens[ref]->pScreen;
- pScreen->x = refScreen->x;
- pScreen->y = refScreen->y - pScreen->height;
- screensLeft &= ~(1 << i);
- break;
- default:
- ErrorF("Illegal placement keyword in Layout!\n");
- break;
- }
-
- }
-
- if(!screensLeft) break;
-
- if(screensLeft == prevScreensLeft) {
- /* All the remaining screens are referencing each other.
- Assign a value to one of them and go through again */
- i = 0;
- while(!((1 << i) & screensLeft)){ i++; }
-
- ref = xf86ConfigLayout.screens[i].refscreen->screennum;
- xf86Screens[ref]->pScreen->x = xf86Screens[ref]->pScreen->y = 0;
- screensLeft &= ~(1 << ref);
- }
-
- prevScreensLeft = screensLeft;
- }
-
- /* justify the topmost and leftmost to (0,0) */
- minX = xf86Screens[0]->pScreen->x;
- minY = xf86Screens[0]->pScreen->y;
-
- for(i = 1; i < xf86NumScreens; i++) {
- if(xf86Screens[i]->pScreen->x < minX)
- minX = xf86Screens[i]->pScreen->x;
- if(xf86Screens[i]->pScreen->y < minY)
- minY = xf86Screens[i]->pScreen->y;
- }
-
- if (minX || minY) {
- for(i = 0; i < xf86NumScreens; i++) {
- xf86Screens[i]->pScreen->x -= minX;
- xf86Screens[i]->pScreen->y -= minY;
- }
- }
-
-
- /* Create the edge lists */
-
- if(!OldStyleConfig) {
- for(i = 0; i < xf86NumScreens; i++) {
- pLayout = &xf86ScreenLayout[i];
-
- pScreen = xf86Screens[i]->pScreen;
-
- left = pScreen->x;
- right = left + pScreen->width;
- top = pScreen->y;
- bottom = top + pScreen->height;
-
- for(j = 0; j < xf86NumScreens; j++) {
- if(i == j) continue;
-
- refScreen = xf86Screens[j]->pScreen;
-
- x1 = refScreen->x;
- x2 = x1 + refScreen->width;
- y1 = refScreen->y;
- y2 = y1 + refScreen->height;
-
- if((bottom > y1) && (top < y2)) {
- min = y1 - top;
- if(min < 0) min = 0;
- max = pScreen->height - (bottom - y2);
- if(max > pScreen->height) max = pScreen->height;
-
- if(((left - 1) >= x1) && ((left - 1) < x2))
- pLayout->left = AddEdge(pLayout->left, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
-
- if((right >= x1) && (right < x2))
- pLayout->right = AddEdge(pLayout->right, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
- }
-
-
- if((left < x2) && (right > x1)) {
- min = x1 - left;
- if(min < 0) min = 0;
- max = pScreen->width - (right - x2);
- if(max > pScreen->width) max = pScreen->width;
-
- if(((top - 1) >= y1) && ((top - 1) < y2))
- pLayout->up = AddEdge(pLayout->up, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
-
- if((bottom >= y1) && (bottom < y2))
- pLayout->down = AddEdge(pLayout->down, min, max,
- pScreen->x - refScreen->x,
- pScreen->y - refScreen->y, j);
- }
- }
- }
- }
-
- if(!HardEdges && !OldStyleConfig) {
- for(i = 0; i < xf86NumScreens; i++) {
- pLayout = &xf86ScreenLayout[i];
- pScreen = xf86Screens[i]->pScreen;
- if(pLayout->left)
- FillOutEdge(pLayout->left, pScreen->height);
- if(pLayout->right)
- FillOutEdge(pLayout->right, pScreen->height);
- if(pLayout->up)
- FillOutEdge(pLayout->up, pScreen->width);
- if(pLayout->down)
- FillOutEdge(pLayout->down, pScreen->width);
- }
- }
-}
-
-void
-xf86ReconfigureLayout(void)
-{
- int i;
-
- for (i = 0; i < MAXSCREENS; i++) {
- xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i];
- /* we don't have to zero these, xf86InitOrigins() takes care of that */
- free(sl->left);
- free(sl->right);
- free(sl->up);
- free(sl->down);
- }
-
- xf86InitOrigins();
-}
-
-
+/* + * Copyright (c) 1994-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> +#include "input.h" +#include "cursor.h" +#include "mipointer.h" +#include "scrnintstr.h" +#include "globals.h" + +#include "compiler.h" + +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86_OSproc.h" + +#include <X11/extensions/XIproto.h> +#include "xf86Xinput.h" + +#ifdef XFreeXDGA +#include "dgaproc.h" +#endif + +typedef struct _xf86EdgeRec { + short screen; + short start; + short end; + DDXPointRec offset; + struct _xf86EdgeRec *next; +} xf86EdgeRec, *xf86EdgePtr; + +typedef struct { + xf86EdgePtr left, right, up, down; +} xf86ScreenLayoutRec, *xf86ScreenLayoutPtr; + +static Bool xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y); +static void xf86CrossScreen(ScreenPtr pScreen, Bool entering); +static void xf86WarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y); + +static void xf86PointerMoved(int scrnIndex, int x, int y); + +static miPointerScreenFuncRec xf86PointerScreenFuncs = { + xf86CursorOffScreen, + xf86CrossScreen, + xf86WarpCursor, + /* let miPointerInitialize take care of these */ + NULL, + NULL +}; + +static xf86ScreenLayoutRec xf86ScreenLayout[MAXSCREENS]; + +static Bool HardEdges; + +/* + * xf86InitViewport -- + * Initialize paning & zooming parameters, so that a driver must only + * check what resolutions are possible and whether the virtual area + * is valid if specified. + */ + +void +xf86InitViewport(ScrnInfoPtr pScr) +{ + + pScr->PointerMoved = xf86PointerMoved; + + /* + * Compute the initial Viewport if necessary + */ + if (pScr->display) { + if (pScr->display->frameX0 < 0) { + pScr->frameX0 = (pScr->virtualX - pScr->modes->HDisplay) / 2; + pScr->frameY0 = (pScr->virtualY - pScr->modes->VDisplay) / 2; + } else { + pScr->frameX0 = pScr->display->frameX0; + pScr->frameY0 = pScr->display->frameY0; + } + } + + pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1; + pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1; + + /* + * Now adjust the initial Viewport, so it lies within the virtual area + */ + if (pScr->frameX1 >= pScr->virtualX) + { + pScr->frameX0 = pScr->virtualX - pScr->modes->HDisplay; + pScr->frameX1 = pScr->frameX0 + pScr->modes->HDisplay - 1; + } + + if (pScr->frameY1 >= pScr->virtualY) + { + pScr->frameY0 = pScr->virtualY - pScr->modes->VDisplay; + pScr->frameY1 = pScr->frameY0 + pScr->modes->VDisplay - 1; + } +} + + +/* + * xf86SetViewport -- + * Scroll the visual part of the screen so the pointer is visible. + */ + +void +xf86SetViewport(ScreenPtr pScreen, int x, int y) +{ + ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); + + (*pScr->PointerMoved)(pScreen->myNum, x, y); +} + + +static void +xf86PointerMoved(int scrnIndex, int x, int y) +{ + Bool frameChanged = FALSE; + ScrnInfoPtr pScr = xf86Screens[scrnIndex]; + + /* + * check wether (x,y) belongs to the visual part of the screen + * if not, change the base of the displayed frame accoring + */ + if ( pScr->frameX0 > x) { + pScr->frameX0 = x; + pScr->frameX1 = x + pScr->currentMode->HDisplay - 1; + frameChanged = TRUE ; + } + + if ( pScr->frameX1 < x) { + pScr->frameX1 = x + 1; + pScr->frameX0 = x - pScr->currentMode->HDisplay + 1; + frameChanged = TRUE ; + } + + if ( pScr->frameY0 > y) { + pScr->frameY0 = y; + pScr->frameY1 = y + pScr->currentMode->VDisplay - 1; + frameChanged = TRUE; + } + + if ( pScr->frameY1 < y) { + pScr->frameY1 = y; + pScr->frameY0 = y - pScr->currentMode->VDisplay + 1; + frameChanged = TRUE; + } + + if (frameChanged && pScr->AdjustFrame != NULL) + pScr->AdjustFrame(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0); +} + +/* + * xf86LockZoom -- + * Enable/disable ZoomViewport + */ + +void +xf86LockZoom(ScreenPtr pScreen, Bool lock) +{ + XF86SCRNINFO(pScreen)->zoomLocked = lock; +} + +/* + * xf86SwitchMode -- + * This is called by both keyboard processing and the VidMode extension to + * set a new mode. + */ + +Bool +xf86SwitchMode(ScreenPtr pScreen, DisplayModePtr mode) +{ + ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); + ScreenPtr pCursorScreen; + Bool Switched; + int px, py, was_blocked; + DeviceIntPtr dev, it; + + if (!pScr->vtSema || !mode || !pScr->SwitchMode) + return FALSE; + +#ifdef XFreeXDGA + if (DGAActive(pScr->scrnIndex)) + return FALSE; +#endif + + if (mode == pScr->currentMode) + return TRUE; + + if (mode->HDisplay > pScr->virtualX || mode->VDisplay > pScr->virtualY) + return FALSE; + + /* Let's take an educated guess for which pointer to take here. And about as + educated as it gets is to take the first pointer we find. + */ + for (dev = inputInfo.devices; dev; dev = dev->next) + { + if (IsPointerDevice(dev) && dev->spriteInfo->spriteOwner) + break; + } + + pCursorScreen = miPointerGetScreen(dev); + if (pScreen == pCursorScreen) + miPointerGetPosition(dev, &px, &py); + + was_blocked = xf86BlockSIGIO(); + Switched = (*pScr->SwitchMode)(pScr->scrnIndex, mode, 0); + if (Switched) { + pScr->currentMode = mode; + + /* + * Adjust frame for new display size. + * Frame is centered around cursor position if cursor is on same screen. + */ + if (pScreen == pCursorScreen) + pScr->frameX0 = px - (mode->HDisplay / 2) + 1; + else + pScr->frameX0 = (pScr->frameX0 + pScr->frameX1 + 1 - mode->HDisplay) / 2; + + if (pScr->frameX0 < 0) + pScr->frameX0 = 0; + + pScr->frameX1 = pScr->frameX0 + mode->HDisplay - 1; + if (pScr->frameX1 >= pScr->virtualX) { + pScr->frameX0 = pScr->virtualX - mode->HDisplay; + pScr->frameX1 = pScr->virtualX - 1; + } + + if (pScreen == pCursorScreen) + pScr->frameY0 = py - (mode->VDisplay / 2) + 1; + else + pScr->frameY0 = (pScr->frameY0 + pScr->frameY1 + 1 - mode->VDisplay) / 2; + + if (pScr->frameY0 < 0) + pScr->frameY0 = 0; + + pScr->frameY1 = pScr->frameY0 + mode->VDisplay - 1; + if (pScr->frameY1 >= pScr->virtualY) { + pScr->frameY0 = pScr->virtualY - mode->VDisplay; + pScr->frameY1 = pScr->virtualY - 1; + } + } + xf86UnblockSIGIO(was_blocked); + + if (pScr->AdjustFrame) + (*pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0); + + /* The original code centered the frame around the cursor if possible. + * Since this is hard to achieve with multiple cursors, we do the following: + * - center around the first pointer + * - move all other pointers to the nearest edge on the screen (or leave + * them unmodified if they are within the boundaries). + */ + if (pScreen == pCursorScreen) + { + xf86WarpCursor(dev, pScreen, px, py); + } + + for (it = inputInfo.devices; it; it = it->next) + { + if (it == dev) + continue; + + if (IsPointerDevice(it) && it->spriteInfo->spriteOwner) + { + pCursorScreen = miPointerGetScreen(it); + if (pScreen == pCursorScreen) + { + miPointerGetPosition(it, &px, &py); + if (px < pScr->frameX0) + px = pScr->frameX0; + else if (px > pScr->frameX1) + px = pScr->frameX1; + + if(py < pScr->frameY0) + py = pScr->frameY0; + else if(py > pScr->frameY1) + py = pScr->frameY1; + + xf86WarpCursor(it, pScreen, px, py); + } + } + } + + return Switched; +} + +/* + * xf86ZoomViewport -- + * Reinitialize the visual part of the screen for another mode. + */ + +void +xf86ZoomViewport(ScreenPtr pScreen, int zoom) +{ + ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); + DisplayModePtr mode; + + if (pScr->zoomLocked || !(mode = pScr->currentMode)) + return; + + do { + if (zoom > 0) + mode = mode->next; + else + mode = mode->prev; + } while (mode != pScr->currentMode && !(mode->type & M_T_USERDEF)); + + (void)xf86SwitchMode(pScreen, mode); +} + + +static xf86EdgePtr +FindEdge(xf86EdgePtr edge, int val) +{ + while(edge && (edge->end <= val)) + edge = edge->next; + + if(edge && (edge->start <= val)) + return edge; + + return NULL; +} + +/* + * xf86CursorOffScreen -- + * Check whether it is necessary to switch to another screen + */ + +static Bool +xf86CursorOffScreen(ScreenPtr *pScreen, int *x, int *y) +{ + xf86EdgePtr edge; + int tmp; + + if(screenInfo.numScreens == 1) + return FALSE; + + if(*x < 0) { + tmp = *y; + if(tmp < 0) tmp = 0; + if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1; + + if((edge = xf86ScreenLayout[(*pScreen)->myNum].left)) + edge = FindEdge(edge, tmp); + + if(!edge) *x = 0; + else { + *x += edge->offset.x; + *y += edge->offset.y; + *pScreen = xf86Screens[edge->screen]->pScreen; + } + } + + if(*x >= (*pScreen)->width) { + tmp = *y; + if(tmp < 0) tmp = 0; + if(tmp >= (*pScreen)->height) tmp = (*pScreen)->height - 1; + + if((edge = xf86ScreenLayout[(*pScreen)->myNum].right)) + edge = FindEdge(edge, tmp); + + if(!edge) *x = (*pScreen)->width - 1; + else { + *x += edge->offset.x; + *y += edge->offset.y; + *pScreen = xf86Screens[edge->screen]->pScreen; + } + } + + if(*y < 0) { + tmp = *x; + if(tmp < 0) tmp = 0; + if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1; + + if((edge = xf86ScreenLayout[(*pScreen)->myNum].up)) + edge = FindEdge(edge, tmp); + + if(!edge) *y = 0; + else { + *x += edge->offset.x; + *y += edge->offset.y; + *pScreen = xf86Screens[edge->screen]->pScreen; + } + } + + if(*y >= (*pScreen)->height) { + tmp = *x; + if(tmp < 0) tmp = 0; + if(tmp >= (*pScreen)->width) tmp = (*pScreen)->width - 1; + + if((edge = xf86ScreenLayout[(*pScreen)->myNum].down)) + edge = FindEdge(edge, tmp); + + if(!edge) *y = (*pScreen)->height - 1; + else { + *x += edge->offset.x; + *y += edge->offset.y; + (*pScreen) = xf86Screens[edge->screen]->pScreen; + } + } + + +#if 0 + /* This presents problems for overlapping screens when + HardEdges is used. Have to think about the logic more */ + if((*x < 0) || (*x >= (*pScreen)->width) || + (*y < 0) || (*y >= (*pScreen)->height)) { + /* We may have crossed more than one screen */ + xf86CursorOffScreen(pScreen, x, y); + } +#endif + + return TRUE; +} + + + +/* + * xf86CrossScreen -- + * Switch to another screen + * + * Currently nothing special happens, but mi assumes the CrossScreen + * method exists. + */ + +static void +xf86CrossScreen (ScreenPtr pScreen, Bool entering) +{ +} + + +/* + * xf86WarpCursor -- + * Warp possible to another screen + */ + +/* ARGSUSED */ +static void +xf86WarpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y) +{ + int sigstate; + sigstate = xf86BlockSIGIO (); + miPointerWarpCursor(pDev, pScreen, x, y); + + xf86Info.currentScreen = pScreen; + xf86UnblockSIGIO (sigstate); +} + + +void * +xf86GetPointerScreenFuncs(void) +{ + return (void *)&xf86PointerScreenFuncs; +} + + +static xf86EdgePtr +AddEdge( + xf86EdgePtr edge, + short min, + short max, + short dx, + short dy, + short screen +){ + xf86EdgePtr pEdge = edge, pPrev = NULL, pNew; + + while(1) { + while(pEdge && (min >= pEdge->end)) { + pPrev = pEdge; + pEdge = pEdge->next; + } + + if(!pEdge) { + if(!(pNew = malloc(sizeof(xf86EdgeRec)))) + break; + + pNew->screen = screen; + pNew->start = min; + pNew->end = max; + pNew->offset.x = dx; + pNew->offset.y = dy; + pNew->next = NULL; + + if(pPrev) + pPrev->next = pNew; + else + edge = pNew; + + break; + } else if (min < pEdge->start) { + if(!(pNew = malloc(sizeof(xf86EdgeRec)))) + break; + + pNew->screen = screen; + pNew->start = min; + pNew->offset.x = dx; + pNew->offset.y = dy; + pNew->next = pEdge; + + if(pPrev) pPrev->next = pNew; + else edge = pNew; + + if(max <= pEdge->start) { + pNew->end = max; + break; + } else { + pNew->end = pEdge->start; + min = pEdge->end; + } + } else + min = pEdge->end; + + pPrev = pEdge; + pEdge = pEdge->next; + + if(max <= min) break; + } + + return edge; +} + +static void +FillOutEdge(xf86EdgePtr pEdge, int limit) +{ + xf86EdgePtr pNext; + int diff; + + if(pEdge->start > 0) pEdge->start = 0; + + while((pNext = pEdge->next)) { + diff = pNext->start - pEdge->end; + if(diff > 0) { + pEdge->end += diff >> 1; + pNext->start -= diff - (diff >> 1); + } + pEdge = pNext; + } + + if(pEdge->end < limit) + pEdge->end = limit; +} + +/* + * xf86InitOrigins() can deal with a maximum of 32 screens + * on 32 bit architectures, 64 on 64 bit architectures. + */ + +void +xf86InitOrigins(void) +{ + unsigned long screensLeft, prevScreensLeft, mask; + screenLayoutPtr screen; + ScreenPtr pScreen, refScreen; + int x1, x2, y1, y2, left, right, top, bottom; + int i, j, ref, minX, minY, min, max; + xf86ScreenLayoutPtr pLayout; + Bool OldStyleConfig = FALSE; + + /* need to have this set up with a config file option */ + HardEdges = FALSE; + + memset(xf86ScreenLayout, 0, MAXSCREENS * sizeof(xf86ScreenLayoutRec)); + + screensLeft = prevScreensLeft = (1 << xf86NumScreens) - 1; + + while(1) { + for(mask = screensLeft, i = 0; mask; mask >>= 1, i++) { + if(!(mask & 1L)) continue; + + screen = &xf86ConfigLayout.screens[i]; + + if (screen->refscreen != NULL && + screen->refscreen->screennum >= xf86NumScreens) { + screensLeft &= ~(1 << i); + xf86Msg(X_WARNING, "Not including screen \"%s\" in origins calculation.\n", + screen->screen->id); + continue; + } + + pScreen = xf86Screens[i]->pScreen; + switch(screen->where) { + case PosObsolete: + OldStyleConfig = TRUE; + pLayout = &xf86ScreenLayout[i]; + /* force edge lists */ + if(screen->left) { + ref = screen->left->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + pLayout->left = AddEdge(pLayout->left, + 0, pScreen->height, + xf86Screens[ref]->pScreen->width, 0, ref); + } + if(screen->right) { + ref = screen->right->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + pLayout->right = AddEdge(pLayout->right, + 0, pScreen->height, -pScreen->width, 0, ref); + } + if(screen->top) { + ref = screen->top->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + pLayout->up = AddEdge(pLayout->up, + 0, pScreen->width, + 0, xf86Screens[ref]->pScreen->height, ref); + } + if(screen->bottom) { + ref = screen->bottom->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + pLayout->down = AddEdge(pLayout->down, + 0, pScreen->width, 0, -pScreen->height, ref); + } + /* we could also try to place it based on those + relative locations if we wanted to */ + screen->x = screen->y = 0; + /* FALLTHROUGH */ + case PosAbsolute: + pScreen->x = screen->x; + pScreen->y = screen->y; + screensLeft &= ~(1 << i); + break; + case PosRelative: + ref = screen->refscreen->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + if(screensLeft & (1 << ref)) break; + refScreen = xf86Screens[ref]->pScreen; + pScreen->x = refScreen->x + screen->x; + pScreen->y = refScreen->y + screen->y; + screensLeft &= ~(1 << i); + break; + case PosRightOf: + ref = screen->refscreen->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + if(screensLeft & (1 << ref)) break; + refScreen = xf86Screens[ref]->pScreen; + pScreen->x = refScreen->x + refScreen->width; + pScreen->y = refScreen->y; + screensLeft &= ~(1 << i); + break; + case PosLeftOf: + ref = screen->refscreen->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + if(screensLeft & (1 << ref)) break; + refScreen = xf86Screens[ref]->pScreen; + pScreen->x = refScreen->x - pScreen->width; + pScreen->y = refScreen->y; + screensLeft &= ~(1 << i); + break; + case PosBelow: + ref = screen->refscreen->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + if(screensLeft & (1 << ref)) break; + refScreen = xf86Screens[ref]->pScreen; + pScreen->x = refScreen->x; + pScreen->y = refScreen->y + refScreen->height; + screensLeft &= ~(1 << i); + break; + case PosAbove: + ref = screen->refscreen->screennum; + if (! xf86Screens[ref] || ! xf86Screens[ref]->pScreen) { + ErrorF("Referenced uninitialized screen in Layout!\n"); + break; + } + if(screensLeft & (1 << ref)) break; + refScreen = xf86Screens[ref]->pScreen; + pScreen->x = refScreen->x; + pScreen->y = refScreen->y - pScreen->height; + screensLeft &= ~(1 << i); + break; + default: + ErrorF("Illegal placement keyword in Layout!\n"); + break; + } + + } + + if(!screensLeft) break; + + if(screensLeft == prevScreensLeft) { + /* All the remaining screens are referencing each other. + Assign a value to one of them and go through again */ + i = 0; + while(!((1 << i) & screensLeft)){ i++; } + + ref = xf86ConfigLayout.screens[i].refscreen->screennum; + xf86Screens[ref]->pScreen->x = xf86Screens[ref]->pScreen->y = 0; + screensLeft &= ~(1 << ref); + } + + prevScreensLeft = screensLeft; + } + + /* justify the topmost and leftmost to (0,0) */ + minX = xf86Screens[0]->pScreen->x; + minY = xf86Screens[0]->pScreen->y; + + for(i = 1; i < xf86NumScreens; i++) { + if(xf86Screens[i]->pScreen->x < minX) + minX = xf86Screens[i]->pScreen->x; + if(xf86Screens[i]->pScreen->y < minY) + minY = xf86Screens[i]->pScreen->y; + } + + if (minX || minY) { + for(i = 0; i < xf86NumScreens; i++) { + xf86Screens[i]->pScreen->x -= minX; + xf86Screens[i]->pScreen->y -= minY; + } + } + + + /* Create the edge lists */ + + if(!OldStyleConfig) { + for(i = 0; i < xf86NumScreens; i++) { + pLayout = &xf86ScreenLayout[i]; + + pScreen = xf86Screens[i]->pScreen; + + left = pScreen->x; + right = left + pScreen->width; + top = pScreen->y; + bottom = top + pScreen->height; + + for(j = 0; j < xf86NumScreens; j++) { + if(i == j) continue; + + refScreen = xf86Screens[j]->pScreen; + + x1 = refScreen->x; + x2 = x1 + refScreen->width; + y1 = refScreen->y; + y2 = y1 + refScreen->height; + + if((bottom > y1) && (top < y2)) { + min = y1 - top; + if(min < 0) min = 0; + max = pScreen->height - (bottom - y2); + if(max > pScreen->height) max = pScreen->height; + + if(((left - 1) >= x1) && ((left - 1) < x2)) + pLayout->left = AddEdge(pLayout->left, min, max, + pScreen->x - refScreen->x, + pScreen->y - refScreen->y, j); + + if((right >= x1) && (right < x2)) + pLayout->right = AddEdge(pLayout->right, min, max, + pScreen->x - refScreen->x, + pScreen->y - refScreen->y, j); + } + + + if((left < x2) && (right > x1)) { + min = x1 - left; + if(min < 0) min = 0; + max = pScreen->width - (right - x2); + if(max > pScreen->width) max = pScreen->width; + + if(((top - 1) >= y1) && ((top - 1) < y2)) + pLayout->up = AddEdge(pLayout->up, min, max, + pScreen->x - refScreen->x, + pScreen->y - refScreen->y, j); + + if((bottom >= y1) && (bottom < y2)) + pLayout->down = AddEdge(pLayout->down, min, max, + pScreen->x - refScreen->x, + pScreen->y - refScreen->y, j); + } + } + } + } + + if(!HardEdges && !OldStyleConfig) { + for(i = 0; i < xf86NumScreens; i++) { + pLayout = &xf86ScreenLayout[i]; + pScreen = xf86Screens[i]->pScreen; + if(pLayout->left) + FillOutEdge(pLayout->left, pScreen->height); + if(pLayout->right) + FillOutEdge(pLayout->right, pScreen->height); + if(pLayout->up) + FillOutEdge(pLayout->up, pScreen->width); + if(pLayout->down) + FillOutEdge(pLayout->down, pScreen->width); + } + } +} + +void +xf86ReconfigureLayout(void) +{ + int i; + + for (i = 0; i < MAXSCREENS; i++) { + xf86ScreenLayoutPtr sl = &xf86ScreenLayout[i]; + /* we don't have to zero these, xf86InitOrigins() takes care of that */ + free(sl->left); + free(sl->right); + free(sl->up); + free(sl->down); + } + + xf86InitOrigins(); +} + + diff --git a/xorg-server/hw/xfree86/common/xf86Events.c b/xorg-server/hw/xfree86/common/xf86Events.c index 004807483..84c0d182a 100644 --- a/xorg-server/hw/xfree86/common/xf86Events.c +++ b/xorg-server/hw/xfree86/common/xf86Events.c @@ -1,758 +1,753 @@ -/*
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- *
- * 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 Thomas Roell not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Thomas Roell makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THOMAS ROELL 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 (c) 1994-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/* [JCH-96/01/21] Extended std reverse map to four buttons. */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xpoll.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "compiler.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#define XF86_OS_PRIVS
-#include "xf86_OSlib.h"
-#include <X11/keysym.h>
-
-#ifdef XFreeXDGA
-#include "dgaproc.h"
-#endif
-
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include "inputstr.h"
-#include "xf86Xinput.h"
-
-#include "mi.h"
-#include "mipointer.h"
-
-#include "xkbsrv.h"
-#include "xkbstr.h"
-
-#ifdef DPMSExtension
-#include <X11/extensions/dpmsconst.h>
-#include "dpmsproc.h"
-#endif
-
-/*
- * This is a toggling variable:
- * FALSE = No VT switching keys have been pressed last time around
- * TRUE = Possible VT switch Pending
- * (DWH - 12/2/93)
- *
- * This has been generalised to work with Linux and *BSD+syscons (DHD)
- */
-
-Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for
- *BSD and for avoiding VT
- switches when using the DRI
- automatic full screen mode.*/
-
-extern fd_set EnabledDevices;
-
-#ifdef XF86PM
-extern void (*xf86OSPMClose)(void);
-#endif
-
-static void xf86VTSwitch(void);
-
-/*
- * Allow arbitrary drivers or other XFree86 code to register with our main
- * Wakeup handler.
- */
-typedef struct x_IHRec {
- int fd;
- InputHandlerProc ihproc;
- pointer data;
- Bool enabled;
- struct x_IHRec * next;
-} IHRec, *IHPtr;
-
-static IHPtr InputHandlers = NULL;
-
-
-Bool
-LegalModifier(unsigned int key, DeviceIntPtr pDev)
-{
- return TRUE;
-}
-
-/*
- * TimeSinceLastInputEvent --
- * Function used for screensaver purposes by the os module. Returns the
- * time in milliseconds since there last was any input.
- */
-int
-TimeSinceLastInputEvent(void)
-{
- if (xf86Info.lastEventTime == 0) {
- xf86Info.lastEventTime = GetTimeInMillis();
- }
- return GetTimeInMillis() - xf86Info.lastEventTime;
-}
-
-/*
- * SetTimeSinceLastInputEvent --
- * Set the lastEventTime to now.
- */
-void
-SetTimeSinceLastInputEvent(void)
-{
- xf86Info.lastEventTime = GetTimeInMillis();
-}
-
-/*
- * ProcessInputEvents --
- * Retrieve all waiting input events and pass them to DIX in their
- * correct chronological order. Only reads from the system pointer
- * and keyboard.
- */
-void
-ProcessInputEvents (void)
-{
- int x, y;
-
- mieqProcessInputEvents();
-
- /* FIXME: This is a problem if we have multiple pointers */
- miPointerGetPosition(inputInfo.pointer, &x, &y);
- xf86SetViewport(xf86Info.currentScreen, x, y);
-}
-
-/*
- * Handle keyboard events that cause some kind of "action"
- * (i.e., server termination, video mode changes, VT switches, etc.)
- */
-void
-xf86ProcessActionEvent(ActionEvent action, void *arg)
-{
- DebugF("ProcessActionEvent(%d,%x)\n", (int) action, arg);
- switch (action) {
- case ACTION_TERMINATE:
- if (!xf86Info.dontZap) {
-#ifdef XFreeXDGA
- DGAShutdown();
-#endif
- GiveUp(0);
- }
- break;
- case ACTION_NEXT_MODE:
- if (!xf86Info.dontZoom)
- xf86ZoomViewport(xf86Info.currentScreen, 1);
- break;
- case ACTION_PREV_MODE:
- if (!xf86Info.dontZoom)
- xf86ZoomViewport(xf86Info.currentScreen, -1);
- break;
- case ACTION_SWITCHSCREEN:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) {
- int vtno = *((int *) arg);
-
- if (vtno != xf86Info.vtno) {
- if (!xf86VTActivate(vtno)) {
- ErrorF("Failed to switch from vt%02d to vt%02d: %s\n",
- xf86Info.vtno, vtno, strerror(errno));
- }
- }
- }
- break;
- case ACTION_SWITCHSCREEN_NEXT:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch) {
- if (!xf86VTActivate(xf86Info.vtno + 1)) {
- /* If first try failed, assume this is the last VT and
- * try wrapping around to the first vt.
- */
- if (!xf86VTActivate(1)) {
- ErrorF("Failed to switch from vt%02d to next vt: %s\n",
- xf86Info.vtno, strerror(errno));
- }
- }
- }
- break;
- case ACTION_SWITCHSCREEN_PREV:
- if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) {
- if (!xf86VTActivate(xf86Info.vtno - 1)) {
- /* Don't know what the maximum VT is, so can't wrap around */
- ErrorF("Failed to switch from vt%02d to previous vt: %s\n",
- xf86Info.vtno, strerror(errno));
- }
- }
- break;
- default:
- break;
- }
-}
-
-/*
- * xf86Wakeup --
- * Os wakeup handler.
- */
-
-/* ARGSUSED */
-void
-xf86Wakeup(pointer blockData, int err, pointer pReadmask)
-{
- fd_set* LastSelectMask = (fd_set*)pReadmask;
- fd_set devicesWithInput;
- InputInfoPtr pInfo;
-
- if (err >= 0) {
-
- XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
- if (XFD_ANYSET(&devicesWithInput)) {
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->read_input && pInfo->fd >= 0 &&
- (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) {
- int sigstate = xf86BlockSIGIO();
-
- /*
- * Remove the descriptior from the set because more than one
- * device may share the same file descriptor.
- */
- FD_CLR(pInfo->fd, &devicesWithInput);
-
- pInfo->read_input(pInfo);
- xf86UnblockSIGIO(sigstate);
- }
- pInfo = pInfo->next;
- }
- }
- }
-
- if (err >= 0) { /* we don't want the handlers called if select() */
- IHPtr ih; /* returned with an error condition, do we? */
-
- for (ih = InputHandlers; ih; ih = ih->next) {
- if (ih->enabled && ih->fd >= 0 && ih->ihproc &&
- (FD_ISSET(ih->fd, ((fd_set *)pReadmask)) != 0)) {
- ih->ihproc(ih->fd, ih->data);
- }
- }
- }
-
- if (xf86VTSwitchPending()) xf86VTSwitch();
-}
-
-
-/*
- * xf86SigioReadInput --
- * signal handler for the SIGIO signal.
- */
-static void
-xf86SigioReadInput(int fd, void *closure)
-{
- int errno_save = errno;
- InputInfoPtr pInfo = closure;
-
- pInfo->read_input(pInfo);
-
- errno = errno_save;
-}
-
-/*
- * xf86AddEnabledDevice --
- *
- */
-void
-xf86AddEnabledDevice(InputInfoPtr pInfo)
-{
- if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) {
- AddEnabledDevice(pInfo->fd);
- }
-}
-
-/*
- * xf86RemoveEnabledDevice --
- *
- */
-void
-xf86RemoveEnabledDevice(InputInfoPtr pInfo)
-{
- if (!xf86RemoveSIGIOHandler (pInfo->fd)) {
- RemoveEnabledDevice(pInfo->fd);
- }
-}
-
-static int *xf86SignalIntercept = NULL;
-
-void
-xf86InterceptSignals(int *signo)
-{
- if ((xf86SignalIntercept = signo))
- *signo = -1;
-}
-
-static void (*xf86SigIllHandler)(void) = NULL;
-
-void
-xf86InterceptSigIll(void (*sigillhandler)(void))
-{
- xf86SigIllHandler = sigillhandler;
-}
-
-/*
- * xf86SigWrapper --
- * Catch unexpected signals and exit or continue cleanly.
- */
-int
-xf86SigWrapper(int signo)
-{
- if ((signo == SIGILL) && xf86SigIllHandler) {
- (*xf86SigIllHandler)();
- return 0; /* continue */
- }
-
- if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) {
- *xf86SignalIntercept = signo;
- return 0; /* continue */
- }
-
- xf86Info.caughtSignal = TRUE;
- return 1; /* abort */
-}
-
-/*
- * xf86PrintBacktrace --
- * Print a stack backtrace for debugging purposes.
- */
-void
-xf86PrintBacktrace(void)
-{
- xorg_backtrace();
-}
-
-static void
-xf86ReleaseKeys(DeviceIntPtr pDev)
-{
- KeyClassPtr keyc;
- int i, j, nevents, sigstate;
-
- if (!pDev || !pDev->key)
- return;
-
- keyc = pDev->key;
-
- /*
- * Hmm... here is the biggest hack of every time !
- * It may be possible that a switch-vt procedure has finished BEFORE
- * you released all keys neccessary to do this. That peculiar behavior
- * can fool the X-server pretty much, cause it assumes that some keys
- * were not released. TWM may stuck alsmost completly....
- * OK, what we are doing here is after returning from the vt-switch
- * exeplicitely unrelease all keyboard keys before the input-devices
- * are reenabled.
- */
-
- for (i = keyc->xkbInfo->desc->min_key_code;
- i < keyc->xkbInfo->desc->max_key_code;
- i++) {
- if (key_is_down(pDev, i, KEY_POSTED)) {
- sigstate = xf86BlockSIGIO ();
- nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i);
- for (j = 0; j < nevents; j++)
- mieqEnqueue(pDev, (InternalEvent*)(xf86Events + j)->event);
- xf86UnblockSIGIO(sigstate);
- }
- }
-}
-
-/*
- * xf86VTSwitch --
- * Handle requests for switching the vt.
- */
-static void
-xf86VTSwitch(void)
-{
- int i, prevSIGIO;
- InputInfoPtr pInfo;
- IHPtr ih;
-
- DebugF("xf86VTSwitch()\n");
-
-#ifdef XFreeXDGA
- if(!DGAVTSwitch())
- return;
-#endif
-
- /*
- * Since all screens are currently all in the same state it is sufficient
- * check the first. This might change in future.
- */
- if (xf86Screens[0]->vtSema) {
-
- DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n",
- BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE));
-#ifdef DPMSExtension
- if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(serverClient, DPMSModeOn);
-#endif
- for (i = 0; i < xf86NumScreens; i++) {
- if (!(dispatchException & DE_TERMINATE))
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE);
- }
-
- /*
- * Keep the order: Disable Device > LeaveVT
- * EnterVT > EnableDevice
- */
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86DisableInputHandler(ih);
- for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
- if (pInfo->dev) {
- xf86ReleaseKeys(pInfo->dev);
- ProcessInputEvents();
- DisableDevice(pInfo->dev, TRUE);
- }
- }
- xf86EnterServerState(SETUP);
- for (i = 0; i < xf86NumScreens; i++)
- xf86Screens[i]->LeaveVT(i, 0);
-
- xf86AccessLeave(); /* We need this here, otherwise */
-
- if (!xf86VTSwitchAway()) {
- /*
- * switch failed
- */
-
- DebugF("xf86VTSwitch: Leave failed\n");
- prevSIGIO = xf86BlockSIGIO();
- xf86AccessEnter();
- xf86EnterServerState(SETUP);
- for (i = 0; i < xf86NumScreens; i++) {
- if (!xf86Screens[i]->EnterVT(i, 0))
- FatalError("EnterVT failed for screen %d\n", i);
- }
- xf86EnterServerState(OPERATING);
- if (!(dispatchException & DE_TERMINATE)) {
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE);
- }
- }
- dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
-
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->dev)
- EnableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
- }
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86EnableInputHandler(ih);
-
- xf86UnblockSIGIO(prevSIGIO);
-
- } else {
-#ifdef XF86PM
- if (xf86OSPMClose)
- xf86OSPMClose();
- xf86OSPMClose = NULL;
-#endif
-
- for (i = 0; i < xf86NumScreens; i++) {
- /*
- * zero all access functions to
- * trap calls when switched away.
- */
- xf86Screens[i]->vtSema = FALSE;
- }
- if (xorgHWAccess)
- xf86DisableIO();
- }
- } else {
-
- DebugF("xf86VTSwitch: Entering\n");
- if (!xf86VTSwitchTo()) return;
-
- prevSIGIO = xf86BlockSIGIO();
-#ifdef XF86PM
- xf86OSPMClose = xf86OSPMOpen();
-#endif
-
- if (xorgHWAccess)
- xf86EnableIO();
- xf86AccessEnter();
- xf86EnterServerState(SETUP);
- for (i = 0; i < xf86NumScreens; i++) {
- xf86Screens[i]->vtSema = TRUE;
- if (!xf86Screens[i]->EnterVT(i, 0))
- FatalError("EnterVT failed for screen %d\n", i);
- }
- xf86EnterServerState(OPERATING);
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->EnableDisableFBAccess)
- (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE);
- }
-
- /* Turn screen saver off when switching back */
- dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
-
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (pInfo->dev)
- EnableDevice(pInfo->dev, TRUE);
- pInfo = pInfo->next;
- }
-
- for (ih = InputHandlers; ih; ih = ih->next)
- xf86EnableInputHandler(ih);
-
- xf86UnblockSIGIO(prevSIGIO);
- }
-}
-
-
-/* Input handler registration */
-
-static pointer
-addInputHandler(int fd, InputHandlerProc proc, pointer data)
-{
- IHPtr ih;
-
- if (fd < 0 || !proc)
- return NULL;
-
- ih = calloc(sizeof(*ih), 1);
- if (!ih)
- return NULL;
-
- ih->fd = fd;
- ih->ihproc = proc;
- ih->data = data;
- ih->enabled = TRUE;
-
- ih->next = InputHandlers;
- InputHandlers = ih;
-
- return ih;
-}
-
-pointer
-xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data)
-{
- IHPtr ih = addInputHandler(fd, proc, data);
-
- if (ih)
- AddEnabledDevice(fd);
- return ih;
-}
-
-pointer
-xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data)
-{
- IHPtr ih = addInputHandler(fd, proc, data);
-
- if (ih)
- AddGeneralSocket(fd);
- return ih;
-}
-
-/**
- * Set the handler for the console's fd. Replaces (and returns) the previous
- * handler or NULL, whichever appropriate.
- * proc may be NULL if the server should not handle events on the console.
- */
-InputHandlerProc
-xf86SetConsoleHandler(InputHandlerProc proc, pointer data)
-{
- static InputHandlerProc handler = NULL;
- InputHandlerProc old_handler = handler;
-
- if (old_handler)
- xf86RemoveGeneralHandler(old_handler);
-
- xf86AddGeneralHandler(xf86Info.consoleFd, proc, data);
- handler = proc;
-
- return old_handler;
-}
-
-static void
-removeInputHandler(IHPtr ih)
-{
- IHPtr p;
-
- if (ih == InputHandlers)
- InputHandlers = ih->next;
- else {
- p = InputHandlers;
- while (p && p->next != ih)
- p = p->next;
- if (ih)
- p->next = ih->next;
- }
- free(ih);
-}
-
-int
-xf86RemoveInputHandler(pointer handler)
-{
- IHPtr ih;
- int fd;
-
- if (!handler)
- return -1;
-
- ih = handler;
- fd = ih->fd;
-
- if (ih->fd >= 0)
- RemoveEnabledDevice(ih->fd);
- removeInputHandler(ih);
-
- return fd;
-}
-
-int
-xf86RemoveGeneralHandler(pointer handler)
-{
- IHPtr ih;
- int fd;
-
- if (!handler)
- return -1;
-
- ih = handler;
- fd = ih->fd;
-
- if (ih->fd >= 0)
- RemoveGeneralSocket(ih->fd);
- removeInputHandler(ih);
-
- return fd;
-}
-
-void
-xf86DisableInputHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = FALSE;
- if (ih->fd >= 0)
- RemoveEnabledDevice(ih->fd);
-}
-
-void
-xf86DisableGeneralHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = FALSE;
- if (ih->fd >= 0)
- RemoveGeneralSocket(ih->fd);
-}
-
-void
-xf86EnableInputHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = TRUE;
- if (ih->fd >= 0)
- AddEnabledDevice(ih->fd);
-}
-
-void
-xf86EnableGeneralHandler(pointer handler)
-{
- IHPtr ih;
-
- if (!handler)
- return;
-
- ih = handler;
- ih->enabled = TRUE;
- if (ih->fd >= 0)
- AddGeneralSocket(ih->fd);
-}
-
-/*
- * As used currently by the DRI, the return value is ignored.
- */
-Bool
-xf86EnableVTSwitch(Bool new)
-{
- static Bool def = TRUE;
- Bool old;
-
- old = VTSwitchEnabled;
- if (!new) {
- /* Disable VT switching */
- def = VTSwitchEnabled;
- VTSwitchEnabled = FALSE;
- } else {
- /* Restore VT switching to default */
- VTSwitchEnabled = def;
- }
- return old;
-}
-
-void
-DDXRingBell(int volume, int pitch, int duration) {
- xf86OSRingBell(volume, pitch, duration);
-}
+/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * 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 Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL 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 (c) 1994-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* [JCH-96/01/21] Extended std reverse map to four buttons. */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include <X11/Xpoll.h> +#include <X11/Xproto.h> +#include "misc.h" +#include "compiler.h" +#include "xf86.h" +#include "xf86Priv.h" +#define XF86_OS_PRIVS +#include "xf86_OSlib.h" +#include <X11/keysym.h> + +#ifdef XFreeXDGA +#include "dgaproc.h" +#endif + +#include <X11/extensions/XI.h> +#include <X11/extensions/XIproto.h> +#include "inputstr.h" +#include "xf86Xinput.h" + +#include "mi.h" +#include "mipointer.h" + +#include "xkbsrv.h" +#include "xkbstr.h" + +#ifdef DPMSExtension +#include <X11/extensions/dpmsconst.h> +#include "dpmsproc.h" +#endif + +/* + * This is a toggling variable: + * FALSE = No VT switching keys have been pressed last time around + * TRUE = Possible VT switch Pending + * (DWH - 12/2/93) + * + * This has been generalised to work with Linux and *BSD+syscons (DHD) + */ + +Bool VTSwitchEnabled = TRUE; /* Allows run-time disabling for + *BSD and for avoiding VT + switches when using the DRI + automatic full screen mode.*/ + +extern fd_set EnabledDevices; + +#ifdef XF86PM +extern void (*xf86OSPMClose)(void); +#endif + +static void xf86VTSwitch(void); + +/* + * Allow arbitrary drivers or other XFree86 code to register with our main + * Wakeup handler. + */ +typedef struct x_IHRec { + int fd; + InputHandlerProc ihproc; + pointer data; + Bool enabled; + struct x_IHRec * next; +} IHRec, *IHPtr; + +static IHPtr InputHandlers = NULL; + + +Bool +LegalModifier(unsigned int key, DeviceIntPtr pDev) +{ + return TRUE; +} + +/* + * TimeSinceLastInputEvent -- + * Function used for screensaver purposes by the os module. Returns the + * time in milliseconds since there last was any input. + */ +int +TimeSinceLastInputEvent(void) +{ + if (xf86Info.lastEventTime == 0) { + xf86Info.lastEventTime = GetTimeInMillis(); + } + return GetTimeInMillis() - xf86Info.lastEventTime; +} + +/* + * SetTimeSinceLastInputEvent -- + * Set the lastEventTime to now. + */ +void +SetTimeSinceLastInputEvent(void) +{ + xf86Info.lastEventTime = GetTimeInMillis(); +} + +/* + * ProcessInputEvents -- + * Retrieve all waiting input events and pass them to DIX in their + * correct chronological order. Only reads from the system pointer + * and keyboard. + */ +void +ProcessInputEvents (void) +{ + int x, y; + + mieqProcessInputEvents(); + + /* FIXME: This is a problem if we have multiple pointers */ + miPointerGetPosition(inputInfo.pointer, &x, &y); + xf86SetViewport(xf86Info.currentScreen, x, y); +} + +/* + * Handle keyboard events that cause some kind of "action" + * (i.e., server termination, video mode changes, VT switches, etc.) + */ +void +xf86ProcessActionEvent(ActionEvent action, void *arg) +{ + DebugF("ProcessActionEvent(%d,%x)\n", (int) action, arg); + switch (action) { + case ACTION_TERMINATE: + if (!xf86Info.dontZap) { +#ifdef XFreeXDGA + DGAShutdown(); +#endif + GiveUp(0); + } + break; + case ACTION_NEXT_MODE: + if (!xf86Info.dontZoom) + xf86ZoomViewport(xf86Info.currentScreen, 1); + break; + case ACTION_PREV_MODE: + if (!xf86Info.dontZoom) + xf86ZoomViewport(xf86Info.currentScreen, -1); + break; + case ACTION_SWITCHSCREEN: + if (VTSwitchEnabled && !xf86Info.dontVTSwitch && arg) { + int vtno = *((int *) arg); + + if (vtno != xf86Info.vtno) { + if (!xf86VTActivate(vtno)) { + ErrorF("Failed to switch from vt%02d to vt%02d: %s\n", + xf86Info.vtno, vtno, strerror(errno)); + } + } + } + break; + case ACTION_SWITCHSCREEN_NEXT: + if (VTSwitchEnabled && !xf86Info.dontVTSwitch) { + if (!xf86VTActivate(xf86Info.vtno + 1)) { + /* If first try failed, assume this is the last VT and + * try wrapping around to the first vt. + */ + if (!xf86VTActivate(1)) { + ErrorF("Failed to switch from vt%02d to next vt: %s\n", + xf86Info.vtno, strerror(errno)); + } + } + } + break; + case ACTION_SWITCHSCREEN_PREV: + if (VTSwitchEnabled && !xf86Info.dontVTSwitch && xf86Info.vtno > 0) { + if (!xf86VTActivate(xf86Info.vtno - 1)) { + /* Don't know what the maximum VT is, so can't wrap around */ + ErrorF("Failed to switch from vt%02d to previous vt: %s\n", + xf86Info.vtno, strerror(errno)); + } + } + break; + default: + break; + } +} + +/* + * xf86Wakeup -- + * Os wakeup handler. + */ + +/* ARGSUSED */ +void +xf86Wakeup(pointer blockData, int err, pointer pReadmask) +{ + fd_set* LastSelectMask = (fd_set*)pReadmask; + fd_set devicesWithInput; + InputInfoPtr pInfo; + + if (err >= 0) { + + XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices); + if (XFD_ANYSET(&devicesWithInput)) { + pInfo = xf86InputDevs; + while (pInfo) { + if (pInfo->read_input && pInfo->fd >= 0 && + (FD_ISSET(pInfo->fd, &devicesWithInput) != 0)) { + int sigstate = xf86BlockSIGIO(); + + /* + * Remove the descriptior from the set because more than one + * device may share the same file descriptor. + */ + FD_CLR(pInfo->fd, &devicesWithInput); + + pInfo->read_input(pInfo); + xf86UnblockSIGIO(sigstate); + } + pInfo = pInfo->next; + } + } + } + + if (err >= 0) { /* we don't want the handlers called if select() */ + IHPtr ih; /* returned with an error condition, do we? */ + + for (ih = InputHandlers; ih; ih = ih->next) { + if (ih->enabled && ih->fd >= 0 && ih->ihproc && + (FD_ISSET(ih->fd, ((fd_set *)pReadmask)) != 0)) { + ih->ihproc(ih->fd, ih->data); + } + } + } + + if (xf86VTSwitchPending()) xf86VTSwitch(); +} + + +/* + * xf86SigioReadInput -- + * signal handler for the SIGIO signal. + */ +static void +xf86SigioReadInput(int fd, void *closure) +{ + int errno_save = errno; + InputInfoPtr pInfo = closure; + + pInfo->read_input(pInfo); + + errno = errno_save; +} + +/* + * xf86AddEnabledDevice -- + * + */ +void +xf86AddEnabledDevice(InputInfoPtr pInfo) +{ + if (!xf86InstallSIGIOHandler (pInfo->fd, xf86SigioReadInput, pInfo)) { + AddEnabledDevice(pInfo->fd); + } +} + +/* + * xf86RemoveEnabledDevice -- + * + */ +void +xf86RemoveEnabledDevice(InputInfoPtr pInfo) +{ + if (!xf86RemoveSIGIOHandler (pInfo->fd)) { + RemoveEnabledDevice(pInfo->fd); + } +} + +static int *xf86SignalIntercept = NULL; + +void +xf86InterceptSignals(int *signo) +{ + if ((xf86SignalIntercept = signo)) + *signo = -1; +} + +static void (*xf86SigIllHandler)(void) = NULL; + +void +xf86InterceptSigIll(void (*sigillhandler)(void)) +{ + xf86SigIllHandler = sigillhandler; +} + +/* + * xf86SigWrapper -- + * Catch unexpected signals and exit or continue cleanly. + */ +int +xf86SigWrapper(int signo) +{ + if ((signo == SIGILL) && xf86SigIllHandler) { + (*xf86SigIllHandler)(); + return 0; /* continue */ + } + + if (xf86SignalIntercept && (*xf86SignalIntercept < 0)) { + *xf86SignalIntercept = signo; + return 0; /* continue */ + } + + xf86Info.caughtSignal = TRUE; + return 1; /* abort */ +} + +/* + * xf86PrintBacktrace -- + * Print a stack backtrace for debugging purposes. + */ +void +xf86PrintBacktrace(void) +{ + xorg_backtrace(); +} + +static void +xf86ReleaseKeys(DeviceIntPtr pDev) +{ + KeyClassPtr keyc; + int i, j, nevents, sigstate; + + if (!pDev || !pDev->key) + return; + + keyc = pDev->key; + + /* + * Hmm... here is the biggest hack of every time ! + * It may be possible that a switch-vt procedure has finished BEFORE + * you released all keys neccessary to do this. That peculiar behavior + * can fool the X-server pretty much, cause it assumes that some keys + * were not released. TWM may stuck alsmost completly.... + * OK, what we are doing here is after returning from the vt-switch + * exeplicitely unrelease all keyboard keys before the input-devices + * are reenabled. + */ + + for (i = keyc->xkbInfo->desc->min_key_code; + i < keyc->xkbInfo->desc->max_key_code; + i++) { + if (key_is_down(pDev, i, KEY_POSTED)) { + sigstate = xf86BlockSIGIO (); + nevents = GetKeyboardEvents(xf86Events, pDev, KeyRelease, i); + for (j = 0; j < nevents; j++) + mieqEnqueue(pDev, (InternalEvent*)(xf86Events + j)->event); + xf86UnblockSIGIO(sigstate); + } + } +} + +/* + * xf86VTSwitch -- + * Handle requests for switching the vt. + */ +static void +xf86VTSwitch(void) +{ + int i; + static int prevSIGIO; + InputInfoPtr pInfo; + IHPtr ih; + + DebugF("xf86VTSwitch()\n"); + +#ifdef XFreeXDGA + if(!DGAVTSwitch()) + return; +#endif + + /* + * Since all screens are currently all in the same state it is sufficient + * check the first. This might change in future. + */ + if (xf86Screens[0]->vtSema) { + + DebugF("xf86VTSwitch: Leaving, xf86Exiting is %s\n", + BOOLTOSTRING((dispatchException & DE_TERMINATE) ? TRUE : FALSE)); +#ifdef DPMSExtension + if (DPMSPowerLevel != DPMSModeOn) + DPMSSet(serverClient, DPMSModeOn); +#endif + for (i = 0; i < xf86NumScreens; i++) { + if (!(dispatchException & DE_TERMINATE)) + if (xf86Screens[i]->EnableDisableFBAccess) + (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE); + } + + /* + * Keep the order: Disable Device > LeaveVT + * EnterVT > EnableDevice + */ + for (ih = InputHandlers; ih; ih = ih->next) + xf86DisableInputHandler(ih); + for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) { + if (pInfo->dev) { + xf86ReleaseKeys(pInfo->dev); + ProcessInputEvents(); + DisableDevice(pInfo->dev, TRUE); + } + } + + prevSIGIO = xf86BlockSIGIO(); + for (i = 0; i < xf86NumScreens; i++) + xf86Screens[i]->LeaveVT(i, 0); + + xf86AccessLeave(); /* We need this here, otherwise */ + + if (!xf86VTSwitchAway()) { + /* + * switch failed + */ + + DebugF("xf86VTSwitch: Leave failed\n"); + xf86AccessEnter(); + for (i = 0; i < xf86NumScreens; i++) { + if (!xf86Screens[i]->EnterVT(i, 0)) + FatalError("EnterVT failed for screen %d\n", i); + } + if (!(dispatchException & DE_TERMINATE)) { + for (i = 0; i < xf86NumScreens; i++) { + if (xf86Screens[i]->EnableDisableFBAccess) + (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); + } + } + dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); + + pInfo = xf86InputDevs; + while (pInfo) { + if (pInfo->dev) + EnableDevice(pInfo->dev, TRUE); + pInfo = pInfo->next; + } + for (ih = InputHandlers; ih; ih = ih->next) + xf86EnableInputHandler(ih); + + xf86UnblockSIGIO(prevSIGIO); + + } else { +#ifdef XF86PM + if (xf86OSPMClose) + xf86OSPMClose(); + xf86OSPMClose = NULL; +#endif + + for (i = 0; i < xf86NumScreens; i++) { + /* + * zero all access functions to + * trap calls when switched away. + */ + xf86Screens[i]->vtSema = FALSE; + } + if (xorgHWAccess) + xf86DisableIO(); + } + } else { + DebugF("xf86VTSwitch: Entering\n"); + if (!xf86VTSwitchTo()) return; + +#ifdef XF86PM + xf86OSPMClose = xf86OSPMOpen(); +#endif + + if (xorgHWAccess) + xf86EnableIO(); + xf86AccessEnter(); + for (i = 0; i < xf86NumScreens; i++) { + xf86Screens[i]->vtSema = TRUE; + if (!xf86Screens[i]->EnterVT(i, 0)) + FatalError("EnterVT failed for screen %d\n", i); + } + for (i = 0; i < xf86NumScreens; i++) { + if (xf86Screens[i]->EnableDisableFBAccess) + (*xf86Screens[i]->EnableDisableFBAccess)(i, TRUE); + } + + /* Turn screen saver off when switching back */ + dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset); + + pInfo = xf86InputDevs; + while (pInfo) { + if (pInfo->dev) + EnableDevice(pInfo->dev, TRUE); + pInfo = pInfo->next; + } + + for (ih = InputHandlers; ih; ih = ih->next) + xf86EnableInputHandler(ih); + + xf86UnblockSIGIO(prevSIGIO); + } +} + + +/* Input handler registration */ + +static pointer +addInputHandler(int fd, InputHandlerProc proc, pointer data) +{ + IHPtr ih; + + if (fd < 0 || !proc) + return NULL; + + ih = calloc(sizeof(*ih), 1); + if (!ih) + return NULL; + + ih->fd = fd; + ih->ihproc = proc; + ih->data = data; + ih->enabled = TRUE; + + ih->next = InputHandlers; + InputHandlers = ih; + + return ih; +} + +pointer +xf86AddInputHandler(int fd, InputHandlerProc proc, pointer data) +{ + IHPtr ih = addInputHandler(fd, proc, data); + + if (ih) + AddEnabledDevice(fd); + return ih; +} + +pointer +xf86AddGeneralHandler(int fd, InputHandlerProc proc, pointer data) +{ + IHPtr ih = addInputHandler(fd, proc, data); + + if (ih) + AddGeneralSocket(fd); + return ih; +} + +/** + * Set the handler for the console's fd. Replaces (and returns) the previous + * handler or NULL, whichever appropriate. + * proc may be NULL if the server should not handle events on the console. + */ +InputHandlerProc +xf86SetConsoleHandler(InputHandlerProc proc, pointer data) +{ + static InputHandlerProc handler = NULL; + InputHandlerProc old_handler = handler; + + if (old_handler) + xf86RemoveGeneralHandler(old_handler); + + xf86AddGeneralHandler(xf86Info.consoleFd, proc, data); + handler = proc; + + return old_handler; +} + +static void +removeInputHandler(IHPtr ih) +{ + IHPtr p; + + if (ih == InputHandlers) + InputHandlers = ih->next; + else { + p = InputHandlers; + while (p && p->next != ih) + p = p->next; + if (ih) + p->next = ih->next; + } + free(ih); +} + +int +xf86RemoveInputHandler(pointer handler) +{ + IHPtr ih; + int fd; + + if (!handler) + return -1; + + ih = handler; + fd = ih->fd; + + if (ih->fd >= 0) + RemoveEnabledDevice(ih->fd); + removeInputHandler(ih); + + return fd; +} + +int +xf86RemoveGeneralHandler(pointer handler) +{ + IHPtr ih; + int fd; + + if (!handler) + return -1; + + ih = handler; + fd = ih->fd; + + if (ih->fd >= 0) + RemoveGeneralSocket(ih->fd); + removeInputHandler(ih); + + return fd; +} + +void +xf86DisableInputHandler(pointer handler) +{ + IHPtr ih; + + if (!handler) + return; + + ih = handler; + ih->enabled = FALSE; + if (ih->fd >= 0) + RemoveEnabledDevice(ih->fd); +} + +void +xf86DisableGeneralHandler(pointer handler) +{ + IHPtr ih; + + if (!handler) + return; + + ih = handler; + ih->enabled = FALSE; + if (ih->fd >= 0) + RemoveGeneralSocket(ih->fd); +} + +void +xf86EnableInputHandler(pointer handler) +{ + IHPtr ih; + + if (!handler) + return; + + ih = handler; + ih->enabled = TRUE; + if (ih->fd >= 0) + AddEnabledDevice(ih->fd); +} + +void +xf86EnableGeneralHandler(pointer handler) +{ + IHPtr ih; + + if (!handler) + return; + + ih = handler; + ih->enabled = TRUE; + if (ih->fd >= 0) + AddGeneralSocket(ih->fd); +} + +/* + * As used currently by the DRI, the return value is ignored. + */ +Bool +xf86EnableVTSwitch(Bool new) +{ + static Bool def = TRUE; + Bool old; + + old = VTSwitchEnabled; + if (!new) { + /* Disable VT switching */ + def = VTSwitchEnabled; + VTSwitchEnabled = FALSE; + } else { + /* Restore VT switching to default */ + VTSwitchEnabled = def; + } + return old; +} + +void +DDXRingBell(int volume, int pitch, int duration) { + xf86OSRingBell(volume, pitch, duration); +} diff --git a/xorg-server/hw/xfree86/common/xf86Globals.c b/xorg-server/hw/xfree86/common/xf86Globals.c index 02f20f690..16d55577e 100644 --- a/xorg-server/hw/xfree86/common/xf86Globals.c +++ b/xorg-server/hw/xfree86/common/xf86Globals.c @@ -1,198 +1,197 @@ -
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * This file contains all the XFree86 global variables.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include "os.h"
-#include "windowstr.h"
-#include "propertyst.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86Parser.h"
-#include "xf86Xinput.h"
-#include "xf86InPriv.h"
-#include "xf86Config.h"
-
-/* Globals that video drivers may access */
-
-DevPrivateKeyRec xf86CreateRootWindowKeyRec;
-DevPrivateKeyRec xf86ScreenKeyRec;
-
-ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
-const unsigned char byte_reversed[256] =
-{
- 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
- 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
- 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
- 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
- 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
- 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
- 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
- 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
- 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
- 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
- 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
- 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
- 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
- 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
- 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
- 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
- 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
- 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
- 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
- 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
- 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
- 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
- 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
- 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
- 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
- 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
- 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
- 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
- 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
- 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
- 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
- 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
-};
-
-/* Globals that input drivers may access */
-InputInfoPtr xf86InputDevs = NULL;
-
-
-/* Globals that video drivers may not access */
-
-xf86InfoRec xf86Info = {
- .consoleFd = -1,
- .vtno = -1,
- .vtSysreq = FALSE,
- .lastEventTime = -1,
- .vtRequestsPending = FALSE,
-#ifdef sun
- .vtPendingNum = -1,
-#endif
- .dontVTSwitch = FALSE,
- .dontZap = FALSE,
- .dontZoom = FALSE,
- .notrapSignals = FALSE,
- .caughtSignal = FALSE,
- .currentScreen = NULL,
-#ifdef CSRG_BASED
- .screenFd = -1,
- .consType = -1,
-#endif
- .allowMouseOpenFail = FALSE,
- .vidModeEnabled = TRUE,
- .vidModeAllowNonLocal = FALSE,
- .miscModInDevEnabled = TRUE,
- .miscModInDevAllowNonLocal = FALSE,
- .pixmap24 = Pix24DontCare,
- .pix24From = X_DEFAULT,
-#ifdef SUPPORT_PC98
- .pc98 = FALSE,
-#endif
- .pmFlag = TRUE,
- .log = LogNone,
- .disableRandR = FALSE,
- .randRFrom = X_DEFAULT,
-#if defined(CONFIG_HAL) || defined(CONFIG_UDEV)
- .forceInputDevices = FALSE,
- .autoAddDevices = TRUE,
- .autoEnableDevices = TRUE
-#else
- .forceInputDevices = TRUE,
- .autoAddDevices = FALSE,
- .autoEnableDevices = FALSE
-#endif
-};
-const char *xf86ConfigFile = NULL;
-const char *xf86ConfigDir = NULL;
-const char *xf86ModulePath = DEFAULT_MODULE_PATH;
-MessageType xf86ModPathFrom = X_DEFAULT;
-const char *xf86LogFile = DEFAULT_LOGPREFIX;
-MessageType xf86LogFileFrom = X_DEFAULT;
-Bool xf86LogFileWasOpened = FALSE;
-serverLayoutRec xf86ConfigLayout = {NULL, };
-confDRIRec xf86ConfigDRI = {0, };
-XF86ConfigPtr xf86configptr = NULL;
-Bool xf86Resetting = FALSE;
-Bool xf86Initialising = FALSE;
-Bool xf86DoConfigure = FALSE;
-Bool xf86DoShowOptions = FALSE;
-DriverPtr *xf86DriverList = NULL;
-int xf86NumDrivers = 0;
-InputDriverPtr *xf86InputDriverList = NULL;
-int xf86NumInputDrivers = 0;
-int xf86NumScreens = 0;
-
-const char *xf86VisualNames[] = {
- "StaticGray",
- "GrayScale",
- "StaticColor",
- "PseudoColor",
- "TrueColor",
- "DirectColor"
-};
-
-/* Parameters set only from the command line */
-char *xf86ServerName = "no-name";
-Bool xf86fpFlag = FALSE;
-Bool xf86sFlag = FALSE;
-Bool xf86bsEnableFlag = FALSE;
-Bool xf86bsDisableFlag = FALSE;
-Bool xf86silkenMouseDisableFlag = FALSE;
-Bool xf86xkbdirFlag = FALSE;
-#ifdef HAVE_ACPI
-Bool xf86acpiDisableFlag = FALSE;
-#endif
-char *xf86LayoutName = NULL;
-char *xf86ScreenName = NULL;
-char *xf86PointerName = NULL;
-char *xf86KeyboardName = NULL;
-int xf86Verbose = DEFAULT_VERBOSE;
-int xf86LogVerbose = DEFAULT_LOG_VERBOSE;
-int xf86FbBpp = -1;
-Pix24Flags xf86Pix24 = Pix24DontCare;
-int xf86Depth = -1;
-rgb xf86Weight = {0, 0, 0};
-Bool xf86FlipPixels = FALSE;
-Gamma xf86Gamma = {0.0, 0.0, 0.0};
-Bool xf86AllowMouseOpenFail = FALSE;
-#ifdef XF86VIDMODE
-Bool xf86VidModeDisabled = FALSE;
-Bool xf86VidModeAllowNonLocal = FALSE;
-#endif
-RootWinPropPtr *xf86RegisteredPropertiesTable = NULL;
-Bool xf86inSuspend = FALSE;
-Bool xorgHWAccess = FALSE;
+ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains all the XFree86 global variables. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <X11/X.h> +#include "os.h" +#include "windowstr.h" +#include "propertyst.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Parser.h" +#include "xf86Xinput.h" +#include "xf86InPriv.h" +#include "xf86Config.h" + +/* Globals that video drivers may access */ + +DevPrivateKeyRec xf86CreateRootWindowKeyRec; +DevPrivateKeyRec xf86ScreenKeyRec; + +ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */ +const unsigned char byte_reversed[256] = +{ + 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, + 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, + 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, + 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, + 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, + 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, + 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, + 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, + 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, + 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, + 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, + 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, + 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, + 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, + 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, + 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, + 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, + 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, + 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, + 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, + 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, + 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, + 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, + 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, + 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, + 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, + 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, + 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, + 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, + 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, + 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, + 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, +}; + +/* Globals that input drivers may access */ +InputInfoPtr xf86InputDevs = NULL; + + +/* Globals that video drivers may not access */ + +xf86InfoRec xf86Info = { + .consoleFd = -1, + .vtno = -1, + .vtSysreq = FALSE, + .lastEventTime = -1, + .vtRequestsPending = FALSE, +#ifdef sun + .vtPendingNum = -1, +#endif + .dontVTSwitch = FALSE, + .dontZap = FALSE, + .dontZoom = FALSE, + .notrapSignals = FALSE, + .caughtSignal = FALSE, + .currentScreen = NULL, +#ifdef CSRG_BASED + .screenFd = -1, + .consType = -1, +#endif + .allowMouseOpenFail = FALSE, + .vidModeEnabled = TRUE, + .vidModeAllowNonLocal = FALSE, + .miscModInDevEnabled = TRUE, + .miscModInDevAllowNonLocal = FALSE, + .pixmap24 = Pix24DontCare, + .pix24From = X_DEFAULT, +#ifdef SUPPORT_PC98 + .pc98 = FALSE, +#endif + .pmFlag = TRUE, + .log = LogNone, + .disableRandR = FALSE, + .randRFrom = X_DEFAULT, +#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) + .forceInputDevices = FALSE, + .autoAddDevices = TRUE, + .autoEnableDevices = TRUE +#else + .forceInputDevices = TRUE, + .autoAddDevices = FALSE, + .autoEnableDevices = FALSE +#endif +}; +const char *xf86ConfigFile = NULL; +const char *xf86ConfigDir = NULL; +const char *xf86ModulePath = DEFAULT_MODULE_PATH; +MessageType xf86ModPathFrom = X_DEFAULT; +const char *xf86LogFile = DEFAULT_LOGPREFIX; +MessageType xf86LogFileFrom = X_DEFAULT; +Bool xf86LogFileWasOpened = FALSE; +serverLayoutRec xf86ConfigLayout = {NULL, }; +confDRIRec xf86ConfigDRI = {0, }; +XF86ConfigPtr xf86configptr = NULL; +Bool xf86Resetting = FALSE; +Bool xf86Initialising = FALSE; +Bool xf86DoConfigure = FALSE; +Bool xf86DoShowOptions = FALSE; +DriverPtr *xf86DriverList = NULL; +int xf86NumDrivers = 0; +InputDriverPtr *xf86InputDriverList = NULL; +int xf86NumInputDrivers = 0; +int xf86NumScreens = 0; + +const char *xf86VisualNames[] = { + "StaticGray", + "GrayScale", + "StaticColor", + "PseudoColor", + "TrueColor", + "DirectColor" +}; + +/* Parameters set only from the command line */ +char *xf86ServerName = "no-name"; +Bool xf86fpFlag = FALSE; +Bool xf86sFlag = FALSE; +Bool xf86bsEnableFlag = FALSE; +Bool xf86bsDisableFlag = FALSE; +Bool xf86silkenMouseDisableFlag = FALSE; +Bool xf86xkbdirFlag = FALSE; +#ifdef HAVE_ACPI +Bool xf86acpiDisableFlag = FALSE; +#endif +char *xf86LayoutName = NULL; +char *xf86ScreenName = NULL; +char *xf86PointerName = NULL; +char *xf86KeyboardName = NULL; +int xf86Verbose = DEFAULT_VERBOSE; +int xf86LogVerbose = DEFAULT_LOG_VERBOSE; +int xf86FbBpp = -1; +Pix24Flags xf86Pix24 = Pix24DontCare; +int xf86Depth = -1; +rgb xf86Weight = {0, 0, 0}; +Bool xf86FlipPixels = FALSE; +Gamma xf86Gamma = {0.0, 0.0, 0.0}; +Bool xf86AllowMouseOpenFail = FALSE; +#ifdef XF86VIDMODE +Bool xf86VidModeDisabled = FALSE; +Bool xf86VidModeAllowNonLocal = FALSE; +#endif +RootWinPropPtr *xf86RegisteredPropertiesTable = NULL; +Bool xorgHWAccess = FALSE; diff --git a/xorg-server/hw/xfree86/common/xf86Init.c b/xorg-server/hw/xfree86/common/xf86Init.c index f3ce3f696..a1fda54cd 100644 --- a/xorg-server/hw/xfree86/common/xf86Init.c +++ b/xorg-server/hw/xfree86/common/xf86Init.c @@ -1,1510 +1,1497 @@ -/*
- * Loosely based on code bearing the following copyright:
- *
- * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
- */
-/*
- * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <stdlib.h>
-#include <errno.h>
-
-#undef HAS_UTSNAME
-#if !defined(WIN32)
-#define HAS_UTSNAME 1
-#include <sys/utsname.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-#include <X11/Xproto.h>
-#include <X11/Xatom.h>
-#include "input.h"
-#include "servermd.h"
-#include "windowstr.h"
-#include "scrnintstr.h"
-#include "site.h"
-#include "mi.h"
-
-#include "compiler.h"
-
-#include "loaderProcs.h"
-#ifdef XFreeXDGA
-#include "dgaproc.h"
-#endif
-
-#define XF86_OS_PRIVS
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86Config.h"
-#include "xf86_OSlib.h"
-#include "xf86cmap.h"
-#include "xorgVersion.h"
-#include "xf86Build.h"
-#include "mipointer.h"
-#include <X11/extensions/XI.h>
-#include <X11/extensions/XIproto.h>
-#include "xf86DDC.h"
-#include "xf86Xinput.h"
-#include "xf86InPriv.h"
-#include "picturestr.h"
-
-#include "xf86Bus.h"
-#include "xf86VGAarbiter.h"
-#include "globals.h"
-
-#ifdef DPMSExtension
-#include <X11/extensions/dpmsconst.h>
-#include "dpmsproc.h"
-#endif
-#include <hotplug.h>
-
-
-#ifdef XF86PM
-void (*xf86OSPMClose)(void) = NULL;
-#endif
-static Bool xorgHWOpenConsole = FALSE;
-
-/* Common pixmap formats */
-
-static PixmapFormatRec formats[MAXFORMATS] = {
- { 1, 1, BITMAP_SCANLINE_PAD },
- { 4, 8, BITMAP_SCANLINE_PAD },
- { 8, 8, BITMAP_SCANLINE_PAD },
- { 15, 16, BITMAP_SCANLINE_PAD },
- { 16, 16, BITMAP_SCANLINE_PAD },
- { 24, 32, BITMAP_SCANLINE_PAD },
- { 32, 32, BITMAP_SCANLINE_PAD },
-};
-static int numFormats = 7;
-static Bool formatsDone = FALSE;
-
-#ifndef OSNAME
-#define OSNAME " unknown"
-#endif
-#ifndef OSVENDOR
-#define OSVENDOR ""
-#endif
-#ifndef PRE_RELEASE
-#define PRE_RELEASE XORG_VERSION_SNAP
-#endif
-
-static void
-xf86PrintBanner(void)
-{
-#if PRE_RELEASE
- xf86ErrorFVerb(0, "\n"
- "This is a pre-release version of the X server from " XVENDORNAME ".\n"
- "It is not supported in any way.\n"
- "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
- "Select the \"xorg\" product for bugs you find in this release.\n"
- "Before reporting bugs in pre-release versions please check the\n"
- "latest version in the X.Org Foundation git repository.\n"
- "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
-#endif
- xf86ErrorFVerb(0, "\nX.Org X Server %d.%d.%d",
- XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR,
- XORG_VERSION_PATCH);
-#if XORG_VERSION_SNAP > 0
- xf86ErrorFVerb(0, ".%d", XORG_VERSION_SNAP);
-#endif
-
-#if XORG_VERSION_SNAP >= 900
- /* When the minor number is 99, that signifies that the we are making
- * a release candidate for a major version. (X.0.0)
- * When the patch number is 99, that signifies that the we are making
- * a release candidate for a minor version. (X.Y.0)
- * When the patch number is < 99, then we are making a release
- * candidate for the next point release. (X.Y.Z)
- */
-#if XORG_VERSION_MINOR >= 99
- xf86ErrorFVerb(0, " (%d.0.0 RC %d)", XORG_VERSION_MAJOR+1,
- XORG_VERSION_SNAP - 900);
-#elif XORG_VERSION_PATCH == 99
- xf86ErrorFVerb(0, " (%d.%d.0 RC %d)", XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR + 1, XORG_VERSION_SNAP - 900);
-#else
- xf86ErrorFVerb(0, " (%d.%d.%d RC %d)", XORG_VERSION_MAJOR,
- XORG_VERSION_MINOR, XORG_VERSION_PATCH + 1,
- XORG_VERSION_SNAP - 900);
-#endif
-#endif
-
-#ifdef XORG_CUSTOM_VERSION
- xf86ErrorFVerb(0, " (%s)", XORG_CUSTOM_VERSION);
-#endif
-#ifndef XORG_DATE
-# define XORG_DATE "Unknown"
-#endif
- xf86ErrorFVerb(0, "\nRelease Date: %s\n", XORG_DATE);
- xf86ErrorFVerb(0, "X Protocol Version %d, Revision %d\n",
- X_PROTOCOL, X_PROTOCOL_REVISION);
- xf86ErrorFVerb(0, "Build Operating System: %s %s\n", OSNAME, OSVENDOR);
-#ifdef HAS_UTSNAME
- {
- struct utsname name;
-
- /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
- and Irix) and Single Unix Spec 3 just say that non-negative is success.
- All agree that failure is represented by a negative number.
- */
- if (uname(&name) >= 0) {
- xf86ErrorFVerb(0, "Current Operating System: %s %s %s %s %s\n",
- name.sysname, name.nodename, name.release, name.version, name.machine);
-#ifdef linux
- do {
- char buf[80];
- int fd = open("/proc/cmdline", O_RDONLY);
- if (fd != -1) {
- xf86ErrorFVerb(0, "Kernel command line: ");
- memset(buf, 0, 80);
- while (read(fd, buf, 80) > 0) {
- xf86ErrorFVerb(0, "%.80s", buf);
- memset(buf, 0, 80);
- }
- close(fd);
- }
- } while (0);
-#endif
- }
- }
-#endif
-#if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
- {
- struct tm t;
- char buf[100];
-
- memset(&t, 0, sizeof(t));
- memset(buf, 0, sizeof(buf));
- t.tm_mday = BUILD_DATE % 100;
- t.tm_mon = (BUILD_DATE / 100) % 100 - 1;
- t.tm_year = BUILD_DATE / 10000 - 1900;
-#if defined(BUILD_TIME)
- t.tm_sec = BUILD_TIME % 100;
- t.tm_min = (BUILD_TIME / 100) % 100;
- t.tm_hour = (BUILD_TIME / 10000) % 100;
- if (strftime(buf, sizeof(buf), "%d %B %Y %I:%M:%S%p", &t))
- xf86ErrorFVerb(0, "Build Date: %s\n", buf);
-#else
- if (strftime(buf, sizeof(buf), "%d %B %Y", &t))
- xf86ErrorFVerb(0, "Build Date: %s\n", buf);
-#endif
- }
-#endif
-#if defined(BUILDERSTRING)
- xf86ErrorFVerb(0, "%s \n", BUILDERSTRING);
-#endif
- xf86ErrorFVerb(0, "Current version of pixman: %s\n",
- pixman_version_string());
- xf86ErrorFVerb(0, "\tBefore reporting problems, check "
- ""__VENDORDWEBSUPPORT__"\n"
- "\tto make sure that you have the latest version.\n");
-}
-
-static void
-xf86PrintMarkers(void)
-{
- LogPrintMarkers();
-}
-
-static Bool
-xf86CreateRootWindow(WindowPtr pWin)
-{
- int ret = TRUE;
- int err = Success;
- ScreenPtr pScreen = pWin->drawable.pScreen;
- RootWinPropPtr pProp;
- CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
- dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
-
- DebugF("xf86CreateRootWindow(%p)\n", pWin);
-
- if ( pScreen->CreateWindow != xf86CreateRootWindow ) {
- /* Can't find hook we are hung on */
- xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */,
- "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
- (void *)xf86CreateRootWindow,
- (void *)pScreen->CreateWindow );
- }
-
- /* Unhook this function ... */
- pScreen->CreateWindow = CreateWindow;
- dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
-
- /* ... and call the previous CreateWindow fuction, if any */
- if (NULL!=pScreen->CreateWindow) {
- ret = (*pScreen->CreateWindow)(pWin);
- }
-
- /* Now do our stuff */
- if (xf86RegisteredPropertiesTable != NULL) {
- if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) {
- for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum];
- pProp != NULL && err==Success;
- pProp = pProp->next )
- {
- Atom prop;
-
- prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE);
- err = dixChangeWindowProperty(serverClient, pWin,
- prop, pProp->type,
- pProp->format, PropModeReplace,
- pProp->size, pProp->data,
- FALSE);
- }
-
- /* Look at err */
- ret &= (err==Success);
-
- } else {
- xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with "
- "non-root window %p (parent %p)\n",
- (void *)pWin, (void *)pWin->parent);
- ret = FALSE;
- }
- }
-
- DebugF("xf86CreateRootWindow() returns %d\n", ret);
- return ret;
-}
-
-
-static void
-InstallSignalHandlers(void)
-{
- /*
- * Install signal handler for unexpected signals
- */
- xf86Info.caughtSignal=FALSE;
- if (!xf86Info.notrapSignals) {
- OsRegisterSigWrapper(xf86SigWrapper);
- } else {
- signal(SIGSEGV, SIG_DFL);
- signal(SIGILL, SIG_DFL);
-#ifdef SIGEMT
- signal(SIGEMT, SIG_DFL);
-#endif
- signal(SIGFPE, SIG_DFL);
- signal(SIGBUS, SIG_DFL);
- signal(SIGSYS, SIG_DFL);
- signal(SIGXCPU, SIG_DFL);
- signal(SIGXFSZ, SIG_DFL);
- }
-}
-
-/*
- * InitOutput --
- * Initialize screenInfo for all actually accessible framebuffers.
- * That includes vt-manager setup, querying all possible devices and
- * collecting the pixmap formats.
- */
-void
-InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
-{
- int i, j, k, scr_index;
- char **modulelist;
- pointer *optionlist;
- Pix24Flags screenpix24, pix24;
- MessageType pix24From = X_DEFAULT;
- Bool pix24Fail = FALSE;
- Bool autoconfig = FALSE;
- GDevPtr configured_device;
-
- xf86Initialising = TRUE;
-
- if (serverGeneration == 1) {
- if ((xf86ServerName = strrchr(argv[0], '/')) != 0)
- xf86ServerName++;
- else
- xf86ServerName = argv[0];
-
- xf86PrintBanner();
- xf86PrintMarkers();
- if (xf86LogFile) {
- time_t t;
- const char *ct;
- t = time(NULL);
- ct = ctime(&t);
- xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s",
- xf86LogFile, ct);
- }
-
- /* Read and parse the config file */
- if (!xf86DoConfigure && !xf86DoShowOptions) {
- switch (xf86HandleConfigFile(FALSE)) {
- case CONFIG_OK:
- break;
- case CONFIG_PARSE_ERROR:
- xf86Msg(X_ERROR, "Error parsing the config file\n");
- return;
- case CONFIG_NOFILE:
- autoconfig = TRUE;
- break;
- }
- }
-
- InstallSignalHandlers();
-
- /* Initialise the loader */
- LoaderInit();
-
- /* Tell the loader the default module search path */
- LoaderSetPath(xf86ModulePath);
-
- if (xf86Info.ignoreABI) {
- LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
- }
-
- if (xf86DoShowOptions)
- DoShowOptions();
-
- /* Do a general bus probe. This will be a PCI probe for x86 platforms */
- xf86BusProbe();
-
- if (xf86DoConfigure)
- DoConfigure();
-
- if (autoconfig) {
- if (!xf86AutoConfig()) {
- xf86Msg(X_ERROR, "Auto configuration failed\n");
- return;
- }
- }
-
-#ifdef XF86PM
- xf86OSPMClose = xf86OSPMOpen();
-#endif
-
- /* Load all modules specified explicitly in the config file */
- if ((modulelist = xf86ModulelistFromConfig(&optionlist))) {
- xf86LoadModules(modulelist, optionlist);
- free(modulelist);
- free(optionlist);
- }
-
- /* Load all driver modules specified in the config file */
- /* If there aren't any specified in the config file, autoconfig them */
- /* FIXME: Does not handle multiple active screen sections, but I'm not
- * sure if we really want to handle that case*/
- configured_device = xf86ConfigLayout.screens->screen->device;
- if ((!configured_device) || (!configured_device->driver)) {
- if (!autoConfigDevice(configured_device)) {
- xf86Msg(X_ERROR, "Automatic driver configuration failed\n");
- return ;
- }
- }
- if ((modulelist = xf86DriverlistFromConfig())) {
- xf86LoadModules(modulelist, NULL);
- free(modulelist);
- }
-
- /* Load all input driver modules specified in the config file. */
- if ((modulelist = xf86InputDriverlistFromConfig())) {
- xf86LoadModules(modulelist, NULL);
- free(modulelist);
- }
-
- /*
- * It is expected that xf86AddDriver()/xf86AddInputDriver will be
- * called for each driver as it is loaded. Those functions save the
- * module pointers for drivers.
- * XXX Nothing keeps track of them for other modules.
- */
- /* XXX What do we do if not all of these could be loaded? */
-
- /*
- * At this point, xf86DriverList[] is all filled in with entries for
- * each of the drivers to try and xf86NumDrivers has the number of
- * drivers. If there are none, return now.
- */
-
- if (xf86NumDrivers == 0) {
- xf86Msg(X_ERROR, "No drivers available.\n");
- return;
- }
-
- /*
- * Call each of the Identify functions and call the driverFunc to check
- * if HW access is required. The Identify functions print out some
- * identifying information, and anything else that might be
- * needed at this early stage.
- */
-
- for (i = 0; i < xf86NumDrivers; i++) {
- if (xf86DriverList[i]->Identify != NULL)
- xf86DriverList[i]->Identify(0);
-
- if (!xorgHWAccess || !xorgHWOpenConsole) {
- xorgHWFlags flags;
- if(!xf86DriverList[i]->driverFunc
- || !xf86DriverList[i]->driverFunc(NULL,
- GET_REQUIRED_HW_INTERFACES,
- &flags))
- flags = HW_IO;
-
- if(NEED_IO_ENABLED(flags))
- xorgHWAccess = TRUE;
- if(!(flags & HW_SKIP_CONSOLE))
- xorgHWOpenConsole = TRUE;
- }
- }
-
- if (xorgHWOpenConsole)
- xf86OpenConsole();
- else
- xf86Info.dontVTSwitch = TRUE;
-
- if (xf86BusConfig() == FALSE)
- return;
-
- xf86PostProbe();
-
- /*
- * Sort the drivers to match the requested ording. Using a slow
- * bubble sort.
- */
- for (j = 0; j < xf86NumScreens - 1; j++) {
- for (i = 0; i < xf86NumScreens - j - 1; i++) {
- if (xf86Screens[i + 1]->confScreen->screennum <
- xf86Screens[i]->confScreen->screennum) {
- ScrnInfoPtr tmpScrn = xf86Screens[i + 1];
- xf86Screens[i + 1] = xf86Screens[i];
- xf86Screens[i] = tmpScrn;
- }
- }
- }
- /* Fix up the indexes */
- for (i = 0; i < xf86NumScreens; i++) {
- xf86Screens[i]->scrnIndex = i;
- }
-
- /*
- * Call the driver's PreInit()'s to complete initialisation for the first
- * generation.
- */
-
- for (i = 0; i < xf86NumScreens; i++) {
- xf86VGAarbiterScrnInit(xf86Screens[i]);
- xf86VGAarbiterLock(xf86Screens[i]);
- if (xf86Screens[i]->PreInit &&
- xf86Screens[i]->PreInit(xf86Screens[i], 0))
- xf86Screens[i]->configured = TRUE;
- xf86VGAarbiterUnlock(xf86Screens[i]);
- }
- for (i = 0; i < xf86NumScreens; i++)
- if (!xf86Screens[i]->configured)
- xf86DeleteScreen(i--, 0);
-
- /*
- * If no screens left, return now.
- */
-
- if (xf86NumScreens == 0) {
- xf86Msg(X_ERROR,
- "Screen(s) found, but none have a usable configuration.\n");
- return;
- }
-
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->name == NULL) {
- XNFasprintf(&xf86Screens[i]->name, "screen%d", i);
- xf86MsgVerb(X_WARNING, 0,
- "Screen driver %d has no name set, using `%s'.\n",
- i, xf86Screens[i]->name);
- }
- }
-
- /* Remove (unload) drivers that are not required */
- for (i = 0; i < xf86NumDrivers; i++)
- if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0)
- xf86DeleteDriver(i);
-
- /*
- * At this stage we know how many screens there are.
- */
-
- for (i = 0; i < xf86NumScreens; i++)
- xf86InitViewport(xf86Screens[i]);
-
- /*
- * Collect all pixmap formats and check for conflicts at the display
- * level. Should we die here? Or just delete the offending screens?
- */
- screenpix24 = Pix24DontCare;
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->imageByteOrder !=
- xf86Screens[0]->imageByteOrder)
- FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
- if (xf86Screens[i]->bitmapScanlinePad !=
- xf86Screens[0]->bitmapScanlinePad)
- FatalError("Inconsistent display bitmapScanlinePad. Exiting\n");
- if (xf86Screens[i]->bitmapScanlineUnit !=
- xf86Screens[0]->bitmapScanlineUnit)
- FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n");
- if (xf86Screens[i]->bitmapBitOrder !=
- xf86Screens[0]->bitmapBitOrder)
- FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
-
- /* Determine the depth 24 pixmap format the screens would like */
- if (xf86Screens[i]->pixmap24 != Pix24DontCare) {
- if (screenpix24 == Pix24DontCare)
- screenpix24 = xf86Screens[i]->pixmap24;
- else if (screenpix24 != xf86Screens[i]->pixmap24)
- FatalError("Inconsistent depth 24 pixmap format. Exiting\n");
- }
- }
- /* check if screenpix24 is consistent with the config/cmdline */
- if (xf86Info.pixmap24 != Pix24DontCare) {
- pix24 = xf86Info.pixmap24;
- pix24From = xf86Info.pix24From;
- if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24)
- pix24Fail = TRUE;
- } else if (screenpix24 != Pix24DontCare) {
- pix24 = screenpix24;
- pix24From = X_PROBED;
- } else
- pix24 = Pix24Use32;
-
- if (pix24Fail)
- FatalError("Screen(s) can't use the required depth 24 pixmap format"
- " (%d). Exiting\n", PIX24TOBPP(pix24));
-
- /* Initialise the depth 24 format */
- for (j = 0; j < numFormats && formats[j].depth != 24; j++)
- ;
- formats[j].bitsPerPixel = PIX24TOBPP(pix24);
-
- /* Collect additional formats */
- for (i = 0; i < xf86NumScreens; i++) {
- for (j = 0; j < xf86Screens[i]->numFormats; j++) {
- for (k = 0; ; k++) {
- if (k >= numFormats) {
- if (k >= MAXFORMATS)
- FatalError("Too many pixmap formats! Exiting\n");
- formats[k] = xf86Screens[i]->formats[j];
- numFormats++;
- break;
- }
- if (formats[k].depth == xf86Screens[i]->formats[j].depth) {
- if ((formats[k].bitsPerPixel ==
- xf86Screens[i]->formats[j].bitsPerPixel) &&
- (formats[k].scanlinePad ==
- xf86Screens[i]->formats[j].scanlinePad))
- break;
- FatalError("Inconsistent pixmap format for depth %d."
- " Exiting\n", formats[k].depth);
- }
- }
- }
- }
- formatsDone = TRUE;
-
- if (xf86Info.vtno >= 0 ) {
-#define VT_ATOM_NAME "XFree86_VT"
- Atom VTAtom=-1;
- CARD32 *VT = NULL;
- int ret;
-
- /* This memory needs to stay available until the screen has been
- initialized, and we can create the property for real.
- */
- if ( (VT = malloc(sizeof(CARD32)))==NULL ) {
- FatalError("Unable to make VT property - out of memory. Exiting...\n");
- }
- *VT = xf86Info.vtno;
-
- VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE);
-
- for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) {
- ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex,
- VTAtom, XA_INTEGER, 32,
- 1, VT );
- if (ret != Success)
- xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING,
- "Failed to register VT property\n");
- }
- }
-
- /* If a screen uses depth 24, show what the pixmap format is */
- for (i = 0; i < xf86NumScreens; i++) {
- if (xf86Screens[i]->depth == 24) {
- xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n",
- PIX24TOBPP(pix24));
- break;
- }
- }
- } else {
- /*
- * serverGeneration != 1; some OSs have to do things here, too.
- */
- if (xorgHWOpenConsole)
- xf86OpenConsole();
-
-#ifdef XF86PM
- /*
- should we reopen it here? We need to deal with an already opened
- device. We could leave this to the OS layer. For now we simply
- close it here
- */
- if (xf86OSPMClose)
- xf86OSPMClose();
- if ((xf86OSPMClose = xf86OSPMOpen()) != NULL)
- xf86MsgVerb(X_INFO, 3, "APM registered successfully\n");
-#endif
-
- /* Make sure full I/O access is enabled */
- if (xorgHWAccess)
- xf86EnableIO();
- }
-
- /*
- * Use the previously collected parts to setup pScreenInfo
- */
-
- pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder;
- pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad;
- pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit;
- pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder;
- pScreenInfo->numPixmapFormats = numFormats;
- for (i = 0; i < numFormats; i++)
- pScreenInfo->formats[i] = formats[i];
-
- /* Make sure the server's VT is active */
-
- if (serverGeneration != 1) {
- xf86Resetting = TRUE;
- /* All screens are in the same state, so just check the first */
- if (!xf86Screens[0]->vtSema) {
-#ifdef HAS_USL_VTS
- ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ);
-#endif
- xf86AccessEnter();
- xf86EnterServerState(SETUP);
- }
- }
-#ifdef SCO325
- else {
- /*
- * Under SCO we must ack that we got the console at startup,
- * I think this is the safest way to assure it.
- */
- static int once = 1;
- if (once) {
- once = 0;
- if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
- xf86Msg(X_WARNING, "VT_ACKACQ failed");
- }
- }
-#endif /* SCO325 */
-
- for (i = 0; i < xf86NumScreens; i++)
- if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
- FatalError("Cannot register DDX private keys");
-
- if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
- !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0))
- FatalError("Cannot register DDX private keys");
-
- for (i = 0; i < xf86NumScreens; i++) {
- xf86VGAarbiterLock(xf86Screens[i]);
- /*
- * Almost everything uses these defaults, and many of those that
- * don't, will wrap them.
- */
- xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess;
-#ifdef XFreeXDGA
- xf86Screens[i]->SetDGAMode = xf86SetDGAMode;
-#endif
- xf86Screens[i]->DPMSSet = NULL;
- xf86Screens[i]->LoadPalette = NULL;
- xf86Screens[i]->SetOverscan = NULL;
- xf86Screens[i]->DriverFunc = NULL;
- xf86Screens[i]->pScreen = NULL;
- scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
- xf86VGAarbiterUnlock(xf86Screens[i]);
- if (scr_index == i) {
- /*
- * Hook in our ScrnInfoRec, and initialise some other pScreen
- * fields.
- */
- dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
- xf86ScreenKey, xf86Screens[i]);
- xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
- /* The driver should set this, but make sure it is set anyway */
- xf86Screens[i]->vtSema = TRUE;
- } else {
- /* This shouldn't normally happen */
- FatalError("AddScreen/ScreenInit failed for driver %d\n", i);
- }
-
- DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
- i, xf86Screens[i]->pScreen );
- DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
- i, xf86Screens[i]->pScreen->CreateWindow );
-
- dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
- xf86CreateRootWindowKey,
- xf86Screens[i]->pScreen->CreateWindow);
- xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
-
- if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown)
- {
- xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC);
- PictureSetSubpixelOrder (xf86Screens[i]->pScreen,
- DDC ?
- (DDC->features.input_type ?
- SubPixelHorizontalRGB : SubPixelNone) :
- SubPixelUnknown);
- }
-#ifdef RANDR
- if (!xf86Info.disableRandR)
- xf86RandRInit (screenInfo.screens[scr_index]);
- xf86Msg(xf86Info.randRFrom, "RandR %s\n",
- xf86Info.disableRandR ? "disabled" : "enabled");
-#endif
- }
-
- xf86PostScreenInit();
-
- xf86InitOrigins();
-
- xf86Resetting = FALSE;
- xf86Initialising = FALSE;
-
- RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup,
- NULL);
-}
-
-/*
- * InitInput --
- * Initialize all supported input devices.
- */
-
-void
-InitInput(int argc, char **argv)
-{
- InputInfoPtr* pDev;
- DeviceIntPtr dev;
-
- xf86Info.vtRequestsPending = FALSE;
-
- mieqInit();
-
- GetEventList(&xf86Events);
-
- /* Call the PreInit function for each input device instance. */
- for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) {
- /* Replace obsolete keyboard driver with kbd */
- if (!xf86NameCmp((*pDev)->driver, "keyboard")) {
- strcpy((*pDev)->driver, "kbd");
- }
-
- /* If one fails, the others will too */
- if (xf86NewInputDevice(*pDev, &dev, TRUE) == BadAlloc)
- break;
- }
-
- config_init();
-}
-
-void
-CloseInput (void)
-{
- config_fini();
-}
-
-/*
- * OsVendorInit --
- * OS/Vendor-specific initialisations. Called from OsInit(), which
- * is called by dix before establishing the well known sockets.
- */
-
-void
-OsVendorInit(void)
-{
- static Bool beenHere = FALSE;
-
- signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */
-
- if (!beenHere) {
- umask(022);
- xf86LogInit();
- }
-
- /* Set stderr to non-blocking. */
-#ifndef O_NONBLOCK
-#if defined(FNDELAY)
-#define O_NONBLOCK FNDELAY
-#elif defined(O_NDELAY)
-#define O_NONBLOCK O_NDELAY
-#endif
-
-#ifdef O_NONBLOCK
- if (!beenHere) {
- if (geteuid() == 0 && getuid() != geteuid())
- {
- int status;
-
- status = fcntl(fileno(stderr), F_GETFL, 0);
- if (status != -1) {
- fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK);
- }
- }
- }
-#endif
-#endif
-
- beenHere = TRUE;
-}
-
-/*
- * ddxGiveUp --
- * Device dependent cleanup. Called by by dix before normal server death.
- * For SYSV386 we must switch the terminal back to normal mode. No error-
- * checking here, since there should be restored as much as possible.
- */
-
-void
-ddxGiveUp(void)
-{
- int i;
-
- xf86VGAarbiterFini();
-
-#ifdef XF86PM
- if (xf86OSPMClose)
- xf86OSPMClose();
- xf86OSPMClose = NULL;
-#endif
-
- for (i = 0; i < xf86NumScreens; i++) {
- /*
- * zero all access functions to
- * trap calls when switched away.
- */
- xf86Screens[i]->vtSema = FALSE;
- }
-
-#ifdef XFreeXDGA
- DGAShutdown();
-#endif
-
- if (xorgHWOpenConsole)
- xf86CloseConsole();
-
- xf86CloseLog();
-
- /* If an unexpected signal was caught, dump a core for debugging */
- if (xf86Info.caughtSignal)
- OsAbort();
-}
-
-
-
-/*
- * AbortDDX --
- * DDX - specific abort routine. Called by AbortServer(). The attempt is
- * made to restore all original setting of the displays. Also all devices
- * are closed.
- */
-
-void
-AbortDDX(void)
-{
- int i;
-
- /*
- * try to restore the original video state
- */
-#ifdef DPMSExtension /* Turn screens back on */
- if (DPMSPowerLevel != DPMSModeOn)
- DPMSSet(serverClient, DPMSModeOn);
-#endif
- if (xf86Screens) {
- if (xf86Screens[0]->vtSema)
- xf86EnterServerState(SETUP);
- for (i = 0; i < xf86NumScreens; i++)
- if (xf86Screens[i]->vtSema) {
- /*
- * if we are aborting before ScreenInit() has finished
- * we might not have been wrapped yet. Therefore enable
- * screen explicitely.
- */
- xf86VGAarbiterLock(xf86Screens[i]);
- (xf86Screens[i]->LeaveVT)(i, 0);
- xf86VGAarbiterUnlock(xf86Screens[i]);
- }
- }
-
- xf86AccessLeave();
-
- /*
- * This is needed for an abnormal server exit, since the normal exit stuff
- * MUST also be performed (i.e. the vt must be left in a defined state)
- */
- ddxGiveUp();
-}
-
-void
-OsVendorFatalError(void)
-{
-#ifdef VENDORSUPPORT
- ErrorF("\nPlease refer to your Operating System Vendor support pages\n"
- "at %s for support on this crash.\n",VENDORSUPPORT);
-#else
- ErrorF("\nPlease consult the "XVENDORNAME" support \n"
- "\t at "__VENDORDWEBSUPPORT__"\n for help. \n");
-#endif
- if (xf86LogFile && xf86LogFileWasOpened)
- ErrorF("Please also check the log file at \"%s\" for additional "
- "information.\n", xf86LogFile);
- ErrorF("\n");
-}
-
-int
-xf86SetVerbosity(int verb)
-{
- int save = xf86Verbose;
-
- xf86Verbose = verb;
- LogSetParameter(XLOG_VERBOSITY, verb);
- return save;
-}
-
-int
-xf86SetLogVerbosity(int verb)
-{
- int save = xf86LogVerbose;
-
- xf86LogVerbose = verb;
- LogSetParameter(XLOG_FILE_VERBOSITY, verb);
- return save;
-}
-
-static void
-xf86PrintDefaultModulePath(void)
-{
- ErrorF("%s\n", DEFAULT_MODULE_PATH);
-}
-
-static void
-xf86PrintDefaultLibraryPath(void)
-{
- ErrorF("%s\n", DEFAULT_LIBRARY_PATH);
-}
-
-/*
- * ddxProcessArgument --
- * Process device-dependent command line args. Returns 0 if argument is
- * not device dependent, otherwise Count of number of elements of argv
- * that are part of a device dependent commandline option.
- *
- */
-
-/* ARGSUSED */
-int
-ddxProcessArgument(int argc, char **argv, int i)
-{
-#define CHECK_FOR_REQUIRED_ARGUMENT() \
- if (((i + 1) >= argc) || (!argv[i + 1])) { \
- ErrorF("Required argument to %s not specified\n", argv[i]); \
- UseMsg(); \
- FatalError("Required argument to %s not specified\n", argv[i]); \
- }
-
- /* First the options that are only allowed for root */
- if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) {
- if ( (geteuid() == 0) && (getuid() != 0) ) {
- FatalError("The '%s' option can only be used by root.\n", argv[i]);
- }
- else if (!strcmp(argv[i], "-modulepath"))
- {
- char *mp;
- CHECK_FOR_REQUIRED_ARGUMENT();
- mp = strdup(argv[i + 1]);
- if (!mp)
- FatalError("Can't allocate memory for ModulePath\n");
- xf86ModulePath = mp;
- xf86ModPathFrom = X_CMDLINE;
- return 2;
- }
- else if (!strcmp(argv[i], "-logfile"))
- {
- char *lf;
- CHECK_FOR_REQUIRED_ARGUMENT();
- lf = strdup(argv[i + 1]);
- if (!lf)
- FatalError("Can't allocate memory for LogFile\n");
- xf86LogFile = lf;
- xf86LogFileFrom = X_CMDLINE;
- return 2;
- }
- }
- if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
- FatalError("\nInvalid argument for %s\n"
- "\tFor non-root users, the file specified with %s must be\n"
- "\ta relative path and must not contain any \"..\" elements.\n"
- "\tUsing default "__XCONFIGFILE__" search path.\n\n",
- argv[i], argv[i]);
- }
- xf86ConfigFile = argv[i + 1];
- return 2;
- }
- if (!strcmp(argv[i], "-configdir"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) {
- FatalError("\nInvalid argument for %s\n"
- "\tFor non-root users, the file specified with %s must be\n"
- "\ta relative path and must not contain any \"..\" elements.\n"
- "\tUsing default "__XCONFIGDIR__" search path.\n\n",
- argv[i], argv[i]);
- }
- xf86ConfigDir = argv[i + 1];
- return 2;
- }
- if (!strcmp(argv[i],"-flipPixels"))
- {
- xf86FlipPixels = TRUE;
- return 1;
- }
-#ifdef XF86VIDMODE
- if (!strcmp(argv[i],"-disableVidMode"))
- {
- xf86VidModeDisabled = TRUE;
- return 1;
- }
- if (!strcmp(argv[i],"-allowNonLocalXvidtune"))
- {
- xf86VidModeAllowNonLocal = TRUE;
- return 1;
- }
-#endif
- if (!strcmp(argv[i],"-allowMouseOpenFail"))
- {
- xf86AllowMouseOpenFail = TRUE;
- return 1;
- }
- if (!strcmp(argv[i],"-ignoreABI"))
- {
- LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL);
- return 1;
- }
- if (!strcmp(argv[i],"-verbose"))
- {
- if (++i < argc && argv[i])
- {
- char *end;
- long val;
- val = strtol(argv[i], &end, 0);
- if (*end == '\0')
- {
- xf86SetVerbosity(val);
- return 2;
- }
- }
- xf86SetVerbosity(++xf86Verbose);
- return 1;
- }
- if (!strcmp(argv[i],"-logverbose"))
- {
- if (++i < argc && argv[i])
- {
- char *end;
- long val;
- val = strtol(argv[i], &end, 0);
- if (*end == '\0')
- {
- xf86SetLogVerbosity(val);
- return 2;
- }
- }
- xf86SetLogVerbosity(++xf86LogVerbose);
- return 1;
- }
- if (!strcmp(argv[i],"-quiet"))
- {
- xf86SetVerbosity(-1);
- return 1;
- }
- if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version"))
- {
- xf86PrintBanner();
- exit(0);
- }
- if (!strcmp(argv[i],"-showDefaultModulePath"))
- {
- xf86PrintDefaultModulePath();
- exit(0);
- }
- if (!strcmp(argv[i],"-showDefaultLibPath"))
- {
- xf86PrintDefaultLibraryPath();
- exit(0);
- }
- /* Notice the -fp flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-fp"))
- {
- xf86fpFlag = TRUE;
- return 0;
- }
- /* Notice the -bs flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-bs"))
- {
- xf86bsDisableFlag = TRUE;
- return 0;
- }
- /* Notice the +bs flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "+bs"))
- {
- xf86bsEnableFlag = TRUE;
- return 0;
- }
- /* Notice the -s flag, but allow it to pass to the dix layer */
- if (!strcmp(argv[i], "-s"))
- {
- xf86sFlag = TRUE;
- return 0;
- }
- if (!strcmp(argv[i], "-pixmap24"))
- {
- xf86Pix24 = Pix24Use24;
- return 1;
- }
- if (!strcmp(argv[i], "-pixmap32"))
- {
- xf86Pix24 = Pix24Use32;
- return 1;
- }
- if (!strcmp(argv[i], "-fbbpp"))
- {
- int bpp;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%d", &bpp) == 1)
- {
- xf86FbBpp = bpp;
- return 2;
- }
- else
- {
- ErrorF("Invalid fbbpp\n");
- return 0;
- }
- }
- if (!strcmp(argv[i], "-depth"))
- {
- int depth;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%d", &depth) == 1)
- {
- xf86Depth = depth;
- return 2;
- }
- else
- {
- ErrorF("Invalid depth\n");
- return 0;
- }
- }
- if (!strcmp(argv[i], "-weight"))
- {
- int red, green, blue;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3)
- {
- xf86Weight.red = red;
- xf86Weight.green = green;
- xf86Weight.blue = blue;
- return 2;
- }
- else
- {
- ErrorF("Invalid weighting\n");
- return 0;
- }
- }
- if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") ||
- !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma"))
- {
- double gamma;
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (sscanf(argv[++i], "%lf", &gamma) == 1) {
- if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) {
- ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
- " is valid\n", GAMMA_MIN, GAMMA_MAX);
- return 0;
- }
- if (!strcmp(argv[i-1], "-gamma"))
- xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma;
- else if (!strcmp(argv[i-1], "-rgamma")) xf86Gamma.red = gamma;
- else if (!strcmp(argv[i-1], "-ggamma")) xf86Gamma.green = gamma;
- else if (!strcmp(argv[i-1], "-bgamma")) xf86Gamma.blue = gamma;
- return 2;
- }
- }
- if (!strcmp(argv[i], "-layout"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86LayoutName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-screen"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86ScreenName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-pointer"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86PointerName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-keyboard"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- xf86KeyboardName = argv[++i];
- return 2;
- }
- if (!strcmp(argv[i], "-nosilk"))
- {
- xf86silkenMouseDisableFlag = TRUE;
- return 1;
- }
-#ifdef HAVE_ACPI
- if (!strcmp(argv[i], "-noacpi"))
- {
- xf86acpiDisableFlag = TRUE;
- return 1;
- }
-#endif
- if (!strcmp(argv[i], "-configure"))
- {
- if (getuid() != 0 && geteuid() == 0) {
- ErrorF("The '-configure' option can only be used by root.\n");
- exit(1);
- }
- xf86DoConfigure = TRUE;
- xf86AllowMouseOpenFail = TRUE;
- return 1;
- }
- if (!strcmp(argv[i], "-showopts"))
- {
- if (getuid() != 0 && geteuid() == 0) {
- ErrorF("The '-showopts' option can only be used by root.\n");
- exit(1);
- }
- xf86DoShowOptions = TRUE;
- return 1;
- }
- if (!strcmp(argv[i], "-isolateDevice"))
- {
- CHECK_FOR_REQUIRED_ARGUMENT();
- if (strncmp(argv[++i], "PCI:", 4)) {
- FatalError("Bus types other than PCI not yet isolable\n");
- }
- xf86PciIsolateDevice(argv[i]);
- return 2;
- }
- /* Notice cmdline xkbdir, but pass to dix as well */
- if (!strcmp(argv[i], "-xkbdir"))
- {
- xf86xkbdirFlag = TRUE;
- return 0;
- }
-
- /* OS-specific processing */
- return xf86ProcessArgument(argc, argv, i);
-}
-
-/*
- * ddxUseMsg --
- * Print out correct use of device dependent commandline options.
- * Maybe the user now knows what really to do ...
- */
-
-void
-ddxUseMsg(void)
-{
- ErrorF("\n");
- ErrorF("\n");
- ErrorF("Device Dependent Usage\n");
- if (getuid() == 0 || geteuid() != 0)
- {
- ErrorF("-modulepath paths specify the module search path\n");
- ErrorF("-logfile file specify a log file name\n");
- ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n");
- ErrorF("-showopts print available options for all installed drivers\n");
- }
- ErrorF("-config file specify a configuration file, relative to the\n");
- ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n");
- ErrorF("-configdir dir specify a configuration directory, relative to the\n");
- ErrorF(" "__XCONFIGDIR__" search path, only root can use absolute\n");
- ErrorF("-verbose [n] verbose startup messages\n");
- ErrorF("-logverbose [n] verbose log messages\n");
- ErrorF("-quiet minimal startup messages\n");
- ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n");
- ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n");
- ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n");
- ErrorF("-depth n set colour depth. Default: 8\n");
- ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n");
- ErrorF("-rgamma f set gamma value for red phase\n");
- ErrorF("-ggamma f set gamma value for green phase\n");
- ErrorF("-bgamma f set gamma value for blue phase\n");
- ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n");
- ErrorF("-layout name specify the ServerLayout section name\n");
- ErrorF("-screen name specify the Screen section name\n");
- ErrorF("-keyboard name specify the core keyboard InputDevice name\n");
- ErrorF("-pointer name specify the core pointer InputDevice name\n");
- ErrorF("-nosilk disable Silken Mouse\n");
- ErrorF("-flipPixels swap default black/white Pixel values\n");
-#ifdef XF86VIDMODE
- ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
- ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n");
-#endif
- ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
- ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
- ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
- ErrorF("-version show the server version\n");
- ErrorF("-showDefaultModulePath show the server default module path\n");
- ErrorF("-showDefaultLibPath show the server default library path\n");
- /* OS-specific usage */
- xf86UseMsg();
- ErrorF("\n");
-}
-
-
-/*
- * xf86LoadModules iterates over a list that is being passed in.
- */
-Bool
-xf86LoadModules(char **list, pointer *optlist)
-{
- int errmaj, errmin;
- pointer opt;
- int i;
- char *name;
- Bool failed = FALSE;
-
- if (!list)
- return TRUE;
-
- for (i = 0; list[i] != NULL; i++) {
-
- /* Normalise the module name */
- name = xf86NormalizeName(list[i]);
-
- /* Skip empty names */
- if (name == NULL || *name == '\0')
- continue;
-
- /* Replace obsolete keyboard driver with kbd */
- if (!xf86NameCmp(name, "keyboard")) {
- strcpy(name, "kbd");
- }
-
- if (optlist)
- opt = optlist[i];
- else
- opt = NULL;
-
- if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
- LoaderErrorMsg(NULL, name, errmaj, errmin);
- failed = TRUE;
- }
- free(name);
- }
- return !failed;
-}
-
-/* Pixmap format stuff */
-
-PixmapFormatPtr
-xf86GetPixFormat(ScrnInfoPtr pScrn, int depth)
-{
- int i;
- static PixmapFormatRec format; /* XXX not reentrant */
-
- /*
- * When the formats[] list initialisation isn't complete, check the
- * depth 24 pixmap config/cmdline options and screen-specified formats.
- */
-
- if (!formatsDone) {
- if (depth == 24) {
- Pix24Flags pix24 = Pix24DontCare;
-
- format.depth = 24;
- format.scanlinePad = BITMAP_SCANLINE_PAD;
- if (xf86Info.pixmap24 != Pix24DontCare)
- pix24 = xf86Info.pixmap24;
- else if (pScrn->pixmap24 != Pix24DontCare)
- pix24 = pScrn->pixmap24;
- if (pix24 == Pix24Use24)
- format.bitsPerPixel = 24;
- else
- format.bitsPerPixel = 32;
- return &format;
- }
- }
-
- for (i = 0; i < numFormats; i++)
- if (formats[i].depth == depth)
- break;
- if (i != numFormats)
- return &formats[i];
- else if (!formatsDone) {
- /* Check for screen-specified formats */
- for (i = 0; i < pScrn->numFormats; i++)
- if (pScrn->formats[i].depth == depth)
- break;
- if (i != pScrn->numFormats)
- return &pScrn->formats[i];
- }
- return NULL;
-}
-
-int
-xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth)
-{
- PixmapFormatPtr format;
-
-
- format = xf86GetPixFormat(pScrn, depth);
- if (format)
- return format->bitsPerPixel;
- else
- return 0;
-}
+/* + * Loosely based on code bearing the following copyright: + * + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + */ +/* + * Copyright (c) 1992-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <stdlib.h> +#include <errno.h> + +#undef HAS_UTSNAME +#if !defined(WIN32) +#define HAS_UTSNAME 1 +#include <sys/utsname.h> +#endif + +#include <X11/X.h> +#include <X11/Xmd.h> +#include <X11/Xproto.h> +#include <X11/Xatom.h> +#include "input.h" +#include "servermd.h" +#include "windowstr.h" +#include "scrnintstr.h" +#include "site.h" +#include "mi.h" + +#include "compiler.h" + +#include "loaderProcs.h" +#ifdef XFreeXDGA +#include "dgaproc.h" +#endif + +#define XF86_OS_PRIVS +#include "xf86.h" +#include "xf86Priv.h" +#include "xf86Config.h" +#include "xf86_OSlib.h" +#include "xf86cmap.h" +#include "xorgVersion.h" +#include "xf86Build.h" +#include "mipointer.h" +#include <X11/extensions/XI.h> +#include <X11/extensions/XIproto.h> +#include "xf86DDC.h" +#include "xf86Xinput.h" +#include "xf86InPriv.h" +#include "picturestr.h" + +#include "xf86Bus.h" +#include "xf86VGAarbiter.h" +#include "globals.h" + +#ifdef DPMSExtension +#include <X11/extensions/dpmsconst.h> +#include "dpmsproc.h" +#endif +#include <hotplug.h> + + +#ifdef XF86PM +void (*xf86OSPMClose)(void) = NULL; +#endif +static Bool xorgHWOpenConsole = FALSE; + +/* Common pixmap formats */ + +static PixmapFormatRec formats[MAXFORMATS] = { + { 1, 1, BITMAP_SCANLINE_PAD }, + { 4, 8, BITMAP_SCANLINE_PAD }, + { 8, 8, BITMAP_SCANLINE_PAD }, + { 15, 16, BITMAP_SCANLINE_PAD }, + { 16, 16, BITMAP_SCANLINE_PAD }, + { 24, 32, BITMAP_SCANLINE_PAD }, + { 32, 32, BITMAP_SCANLINE_PAD }, +}; +static int numFormats = 7; +static Bool formatsDone = FALSE; + +#ifndef OSNAME +#define OSNAME " unknown" +#endif +#ifndef OSVENDOR +#define OSVENDOR "" +#endif +#ifndef PRE_RELEASE +#define PRE_RELEASE XORG_VERSION_SNAP +#endif + +static void +xf86PrintBanner(void) +{ +#if PRE_RELEASE + xf86ErrorFVerb(0, "\n" + "This is a pre-release version of the X server from " XVENDORNAME ".\n" + "It is not supported in any way.\n" + "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n" + "Select the \"xorg\" product for bugs you find in this release.\n" + "Before reporting bugs in pre-release versions please check the\n" + "latest version in the X.Org Foundation git repository.\n" + "See http://wiki.x.org/wiki/GitPage for git access instructions.\n"); +#endif + xf86ErrorFVerb(0, "\nX.Org X Server %d.%d.%d", + XORG_VERSION_MAJOR, + XORG_VERSION_MINOR, + XORG_VERSION_PATCH); +#if XORG_VERSION_SNAP > 0 + xf86ErrorFVerb(0, ".%d", XORG_VERSION_SNAP); +#endif + +#if XORG_VERSION_SNAP >= 900 + /* When the minor number is 99, that signifies that the we are making + * a release candidate for a major version. (X.0.0) + * When the patch number is 99, that signifies that the we are making + * a release candidate for a minor version. (X.Y.0) + * When the patch number is < 99, then we are making a release + * candidate for the next point release. (X.Y.Z) + */ +#if XORG_VERSION_MINOR >= 99 + xf86ErrorFVerb(0, " (%d.0.0 RC %d)", XORG_VERSION_MAJOR+1, + XORG_VERSION_SNAP - 900); +#elif XORG_VERSION_PATCH == 99 + xf86ErrorFVerb(0, " (%d.%d.0 RC %d)", XORG_VERSION_MAJOR, + XORG_VERSION_MINOR + 1, XORG_VERSION_SNAP - 900); +#else + xf86ErrorFVerb(0, " (%d.%d.%d RC %d)", XORG_VERSION_MAJOR, + XORG_VERSION_MINOR, XORG_VERSION_PATCH + 1, + XORG_VERSION_SNAP - 900); +#endif +#endif + +#ifdef XORG_CUSTOM_VERSION + xf86ErrorFVerb(0, " (%s)", XORG_CUSTOM_VERSION); +#endif +#ifndef XORG_DATE +# define XORG_DATE "Unknown" +#endif + xf86ErrorFVerb(0, "\nRelease Date: %s\n", XORG_DATE); + xf86ErrorFVerb(0, "X Protocol Version %d, Revision %d\n", + X_PROTOCOL, X_PROTOCOL_REVISION); + xf86ErrorFVerb(0, "Build Operating System: %s %s\n", OSNAME, OSVENDOR); +#ifdef HAS_UTSNAME + { + struct utsname name; + + /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX, + and Irix) and Single Unix Spec 3 just say that non-negative is success. + All agree that failure is represented by a negative number. + */ + if (uname(&name) >= 0) { + xf86ErrorFVerb(0, "Current Operating System: %s %s %s %s %s\n", + name.sysname, name.nodename, name.release, name.version, name.machine); +#ifdef linux + do { + char buf[80]; + int fd = open("/proc/cmdline", O_RDONLY); + if (fd != -1) { + xf86ErrorFVerb(0, "Kernel command line: "); + memset(buf, 0, 80); + while (read(fd, buf, 80) > 0) { + xf86ErrorFVerb(0, "%.80s", buf); + memset(buf, 0, 80); + } + close(fd); + } + } while (0); +#endif + } + } +#endif +#if defined(BUILD_DATE) && (BUILD_DATE > 19000000) + { + struct tm t; + char buf[100]; + + memset(&t, 0, sizeof(t)); + memset(buf, 0, sizeof(buf)); + t.tm_mday = BUILD_DATE % 100; + t.tm_mon = (BUILD_DATE / 100) % 100 - 1; + t.tm_year = BUILD_DATE / 10000 - 1900; +#if defined(BUILD_TIME) + t.tm_sec = BUILD_TIME % 100; + t.tm_min = (BUILD_TIME / 100) % 100; + t.tm_hour = (BUILD_TIME / 10000) % 100; + if (strftime(buf, sizeof(buf), "%d %B %Y %I:%M:%S%p", &t)) + xf86ErrorFVerb(0, "Build Date: %s\n", buf); +#else + if (strftime(buf, sizeof(buf), "%d %B %Y", &t)) + xf86ErrorFVerb(0, "Build Date: %s\n", buf); +#endif + } +#endif +#if defined(BUILDERSTRING) + xf86ErrorFVerb(0, "%s \n", BUILDERSTRING); +#endif + xf86ErrorFVerb(0, "Current version of pixman: %s\n", + pixman_version_string()); + xf86ErrorFVerb(0, "\tBefore reporting problems, check " + ""__VENDORDWEBSUPPORT__"\n" + "\tto make sure that you have the latest version.\n"); +} + +static void +xf86PrintMarkers(void) +{ + LogPrintMarkers(); +} + +static Bool +xf86CreateRootWindow(WindowPtr pWin) +{ + int ret = TRUE; + int err = Success; + ScreenPtr pScreen = pWin->drawable.pScreen; + RootWinPropPtr pProp; + CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr) + dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey); + + DebugF("xf86CreateRootWindow(%p)\n", pWin); + + if ( pScreen->CreateWindow != xf86CreateRootWindow ) { + /* Can't find hook we are hung on */ + xf86DrvMsg(pScreen->myNum, X_WARNING /* X_ERROR */, + "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n", + (void *)xf86CreateRootWindow, + (void *)pScreen->CreateWindow ); + } + + /* Unhook this function ... */ + pScreen->CreateWindow = CreateWindow; + dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL); + + /* ... and call the previous CreateWindow fuction, if any */ + if (NULL!=pScreen->CreateWindow) { + ret = (*pScreen->CreateWindow)(pWin); + } + + /* Now do our stuff */ + if (xf86RegisteredPropertiesTable != NULL) { + if (pWin->parent == NULL && xf86RegisteredPropertiesTable != NULL) { + for (pProp = xf86RegisteredPropertiesTable[pScreen->myNum]; + pProp != NULL && err==Success; + pProp = pProp->next ) + { + Atom prop; + + prop = MakeAtom(pProp->name, strlen(pProp->name), TRUE); + err = dixChangeWindowProperty(serverClient, pWin, + prop, pProp->type, + pProp->format, PropModeReplace, + pProp->size, pProp->data, + FALSE); + } + + /* Look at err */ + ret &= (err==Success); + + } else { + xf86Msg(X_ERROR, "xf86CreateRootWindow unexpectedly called with " + "non-root window %p (parent %p)\n", + (void *)pWin, (void *)pWin->parent); + ret = FALSE; + } + } + + DebugF("xf86CreateRootWindow() returns %d\n", ret); + return ret; +} + + +static void +InstallSignalHandlers(void) +{ + /* + * Install signal handler for unexpected signals + */ + xf86Info.caughtSignal=FALSE; + if (!xf86Info.notrapSignals) { + OsRegisterSigWrapper(xf86SigWrapper); + } else { + signal(SIGSEGV, SIG_DFL); + signal(SIGILL, SIG_DFL); +#ifdef SIGEMT + signal(SIGEMT, SIG_DFL); +#endif + signal(SIGFPE, SIG_DFL); + signal(SIGBUS, SIG_DFL); + signal(SIGSYS, SIG_DFL); + signal(SIGXCPU, SIG_DFL); + signal(SIGXFSZ, SIG_DFL); + } +} + +/* + * InitOutput -- + * Initialize screenInfo for all actually accessible framebuffers. + * That includes vt-manager setup, querying all possible devices and + * collecting the pixmap formats. + */ +void +InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) +{ + int i, j, k, scr_index, was_blocked = 0; + char **modulelist; + pointer *optionlist; + Pix24Flags screenpix24, pix24; + MessageType pix24From = X_DEFAULT; + Bool pix24Fail = FALSE; + Bool autoconfig = FALSE; + GDevPtr configured_device; + + xf86Initialising = TRUE; + + if (serverGeneration == 1) { + if ((xf86ServerName = strrchr(argv[0], '/')) != 0) + xf86ServerName++; + else + xf86ServerName = argv[0]; + + xf86PrintBanner(); + xf86PrintMarkers(); + if (xf86LogFile) { + time_t t; + const char *ct; + t = time(NULL); + ct = ctime(&t); + xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s", + xf86LogFile, ct); + } + + /* Read and parse the config file */ + if (!xf86DoConfigure && !xf86DoShowOptions) { + switch (xf86HandleConfigFile(FALSE)) { + case CONFIG_OK: + break; + case CONFIG_PARSE_ERROR: + xf86Msg(X_ERROR, "Error parsing the config file\n"); + return; + case CONFIG_NOFILE: + autoconfig = TRUE; + break; + } + } + + InstallSignalHandlers(); + + /* Initialise the loader */ + LoaderInit(); + + /* Tell the loader the default module search path */ + LoaderSetPath(xf86ModulePath); + + if (xf86Info.ignoreABI) { + LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL); + } + + if (xf86DoShowOptions) + DoShowOptions(); + + /* Do a general bus probe. This will be a PCI probe for x86 platforms */ + xf86BusProbe(); + + if (xf86DoConfigure) + DoConfigure(); + + if (autoconfig) { + if (!xf86AutoConfig()) { + xf86Msg(X_ERROR, "Auto configuration failed\n"); + return; + } + } + +#ifdef XF86PM + xf86OSPMClose = xf86OSPMOpen(); +#endif + + /* Load all modules specified explicitly in the config file */ + if ((modulelist = xf86ModulelistFromConfig(&optionlist))) { + xf86LoadModules(modulelist, optionlist); + free(modulelist); + free(optionlist); + } + + /* Load all driver modules specified in the config file */ + /* If there aren't any specified in the config file, autoconfig them */ + /* FIXME: Does not handle multiple active screen sections, but I'm not + * sure if we really want to handle that case*/ + configured_device = xf86ConfigLayout.screens->screen->device; + if ((!configured_device) || (!configured_device->driver)) { + if (!autoConfigDevice(configured_device)) { + xf86Msg(X_ERROR, "Automatic driver configuration failed\n"); + return ; + } + } + if ((modulelist = xf86DriverlistFromConfig())) { + xf86LoadModules(modulelist, NULL); + free(modulelist); + } + + /* Load all input driver modules specified in the config file. */ + if ((modulelist = xf86InputDriverlistFromConfig())) { + xf86LoadModules(modulelist, NULL); + free(modulelist); + } + + /* + * It is expected that xf86AddDriver()/xf86AddInputDriver will be + * called for each driver as it is loaded. Those functions save the + * module pointers for drivers. + * XXX Nothing keeps track of them for other modules. + */ + /* XXX What do we do if not all of these could be loaded? */ + + /* + * At this point, xf86DriverList[] is all filled in with entries for + * each of the drivers to try and xf86NumDrivers has the number of + * drivers. If there are none, return now. + */ + + if (xf86NumDrivers == 0) { + xf86Msg(X_ERROR, "No drivers available.\n"); + return; + } + + /* + * Call each of the Identify functions and call the driverFunc to check + * if HW access is required. The Identify functions print out some + * identifying information, and anything else that might be + * needed at this early stage. + */ + + for (i = 0; i < xf86NumDrivers; i++) { + if (xf86DriverList[i]->Identify != NULL) + xf86DriverList[i]->Identify(0); + + if (!xorgHWAccess || !xorgHWOpenConsole) { + xorgHWFlags flags; + if(!xf86DriverList[i]->driverFunc + || !xf86DriverList[i]->driverFunc(NULL, + GET_REQUIRED_HW_INTERFACES, + &flags)) + flags = HW_IO; + + if(NEED_IO_ENABLED(flags)) + xorgHWAccess = TRUE; + if(!(flags & HW_SKIP_CONSOLE)) + xorgHWOpenConsole = TRUE; + } + } + + if (xorgHWOpenConsole) + xf86OpenConsole(); + else + xf86Info.dontVTSwitch = TRUE; + + if (xf86BusConfig() == FALSE) + return; + + xf86PostProbe(); + + /* + * Sort the drivers to match the requested ording. Using a slow + * bubble sort. + */ + for (j = 0; j < xf86NumScreens - 1; j++) { + for (i = 0; i < xf86NumScreens - j - 1; i++) { + if (xf86Screens[i + 1]->confScreen->screennum < + xf86Screens[i]->confScreen->screennum) { + ScrnInfoPtr tmpScrn = xf86Screens[i + 1]; + xf86Screens[i + 1] = xf86Screens[i]; + xf86Screens[i] = tmpScrn; + } + } + } + /* Fix up the indexes */ + for (i = 0; i < xf86NumScreens; i++) { + xf86Screens[i]->scrnIndex = i; + } + + /* + * Call the driver's PreInit()'s to complete initialisation for the first + * generation. + */ + + for (i = 0; i < xf86NumScreens; i++) { + xf86VGAarbiterScrnInit(xf86Screens[i]); + xf86VGAarbiterLock(xf86Screens[i]); + if (xf86Screens[i]->PreInit && + xf86Screens[i]->PreInit(xf86Screens[i], 0)) + xf86Screens[i]->configured = TRUE; + xf86VGAarbiterUnlock(xf86Screens[i]); + } + for (i = 0; i < xf86NumScreens; i++) + if (!xf86Screens[i]->configured) + xf86DeleteScreen(i--, 0); + + /* + * If no screens left, return now. + */ + + if (xf86NumScreens == 0) { + xf86Msg(X_ERROR, + "Screen(s) found, but none have a usable configuration.\n"); + return; + } + + for (i = 0; i < xf86NumScreens; i++) { + if (xf86Screens[i]->name == NULL) { + XNFasprintf(&xf86Screens[i]->name, "screen%d", i); + xf86MsgVerb(X_WARNING, 0, + "Screen driver %d has no name set, using `%s'.\n", + i, xf86Screens[i]->name); + } + } + + /* Remove (unload) drivers that are not required */ + for (i = 0; i < xf86NumDrivers; i++) + if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0) + xf86DeleteDriver(i); + + /* + * At this stage we know how many screens there are. + */ + + for (i = 0; i < xf86NumScreens; i++) + xf86InitViewport(xf86Screens[i]); + + /* + * Collect all pixmap formats and check for conflicts at the display + * level. Should we die here? Or just delete the offending screens? + */ + screenpix24 = Pix24DontCare; + for (i = 0; i < xf86NumScreens; i++) { + if (xf86Screens[i]->imageByteOrder != + xf86Screens[0]->imageByteOrder) + FatalError("Inconsistent display bitmapBitOrder. Exiting\n"); + if (xf86Screens[i]->bitmapScanlinePad != + xf86Screens[0]->bitmapScanlinePad) + FatalError("Inconsistent display bitmapScanlinePad. Exiting\n"); + if (xf86Screens[i]->bitmapScanlineUnit != + xf86Screens[0]->bitmapScanlineUnit) + FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n"); + if (xf86Screens[i]->bitmapBitOrder != + xf86Screens[0]->bitmapBitOrder) + FatalError("Inconsistent display bitmapBitOrder. Exiting\n"); + + /* Determine the depth 24 pixmap format the screens would like */ + if (xf86Screens[i]->pixmap24 != Pix24DontCare) { + if (screenpix24 == Pix24DontCare) + screenpix24 = xf86Screens[i]->pixmap24; + else if (screenpix24 != xf86Screens[i]->pixmap24) + FatalError("Inconsistent depth 24 pixmap format. Exiting\n"); + } + } + /* check if screenpix24 is consistent with the config/cmdline */ + if (xf86Info.pixmap24 != Pix24DontCare) { + pix24 = xf86Info.pixmap24; + pix24From = xf86Info.pix24From; + if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24) + pix24Fail = TRUE; + } else if (screenpix24 != Pix24DontCare) { + pix24 = screenpix24; + pix24From = X_PROBED; + } else + pix24 = Pix24Use32; + + if (pix24Fail) + FatalError("Screen(s) can't use the required depth 24 pixmap format" + " (%d). Exiting\n", PIX24TOBPP(pix24)); + + /* Initialise the depth 24 format */ + for (j = 0; j < numFormats && formats[j].depth != 24; j++) + ; + formats[j].bitsPerPixel = PIX24TOBPP(pix24); + + /* Collect additional formats */ + for (i = 0; i < xf86NumScreens; i++) { + for (j = 0; j < xf86Screens[i]->numFormats; j++) { + for (k = 0; ; k++) { + if (k >= numFormats) { + if (k >= MAXFORMATS) + FatalError("Too many pixmap formats! Exiting\n"); + formats[k] = xf86Screens[i]->formats[j]; + numFormats++; + break; + } + if (formats[k].depth == xf86Screens[i]->formats[j].depth) { + if ((formats[k].bitsPerPixel == + xf86Screens[i]->formats[j].bitsPerPixel) && + (formats[k].scanlinePad == + xf86Screens[i]->formats[j].scanlinePad)) + break; + FatalError("Inconsistent pixmap format for depth %d." + " Exiting\n", formats[k].depth); + } + } + } + } + formatsDone = TRUE; + + if (xf86Info.vtno >= 0 ) { +#define VT_ATOM_NAME "XFree86_VT" + Atom VTAtom=-1; + CARD32 *VT = NULL; + int ret; + + /* This memory needs to stay available until the screen has been + initialized, and we can create the property for real. + */ + if ( (VT = malloc(sizeof(CARD32)))==NULL ) { + FatalError("Unable to make VT property - out of memory. Exiting...\n"); + } + *VT = xf86Info.vtno; + + VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE); + + for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) { + ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex, + VTAtom, XA_INTEGER, 32, + 1, VT ); + if (ret != Success) + xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING, + "Failed to register VT property\n"); + } + } + + /* If a screen uses depth 24, show what the pixmap format is */ + for (i = 0; i < xf86NumScreens; i++) { + if (xf86Screens[i]->depth == 24) { + xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n", + PIX24TOBPP(pix24)); + break; + } + } + } else { + /* + * serverGeneration != 1; some OSs have to do things here, too. + */ + if (xorgHWOpenConsole) + xf86OpenConsole(); + +#ifdef XF86PM + /* + should we reopen it here? We need to deal with an already opened + device. We could leave this to the OS layer. For now we simply + close it here + */ + if (xf86OSPMClose) + xf86OSPMClose(); + if ((xf86OSPMClose = xf86OSPMOpen()) != NULL) + xf86MsgVerb(X_INFO, 3, "APM registered successfully\n"); +#endif + + /* Make sure full I/O access is enabled */ + if (xorgHWAccess) + xf86EnableIO(); + } + + /* + * Use the previously collected parts to setup pScreenInfo + */ + + pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder; + pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad; + pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit; + pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder; + pScreenInfo->numPixmapFormats = numFormats; + for (i = 0; i < numFormats; i++) + pScreenInfo->formats[i] = formats[i]; + + /* Make sure the server's VT is active */ + + if (serverGeneration != 1) { + xf86Resetting = TRUE; + /* All screens are in the same state, so just check the first */ + if (!xf86Screens[0]->vtSema) { +#ifdef HAS_USL_VTS + ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ); +#endif + xf86AccessEnter(); + was_blocked = xf86BlockSIGIO(); + } + } + + for (i = 0; i < xf86NumScreens; i++) + if (!xf86ColormapAllocatePrivates(xf86Screens[i])) + FatalError("Cannot register DDX private keys"); + + if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) || + !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0)) + FatalError("Cannot register DDX private keys"); + + for (i = 0; i < xf86NumScreens; i++) { + xf86VGAarbiterLock(xf86Screens[i]); + /* + * Almost everything uses these defaults, and many of those that + * don't, will wrap them. + */ + xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess; +#ifdef XFreeXDGA + xf86Screens[i]->SetDGAMode = xf86SetDGAMode; +#endif + xf86Screens[i]->DPMSSet = NULL; + xf86Screens[i]->LoadPalette = NULL; + xf86Screens[i]->SetOverscan = NULL; + xf86Screens[i]->DriverFunc = NULL; + xf86Screens[i]->pScreen = NULL; + scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv); + xf86VGAarbiterUnlock(xf86Screens[i]); + if (scr_index == i) { + /* + * Hook in our ScrnInfoRec, and initialise some other pScreen + * fields. + */ + dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, + xf86ScreenKey, xf86Screens[i]); + xf86Screens[i]->pScreen = screenInfo.screens[scr_index]; + /* The driver should set this, but make sure it is set anyway */ + xf86Screens[i]->vtSema = TRUE; + } else { + /* This shouldn't normally happen */ + FatalError("AddScreen/ScreenInit failed for driver %d\n", i); + } + + DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n", + i, xf86Screens[i]->pScreen ); + DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n", + i, xf86Screens[i]->pScreen->CreateWindow ); + + dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, + xf86CreateRootWindowKey, + xf86Screens[i]->pScreen->CreateWindow); + xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow; + + if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown) + { + xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC); + PictureSetSubpixelOrder (xf86Screens[i]->pScreen, + DDC ? + (DDC->features.input_type ? + SubPixelHorizontalRGB : SubPixelNone) : + SubPixelUnknown); + } +#ifdef RANDR + if (!xf86Info.disableRandR) + xf86RandRInit (screenInfo.screens[scr_index]); + xf86Msg(xf86Info.randRFrom, "RandR %s\n", + xf86Info.disableRandR ? "disabled" : "enabled"); +#endif + } + + xf86VGAarbiterWrapFunctions(); + xf86UnblockSIGIO(was_blocked); + + xf86InitOrigins(); + + xf86Resetting = FALSE; + xf86Initialising = FALSE; + + RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup, + NULL); +} + +/* + * InitInput -- + * Initialize all supported input devices. + */ + +void +InitInput(int argc, char **argv) +{ + InputInfoPtr* pDev; + DeviceIntPtr dev; + + xf86Info.vtRequestsPending = FALSE; + + mieqInit(); + + GetEventList(&xf86Events); + + /* Call the PreInit function for each input device instance. */ + for (pDev = xf86ConfigLayout.inputs; pDev && *pDev; pDev++) { + /* Replace obsolete keyboard driver with kbd */ + if (!xf86NameCmp((*pDev)->driver, "keyboard")) { + strcpy((*pDev)->driver, "kbd"); + } + + /* If one fails, the others will too */ + if (xf86NewInputDevice(*pDev, &dev, TRUE) == BadAlloc) + break; + } + + config_init(); +} + +void +CloseInput (void) +{ + config_fini(); +} + +/* + * OsVendorInit -- + * OS/Vendor-specific initialisations. Called from OsInit(), which + * is called by dix before establishing the well known sockets. + */ + +void +OsVendorInit(void) +{ + static Bool beenHere = FALSE; + + signal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */ + + if (!beenHere) { + umask(022); + xf86LogInit(); + } + + /* Set stderr to non-blocking. */ +#ifndef O_NONBLOCK +#if defined(FNDELAY) +#define O_NONBLOCK FNDELAY +#elif defined(O_NDELAY) +#define O_NONBLOCK O_NDELAY +#endif + +#ifdef O_NONBLOCK + if (!beenHere) { + if (geteuid() == 0 && getuid() != geteuid()) + { + int status; + + status = fcntl(fileno(stderr), F_GETFL, 0); + if (status != -1) { + fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK); + } + } + } +#endif +#endif + + beenHere = TRUE; +} + +/* + * ddxGiveUp -- + * Device dependent cleanup. Called by by dix before normal server death. + * For SYSV386 we must switch the terminal back to normal mode. No error- + * checking here, since there should be restored as much as possible. + */ + +void +ddxGiveUp(void) +{ + int i; + + xf86VGAarbiterFini(); + +#ifdef XF86PM + if (xf86OSPMClose) + xf86OSPMClose(); + xf86OSPMClose = NULL; +#endif + + for (i = 0; i < xf86NumScreens; i++) { + /* + * zero all access functions to + * trap calls when switched away. + */ + xf86Screens[i]->vtSema = FALSE; + } + +#ifdef XFreeXDGA + DGAShutdown(); +#endif + + if (xorgHWOpenConsole) + xf86CloseConsole(); + + xf86CloseLog(); + + /* If an unexpected signal was caught, dump a core for debugging */ + if (xf86Info.caughtSignal) + OsAbort(); +} + + + +/* + * AbortDDX -- + * DDX - specific abort routine. Called by AbortServer(). The attempt is + * made to restore all original setting of the displays. Also all devices + * are closed. + */ + +void +AbortDDX(void) +{ + int i; + + xf86BlockSIGIO(); + + /* + * try to restore the original video state + */ +#ifdef DPMSExtension /* Turn screens back on */ + if (DPMSPowerLevel != DPMSModeOn) + DPMSSet(serverClient, DPMSModeOn); +#endif + if (xf86Screens) { + for (i = 0; i < xf86NumScreens; i++) + if (xf86Screens[i]->vtSema) { + /* + * if we are aborting before ScreenInit() has finished + * we might not have been wrapped yet. Therefore enable + * screen explicitely. + */ + xf86VGAarbiterLock(xf86Screens[i]); + (xf86Screens[i]->LeaveVT)(i, 0); + xf86VGAarbiterUnlock(xf86Screens[i]); + } + } + + xf86AccessLeave(); + + /* + * This is needed for an abnormal server exit, since the normal exit stuff + * MUST also be performed (i.e. the vt must be left in a defined state) + */ + ddxGiveUp(); +} + +void +OsVendorFatalError(void) +{ +#ifdef VENDORSUPPORT + ErrorF("\nPlease refer to your Operating System Vendor support pages\n" + "at %s for support on this crash.\n",VENDORSUPPORT); +#else + ErrorF("\nPlease consult the "XVENDORNAME" support \n" + "\t at "__VENDORDWEBSUPPORT__"\n for help. \n"); +#endif + if (xf86LogFile && xf86LogFileWasOpened) + ErrorF("Please also check the log file at \"%s\" for additional " + "information.\n", xf86LogFile); + ErrorF("\n"); +} + +int +xf86SetVerbosity(int verb) +{ + int save = xf86Verbose; + + xf86Verbose = verb; + LogSetParameter(XLOG_VERBOSITY, verb); + return save; +} + +int +xf86SetLogVerbosity(int verb) +{ + int save = xf86LogVerbose; + + xf86LogVerbose = verb; + LogSetParameter(XLOG_FILE_VERBOSITY, verb); + return save; +} + +static void +xf86PrintDefaultModulePath(void) +{ + ErrorF("%s\n", DEFAULT_MODULE_PATH); +} + +static void +xf86PrintDefaultLibraryPath(void) +{ + ErrorF("%s\n", DEFAULT_LIBRARY_PATH); +} + +/* + * ddxProcessArgument -- + * Process device-dependent command line args. Returns 0 if argument is + * not device dependent, otherwise Count of number of elements of argv + * that are part of a device dependent commandline option. + * + */ + +/* ARGSUSED */ +int +ddxProcessArgument(int argc, char **argv, int i) +{ +#define CHECK_FOR_REQUIRED_ARGUMENT() \ + if (((i + 1) >= argc) || (!argv[i + 1])) { \ + ErrorF("Required argument to %s not specified\n", argv[i]); \ + UseMsg(); \ + FatalError("Required argument to %s not specified\n", argv[i]); \ + } + + /* First the options that are only allowed for root */ + if (!strcmp(argv[i], "-modulepath") || !strcmp(argv[i], "-logfile")) { + if ( (geteuid() == 0) && (getuid() != 0) ) { + FatalError("The '%s' option can only be used by root.\n", argv[i]); + } + else if (!strcmp(argv[i], "-modulepath")) + { + char *mp; + CHECK_FOR_REQUIRED_ARGUMENT(); + mp = strdup(argv[i + 1]); + if (!mp) + FatalError("Can't allocate memory for ModulePath\n"); + xf86ModulePath = mp; + xf86ModPathFrom = X_CMDLINE; + return 2; + } + else if (!strcmp(argv[i], "-logfile")) + { + char *lf; + CHECK_FOR_REQUIRED_ARGUMENT(); + lf = strdup(argv[i + 1]); + if (!lf) + FatalError("Can't allocate memory for LogFile\n"); + xf86LogFile = lf; + xf86LogFileFrom = X_CMDLINE; + return 2; + } + } + if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) { + FatalError("\nInvalid argument for %s\n" + "\tFor non-root users, the file specified with %s must be\n" + "\ta relative path and must not contain any \"..\" elements.\n" + "\tUsing default "__XCONFIGFILE__" search path.\n\n", + argv[i], argv[i]); + } + xf86ConfigFile = argv[i + 1]; + return 2; + } + if (!strcmp(argv[i], "-configdir")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + if (getuid() != 0 && !xf86PathIsSafe(argv[i + 1])) { + FatalError("\nInvalid argument for %s\n" + "\tFor non-root users, the file specified with %s must be\n" + "\ta relative path and must not contain any \"..\" elements.\n" + "\tUsing default "__XCONFIGDIR__" search path.\n\n", + argv[i], argv[i]); + } + xf86ConfigDir = argv[i + 1]; + return 2; + } + if (!strcmp(argv[i],"-flipPixels")) + { + xf86FlipPixels = TRUE; + return 1; + } +#ifdef XF86VIDMODE + if (!strcmp(argv[i],"-disableVidMode")) + { + xf86VidModeDisabled = TRUE; + return 1; + } + if (!strcmp(argv[i],"-allowNonLocalXvidtune")) + { + xf86VidModeAllowNonLocal = TRUE; + return 1; + } +#endif + if (!strcmp(argv[i],"-allowMouseOpenFail")) + { + xf86AllowMouseOpenFail = TRUE; + return 1; + } + if (!strcmp(argv[i],"-ignoreABI")) + { + LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL); + return 1; + } + if (!strcmp(argv[i],"-verbose")) + { + if (++i < argc && argv[i]) + { + char *end; + long val; + val = strtol(argv[i], &end, 0); + if (*end == '\0') + { + xf86SetVerbosity(val); + return 2; + } + } + xf86SetVerbosity(++xf86Verbose); + return 1; + } + if (!strcmp(argv[i],"-logverbose")) + { + if (++i < argc && argv[i]) + { + char *end; + long val; + val = strtol(argv[i], &end, 0); + if (*end == '\0') + { + xf86SetLogVerbosity(val); + return 2; + } + } + xf86SetLogVerbosity(++xf86LogVerbose); + return 1; + } + if (!strcmp(argv[i],"-quiet")) + { + xf86SetVerbosity(-1); + return 1; + } + if (!strcmp(argv[i],"-showconfig") || !strcmp(argv[i],"-version")) + { + xf86PrintBanner(); + exit(0); + } + if (!strcmp(argv[i],"-showDefaultModulePath")) + { + xf86PrintDefaultModulePath(); + exit(0); + } + if (!strcmp(argv[i],"-showDefaultLibPath")) + { + xf86PrintDefaultLibraryPath(); + exit(0); + } + /* Notice the -fp flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "-fp")) + { + xf86fpFlag = TRUE; + return 0; + } + /* Notice the -bs flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "-bs")) + { + xf86bsDisableFlag = TRUE; + return 0; + } + /* Notice the +bs flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "+bs")) + { + xf86bsEnableFlag = TRUE; + return 0; + } + /* Notice the -s flag, but allow it to pass to the dix layer */ + if (!strcmp(argv[i], "-s")) + { + xf86sFlag = TRUE; + return 0; + } + if (!strcmp(argv[i], "-pixmap24")) + { + xf86Pix24 = Pix24Use24; + return 1; + } + if (!strcmp(argv[i], "-pixmap32")) + { + xf86Pix24 = Pix24Use32; + return 1; + } + if (!strcmp(argv[i], "-fbbpp")) + { + int bpp; + CHECK_FOR_REQUIRED_ARGUMENT(); + if (sscanf(argv[++i], "%d", &bpp) == 1) + { + xf86FbBpp = bpp; + return 2; + } + else + { + ErrorF("Invalid fbbpp\n"); + return 0; + } + } + if (!strcmp(argv[i], "-depth")) + { + int depth; + CHECK_FOR_REQUIRED_ARGUMENT(); + if (sscanf(argv[++i], "%d", &depth) == 1) + { + xf86Depth = depth; + return 2; + } + else + { + ErrorF("Invalid depth\n"); + return 0; + } + } + if (!strcmp(argv[i], "-weight")) + { + int red, green, blue; + CHECK_FOR_REQUIRED_ARGUMENT(); + if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3) + { + xf86Weight.red = red; + xf86Weight.green = green; + xf86Weight.blue = blue; + return 2; + } + else + { + ErrorF("Invalid weighting\n"); + return 0; + } + } + if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") || + !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma")) + { + double gamma; + CHECK_FOR_REQUIRED_ARGUMENT(); + if (sscanf(argv[++i], "%lf", &gamma) == 1) { + if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) { + ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f" + " is valid\n", GAMMA_MIN, GAMMA_MAX); + return 0; + } + if (!strcmp(argv[i-1], "-gamma")) + xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma; + else if (!strcmp(argv[i-1], "-rgamma")) xf86Gamma.red = gamma; + else if (!strcmp(argv[i-1], "-ggamma")) xf86Gamma.green = gamma; + else if (!strcmp(argv[i-1], "-bgamma")) xf86Gamma.blue = gamma; + return 2; + } + } + if (!strcmp(argv[i], "-layout")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + xf86LayoutName = argv[++i]; + return 2; + } + if (!strcmp(argv[i], "-screen")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + xf86ScreenName = argv[++i]; + return 2; + } + if (!strcmp(argv[i], "-pointer")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + xf86PointerName = argv[++i]; + return 2; + } + if (!strcmp(argv[i], "-keyboard")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + xf86KeyboardName = argv[++i]; + return 2; + } + if (!strcmp(argv[i], "-nosilk")) + { + xf86silkenMouseDisableFlag = TRUE; + return 1; + } +#ifdef HAVE_ACPI + if (!strcmp(argv[i], "-noacpi")) + { + xf86acpiDisableFlag = TRUE; + return 1; + } +#endif + if (!strcmp(argv[i], "-configure")) + { + if (getuid() != 0 && geteuid() == 0) { + ErrorF("The '-configure' option can only be used by root.\n"); + exit(1); + } + xf86DoConfigure = TRUE; + xf86AllowMouseOpenFail = TRUE; + return 1; + } + if (!strcmp(argv[i], "-showopts")) + { + if (getuid() != 0 && geteuid() == 0) { + ErrorF("The '-showopts' option can only be used by root.\n"); + exit(1); + } + xf86DoShowOptions = TRUE; + return 1; + } + if (!strcmp(argv[i], "-isolateDevice")) + { + CHECK_FOR_REQUIRED_ARGUMENT(); + if (strncmp(argv[++i], "PCI:", 4)) { + FatalError("Bus types other than PCI not yet isolable\n"); + } + xf86PciIsolateDevice(argv[i]); + return 2; + } + /* Notice cmdline xkbdir, but pass to dix as well */ + if (!strcmp(argv[i], "-xkbdir")) + { + xf86xkbdirFlag = TRUE; + return 0; + } + + /* OS-specific processing */ + return xf86ProcessArgument(argc, argv, i); +} + +/* + * ddxUseMsg -- + * Print out correct use of device dependent commandline options. + * Maybe the user now knows what really to do ... + */ + +void +ddxUseMsg(void) +{ + ErrorF("\n"); + ErrorF("\n"); + ErrorF("Device Dependent Usage\n"); + if (getuid() == 0 || geteuid() != 0) + { + ErrorF("-modulepath paths specify the module search path\n"); + ErrorF("-logfile file specify a log file name\n"); + ErrorF("-configure probe for devices and write an "__XCONFIGFILE__"\n"); + ErrorF("-showopts print available options for all installed drivers\n"); + } + ErrorF("-config file specify a configuration file, relative to the\n"); + ErrorF(" "__XCONFIGFILE__" search path, only root can use absolute\n"); + ErrorF("-configdir dir specify a configuration directory, relative to the\n"); + ErrorF(" "__XCONFIGDIR__" search path, only root can use absolute\n"); + ErrorF("-verbose [n] verbose startup messages\n"); + ErrorF("-logverbose [n] verbose log messages\n"); + ErrorF("-quiet minimal startup messages\n"); + ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n"); + ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n"); + ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n"); + ErrorF("-depth n set colour depth. Default: 8\n"); + ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n"); + ErrorF("-rgamma f set gamma value for red phase\n"); + ErrorF("-ggamma f set gamma value for green phase\n"); + ErrorF("-bgamma f set gamma value for blue phase\n"); + ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n"); + ErrorF("-layout name specify the ServerLayout section name\n"); + ErrorF("-screen name specify the Screen section name\n"); + ErrorF("-keyboard name specify the core keyboard InputDevice name\n"); + ErrorF("-pointer name specify the core pointer InputDevice name\n"); + ErrorF("-nosilk disable Silken Mouse\n"); + ErrorF("-flipPixels swap default black/white Pixel values\n"); +#ifdef XF86VIDMODE + ErrorF("-disableVidMode disable mode adjustments with xvidtune\n"); + ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n"); +#endif + ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n"); + ErrorF("-ignoreABI make module ABI mismatches non-fatal\n"); + ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n"); + ErrorF("-version show the server version\n"); + ErrorF("-showDefaultModulePath show the server default module path\n"); + ErrorF("-showDefaultLibPath show the server default library path\n"); + /* OS-specific usage */ + xf86UseMsg(); + ErrorF("\n"); +} + + +/* + * xf86LoadModules iterates over a list that is being passed in. + */ +Bool +xf86LoadModules(char **list, pointer *optlist) +{ + int errmaj, errmin; + pointer opt; + int i; + char *name; + Bool failed = FALSE; + + if (!list) + return TRUE; + + for (i = 0; list[i] != NULL; i++) { + + /* Normalise the module name */ + name = xf86NormalizeName(list[i]); + + /* Skip empty names */ + if (name == NULL || *name == '\0') + continue; + + /* Replace obsolete keyboard driver with kbd */ + if (!xf86NameCmp(name, "keyboard")) { + strcpy(name, "kbd"); + } + + if (optlist) + opt = optlist[i]; + else + opt = NULL; + + if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) { + LoaderErrorMsg(NULL, name, errmaj, errmin); + failed = TRUE; + } + free(name); + } + return !failed; +} + +/* Pixmap format stuff */ + +PixmapFormatPtr +xf86GetPixFormat(ScrnInfoPtr pScrn, int depth) +{ + int i; + static PixmapFormatRec format; /* XXX not reentrant */ + + /* + * When the formats[] list initialisation isn't complete, check the + * depth 24 pixmap config/cmdline options and screen-specified formats. + */ + + if (!formatsDone) { + if (depth == 24) { + Pix24Flags pix24 = Pix24DontCare; + + format.depth = 24; + format.scanlinePad = BITMAP_SCANLINE_PAD; + if (xf86Info.pixmap24 != Pix24DontCare) + pix24 = xf86Info.pixmap24; + else if (pScrn->pixmap24 != Pix24DontCare) + pix24 = pScrn->pixmap24; + if (pix24 == Pix24Use24) + format.bitsPerPixel = 24; + else + format.bitsPerPixel = 32; + return &format; + } + } + + for (i = 0; i < numFormats; i++) + if (formats[i].depth == depth) + break; + if (i != numFormats) + return &formats[i]; + else if (!formatsDone) { + /* Check for screen-specified formats */ + for (i = 0; i < pScrn->numFormats; i++) + if (pScrn->formats[i].depth == depth) + break; + if (i != pScrn->numFormats) + return &pScrn->formats[i]; + } + return NULL; +} + +int +xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth) +{ + PixmapFormatPtr format; + + + format = xf86GetPixFormat(pScrn, depth); + if (format) + return format->bitsPerPixel; + else + return 0; +} diff --git a/xorg-server/hw/xfree86/common/xf86PM.c b/xorg-server/hw/xfree86/common/xf86PM.c index 7af89b5b4..16b6bdc4a 100644 --- a/xorg-server/hw/xfree86/common/xf86PM.c +++ b/xorg-server/hw/xfree86/common/xf86PM.c @@ -33,6 +33,7 @@ #include "xf86.h" #include "xf86Priv.h" #include "xf86Xinput.h" +#include "xf86_OSproc.h" int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num) = NULL; pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event) = NULL; @@ -61,14 +62,14 @@ eventName(pmEvent event, char **str) } } +static int sigio_blocked_for_suspend; + static void suspend (pmEvent event, Bool undo) { int i; InputInfoPtr pInfo; - xf86inSuspend = TRUE; - for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->EnableDisableFBAccess) (*xf86Screens[i]->EnableDisableFBAccess) (i, FALSE); @@ -78,7 +79,7 @@ suspend (pmEvent event, Bool undo) DisableDevice(pInfo->dev, TRUE); pInfo = pInfo->next; } - xf86EnterServerState(SETUP); + sigio_blocked_for_suspend = xf86BlockSIGIO(); for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->PMEvent) xf86Screens[i]->PMEvent(i,event,undo); @@ -98,7 +99,6 @@ resume(pmEvent event, Bool undo) InputInfoPtr pInfo; xf86AccessEnter(); - xf86EnterServerState(SETUP); for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->PMEvent) xf86Screens[i]->PMEvent(i,event,undo); @@ -107,7 +107,7 @@ resume(pmEvent event, Bool undo) xf86Screens[i]->EnterVT(i, 0); } } - xf86EnterServerState(OPERATING); + xf86UnblockSIGIO(sigio_blocked_for_suspend); for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->EnableDisableFBAccess) (*xf86Screens[i]->EnableDisableFBAccess) (i, TRUE); @@ -118,18 +118,12 @@ resume(pmEvent event, Bool undo) EnableDevice(pInfo->dev, TRUE); pInfo = pInfo->next; } - xf86inSuspend = FALSE; } static void DoApmEvent(pmEvent event, Bool undo) { - /* - * we leave that as a global function for now. I don't know if - * this might cause problems in the future. It is a global server - * variable therefore it needs to be in a server info structure - */ - int i, setup = 0; + int i, was_blocked; switch(event) { #if 0 @@ -159,14 +153,13 @@ DoApmEvent(pmEvent event, Bool undo) } break; default: + was_blocked = xf86BlockSIGIO(); for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->PMEvent) { - if (!setup) xf86EnterServerState(SETUP); - setup = 1; xf86Screens[i]->PMEvent(i,event,undo); } } - if (setup) xf86EnterServerState(OPERATING); + xf86UnblockSIGIO(was_blocked); break; } } diff --git a/xorg-server/hw/xfree86/common/xf86Priv.h b/xorg-server/hw/xfree86/common/xf86Priv.h index 01e178372..7137a5363 100644 --- a/xorg-server/hw/xfree86/common/xf86Priv.h +++ b/xorg-server/hw/xfree86/common/xf86Priv.h @@ -1,158 +1,157 @@ -/*
- * Copyright (c) 1997-2002 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * This file contains declarations for private XFree86 functions and variables,
- * and definitions of private macros.
- *
- * "private" means not available to video drivers.
- */
-
-#ifndef _XF86PRIV_H
-#define _XF86PRIV_H
-
-#include "xf86Privstr.h"
-#include "propertyst.h"
-#include "input.h"
-
-/*
- * Parameters set ONLY from the command line options
- * The global state of these things is held in xf86InfoRec (when appropriate).
- */
-extern _X_EXPORT const char *xf86ConfigFile;
-extern _X_EXPORT const char *xf86ConfigDir;
-extern _X_EXPORT Bool xf86AllowMouseOpenFail;
-#ifdef XF86VIDMODE
-extern _X_EXPORT Bool xf86VidModeDisabled;
-extern _X_EXPORT Bool xf86VidModeAllowNonLocal;
-#endif
-extern _X_EXPORT Bool xf86fpFlag;
-extern _X_EXPORT Bool xf86sFlag;
-extern _X_EXPORT Bool xf86bsEnableFlag;
-extern _X_EXPORT Bool xf86bsDisableFlag;
-extern _X_EXPORT Bool xf86silkenMouseDisableFlag;
-extern _X_EXPORT Bool xf86xkbdirFlag;
-#ifdef HAVE_ACPI
-extern _X_EXPORT Bool xf86acpiDisableFlag;
-#endif
-extern _X_EXPORT char *xf86LayoutName;
-extern _X_EXPORT char *xf86ScreenName;
-extern _X_EXPORT char *xf86PointerName;
-extern _X_EXPORT char *xf86KeyboardName;
-extern _X_EXPORT int xf86FbBpp;
-extern _X_EXPORT int xf86Depth;
-extern _X_EXPORT Pix24Flags xf86Pix24;
-extern _X_EXPORT rgb xf86Weight;
-extern _X_EXPORT Bool xf86FlipPixels;
-extern _X_EXPORT Gamma xf86Gamma;
-extern _X_EXPORT char *xf86ServerName;
-
-/* Other parameters */
-
-extern _X_EXPORT xf86InfoRec xf86Info;
-extern _X_EXPORT const char *xf86ModulePath;
-extern _X_EXPORT MessageType xf86ModPathFrom;
-extern _X_EXPORT const char *xf86LogFile;
-extern _X_EXPORT MessageType xf86LogFileFrom;
-extern _X_EXPORT Bool xf86LogFileWasOpened;
-extern _X_EXPORT serverLayoutRec xf86ConfigLayout;
-
-extern _X_EXPORT DriverPtr *xf86DriverList;
-extern _X_EXPORT int xf86NumDrivers;
-extern _X_EXPORT Bool xf86Resetting;
-extern _X_EXPORT Bool xf86Initialising;
-extern _X_EXPORT int xf86NumScreens;
-extern _X_EXPORT const char *xf86VisualNames[];
-extern _X_EXPORT int xf86Verbose; /* verbosity level */
-extern _X_EXPORT int xf86LogVerbose; /* log file verbosity level */
-extern _X_EXPORT Bool xorgHWAccess;
-
-extern _X_EXPORT RootWinPropPtr *xf86RegisteredPropertiesTable;
-
-#ifndef DEFAULT_VERBOSE
-#define DEFAULT_VERBOSE 0
-#endif
-#ifndef DEFAULT_LOG_VERBOSE
-#define DEFAULT_LOG_VERBOSE 3
-#endif
-#ifndef DEFAULT_DPI
-#define DEFAULT_DPI 96
-#endif
-
-/* Function Prototypes */
-#ifndef _NO_XF86_PROTOTYPES
-
-/* xf86Bus.c */
-extern _X_EXPORT Bool xf86BusConfig(void);
-extern _X_EXPORT void xf86BusProbe(void);
-extern _X_EXPORT void xf86AccessEnter(void);
-extern _X_EXPORT void xf86AccessLeave(void);
-extern _X_EXPORT void xf86PostProbe(void);
-extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex);
-extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
-extern _X_EXPORT void xf86PostScreenInit(void);
-
-/* xf86Config.c */
-
-extern _X_EXPORT Bool xf86PathIsSafe(const char *path);
-
-/* xf86DefaultModes */
-
-extern _X_EXPORT const DisplayModeRec xf86DefaultModes[];
-extern _X_EXPORT const int xf86NumDefaultModes;
-
-/* xf86Configure.c */
-extern _X_EXPORT void DoConfigure(void);
-
-/* xf86ShowOpts.c */
-extern _X_EXPORT void DoShowOptions(void);
-
-/* xf86Events.c */
-
-extern _X_EXPORT void xf86Wakeup(pointer blockData, int err, pointer pReadmask);
-extern _X_HIDDEN int xf86SigWrapper(int signo);
-extern _X_EXPORT void xf86HandlePMEvents(int fd, pointer data);
-extern _X_EXPORT int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num);
-extern _X_EXPORT pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event);
-
-/* xf86Helper.c */
-extern _X_EXPORT void xf86LogInit(void);
-extern _X_EXPORT void xf86CloseLog(void);
-
-/* xf86Init.c */
-extern _X_EXPORT Bool xf86LoadModules(char **list, pointer *optlist);
-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 */
-
-
-#endif /* _XF86PRIV_H */
+/* + * Copyright (c) 1997-2002 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains declarations for private XFree86 functions and variables, + * and definitions of private macros. + * + * "private" means not available to video drivers. + */ + +#ifndef _XF86PRIV_H +#define _XF86PRIV_H + +#include "xf86Privstr.h" +#include "propertyst.h" +#include "input.h" + +/* + * Parameters set ONLY from the command line options + * The global state of these things is held in xf86InfoRec (when appropriate). + */ +extern _X_EXPORT const char *xf86ConfigFile; +extern _X_EXPORT const char *xf86ConfigDir; +extern _X_EXPORT Bool xf86AllowMouseOpenFail; +#ifdef XF86VIDMODE +extern _X_EXPORT Bool xf86VidModeDisabled; +extern _X_EXPORT Bool xf86VidModeAllowNonLocal; +#endif +extern _X_EXPORT Bool xf86fpFlag; +extern _X_EXPORT Bool xf86sFlag; +extern _X_EXPORT Bool xf86bsEnableFlag; +extern _X_EXPORT Bool xf86bsDisableFlag; +extern _X_EXPORT Bool xf86silkenMouseDisableFlag; +extern _X_EXPORT Bool xf86xkbdirFlag; +#ifdef HAVE_ACPI +extern _X_EXPORT Bool xf86acpiDisableFlag; +#endif +extern _X_EXPORT char *xf86LayoutName; +extern _X_EXPORT char *xf86ScreenName; +extern _X_EXPORT char *xf86PointerName; +extern _X_EXPORT char *xf86KeyboardName; +extern _X_EXPORT int xf86FbBpp; +extern _X_EXPORT int xf86Depth; +extern _X_EXPORT Pix24Flags xf86Pix24; +extern _X_EXPORT rgb xf86Weight; +extern _X_EXPORT Bool xf86FlipPixels; +extern _X_EXPORT Gamma xf86Gamma; +extern _X_EXPORT char *xf86ServerName; + +/* Other parameters */ + +extern _X_EXPORT xf86InfoRec xf86Info; +extern _X_EXPORT const char *xf86ModulePath; +extern _X_EXPORT MessageType xf86ModPathFrom; +extern _X_EXPORT const char *xf86LogFile; +extern _X_EXPORT MessageType xf86LogFileFrom; +extern _X_EXPORT Bool xf86LogFileWasOpened; +extern _X_EXPORT serverLayoutRec xf86ConfigLayout; + +extern _X_EXPORT DriverPtr *xf86DriverList; +extern _X_EXPORT int xf86NumDrivers; +extern _X_EXPORT Bool xf86Resetting; +extern _X_EXPORT Bool xf86Initialising; +extern _X_EXPORT int xf86NumScreens; +extern _X_EXPORT const char *xf86VisualNames[]; +extern _X_EXPORT int xf86Verbose; /* verbosity level */ +extern _X_EXPORT int xf86LogVerbose; /* log file verbosity level */ +extern _X_EXPORT Bool xorgHWAccess; + +extern _X_EXPORT RootWinPropPtr *xf86RegisteredPropertiesTable; + +#ifndef DEFAULT_VERBOSE +#define DEFAULT_VERBOSE 0 +#endif +#ifndef DEFAULT_LOG_VERBOSE +#define DEFAULT_LOG_VERBOSE 3 +#endif +#ifndef DEFAULT_DPI +#define DEFAULT_DPI 96 +#endif + +/* Function Prototypes */ +#ifndef _NO_XF86_PROTOTYPES + +/* xf86Bus.c */ +extern _X_EXPORT Bool xf86BusConfig(void); +extern _X_EXPORT void xf86BusProbe(void); +extern _X_EXPORT void xf86AccessEnter(void); +extern _X_EXPORT void xf86AccessLeave(void); +extern _X_EXPORT void xf86PostProbe(void); +extern _X_EXPORT void xf86ClearEntityListForScreen(int scrnIndex); +extern _X_EXPORT void xf86AddDevToEntity(int entityIndex, GDevPtr dev); + +/* xf86Config.c */ + +extern _X_EXPORT Bool xf86PathIsSafe(const char *path); + +/* xf86DefaultModes */ + +extern _X_EXPORT const DisplayModeRec xf86DefaultModes[]; +extern _X_EXPORT const int xf86NumDefaultModes; + +/* xf86Configure.c */ +extern _X_EXPORT void DoConfigure(void); + +/* xf86ShowOpts.c */ +extern _X_EXPORT void DoShowOptions(void); + +/* xf86Events.c */ + +extern _X_EXPORT void xf86Wakeup(pointer blockData, int err, pointer pReadmask); +extern _X_HIDDEN int xf86SigWrapper(int signo); +extern _X_EXPORT void xf86HandlePMEvents(int fd, pointer data); +extern _X_EXPORT int (*xf86PMGetEventFromOs)(int fd,pmEvent *events,int num); +extern _X_EXPORT pmWait (*xf86PMConfirmEventToOs)(int fd,pmEvent event); + +/* xf86Helper.c */ +extern _X_EXPORT void xf86LogInit(void); +extern _X_EXPORT void xf86CloseLog(void); + +/* xf86Init.c */ +extern _X_EXPORT Bool xf86LoadModules(char **list, pointer *optlist); +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 */ + + +#endif /* _XF86PRIV_H */ diff --git a/xorg-server/hw/xfree86/common/xf86str.h b/xorg-server/hw/xfree86/common/xf86str.h index 74ad759c5..0493dc53c 100644 --- a/xorg-server/hw/xfree86/common/xf86str.h +++ b/xorg-server/hw/xfree86/common/xf86str.h @@ -1,913 +1,906 @@ -
-/*
- * Copyright (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-/*
- * This file contains definitions of the public XFree86 data structures/types.
- * Any data structures that video drivers need to access should go here.
- */
-
-#ifndef _XF86STR_H
-#define _XF86STR_H
-
-#include "misc.h"
-#include "input.h"
-#include "scrnintstr.h"
-#include "pixmapstr.h"
-#include "colormapst.h"
-#include "xf86Module.h"
-#include "xf86Opt.h"
-#include "xf86Pci.h"
-
-#include <pciaccess.h>
-
-/**
- * Integer type that is of the size of the addressable memory (machine size).
- * On most platforms \c uintptr_t will suffice. However, on some mixed
- * 32-bit / 64-bit platforms, such as 32-bit binaries on 64-bit PowerPC, this
- * must be 64-bits.
- */
-#include <inttypes.h>
-#if defined(__powerpc__)
-typedef uint64_t memType;
-#else
-typedef uintptr_t memType;
-#endif
-
-
-/* Video mode flags */
-
-typedef enum {
- V_PHSYNC = 0x0001,
- V_NHSYNC = 0x0002,
- V_PVSYNC = 0x0004,
- V_NVSYNC = 0x0008,
- V_INTERLACE = 0x0010,
- V_DBLSCAN = 0x0020,
- V_CSYNC = 0x0040,
- V_PCSYNC = 0x0080,
- V_NCSYNC = 0x0100,
- V_HSKEW = 0x0200, /* hskew provided */
- V_BCAST = 0x0400,
- V_PIXMUX = 0x1000,
- V_DBLCLK = 0x2000,
- V_CLKDIV2 = 0x4000
-} ModeFlags;
-
-typedef enum {
- INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */
-} CrtcAdjustFlags;
-
-/* Flags passed to ChipValidMode() */
-typedef enum {
- MODECHECK_INITIAL = 0,
- MODECHECK_FINAL = 1
-} ModeCheckFlags;
-
-/* These are possible return values for xf86CheckMode() and ValidMode() */
-typedef enum {
- MODE_OK = 0, /* Mode OK */
- MODE_HSYNC, /* hsync out of range */
- MODE_VSYNC, /* vsync out of range */
- MODE_H_ILLEGAL, /* mode has illegal horizontal timings */
- MODE_V_ILLEGAL, /* mode has illegal horizontal timings */
- MODE_BAD_WIDTH, /* requires an unsupported linepitch */
- MODE_NOMODE, /* no mode with a maching name */
- MODE_NO_INTERLACE, /* interlaced mode not supported */
- MODE_NO_DBLESCAN, /* doublescan mode not supported */
- MODE_NO_VSCAN, /* multiscan mode not supported */
- MODE_MEM, /* insufficient video memory */
- MODE_VIRTUAL_X, /* mode width too large for specified virtual size */
- MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */
- MODE_MEM_VIRT, /* insufficient video memory given virtual size */
- MODE_NOCLOCK, /* no fixed clock available */
- MODE_CLOCK_HIGH, /* clock required is too high */
- MODE_CLOCK_LOW, /* clock required is too low */
- MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */
- MODE_BAD_HVALUE, /* horizontal timing was out of range */
- MODE_BAD_VVALUE, /* vertical timing was out of range */
- MODE_BAD_VSCAN, /* VScan value out of range */
- MODE_HSYNC_NARROW, /* horizontal sync too narrow */
- MODE_HSYNC_WIDE, /* horizontal sync too wide */
- MODE_HBLANK_NARROW, /* horizontal blanking too narrow */
- MODE_HBLANK_WIDE, /* horizontal blanking too wide */
- MODE_VSYNC_NARROW, /* vertical sync too narrow */
- MODE_VSYNC_WIDE, /* vertical sync too wide */
- MODE_VBLANK_NARROW, /* vertical blanking too narrow */
- MODE_VBLANK_WIDE, /* vertical blanking too wide */
- MODE_PANEL, /* exceeds panel dimensions */
- MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */
- MODE_ONE_WIDTH, /* only one width is supported */
- MODE_ONE_HEIGHT, /* only one height is supported */
- MODE_ONE_SIZE, /* only one resolution is supported */
- MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */
- MODE_BANDWIDTH, /* mode requires too much memory bandwidth */
- MODE_BAD = -2, /* unspecified reason */
- MODE_ERROR = -1 /* error condition */
-} ModeStatus;
-
-/*
- * The mode sets are, from best to worst: USERDEF, DRIVER, and DEFAULT/BUILTIN.
- * Preferred will bubble a mode to the top within a set.
- */
-# define M_T_BUILTIN 0x01 /* built-in mode */
-# define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */
-# define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */
-# define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C)
- /* built-in mode - configure CRTC and clock */
-# define M_T_PREFERRED 0x08 /* preferred mode within a set */
-# define M_T_DEFAULT 0x10 /* (VESA) default modes */
-# define M_T_USERDEF 0x20 /* One of the modes from the config file */
-# define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */
-# define M_T_USERPREF 0x80 /* mode preferred by the user config */
-
-/* Video mode */
-typedef struct _DisplayModeRec {
- struct _DisplayModeRec * prev;
- struct _DisplayModeRec * next;
- char * name; /* identifier for the mode */
- ModeStatus status;
- int type;
-
- /* These are the values that the user sees/provides */
- int Clock; /* pixel clock freq (kHz) */
- int HDisplay; /* horizontal timing */
- int HSyncStart;
- int HSyncEnd;
- int HTotal;
- int HSkew;
- int VDisplay; /* vertical timing */
- int VSyncStart;
- int VSyncEnd;
- int VTotal;
- int VScan;
- int Flags;
-
- /* These are the values the hardware uses */
- int ClockIndex;
- int SynthClock; /* Actual clock freq to
- * be programmed (kHz) */
- int CrtcHDisplay;
- int CrtcHBlankStart;
- int CrtcHSyncStart;
- int CrtcHSyncEnd;
- int CrtcHBlankEnd;
- int CrtcHTotal;
- int CrtcHSkew;
- int CrtcVDisplay;
- int CrtcVBlankStart;
- int CrtcVSyncStart;
- int CrtcVSyncEnd;
- int CrtcVBlankEnd;
- int CrtcVTotal;
- Bool CrtcHAdjusted;
- Bool CrtcVAdjusted;
- int PrivSize;
- INT32 * Private;
- int PrivFlags;
-
- float HSync, VRefresh;
-} DisplayModeRec, *DisplayModePtr;
-
-/* The monitor description */
-
-#define MAX_HSYNC 8
-#define MAX_VREFRESH 8
-
-typedef struct { float hi, lo; } range;
-
-typedef struct { CARD32 red, green, blue; } rgb;
-
-typedef struct { float red, green, blue; } Gamma;
-
-/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */
-#define GAMMA_MAX 10.0
-#define GAMMA_MIN (1.0 / GAMMA_MAX)
-#define GAMMA_ZERO (GAMMA_MIN / 100.0)
-
-typedef struct {
- char * id;
- char * vendor;
- char * model;
- int nHsync;
- range hsync[MAX_HSYNC];
- int nVrefresh;
- range vrefresh[MAX_VREFRESH];
- DisplayModePtr Modes; /* Start of the monitor's mode list */
- DisplayModePtr Last; /* End of the monitor's mode list */
- Gamma gamma; /* Gamma of the monitor */
- int widthmm;
- int heightmm;
- pointer options;
- pointer DDC;
- Bool reducedblanking; /* Allow CVT reduced blanking modes? */
- int maxPixClock; /* in kHz, like mode->Clock */
-} MonRec, *MonPtr;
-
-/* the list of clock ranges */
-typedef struct x_ClockRange {
- struct x_ClockRange *next;
- int minClock; /* (kHz) */
- int maxClock; /* (kHz) */
- int clockIndex; /* -1 for programmable clocks */
- Bool interlaceAllowed;
- Bool doubleScanAllowed;
- int ClockMulFactor;
- int ClockDivFactor;
- int PrivFlags;
-} ClockRange, *ClockRangePtr;
-
-/*
- * The driverFunc. xorgDriverFuncOp specifies the action driver should
- * perform. If requested option is not supported function should return
- * FALSE. pointer can be used to pass arguments to the function or
- * to return data to the caller.
- */
-typedef struct _ScrnInfoRec *ScrnInfoPtr;
-
-/* do not change order */
-typedef enum {
- RR_GET_INFO,
- RR_SET_CONFIG,
- RR_GET_MODE_MM,
- GET_REQUIRED_HW_INTERFACES = 10
-} xorgDriverFuncOp;
-
-typedef Bool xorgDriverFuncProc (ScrnInfoPtr, xorgDriverFuncOp,
- pointer);
-
-/* RR_GET_INFO, RR_SET_CONFIG */
-typedef struct {
- int rotation;
- int rate;
- int width;
- int height;
-} xorgRRConfig;
-
-typedef union {
- short RRRotations;
- xorgRRConfig RRConfig;
-} xorgRRRotation, *xorgRRRotationPtr;
-
-/* RR_GET_MODE_MM */
-typedef struct {
- DisplayModePtr mode;
- int virtX;
- int virtY;
- int mmWidth;
- int mmHeight;
-} xorgRRModeMM, *xorgRRModeMMPtr;
-
-/* GET_REQUIRED_HW_INTERFACES */
-#define HW_IO 1
-#define HW_MMIO 2
-#define HW_SKIP_CONSOLE 4
-#define NEED_IO_ENABLED(x) (x & HW_IO)
-
-typedef CARD32 xorgHWFlags;
-
-/*
- * The driver list struct. This contains the information required for each
- * driver before a ScrnInfoRec has been allocated.
- */
-struct _DriverRec;
-
-typedef struct {
- int driverVersion;
- char * driverName;
- void (*Identify)(int flags);
- Bool (*Probe)(struct _DriverRec *drv, int flags);
- const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
- pointer module;
- int refCount;
-} DriverRec1;
-
-struct _SymTabRec;
-struct _PciChipsets;
-
-typedef struct _DriverRec {
- int driverVersion;
- char * driverName;
- void (*Identify)(int flags);
- Bool (*Probe)(struct _DriverRec *drv, int flags);
- const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype);
- pointer module;
- int refCount;
- xorgDriverFuncProc *driverFunc;
-
- const struct pci_id_match * supported_devices;
- Bool (*PciProbe)( struct _DriverRec * drv, int entity_num,
- struct pci_device * dev, intptr_t match_data );
-} DriverRec, *DriverPtr;
-
-/*
- * AddDriver flags
- */
-#define HaveDriverFuncs 1
-
-/*
- * These are the private bus types. New types can be added here. Types
- * required for the public interface should be added to xf86str.h, with
- * function prototypes added to xf86.h.
- */
-
-/* Tolerate prior #include <linux/input.h> */
-#if defined(linux) && defined(_INPUT_H)
-#undef BUS_NONE
-#undef BUS_PCI
-#undef BUS_SBUS
-#undef BUS_last
-#endif
-
-typedef enum {
- BUS_NONE,
- BUS_PCI,
- BUS_SBUS,
- BUS_last /* Keep last */
-} BusType;
-
-struct pci_device;
-
-typedef struct {
- int fbNum;
-} SbusBusId;
-
-typedef struct _bus {
- BusType type;
- union {
- struct pci_device *pci;
- SbusBusId sbus;
- } id;
-} BusRec, *BusPtr;
-
-#define MAXCLOCKS 128
-typedef enum {
- DAC_BPP8 = 0,
- DAC_BPP16,
- DAC_BPP24,
- DAC_BPP32,
- MAXDACSPEEDS
-} DacSpeedIndex;
-
-typedef struct {
- char * identifier;
- char * vendor;
- char * board;
- char * chipset;
- char * ramdac;
- char * driver;
- struct _confscreenrec * myScreenSection;
- Bool claimed;
- int dacSpeeds[MAXDACSPEEDS];
- int numclocks;
- int clock[MAXCLOCKS];
- char * clockchip;
- char * busID;
- Bool active;
- Bool inUse;
- int videoRam;
- int textClockFreq;
- unsigned long BiosBase; /* Base address of video BIOS */
- unsigned long MemBase; /* Frame buffer base address */
- unsigned long IOBase;
- int chipID;
- int chipRev;
- pointer options;
- int irq;
- int screen; /* For multi-CRTC cards */
-} GDevRec, *GDevPtr;
-
-typedef struct {
- int frameX0;
- int frameY0;
- int virtualX;
- int virtualY;
- int depth;
- int fbbpp;
- rgb weight;
- rgb blackColour;
- rgb whiteColour;
- int defaultVisual;
- char ** modes;
- pointer options;
-} DispRec, *DispPtr;
-
-typedef struct _confxvportrec {
- char * identifier;
- pointer options;
-} confXvPortRec, *confXvPortPtr;
-
-typedef struct _confxvadaptrec {
- char * identifier;
- int numports;
- confXvPortPtr ports;
- pointer options;
-} confXvAdaptorRec, *confXvAdaptorPtr;
-
-typedef struct _confscreenrec {
- char * id;
- int screennum;
- int defaultdepth;
- int defaultbpp;
- int defaultfbbpp;
- MonPtr monitor;
- GDevPtr device;
- int numdisplays;
- DispPtr displays;
- int numxvadaptors;
- confXvAdaptorPtr xvadaptors;
- pointer options;
-} confScreenRec, *confScreenPtr;
-
-typedef enum {
- PosObsolete = -1,
- PosAbsolute = 0,
- PosRightOf,
- PosLeftOf,
- PosAbove,
- PosBelow,
- PosRelative
-} PositionType;
-
-typedef struct _screenlayoutrec {
- confScreenPtr screen;
- char * topname;
- confScreenPtr top;
- char * bottomname;
- confScreenPtr bottom;
- char * leftname;
- confScreenPtr left;
- char * rightname;
- confScreenPtr right;
- PositionType where;
- int x;
- int y;
- char * refname;
- confScreenPtr refscreen;
-} screenLayoutRec, *screenLayoutPtr;
-
-typedef struct _InputInfoRec InputInfoRec;
-
-typedef struct _serverlayoutrec {
- char * id;
- screenLayoutPtr screens;
- GDevPtr inactives;
- InputInfoRec** inputs; /* NULL terminated */
- pointer options;
-} serverLayoutRec, *serverLayoutPtr;
-
-typedef struct _confdribufferrec {
- int count;
- int size;
- enum {
- XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */
- } flags;
-} confDRIBufferRec, *confDRIBufferPtr;
-
-typedef struct _confdrirec {
- int group;
- int mode;
- int bufs_count;
- confDRIBufferRec *bufs;
-} confDRIRec, *confDRIPtr;
-
-/* These values should be adjusted when new fields are added to ScrnInfoRec */
-#define NUM_RESERVED_INTS 16
-#define NUM_RESERVED_POINTERS 14
-#define NUM_RESERVED_FUNCS 10
-
-typedef pointer (*funcPointer)(void);
-
-/* flags for depth 24 pixmap options */
-typedef enum {
- Pix24DontCare = 0,
- Pix24Use24,
- Pix24Use32
-} Pix24Flags;
-
-/* Power management events: so far we only support APM */
-
-typedef enum {
- XF86_APM_UNKNOWN = -1,
- XF86_APM_SYS_STANDBY,
- XF86_APM_SYS_SUSPEND,
- XF86_APM_CRITICAL_SUSPEND,
- XF86_APM_USER_STANDBY,
- XF86_APM_USER_SUSPEND,
- XF86_APM_STANDBY_RESUME,
- XF86_APM_NORMAL_RESUME,
- XF86_APM_CRITICAL_RESUME,
- XF86_APM_LOW_BATTERY,
- XF86_APM_POWER_STATUS_CHANGE,
- XF86_APM_UPDATE_TIME,
- XF86_APM_CAPABILITY_CHANGED,
- XF86_APM_STANDBY_FAILED,
- XF86_APM_SUSPEND_FAILED
-} pmEvent;
-
-typedef enum {
- PM_WAIT,
- PM_CONTINUE,
- PM_FAILED,
- PM_NONE
-} pmWait;
-
-typedef struct _PciChipsets {
- /**
- * Key used to match this device with its name in an array of
- * \c SymTabRec.
- */
- int numChipset;
-
- /**
- * This value is quirky. Depending on the driver, it can take on one of
- * three meanings. In drivers that have exactly one vendor ID (e.g.,
- * radeon, mga, i810) the low 16-bits are the device ID.
- *
- * In drivers that can have multiple vendor IDs (e.g., the glint driver
- * can have either 3dlabs' ID or TI's ID, the i740 driver can have either
- * Intel's ID or Real3D's ID, etc.) the low 16-bits are the device ID and
- * the high 16-bits are the vendor ID.
- *
- * In drivers that don't have a specific vendor (e.g., vga) contains the
- * device ID for either the generic VGA or generic 8514 devices. This
- * turns out to be the same as the subclass and programming interface
- * value (e.g., the full 24-bit class for the VGA device is 0x030000 (or
- * 0x000101) and for 8514 is 0x030001).
- */
- int PCIid;
-
-/* dummy place holders for drivers to build against old/new servers */
-#define RES_UNDEFINED NULL
-#define RES_EXCLUSIVE_VGA NULL
-#define RES_SHARED_VGA NULL
- void *dummy;
-} PciChipsets;
-
-
-/* Entity properties */
-typedef void (*EntityProc)(int entityIndex,pointer private);
-
-typedef struct _entityInfo {
- int index;
- BusRec location;
- int chipset;
- Bool active;
- GDevPtr device;
- DriverPtr driver;
-} EntityInfoRec, *EntityInfoPtr;
-
-/* server states */
-
-typedef enum {
- SETUP,
- OPERATING
-} xf86State;
-
-/* DGA */
-
-typedef struct {
- int num; /* A unique identifier for the mode (num > 0) */
- DisplayModePtr mode;
- int flags; /* DGA_CONCURRENT_ACCESS, etc... */
- int imageWidth; /* linear accessible portion (pixels) */
- int imageHeight;
- int pixmapWidth; /* Xlib accessible portion (pixels) */
- int pixmapHeight; /* both fields ignored if no concurrent access */
- int bytesPerScanline;
- int byteOrder; /* MSBFirst, LSBFirst */
- int depth;
- int bitsPerPixel;
- unsigned long red_mask;
- unsigned long green_mask;
- unsigned long blue_mask;
- short visualClass;
- int viewportWidth;
- int viewportHeight;
- int xViewportStep; /* viewport position granularity */
- int yViewportStep;
- int maxViewportX; /* max viewport origin */
- int maxViewportY;
- int viewportFlags; /* types of page flipping possible */
- int offset; /* offset into physical memory */
- unsigned char *address; /* server's mapped framebuffer */
- int reserved1;
- int reserved2;
-} DGAModeRec, *DGAModePtr;
-
-typedef struct {
- DGAModePtr mode;
- PixmapPtr pPix;
-} DGADeviceRec, *DGADevicePtr;
-
-/*
- * Flags for driver Probe() functions.
- */
-#define PROBE_DEFAULT 0x00
-#define PROBE_DETECT 0x01
-#define PROBE_TRYHARD 0x02
-
-/*
- * Driver entry point types
- */
-
-typedef Bool xf86ProbeProc (DriverPtr, int);
-typedef Bool xf86PreInitProc (ScrnInfoPtr, int);
-typedef Bool xf86ScreenInitProc (int, ScreenPtr, int, char**);
-typedef Bool xf86SwitchModeProc (int, DisplayModePtr, int);
-typedef void xf86AdjustFrameProc (int, int, int, int);
-typedef Bool xf86EnterVTProc (int, int);
-typedef void xf86LeaveVTProc (int, int);
-typedef void xf86FreeScreenProc (int, int);
-typedef ModeStatus xf86ValidModeProc (int, DisplayModePtr, Bool, int);
-typedef void xf86EnableDisableFBAccessProc(int, Bool);
-typedef int xf86SetDGAModeProc (int, int, DGADevicePtr);
-typedef int xf86ChangeGammaProc (int, Gamma);
-typedef void xf86PointerMovedProc (int, int, int);
-typedef Bool xf86PMEventProc (int, pmEvent, Bool);
-typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int);
-typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
-typedef void xf86SetOverscanProc (ScrnInfoPtr, int);
-typedef void xf86ModeSetProc (ScrnInfoPtr);
-
-
-/*
- * ScrnInfoRec
- *
- * There is one of these for each screen, and it holds all the screen-specific
- * information.
- *
- * Note: the size and layout must be kept the same across versions. New
- * fields are to be added in place of the "reserved*" fields. No fields
- * are to be dependent on compile-time defines.
- */
-
-
-typedef struct _ScrnInfoRec {
- int driverVersion;
- char * driverName; /* canonical name used in */
- /* the config file */
- ScreenPtr pScreen; /* Pointer to the ScreenRec */
- int scrnIndex; /* Number of this screen */
- Bool configured; /* Is this screen valid */
- int origIndex; /* initial number assigned to
- * this screen before
- * finalising the number of
- * available screens */
-
- /* Display-wide screenInfo values needed by this screen */
- int imageByteOrder;
- int bitmapScanlineUnit;
- int bitmapScanlinePad;
- int bitmapBitOrder;
- int numFormats;
- PixmapFormatRec formats[MAXFORMATS];
- PixmapFormatRec fbFormat;
-
- int bitsPerPixel; /* fb bpp */
- Pix24Flags pixmap24; /* pixmap pref for depth 24 */
- int depth; /* depth of default visual */
- MessageType depthFrom; /* set from config? */
- MessageType bitsPerPixelFrom; /* set from config? */
- rgb weight; /* r/g/b weights */
- rgb mask; /* rgb masks */
- rgb offset; /* rgb offsets */
- int rgbBits; /* Number of bits in r/g/b */
- Gamma gamma; /* Gamma of the monitor */
- int defaultVisual; /* default visual class */
- int maxHValue; /* max horizontal timing */
- int maxVValue; /* max vertical timing value */
- int virtualX; /* Virtual width */
- int virtualY; /* Virtual height */
- int xInc; /* Horizontal timing increment */
- MessageType virtualFrom; /* set from config? */
- int displayWidth; /* memory pitch */
- int frameX0; /* viewport position */
- int frameY0;
- int frameX1;
- int frameY1;
- int zoomLocked; /* Disallow mode changes */
- DisplayModePtr modePool; /* list of compatible modes */
- DisplayModePtr modes; /* list of actual modes */
- DisplayModePtr currentMode; /* current mode
- * This was previously
- * overloaded with the modes
- * field, which is a pointer
- * into a circular list */
- confScreenPtr confScreen; /* Screen config info */
- MonPtr monitor; /* Monitor information */
- DispPtr display; /* Display information */
- int * entityList; /* List of device entities */
- int numEntities;
- int widthmm; /* physical display dimensions
- * in mm */
- int heightmm;
- int xDpi; /* width DPI */
- int yDpi; /* height DPI */
- char * name; /* Name to prefix messages */
- pointer driverPrivate; /* Driver private area */
- DevUnion * privates; /* Other privates can hook in
- * here */
- DriverPtr drv; /* xf86DriverList[] entry */
- pointer module; /* Pointer to module head */
- int colorKey;
- int overlayFlags;
-
- /* Some of these may be moved out of here into the driver private area */
-
- char * chipset; /* chipset name */
- char * ramdac; /* ramdac name */
- char * clockchip; /* clock name */
- Bool progClock; /* clock is programmable */
- int numClocks; /* number of clocks */
- int clock[MAXCLOCKS]; /* list of clock frequencies */
- int videoRam; /* amount of video ram (kb) */
- unsigned long biosBase; /* Base address of video BIOS */
- unsigned long memPhysBase; /* Physical address of FB */
- unsigned long fbOffset; /* Offset of FB in the above */
- IOADDRESS domainIOBase; /* Domain I/O base address */
- int memClk; /* memory clock */
- int textClockFreq; /* clock of text mode */
- Bool flipPixels; /* swap default black/white */
- pointer options;
-
- int chipID;
- int chipRev;
-
- /* Allow screens to be enabled/disabled individually */
- Bool vtSema;
-
- /* hw cursor moves at SIGIO time */
- Bool silkenMouse;
-
- /* Storage for clockRanges and adjustFlags for use with the VidMode ext */
- ClockRangePtr clockRanges;
- int adjustFlags;
-
- /*
- * These can be used when the minor ABI version is incremented.
- * The NUM_* parameters must be reduced appropriately to keep the
- * structure size and alignment unchanged.
- */
- int reservedInt[NUM_RESERVED_INTS];
-
- int * entityInstanceList;
- struct pci_device *vgaDev;
-
- pointer reservedPtr[NUM_RESERVED_POINTERS];
-
- /*
- * Driver entry points.
- *
- */
-
- xf86ProbeProc *Probe;
- xf86PreInitProc *PreInit;
- xf86ScreenInitProc *ScreenInit;
- xf86SwitchModeProc *SwitchMode;
- xf86AdjustFrameProc *AdjustFrame;
- xf86EnterVTProc *EnterVT;
- xf86LeaveVTProc *LeaveVT;
- xf86FreeScreenProc *FreeScreen;
- xf86ValidModeProc *ValidMode;
- xf86EnableDisableFBAccessProc *EnableDisableFBAccess;
- xf86SetDGAModeProc *SetDGAMode;
- xf86ChangeGammaProc *ChangeGamma;
- xf86PointerMovedProc *PointerMoved;
- xf86PMEventProc *PMEvent;
- xf86DPMSSetProc *DPMSSet;
- xf86LoadPaletteProc *LoadPalette;
- xf86SetOverscanProc *SetOverscan;
- xorgDriverFuncProc *DriverFunc;
- xf86ModeSetProc *ModeSet;
-
- /*
- * This can be used when the minor ABI version is incremented.
- * The NUM_* parameter must be reduced appropriately to keep the
- * structure size and alignment unchanged.
- */
- funcPointer reservedFuncs[NUM_RESERVED_FUNCS];
-
-} ScrnInfoRec;
-
-
-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;
-
-typedef struct _SymTabRec {
- int token; /* id of the token */
- const char * name; /* token name */
-} SymTabRec, *SymTabPtr;
-
-/* flags for xf86LookupMode */
-typedef enum {
- LOOKUP_DEFAULT = 0, /* Use default mode lookup method */
- LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */
- LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */
- LOOKUP_LIST_ORDER, /* Pick first useful mode in list */
- LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */
- LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */
-} LookupModeFlags;
-
-#define NoDepth24Support 0x00
-#define Support24bppFb 0x01 /* 24bpp framebuffer supported */
-#define Support32bppFb 0x02 /* 32bpp framebuffer supported */
-#define SupportConvert24to32 0x04 /* Can convert 24bpp pixmap to 32bpp */
-#define SupportConvert32to24 0x08 /* Can convert 32bpp pixmap to 24bpp */
-#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */
-#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */
-
-
-/* For DPMS */
-typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int);
-
-/* Input handler proc */
-typedef void (*InputHandlerProc)(int fd, pointer data);
-
-/* These are used by xf86GetClocks */
-#define CLK_REG_SAVE -1
-#define CLK_REG_RESTORE -2
-
-/*
- * misc constants
- */
-#define INTERLACE_REFRESH_WEIGHT 1.5
-#define SYNC_TOLERANCE 0.01 /* 1 percent */
-#define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */
-
-
-#define OVERLAY_8_32_DUALFB 0x00000001
-#define OVERLAY_8_24_DUALFB 0x00000002
-#define OVERLAY_8_16_DUALFB 0x00000004
-#define OVERLAY_8_32_PLANAR 0x00000008
-
-/* Values of xf86Info.mouseFlags */
-#define MF_CLEAR_DTR 1
-#define MF_CLEAR_RTS 2
-
-/* Action Events */
-typedef enum {
- ACTION_TERMINATE = 0, /* Terminate Server */
- ACTION_NEXT_MODE = 10, /* Switch to next video mode */
- ACTION_PREV_MODE,
- ACTION_SWITCHSCREEN = 100, /* VT switch */
- ACTION_SWITCHSCREEN_NEXT,
- ACTION_SWITCHSCREEN_PREV,
-} ActionEvent;
-
-#endif /* _XF86STR_H */
+ +/* + * Copyright (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * This file contains definitions of the public XFree86 data structures/types. + * Any data structures that video drivers need to access should go here. + */ + +#ifndef _XF86STR_H +#define _XF86STR_H + +#include "misc.h" +#include "input.h" +#include "scrnintstr.h" +#include "pixmapstr.h" +#include "colormapst.h" +#include "xf86Module.h" +#include "xf86Opt.h" +#include "xf86Pci.h" + +#include <pciaccess.h> + +/** + * Integer type that is of the size of the addressable memory (machine size). + * On most platforms \c uintptr_t will suffice. However, on some mixed + * 32-bit / 64-bit platforms, such as 32-bit binaries on 64-bit PowerPC, this + * must be 64-bits. + */ +#include <inttypes.h> +#if defined(__powerpc__) +typedef uint64_t memType; +#else +typedef uintptr_t memType; +#endif + + +/* Video mode flags */ + +typedef enum { + V_PHSYNC = 0x0001, + V_NHSYNC = 0x0002, + V_PVSYNC = 0x0004, + V_NVSYNC = 0x0008, + V_INTERLACE = 0x0010, + V_DBLSCAN = 0x0020, + V_CSYNC = 0x0040, + V_PCSYNC = 0x0080, + V_NCSYNC = 0x0100, + V_HSKEW = 0x0200, /* hskew provided */ + V_BCAST = 0x0400, + V_PIXMUX = 0x1000, + V_DBLCLK = 0x2000, + V_CLKDIV2 = 0x4000 +} ModeFlags; + +typedef enum { + INTERLACE_HALVE_V = 0x0001 /* Halve V values for interlacing */ +} CrtcAdjustFlags; + +/* Flags passed to ChipValidMode() */ +typedef enum { + MODECHECK_INITIAL = 0, + MODECHECK_FINAL = 1 +} ModeCheckFlags; + +/* These are possible return values for xf86CheckMode() and ValidMode() */ +typedef enum { + MODE_OK = 0, /* Mode OK */ + MODE_HSYNC, /* hsync out of range */ + MODE_VSYNC, /* vsync out of range */ + MODE_H_ILLEGAL, /* mode has illegal horizontal timings */ + MODE_V_ILLEGAL, /* mode has illegal horizontal timings */ + MODE_BAD_WIDTH, /* requires an unsupported linepitch */ + MODE_NOMODE, /* no mode with a maching name */ + MODE_NO_INTERLACE, /* interlaced mode not supported */ + MODE_NO_DBLESCAN, /* doublescan mode not supported */ + MODE_NO_VSCAN, /* multiscan mode not supported */ + MODE_MEM, /* insufficient video memory */ + MODE_VIRTUAL_X, /* mode width too large for specified virtual size */ + MODE_VIRTUAL_Y, /* mode height too large for specified virtual size */ + MODE_MEM_VIRT, /* insufficient video memory given virtual size */ + MODE_NOCLOCK, /* no fixed clock available */ + MODE_CLOCK_HIGH, /* clock required is too high */ + MODE_CLOCK_LOW, /* clock required is too low */ + MODE_CLOCK_RANGE, /* clock/mode isn't in a ClockRange */ + MODE_BAD_HVALUE, /* horizontal timing was out of range */ + MODE_BAD_VVALUE, /* vertical timing was out of range */ + MODE_BAD_VSCAN, /* VScan value out of range */ + MODE_HSYNC_NARROW, /* horizontal sync too narrow */ + MODE_HSYNC_WIDE, /* horizontal sync too wide */ + MODE_HBLANK_NARROW, /* horizontal blanking too narrow */ + MODE_HBLANK_WIDE, /* horizontal blanking too wide */ + MODE_VSYNC_NARROW, /* vertical sync too narrow */ + MODE_VSYNC_WIDE, /* vertical sync too wide */ + MODE_VBLANK_NARROW, /* vertical blanking too narrow */ + MODE_VBLANK_WIDE, /* vertical blanking too wide */ + MODE_PANEL, /* exceeds panel dimensions */ + MODE_INTERLACE_WIDTH, /* width too large for interlaced mode */ + MODE_ONE_WIDTH, /* only one width is supported */ + MODE_ONE_HEIGHT, /* only one height is supported */ + MODE_ONE_SIZE, /* only one resolution is supported */ + MODE_NO_REDUCED, /* monitor doesn't accept reduced blanking */ + MODE_BANDWIDTH, /* mode requires too much memory bandwidth */ + MODE_BAD = -2, /* unspecified reason */ + MODE_ERROR = -1 /* error condition */ +} ModeStatus; + +/* + * The mode sets are, from best to worst: USERDEF, DRIVER, and DEFAULT/BUILTIN. + * Preferred will bubble a mode to the top within a set. + */ +# define M_T_BUILTIN 0x01 /* built-in mode */ +# define M_T_CLOCK_C (0x02 | M_T_BUILTIN) /* built-in mode - configure clock */ +# define M_T_CRTC_C (0x04 | M_T_BUILTIN) /* built-in mode - configure CRTC */ +# define M_T_CLOCK_CRTC_C (M_T_CLOCK_C | M_T_CRTC_C) + /* built-in mode - configure CRTC and clock */ +# define M_T_PREFERRED 0x08 /* preferred mode within a set */ +# define M_T_DEFAULT 0x10 /* (VESA) default modes */ +# define M_T_USERDEF 0x20 /* One of the modes from the config file */ +# define M_T_DRIVER 0x40 /* Supplied by the driver (EDID, etc) */ +# define M_T_USERPREF 0x80 /* mode preferred by the user config */ + +/* Video mode */ +typedef struct _DisplayModeRec { + struct _DisplayModeRec * prev; + struct _DisplayModeRec * next; + char * name; /* identifier for the mode */ + ModeStatus status; + int type; + + /* These are the values that the user sees/provides */ + int Clock; /* pixel clock freq (kHz) */ + int HDisplay; /* horizontal timing */ + int HSyncStart; + int HSyncEnd; + int HTotal; + int HSkew; + int VDisplay; /* vertical timing */ + int VSyncStart; + int VSyncEnd; + int VTotal; + int VScan; + int Flags; + + /* These are the values the hardware uses */ + int ClockIndex; + int SynthClock; /* Actual clock freq to + * be programmed (kHz) */ + int CrtcHDisplay; + int CrtcHBlankStart; + int CrtcHSyncStart; + int CrtcHSyncEnd; + int CrtcHBlankEnd; + int CrtcHTotal; + int CrtcHSkew; + int CrtcVDisplay; + int CrtcVBlankStart; + int CrtcVSyncStart; + int CrtcVSyncEnd; + int CrtcVBlankEnd; + int CrtcVTotal; + Bool CrtcHAdjusted; + Bool CrtcVAdjusted; + int PrivSize; + INT32 * Private; + int PrivFlags; + + float HSync, VRefresh; +} DisplayModeRec, *DisplayModePtr; + +/* The monitor description */ + +#define MAX_HSYNC 8 +#define MAX_VREFRESH 8 + +typedef struct { float hi, lo; } range; + +typedef struct { CARD32 red, green, blue; } rgb; + +typedef struct { float red, green, blue; } Gamma; + +/* The permitted gamma range is 1 / GAMMA_MAX <= g <= GAMMA_MAX */ +#define GAMMA_MAX 10.0 +#define GAMMA_MIN (1.0 / GAMMA_MAX) +#define GAMMA_ZERO (GAMMA_MIN / 100.0) + +typedef struct { + char * id; + char * vendor; + char * model; + int nHsync; + range hsync[MAX_HSYNC]; + int nVrefresh; + range vrefresh[MAX_VREFRESH]; + DisplayModePtr Modes; /* Start of the monitor's mode list */ + DisplayModePtr Last; /* End of the monitor's mode list */ + Gamma gamma; /* Gamma of the monitor */ + int widthmm; + int heightmm; + pointer options; + pointer DDC; + Bool reducedblanking; /* Allow CVT reduced blanking modes? */ + int maxPixClock; /* in kHz, like mode->Clock */ +} MonRec, *MonPtr; + +/* the list of clock ranges */ +typedef struct x_ClockRange { + struct x_ClockRange *next; + int minClock; /* (kHz) */ + int maxClock; /* (kHz) */ + int clockIndex; /* -1 for programmable clocks */ + Bool interlaceAllowed; + Bool doubleScanAllowed; + int ClockMulFactor; + int ClockDivFactor; + int PrivFlags; +} ClockRange, *ClockRangePtr; + +/* + * The driverFunc. xorgDriverFuncOp specifies the action driver should + * perform. If requested option is not supported function should return + * FALSE. pointer can be used to pass arguments to the function or + * to return data to the caller. + */ +typedef struct _ScrnInfoRec *ScrnInfoPtr; + +/* do not change order */ +typedef enum { + RR_GET_INFO, + RR_SET_CONFIG, + RR_GET_MODE_MM, + GET_REQUIRED_HW_INTERFACES = 10 +} xorgDriverFuncOp; + +typedef Bool xorgDriverFuncProc (ScrnInfoPtr, xorgDriverFuncOp, + pointer); + +/* RR_GET_INFO, RR_SET_CONFIG */ +typedef struct { + int rotation; + int rate; + int width; + int height; +} xorgRRConfig; + +typedef union { + short RRRotations; + xorgRRConfig RRConfig; +} xorgRRRotation, *xorgRRRotationPtr; + +/* RR_GET_MODE_MM */ +typedef struct { + DisplayModePtr mode; + int virtX; + int virtY; + int mmWidth; + int mmHeight; +} xorgRRModeMM, *xorgRRModeMMPtr; + +/* GET_REQUIRED_HW_INTERFACES */ +#define HW_IO 1 +#define HW_MMIO 2 +#define HW_SKIP_CONSOLE 4 +#define NEED_IO_ENABLED(x) (x & HW_IO) + +typedef CARD32 xorgHWFlags; + +/* + * The driver list struct. This contains the information required for each + * driver before a ScrnInfoRec has been allocated. + */ +struct _DriverRec; + +typedef struct { + int driverVersion; + char * driverName; + void (*Identify)(int flags); + Bool (*Probe)(struct _DriverRec *drv, int flags); + const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype); + pointer module; + int refCount; +} DriverRec1; + +struct _SymTabRec; +struct _PciChipsets; + +typedef struct _DriverRec { + int driverVersion; + char * driverName; + void (*Identify)(int flags); + Bool (*Probe)(struct _DriverRec *drv, int flags); + const OptionInfoRec * (*AvailableOptions)(int chipid, int bustype); + pointer module; + int refCount; + xorgDriverFuncProc *driverFunc; + + const struct pci_id_match * supported_devices; + Bool (*PciProbe)( struct _DriverRec * drv, int entity_num, + struct pci_device * dev, intptr_t match_data ); +} DriverRec, *DriverPtr; + +/* + * AddDriver flags + */ +#define HaveDriverFuncs 1 + +/* + * These are the private bus types. New types can be added here. Types + * required for the public interface should be added to xf86str.h, with + * function prototypes added to xf86.h. + */ + +/* Tolerate prior #include <linux/input.h> */ +#if defined(linux) && defined(_INPUT_H) +#undef BUS_NONE +#undef BUS_PCI +#undef BUS_SBUS +#undef BUS_last +#endif + +typedef enum { + BUS_NONE, + BUS_PCI, + BUS_SBUS, + BUS_last /* Keep last */ +} BusType; + +struct pci_device; + +typedef struct { + int fbNum; +} SbusBusId; + +typedef struct _bus { + BusType type; + union { + struct pci_device *pci; + SbusBusId sbus; + } id; +} BusRec, *BusPtr; + +#define MAXCLOCKS 128 +typedef enum { + DAC_BPP8 = 0, + DAC_BPP16, + DAC_BPP24, + DAC_BPP32, + MAXDACSPEEDS +} DacSpeedIndex; + +typedef struct { + char * identifier; + char * vendor; + char * board; + char * chipset; + char * ramdac; + char * driver; + struct _confscreenrec * myScreenSection; + Bool claimed; + int dacSpeeds[MAXDACSPEEDS]; + int numclocks; + int clock[MAXCLOCKS]; + char * clockchip; + char * busID; + Bool active; + Bool inUse; + int videoRam; + int textClockFreq; + unsigned long BiosBase; /* Base address of video BIOS */ + unsigned long MemBase; /* Frame buffer base address */ + unsigned long IOBase; + int chipID; + int chipRev; + pointer options; + int irq; + int screen; /* For multi-CRTC cards */ +} GDevRec, *GDevPtr; + +typedef struct { + int frameX0; + int frameY0; + int virtualX; + int virtualY; + int depth; + int fbbpp; + rgb weight; + rgb blackColour; + rgb whiteColour; + int defaultVisual; + char ** modes; + pointer options; +} DispRec, *DispPtr; + +typedef struct _confxvportrec { + char * identifier; + pointer options; +} confXvPortRec, *confXvPortPtr; + +typedef struct _confxvadaptrec { + char * identifier; + int numports; + confXvPortPtr ports; + pointer options; +} confXvAdaptorRec, *confXvAdaptorPtr; + +typedef struct _confscreenrec { + char * id; + int screennum; + int defaultdepth; + int defaultbpp; + int defaultfbbpp; + MonPtr monitor; + GDevPtr device; + int numdisplays; + DispPtr displays; + int numxvadaptors; + confXvAdaptorPtr xvadaptors; + pointer options; +} confScreenRec, *confScreenPtr; + +typedef enum { + PosObsolete = -1, + PosAbsolute = 0, + PosRightOf, + PosLeftOf, + PosAbove, + PosBelow, + PosRelative +} PositionType; + +typedef struct _screenlayoutrec { + confScreenPtr screen; + char * topname; + confScreenPtr top; + char * bottomname; + confScreenPtr bottom; + char * leftname; + confScreenPtr left; + char * rightname; + confScreenPtr right; + PositionType where; + int x; + int y; + char * refname; + confScreenPtr refscreen; +} screenLayoutRec, *screenLayoutPtr; + +typedef struct _InputInfoRec InputInfoRec; + +typedef struct _serverlayoutrec { + char * id; + screenLayoutPtr screens; + GDevPtr inactives; + InputInfoRec** inputs; /* NULL terminated */ + pointer options; +} serverLayoutRec, *serverLayoutPtr; + +typedef struct _confdribufferrec { + int count; + int size; + enum { + XF86DRI_WC_HINT = 0x0001 /* Placeholder: not implemented */ + } flags; +} confDRIBufferRec, *confDRIBufferPtr; + +typedef struct _confdrirec { + int group; + int mode; + int bufs_count; + confDRIBufferRec *bufs; +} confDRIRec, *confDRIPtr; + +/* These values should be adjusted when new fields are added to ScrnInfoRec */ +#define NUM_RESERVED_INTS 16 +#define NUM_RESERVED_POINTERS 14 +#define NUM_RESERVED_FUNCS 10 + +typedef pointer (*funcPointer)(void); + +/* flags for depth 24 pixmap options */ +typedef enum { + Pix24DontCare = 0, + Pix24Use24, + Pix24Use32 +} Pix24Flags; + +/* Power management events: so far we only support APM */ + +typedef enum { + XF86_APM_UNKNOWN = -1, + XF86_APM_SYS_STANDBY, + XF86_APM_SYS_SUSPEND, + XF86_APM_CRITICAL_SUSPEND, + XF86_APM_USER_STANDBY, + XF86_APM_USER_SUSPEND, + XF86_APM_STANDBY_RESUME, + XF86_APM_NORMAL_RESUME, + XF86_APM_CRITICAL_RESUME, + XF86_APM_LOW_BATTERY, + XF86_APM_POWER_STATUS_CHANGE, + XF86_APM_UPDATE_TIME, + XF86_APM_CAPABILITY_CHANGED, + XF86_APM_STANDBY_FAILED, + XF86_APM_SUSPEND_FAILED +} pmEvent; + +typedef enum { + PM_WAIT, + PM_CONTINUE, + PM_FAILED, + PM_NONE +} pmWait; + +typedef struct _PciChipsets { + /** + * Key used to match this device with its name in an array of + * \c SymTabRec. + */ + int numChipset; + + /** + * This value is quirky. Depending on the driver, it can take on one of + * three meanings. In drivers that have exactly one vendor ID (e.g., + * radeon, mga, i810) the low 16-bits are the device ID. + * + * In drivers that can have multiple vendor IDs (e.g., the glint driver + * can have either 3dlabs' ID or TI's ID, the i740 driver can have either + * Intel's ID or Real3D's ID, etc.) the low 16-bits are the device ID and + * the high 16-bits are the vendor ID. + * + * In drivers that don't have a specific vendor (e.g., vga) contains the + * device ID for either the generic VGA or generic 8514 devices. This + * turns out to be the same as the subclass and programming interface + * value (e.g., the full 24-bit class for the VGA device is 0x030000 (or + * 0x000101) and for 8514 is 0x030001). + */ + int PCIid; + +/* dummy place holders for drivers to build against old/new servers */ +#define RES_UNDEFINED NULL +#define RES_EXCLUSIVE_VGA NULL +#define RES_SHARED_VGA NULL + void *dummy; +} PciChipsets; + + +/* Entity properties */ +typedef void (*EntityProc)(int entityIndex,pointer private); + +typedef struct _entityInfo { + int index; + BusRec location; + int chipset; + Bool active; + GDevPtr device; + DriverPtr driver; +} EntityInfoRec, *EntityInfoPtr; + +/* DGA */ + +typedef struct { + int num; /* A unique identifier for the mode (num > 0) */ + DisplayModePtr mode; + int flags; /* DGA_CONCURRENT_ACCESS, etc... */ + int imageWidth; /* linear accessible portion (pixels) */ + int imageHeight; + int pixmapWidth; /* Xlib accessible portion (pixels) */ + int pixmapHeight; /* both fields ignored if no concurrent access */ + int bytesPerScanline; + int byteOrder; /* MSBFirst, LSBFirst */ + int depth; + int bitsPerPixel; + unsigned long red_mask; + unsigned long green_mask; + unsigned long blue_mask; + short visualClass; + int viewportWidth; + int viewportHeight; + int xViewportStep; /* viewport position granularity */ + int yViewportStep; + int maxViewportX; /* max viewport origin */ + int maxViewportY; + int viewportFlags; /* types of page flipping possible */ + int offset; /* offset into physical memory */ + unsigned char *address; /* server's mapped framebuffer */ + int reserved1; + int reserved2; +} DGAModeRec, *DGAModePtr; + +typedef struct { + DGAModePtr mode; + PixmapPtr pPix; +} DGADeviceRec, *DGADevicePtr; + +/* + * Flags for driver Probe() functions. + */ +#define PROBE_DEFAULT 0x00 +#define PROBE_DETECT 0x01 +#define PROBE_TRYHARD 0x02 + +/* + * Driver entry point types + */ + +typedef Bool xf86ProbeProc (DriverPtr, int); +typedef Bool xf86PreInitProc (ScrnInfoPtr, int); +typedef Bool xf86ScreenInitProc (int, ScreenPtr, int, char**); +typedef Bool xf86SwitchModeProc (int, DisplayModePtr, int); +typedef void xf86AdjustFrameProc (int, int, int, int); +typedef Bool xf86EnterVTProc (int, int); +typedef void xf86LeaveVTProc (int, int); +typedef void xf86FreeScreenProc (int, int); +typedef ModeStatus xf86ValidModeProc (int, DisplayModePtr, Bool, int); +typedef void xf86EnableDisableFBAccessProc(int, Bool); +typedef int xf86SetDGAModeProc (int, int, DGADevicePtr); +typedef int xf86ChangeGammaProc (int, Gamma); +typedef void xf86PointerMovedProc (int, int, int); +typedef Bool xf86PMEventProc (int, pmEvent, Bool); +typedef void xf86DPMSSetProc (ScrnInfoPtr, int, int); +typedef void xf86LoadPaletteProc (ScrnInfoPtr, int, int *, LOCO *, VisualPtr); +typedef void xf86SetOverscanProc (ScrnInfoPtr, int); +typedef void xf86ModeSetProc (ScrnInfoPtr); + + +/* + * ScrnInfoRec + * + * There is one of these for each screen, and it holds all the screen-specific + * information. + * + * Note: the size and layout must be kept the same across versions. New + * fields are to be added in place of the "reserved*" fields. No fields + * are to be dependent on compile-time defines. + */ + + +typedef struct _ScrnInfoRec { + int driverVersion; + char * driverName; /* canonical name used in */ + /* the config file */ + ScreenPtr pScreen; /* Pointer to the ScreenRec */ + int scrnIndex; /* Number of this screen */ + Bool configured; /* Is this screen valid */ + int origIndex; /* initial number assigned to + * this screen before + * finalising the number of + * available screens */ + + /* Display-wide screenInfo values needed by this screen */ + int imageByteOrder; + int bitmapScanlineUnit; + int bitmapScanlinePad; + int bitmapBitOrder; + int numFormats; + PixmapFormatRec formats[MAXFORMATS]; + PixmapFormatRec fbFormat; + + int bitsPerPixel; /* fb bpp */ + Pix24Flags pixmap24; /* pixmap pref for depth 24 */ + int depth; /* depth of default visual */ + MessageType depthFrom; /* set from config? */ + MessageType bitsPerPixelFrom; /* set from config? */ + rgb weight; /* r/g/b weights */ + rgb mask; /* rgb masks */ + rgb offset; /* rgb offsets */ + int rgbBits; /* Number of bits in r/g/b */ + Gamma gamma; /* Gamma of the monitor */ + int defaultVisual; /* default visual class */ + int maxHValue; /* max horizontal timing */ + int maxVValue; /* max vertical timing value */ + int virtualX; /* Virtual width */ + int virtualY; /* Virtual height */ + int xInc; /* Horizontal timing increment */ + MessageType virtualFrom; /* set from config? */ + int displayWidth; /* memory pitch */ + int frameX0; /* viewport position */ + int frameY0; + int frameX1; + int frameY1; + int zoomLocked; /* Disallow mode changes */ + DisplayModePtr modePool; /* list of compatible modes */ + DisplayModePtr modes; /* list of actual modes */ + DisplayModePtr currentMode; /* current mode + * This was previously + * overloaded with the modes + * field, which is a pointer + * into a circular list */ + confScreenPtr confScreen; /* Screen config info */ + MonPtr monitor; /* Monitor information */ + DispPtr display; /* Display information */ + int * entityList; /* List of device entities */ + int numEntities; + int widthmm; /* physical display dimensions + * in mm */ + int heightmm; + int xDpi; /* width DPI */ + int yDpi; /* height DPI */ + char * name; /* Name to prefix messages */ + pointer driverPrivate; /* Driver private area */ + DevUnion * privates; /* Other privates can hook in + * here */ + DriverPtr drv; /* xf86DriverList[] entry */ + pointer module; /* Pointer to module head */ + int colorKey; + int overlayFlags; + + /* Some of these may be moved out of here into the driver private area */ + + char * chipset; /* chipset name */ + char * ramdac; /* ramdac name */ + char * clockchip; /* clock name */ + Bool progClock; /* clock is programmable */ + int numClocks; /* number of clocks */ + int clock[MAXCLOCKS]; /* list of clock frequencies */ + int videoRam; /* amount of video ram (kb) */ + unsigned long biosBase; /* Base address of video BIOS */ + unsigned long memPhysBase; /* Physical address of FB */ + unsigned long fbOffset; /* Offset of FB in the above */ + IOADDRESS domainIOBase; /* Domain I/O base address */ + int memClk; /* memory clock */ + int textClockFreq; /* clock of text mode */ + Bool flipPixels; /* swap default black/white */ + pointer options; + + int chipID; + int chipRev; + + /* Allow screens to be enabled/disabled individually */ + Bool vtSema; + + /* hw cursor moves at SIGIO time */ + Bool silkenMouse; + + /* Storage for clockRanges and adjustFlags for use with the VidMode ext */ + ClockRangePtr clockRanges; + int adjustFlags; + + /* + * These can be used when the minor ABI version is incremented. + * The NUM_* parameters must be reduced appropriately to keep the + * structure size and alignment unchanged. + */ + int reservedInt[NUM_RESERVED_INTS]; + + int * entityInstanceList; + struct pci_device *vgaDev; + + pointer reservedPtr[NUM_RESERVED_POINTERS]; + + /* + * Driver entry points. + * + */ + + xf86ProbeProc *Probe; + xf86PreInitProc *PreInit; + xf86ScreenInitProc *ScreenInit; + xf86SwitchModeProc *SwitchMode; + xf86AdjustFrameProc *AdjustFrame; + xf86EnterVTProc *EnterVT; + xf86LeaveVTProc *LeaveVT; + xf86FreeScreenProc *FreeScreen; + xf86ValidModeProc *ValidMode; + xf86EnableDisableFBAccessProc *EnableDisableFBAccess; + xf86SetDGAModeProc *SetDGAMode; + xf86ChangeGammaProc *ChangeGamma; + xf86PointerMovedProc *PointerMoved; + xf86PMEventProc *PMEvent; + xf86DPMSSetProc *DPMSSet; + xf86LoadPaletteProc *LoadPalette; + xf86SetOverscanProc *SetOverscan; + xorgDriverFuncProc *DriverFunc; + xf86ModeSetProc *ModeSet; + + /* + * This can be used when the minor ABI version is incremented. + * The NUM_* parameter must be reduced appropriately to keep the + * structure size and alignment unchanged. + */ + funcPointer reservedFuncs[NUM_RESERVED_FUNCS]; + +} ScrnInfoRec; + + +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; + +typedef struct _SymTabRec { + int token; /* id of the token */ + const char * name; /* token name */ +} SymTabRec, *SymTabPtr; + +/* flags for xf86LookupMode */ +typedef enum { + LOOKUP_DEFAULT = 0, /* Use default mode lookup method */ + LOOKUP_BEST_REFRESH, /* Pick modes with best refresh */ + LOOKUP_CLOSEST_CLOCK, /* Pick modes with the closest clock */ + LOOKUP_LIST_ORDER, /* Pick first useful mode in list */ + LOOKUP_CLKDIV2 = 0x0100, /* Allow half clocks */ + LOOKUP_OPTIONAL_TOLERANCES = 0x0200 /* Allow missing hsync/vrefresh */ +} LookupModeFlags; + +#define NoDepth24Support 0x00 +#define Support24bppFb 0x01 /* 24bpp framebuffer supported */ +#define Support32bppFb 0x02 /* 32bpp framebuffer supported */ +#define SupportConvert24to32 0x04 /* Can convert 24bpp pixmap to 32bpp */ +#define SupportConvert32to24 0x08 /* Can convert 32bpp pixmap to 24bpp */ +#define PreferConvert24to32 0x10 /* prefer 24bpp pixmap to 32bpp conv */ +#define PreferConvert32to24 0x20 /* prefer 32bpp pixmap to 24bpp conv */ + + +/* For DPMS */ +typedef void (*DPMSSetProcPtr)(ScrnInfoPtr, int, int); + +/* Input handler proc */ +typedef void (*InputHandlerProc)(int fd, pointer data); + +/* These are used by xf86GetClocks */ +#define CLK_REG_SAVE -1 +#define CLK_REG_RESTORE -2 + +/* + * misc constants + */ +#define INTERLACE_REFRESH_WEIGHT 1.5 +#define SYNC_TOLERANCE 0.01 /* 1 percent */ +#define CLOCK_TOLERANCE 2000 /* Clock matching tolerance (2MHz) */ + + +#define OVERLAY_8_32_DUALFB 0x00000001 +#define OVERLAY_8_24_DUALFB 0x00000002 +#define OVERLAY_8_16_DUALFB 0x00000004 +#define OVERLAY_8_32_PLANAR 0x00000008 + +/* Values of xf86Info.mouseFlags */ +#define MF_CLEAR_DTR 1 +#define MF_CLEAR_RTS 2 + +/* Action Events */ +typedef enum { + ACTION_TERMINATE = 0, /* Terminate Server */ + ACTION_NEXT_MODE = 10, /* Switch to next video mode */ + ACTION_PREV_MODE, + ACTION_SWITCHSCREEN = 100, /* VT switch */ + ACTION_SWITCHSCREEN_NEXT, + ACTION_SWITCHSCREEN_PREV, +} ActionEvent; + +#endif /* _XF86STR_H */ diff --git a/xorg-server/hw/xfree86/ddc/ddc.c b/xorg-server/hw/xfree86/ddc/ddc.c index e9b8a52eb..179f42ccd 100644 --- a/xorg-server/hw/xfree86/ddc/ddc.c +++ b/xorg-server/hw/xfree86/ddc/ddc.c @@ -1,506 +1,503 @@ -/* xf86DDC.c
- *
- * Copyright 1998,1999 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE>
- */
-
-/*
- * A note on terminology. DDC1 is the original dumb serial protocol, and
- * can only do up to 128 bytes of EDID. DDC2 is I2C-encapsulated and
- * introduces extension blocks. EDID is the old display identification
- * block, DisplayID is the new one.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include "misc.h"
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "xf86DDC.h"
-#include <string.h>
-
-#define RETRIES 4
-
-typedef enum {
- DDCOPT_NODDC1,
- DDCOPT_NODDC2,
- DDCOPT_NODDC
-} DDCOpts;
-
-static const OptionInfoRec DDCOptions[] = {
- { DDCOPT_NODDC1, "NoDDC1", OPTV_BOOLEAN, {0}, FALSE },
- { DDCOPT_NODDC2, "NoDDC2", OPTV_BOOLEAN, {0}, FALSE },
- { DDCOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE },
-};
-
-/* DDC1 */
-
-static int
-find_start(unsigned int *ptr)
-{
- unsigned int comp[9], test[9];
- int i,j;
-
- for (i=0;i<9;i++){
- comp[i] = *(ptr++);
- test[i] = 1;
- }
- for (i=0;i<127;i++){
- for (j=0;j<9;j++){
- test[j] = test[j] & !(comp[j] ^ *(ptr++));
- }
- }
- for (i=0;i<9;i++)
- if (test[i]) return i+1;
- return -1;
-}
-
-static unsigned char *
-find_header(unsigned char *block)
-{
- unsigned char *ptr, *head_ptr, *end;
- unsigned char header[]={0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00};
-
- ptr = block;
- end = block + EDID1_LEN;
- while (ptr<end) {
- int i;
- head_ptr = ptr;
- for (i=0;i<8;i++){
- if (header[i] != *(head_ptr++)) break;
- if (head_ptr == end) head_ptr = block;
- }
- if (i==8) break;
- ptr++;
- }
- if (ptr == end) return NULL;
- return ptr;
-}
-
-static unsigned char *
-resort(unsigned char *s_block)
-{
- unsigned char *d_new, *d_ptr, *d_end, *s_ptr, *s_end;
- unsigned char tmp;
-
- s_end = s_block + EDID1_LEN;
- d_new = malloc(EDID1_LEN);
- if (!d_new) return NULL;
- d_end = d_new + EDID1_LEN;
-
- s_ptr = find_header(s_block);
- if (!s_ptr) return NULL;
- for (d_ptr=d_new;d_ptr<d_end;d_ptr++){
- tmp = *(s_ptr++);
- *d_ptr = tmp;
- if (s_ptr == s_end) s_ptr = s_block;
- }
- free(s_block);
- return d_new;
-}
-
-static int
-DDC_checksum(const unsigned char *block, int len)
-{
- int i, result = 0;
- int not_null = 0;
-
- for (i=0;i<len;i++) {
- not_null |= block[i];
- result += block[i];
- }
-
-#ifdef DEBUG
- if (result & 0xFF) ErrorF("DDC checksum not correct\n");
- if (!not_null) ErrorF("DDC read all Null\n");
-#endif
-
- /* catch the trivial case where all bytes are 0 */
- if (!not_null) return 1;
-
- return result&0xFF;
-}
-
-static unsigned char *
-GetEDID_DDC1(unsigned int *s_ptr)
-{
- unsigned char *d_block, *d_pos;
- unsigned int *s_pos, *s_end;
- int s_start;
- int i,j;
- s_start = find_start(s_ptr);
- if (s_start==-1) return NULL;
- s_end = s_ptr + NUM;
- s_pos = s_ptr + s_start;
- d_block=malloc(EDID1_LEN);
- if (!d_block) return NULL;
- d_pos = d_block;
- for (i=0;i<EDID1_LEN;i++) {
- for (j=0;j<8;j++) {
- *d_pos <<= 1;
- if (*s_pos) {
- *d_pos |= 0x01;
- }
- s_pos++; if (s_pos == s_end) s_pos=s_ptr;
- };
- s_pos++; if (s_pos == s_end) s_pos=s_ptr;
- d_pos++;
- }
- free(s_ptr);
- if (d_block && DDC_checksum(d_block,EDID1_LEN)) {
- free(d_block);
- return NULL;
- }
- return (resort(d_block));
-}
-
-/* fetch entire EDID record; DDC bit needs to be masked */
-static unsigned int *
-FetchEDID_DDC1(register ScrnInfoPtr pScrn,
- register unsigned int (*read_DDC)(ScrnInfoPtr))
-{
- int count = NUM;
- unsigned int *ptr, *xp;
-
- ptr=xp=malloc(sizeof(int)*NUM);
-
- if (!ptr) return NULL;
- do {
- /* wait for next retrace */
- *xp = read_DDC(pScrn);
- xp++;
- } while(--count);
- return ptr;
-}
-
-/* test if DDC1 return 0 if not */
-static Bool
-TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC)(ScrnInfoPtr))
-{
- int old, count;
-
- old = read_DDC(pScrn);
- count = HEADER * BITS_PER_BYTE;
- do {
- /* wait for next retrace */
- if (old != read_DDC(pScrn)) break;
- } while(count--);
- return count;
-}
-
-/*
- * read EDID record , pass it to callback function to interpret.
- * callback function will store it for further use by calling
- * function; it will also decide if we need to reread it
- */
-static unsigned char *
-EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed,
- unsigned int (*read_DDC)(ScrnInfoPtr))
-{
- unsigned char *EDID_block = NULL;
- int count = RETRIES;
-
- if (!read_DDC) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "chipset doesn't support DDC1\n");
- return NULL;
- };
-
- if (TestDDC1(pScrn,read_DDC)==-1) {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No DDC signal\n");
- return NULL;
- };
-
- if (DDCSpeed) DDCSpeed(pScrn,DDC_FAST);
- do {
- EDID_block = GetEDID_DDC1(FetchEDID_DDC1(pScrn,read_DDC));
- count --;
- } while (!EDID_block && count);
- if (DDCSpeed) DDCSpeed(pScrn,DDC_SLOW);
-
- return EDID_block;
-}
-
-/**
- * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC1 are
- * unset. EDID information blocks are interpreted and the results returned in
- * an xf86MonPtr.
- *
- * This function does not affect the list of modes used by drivers -- it is up
- * to the driver to decide policy on what to do with EDID information.
- *
- * @return pointer to a new xf86MonPtr containing the EDID information.
- * @return NULL if no monitor attached or failure to interpret the EDID.
- */
-xf86MonPtr
-xf86DoEDID_DDC1(
- int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed,
- unsigned int (*DDC1Read)(ScrnInfoPtr)
-)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- unsigned char *EDID_block = NULL;
- xf86MonPtr tmp = NULL;
- int sigio;
- /* Default DDC and DDC1 to enabled. */
- Bool noddc = FALSE, noddc1 = FALSE;
- OptionInfoPtr options;
-
- options = xnfalloc(sizeof(DDCOptions));
- (void)memcpy(options, DDCOptions, sizeof(DDCOptions));
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
- xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
- xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1);
- free(options);
-
- if (noddc || noddc1)
- return NULL;
-
- sigio = xf86BlockSIGIO();
- EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read);
- xf86UnblockSIGIO(sigio);
-
- if (EDID_block){
- tmp = xf86InterpretEDID(scrnIndex,EDID_block);
- }
-#ifdef DEBUG
- else ErrorF("No EDID block returned\n");
- if (!tmp)
- ErrorF("Cannot interpret EDID block\n");
-#endif
- return tmp;
-}
-
-/* DDC2 */
-
-static I2CDevPtr
-DDC2MakeDevice(I2CBusPtr pBus, int address, char *name)
-{
- I2CDevPtr dev = NULL;
-
- if (!(dev = xf86I2CFindDev(pBus, address))) {
- dev = xf86CreateI2CDevRec();
- dev->DevName = name;
- dev->SlaveAddr = address;
- dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */
- dev->StartTimeout = 550;
- dev->BitTimeout = 40;
- dev->AcknTimeout = 40;
-
- dev->pI2CBus = pBus;
- if (!xf86I2CDevInit(dev)) {
- xf86DrvMsg(pBus->scrnIndex, X_PROBED, "No DDC2 device\n");
- return NULL;
- }
- }
-
- return dev;
-}
-
-static I2CDevPtr
-DDC2Init(int scrnIndex, I2CBusPtr pBus)
-{
- I2CDevPtr dev = NULL;
-
- /*
- * Slow down the bus so that older monitors don't
- * miss things.
- */
- pBus->RiseFallTime = 20;
-
- dev = DDC2MakeDevice(pBus, 0x00A0, "ddc2");
- if (xf86I2CProbeAddress(pBus, 0x0060))
- DDC2MakeDevice(pBus, 0x0060, "E-EDID segment register");
-
- return dev;
-}
-
-/* Mmmm, smell the hacks */
-static void
-EEDIDStop(I2CDevPtr d)
-{
-}
-
-/* block is the EDID block number. a segment is two blocks. */
-static Bool
-DDC2Read(I2CDevPtr dev, int block, unsigned char *R_Buffer)
-{
- unsigned char W_Buffer[1];
- int i, segment;
- I2CDevPtr seg;
- void (*stop)(I2CDevPtr);
-
- for (i = 0; i < RETRIES; i++) {
- /* Stop bits reset the segment pointer to 0, so be careful here. */
- segment = block >> 1;
- if (segment) {
- Bool b;
-
- if (!(seg = xf86I2CFindDev(dev->pI2CBus, 0x0060)))
- return FALSE;
-
- W_Buffer[0] = segment;
-
- stop = dev->pI2CBus->I2CStop;
- dev->pI2CBus->I2CStop = EEDIDStop;
-
- b = xf86I2CWriteRead(seg, W_Buffer, 1, NULL, 0);
-
- dev->pI2CBus->I2CStop = stop;
- if (!b) {
- dev->pI2CBus->I2CStop(dev);
- continue;
- }
- }
-
- W_Buffer[0] = (block & 0x01) * EDID1_LEN;
-
- if (xf86I2CWriteRead(dev, W_Buffer, 1, R_Buffer, EDID1_LEN)) {
- if (!DDC_checksum(R_Buffer, EDID1_LEN))
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-/**
- * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are
- * unset. EDID information blocks are interpreted and the results returned in
- * an xf86MonPtr. Unlike xf86DoEDID_DDC[12](), this function will return
- * the complete EDID data, including all extension blocks, if the 'complete'
- * parameter is TRUE;
- *
- * This function does not affect the list of modes used by drivers -- it is up
- * to the driver to decide policy on what to do with EDID information.
- *
- * @return pointer to a new xf86MonPtr containing the EDID information.
- * @return NULL if no monitor attached or failure to interpret the EDID.
- */
-xf86MonPtr
-xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- unsigned char *EDID_block = NULL;
- xf86MonPtr tmp = NULL;
- I2CDevPtr dev = NULL;
- /* Default DDC and DDC2 to enabled. */
- Bool noddc = FALSE, noddc2 = FALSE;
- OptionInfoPtr options;
-
- options = malloc(sizeof(DDCOptions));
- if (!options)
- return NULL;
- memcpy(options, DDCOptions, sizeof(DDCOptions));
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
- xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
- xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2);
- free(options);
-
- if (noddc || noddc2)
- return NULL;
-
- if (!(dev = DDC2Init(scrnIndex, pBus)))
- return NULL;
-
- EDID_block = calloc(1, EDID1_LEN);
- if (!EDID_block)
- return NULL;
-
- if (DDC2Read(dev, 0, EDID_block)) {
- int i, n = EDID_block[0x7e];
-
- if (complete && n) {
- EDID_block = realloc(EDID_block, EDID1_LEN * (1+n));
-
- for (i = 0; i < n; i++)
- DDC2Read(dev, i+1, EDID_block + (EDID1_LEN * (1+i)));
- }
-
- tmp = xf86InterpretEEDID(scrnIndex, EDID_block);
- }
-
- if (tmp && complete)
- tmp->flags |= MONITOR_EDID_COMPLETE_RAWDATA;
-
- return tmp;
-}
-
-/**
- * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are
- * unset. EDID information blocks are interpreted and the results returned in
- * an xf86MonPtr.
- *
- * This function does not affect the list of modes used by drivers -- it is up
- * to the driver to decide policy on what to do with EDID information.
- *
- * @return pointer to a new xf86MonPtr containing the EDID information.
- * @return NULL if no monitor attached or failure to interpret the EDID.
- */
-xf86MonPtr
-xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus)
-{
- return xf86DoEEDID(scrnIndex, pBus, FALSE);
-}
-
-/* XXX write me */
-static void *
-DDC2ReadDisplayID(void)
-{
- return FALSE;
-}
-
-/**
- * Attempts to probe the monitor for DisplayID information, if NoDDC and
- * NoDDC2 are unset. DisplayID blocks are interpreted and the results
- * returned in an xf86MonPtr.
- *
- * This function does not affect the list of modes used by drivers -- it is up
- * to the driver to decide policy on what to do with DisplayID information.
- *
- * @return pointer to a new xf86MonPtr containing the DisplayID information.
- * @return NULL if no monitor attached or failure to interpret the DisplayID.
- */
-xf86MonPtr
-xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- unsigned char *did = NULL;
- xf86MonPtr tmp = NULL;
- I2CDevPtr dev = NULL;
- /* Default DDC and DDC2 to enabled. */
- Bool noddc = FALSE, noddc2 = FALSE;
- OptionInfoPtr options;
-
- options = malloc(sizeof(DDCOptions));
- if (!options)
- return NULL;
- memcpy(options, DDCOptions, sizeof(DDCOptions));
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
-
- xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
- xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2);
- free(options);
-
- if (noddc || noddc2)
- return NULL;
-
- if (!(dev = DDC2Init(scrnIndex, pBus)))
- return NULL;
-
- if ((did = DDC2ReadDisplayID())) {
- tmp = calloc(1, sizeof(*tmp));
- if (!tmp)
- return NULL;
-
- tmp->scrnIndex = scrnIndex;
- tmp->flags |= MONITOR_DISPLAYID;
- tmp->rawData = did;
- }
-
- return tmp;
-}
+/* xf86DDC.c + * + * Copyright 1998,1999 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE> + */ + +/* + * A note on terminology. DDC1 is the original dumb serial protocol, and + * can only do up to 128 bytes of EDID. DDC2 is I2C-encapsulated and + * introduces extension blocks. EDID is the old display identification + * block, DisplayID is the new one. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include "misc.h" +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86DDC.h" +#include <string.h> + +#define RETRIES 4 + +typedef enum { + DDCOPT_NODDC1, + DDCOPT_NODDC2, + DDCOPT_NODDC +} DDCOpts; + +static const OptionInfoRec DDCOptions[] = { + { DDCOPT_NODDC1, "NoDDC1", OPTV_BOOLEAN, {0}, FALSE }, + { DDCOPT_NODDC2, "NoDDC2", OPTV_BOOLEAN, {0}, FALSE }, + { DDCOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE }, +}; + +/* DDC1 */ + +static int +find_start(unsigned int *ptr) +{ + unsigned int comp[9], test[9]; + int i,j; + + for (i=0;i<9;i++){ + comp[i] = *(ptr++); + test[i] = 1; + } + for (i=0;i<127;i++){ + for (j=0;j<9;j++){ + test[j] = test[j] & !(comp[j] ^ *(ptr++)); + } + } + for (i=0;i<9;i++) + if (test[i]) return i+1; + return -1; +} + +static unsigned char * +find_header(unsigned char *block) +{ + unsigned char *ptr, *head_ptr, *end; + unsigned char header[]={0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00}; + + ptr = block; + end = block + EDID1_LEN; + while (ptr<end) { + int i; + head_ptr = ptr; + for (i=0;i<8;i++){ + if (header[i] != *(head_ptr++)) break; + if (head_ptr == end) head_ptr = block; + } + if (i==8) break; + ptr++; + } + if (ptr == end) return NULL; + return ptr; +} + +static unsigned char * +resort(unsigned char *s_block) +{ + unsigned char *d_new, *d_ptr, *d_end, *s_ptr, *s_end; + unsigned char tmp; + + s_end = s_block + EDID1_LEN; + d_new = malloc(EDID1_LEN); + if (!d_new) return NULL; + d_end = d_new + EDID1_LEN; + + s_ptr = find_header(s_block); + if (!s_ptr) return NULL; + for (d_ptr=d_new;d_ptr<d_end;d_ptr++){ + tmp = *(s_ptr++); + *d_ptr = tmp; + if (s_ptr == s_end) s_ptr = s_block; + } + free(s_block); + return d_new; +} + +static int +DDC_checksum(const unsigned char *block, int len) +{ + int i, result = 0; + int not_null = 0; + + for (i=0;i<len;i++) { + not_null |= block[i]; + result += block[i]; + } + +#ifdef DEBUG + if (result & 0xFF) ErrorF("DDC checksum not correct\n"); + if (!not_null) ErrorF("DDC read all Null\n"); +#endif + + /* catch the trivial case where all bytes are 0 */ + if (!not_null) return 1; + + return result&0xFF; +} + +static unsigned char * +GetEDID_DDC1(unsigned int *s_ptr) +{ + unsigned char *d_block, *d_pos; + unsigned int *s_pos, *s_end; + int s_start; + int i,j; + s_start = find_start(s_ptr); + if (s_start==-1) return NULL; + s_end = s_ptr + NUM; + s_pos = s_ptr + s_start; + d_block=malloc(EDID1_LEN); + if (!d_block) return NULL; + d_pos = d_block; + for (i=0;i<EDID1_LEN;i++) { + for (j=0;j<8;j++) { + *d_pos <<= 1; + if (*s_pos) { + *d_pos |= 0x01; + } + s_pos++; if (s_pos == s_end) s_pos=s_ptr; + }; + s_pos++; if (s_pos == s_end) s_pos=s_ptr; + d_pos++; + } + free(s_ptr); + if (d_block && DDC_checksum(d_block,EDID1_LEN)) { + free(d_block); + return NULL; + } + return (resort(d_block)); +} + +/* fetch entire EDID record; DDC bit needs to be masked */ +static unsigned int * +FetchEDID_DDC1(register ScrnInfoPtr pScrn, + register unsigned int (*read_DDC)(ScrnInfoPtr)) +{ + int count = NUM; + unsigned int *ptr, *xp; + + ptr=xp=malloc(sizeof(int)*NUM); + + if (!ptr) return NULL; + do { + /* wait for next retrace */ + *xp = read_DDC(pScrn); + xp++; + } while(--count); + return ptr; +} + +/* test if DDC1 return 0 if not */ +static Bool +TestDDC1(ScrnInfoPtr pScrn, unsigned int (*read_DDC)(ScrnInfoPtr)) +{ + int old, count; + + old = read_DDC(pScrn); + count = HEADER * BITS_PER_BYTE; + do { + /* wait for next retrace */ + if (old != read_DDC(pScrn)) break; + } while(count--); + return count; +} + +/* + * read EDID record , pass it to callback function to interpret. + * callback function will store it for further use by calling + * function; it will also decide if we need to reread it + */ +static unsigned char * +EDIDRead_DDC1(ScrnInfoPtr pScrn, DDC1SetSpeedProc DDCSpeed, + unsigned int (*read_DDC)(ScrnInfoPtr)) +{ + unsigned char *EDID_block = NULL; + int count = RETRIES; + + if (!read_DDC) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, + "chipset doesn't support DDC1\n"); + return NULL; + }; + + if (TestDDC1(pScrn,read_DDC)==-1) { + xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "No DDC signal\n"); + return NULL; + }; + + if (DDCSpeed) DDCSpeed(pScrn,DDC_FAST); + do { + EDID_block = GetEDID_DDC1(FetchEDID_DDC1(pScrn,read_DDC)); + count --; + } while (!EDID_block && count); + if (DDCSpeed) DDCSpeed(pScrn,DDC_SLOW); + + return EDID_block; +} + +/** + * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC1 are + * unset. EDID information blocks are interpreted and the results returned in + * an xf86MonPtr. + * + * This function does not affect the list of modes used by drivers -- it is up + * to the driver to decide policy on what to do with EDID information. + * + * @return pointer to a new xf86MonPtr containing the EDID information. + * @return NULL if no monitor attached or failure to interpret the EDID. + */ +xf86MonPtr +xf86DoEDID_DDC1(int scrnIndex, DDC1SetSpeedProc DDC1SetSpeed, + unsigned int (*DDC1Read)(ScrnInfoPtr)) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + unsigned char *EDID_block = NULL; + xf86MonPtr tmp = NULL; + /* Default DDC and DDC1 to enabled. */ + Bool noddc = FALSE, noddc1 = FALSE; + OptionInfoPtr options; + + options = xnfalloc(sizeof(DDCOptions)); + (void)memcpy(options, DDCOptions, sizeof(DDCOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); + + xf86GetOptValBool(options, DDCOPT_NODDC, &noddc); + xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1); + free(options); + + if (noddc || noddc1) + return NULL; + + OsBlockSignals(); + EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read); + OsReleaseSignals(); + + if (EDID_block){ + tmp = xf86InterpretEDID(scrnIndex,EDID_block); + } +#ifdef DEBUG + else ErrorF("No EDID block returned\n"); + if (!tmp) + ErrorF("Cannot interpret EDID block\n"); +#endif + return tmp; +} + +/* DDC2 */ + +static I2CDevPtr +DDC2MakeDevice(I2CBusPtr pBus, int address, char *name) +{ + I2CDevPtr dev = NULL; + + if (!(dev = xf86I2CFindDev(pBus, address))) { + dev = xf86CreateI2CDevRec(); + dev->DevName = name; + dev->SlaveAddr = address; + dev->ByteTimeout = 2200; /* VESA DDC spec 3 p. 43 (+10 %) */ + dev->StartTimeout = 550; + dev->BitTimeout = 40; + dev->AcknTimeout = 40; + + dev->pI2CBus = pBus; + if (!xf86I2CDevInit(dev)) { + xf86DrvMsg(pBus->scrnIndex, X_PROBED, "No DDC2 device\n"); + return NULL; + } + } + + return dev; +} + +static I2CDevPtr +DDC2Init(int scrnIndex, I2CBusPtr pBus) +{ + I2CDevPtr dev = NULL; + + /* + * Slow down the bus so that older monitors don't + * miss things. + */ + pBus->RiseFallTime = 20; + + dev = DDC2MakeDevice(pBus, 0x00A0, "ddc2"); + if (xf86I2CProbeAddress(pBus, 0x0060)) + DDC2MakeDevice(pBus, 0x0060, "E-EDID segment register"); + + return dev; +} + +/* Mmmm, smell the hacks */ +static void +EEDIDStop(I2CDevPtr d) +{ +} + +/* block is the EDID block number. a segment is two blocks. */ +static Bool +DDC2Read(I2CDevPtr dev, int block, unsigned char *R_Buffer) +{ + unsigned char W_Buffer[1]; + int i, segment; + I2CDevPtr seg; + void (*stop)(I2CDevPtr); + + for (i = 0; i < RETRIES; i++) { + /* Stop bits reset the segment pointer to 0, so be careful here. */ + segment = block >> 1; + if (segment) { + Bool b; + + if (!(seg = xf86I2CFindDev(dev->pI2CBus, 0x0060))) + return FALSE; + + W_Buffer[0] = segment; + + stop = dev->pI2CBus->I2CStop; + dev->pI2CBus->I2CStop = EEDIDStop; + + b = xf86I2CWriteRead(seg, W_Buffer, 1, NULL, 0); + + dev->pI2CBus->I2CStop = stop; + if (!b) { + dev->pI2CBus->I2CStop(dev); + continue; + } + } + + W_Buffer[0] = (block & 0x01) * EDID1_LEN; + + if (xf86I2CWriteRead(dev, W_Buffer, 1, R_Buffer, EDID1_LEN)) { + if (!DDC_checksum(R_Buffer, EDID1_LEN)) + return TRUE; + } + } + + return FALSE; +} + +/** + * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are + * unset. EDID information blocks are interpreted and the results returned in + * an xf86MonPtr. Unlike xf86DoEDID_DDC[12](), this function will return + * the complete EDID data, including all extension blocks, if the 'complete' + * parameter is TRUE; + * + * This function does not affect the list of modes used by drivers -- it is up + * to the driver to decide policy on what to do with EDID information. + * + * @return pointer to a new xf86MonPtr containing the EDID information. + * @return NULL if no monitor attached or failure to interpret the EDID. + */ +xf86MonPtr +xf86DoEEDID(int scrnIndex, I2CBusPtr pBus, Bool complete) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + unsigned char *EDID_block = NULL; + xf86MonPtr tmp = NULL; + I2CDevPtr dev = NULL; + /* Default DDC and DDC2 to enabled. */ + Bool noddc = FALSE, noddc2 = FALSE; + OptionInfoPtr options; + + options = malloc(sizeof(DDCOptions)); + if (!options) + return NULL; + memcpy(options, DDCOptions, sizeof(DDCOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); + + xf86GetOptValBool(options, DDCOPT_NODDC, &noddc); + xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2); + free(options); + + if (noddc || noddc2) + return NULL; + + if (!(dev = DDC2Init(scrnIndex, pBus))) + return NULL; + + EDID_block = calloc(1, EDID1_LEN); + if (!EDID_block) + return NULL; + + if (DDC2Read(dev, 0, EDID_block)) { + int i, n = EDID_block[0x7e]; + + if (complete && n) { + EDID_block = realloc(EDID_block, EDID1_LEN * (1+n)); + + for (i = 0; i < n; i++) + DDC2Read(dev, i+1, EDID_block + (EDID1_LEN * (1+i))); + } + + tmp = xf86InterpretEEDID(scrnIndex, EDID_block); + } + + if (tmp && complete) + tmp->flags |= MONITOR_EDID_COMPLETE_RAWDATA; + + return tmp; +} + +/** + * Attempts to probe the monitor for EDID information, if NoDDC and NoDDC2 are + * unset. EDID information blocks are interpreted and the results returned in + * an xf86MonPtr. + * + * This function does not affect the list of modes used by drivers -- it is up + * to the driver to decide policy on what to do with EDID information. + * + * @return pointer to a new xf86MonPtr containing the EDID information. + * @return NULL if no monitor attached or failure to interpret the EDID. + */ +xf86MonPtr +xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus) +{ + return xf86DoEEDID(scrnIndex, pBus, FALSE); +} + +/* XXX write me */ +static void * +DDC2ReadDisplayID(void) +{ + return FALSE; +} + +/** + * Attempts to probe the monitor for DisplayID information, if NoDDC and + * NoDDC2 are unset. DisplayID blocks are interpreted and the results + * returned in an xf86MonPtr. + * + * This function does not affect the list of modes used by drivers -- it is up + * to the driver to decide policy on what to do with DisplayID information. + * + * @return pointer to a new xf86MonPtr containing the DisplayID information. + * @return NULL if no monitor attached or failure to interpret the DisplayID. + */ +xf86MonPtr +xf86DoDisplayID(int scrnIndex, I2CBusPtr pBus) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + unsigned char *did = NULL; + xf86MonPtr tmp = NULL; + I2CDevPtr dev = NULL; + /* Default DDC and DDC2 to enabled. */ + Bool noddc = FALSE, noddc2 = FALSE; + OptionInfoPtr options; + + options = malloc(sizeof(DDCOptions)); + if (!options) + return NULL; + memcpy(options, DDCOptions, sizeof(DDCOptions)); + xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); + + xf86GetOptValBool(options, DDCOPT_NODDC, &noddc); + xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2); + free(options); + + if (noddc || noddc2) + return NULL; + + if (!(dev = DDC2Init(scrnIndex, pBus))) + return NULL; + + if ((did = DDC2ReadDisplayID())) { + tmp = calloc(1, sizeof(*tmp)); + if (!tmp) + return NULL; + + tmp->scrnIndex = scrnIndex; + tmp->flags |= MONITOR_DISPLAYID; + tmp->rawData = did; + } + + return tmp; +} diff --git a/xorg-server/hw/xfree86/int10/helper_exec.c b/xorg-server/hw/xfree86/int10/helper_exec.c index a55390194..b9af473b1 100644 --- a/xorg-server/hw/xfree86/int10/helper_exec.c +++ b/xorg-server/hw/xfree86/int10/helper_exec.c @@ -1,732 +1,733 @@ -/*
- * XFree86 int10 module
- * execute BIOS int 10h calls in x86 real mode environment
- * Copyright 1999 Egbert Eich
- *
- * Part of this code was inspired by the VBIOS POSTing code in DOSEMU
- * developed by the "DOSEMU-Development-Team"
- */
-
-/*
- * To debug port accesses define PRINT_PORT to 1.
- * Note! You also have to comment out ioperm()
- * in xf86EnableIO(). Otherwise we won't trap
- * on PIO.
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#define PRINT_PORT 0
-
-#include <unistd.h>
-
-#include <X11/Xos.h>
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "compiler.h"
-#define _INT10_PRIVATE
-#include "int10Defines.h"
-#include "xf86int10.h"
-#include "Pci.h"
-#ifdef _X86EMU
-#include "x86emu/x86emui.h"
-#else
-#define DEBUG_IO_TRACE() 0
-#endif
-#include <pciaccess.h>
-
-static int pciCfg1in(CARD16 addr, CARD32 *val);
-static int pciCfg1out(CARD16 addr, CARD32 val);
-static int pciCfg1inw(CARD16 addr, CARD16 *val);
-static int pciCfg1outw(CARD16 addr, CARD16 val);
-static int pciCfg1inb(CARD16 addr, CARD8 *val);
-static int pciCfg1outb(CARD16 addr, CARD8 val);
-#if defined (_PC)
-static void SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set);
-#endif
-
-#define REG pInt
-
-int
-setup_int(xf86Int10InfoPtr pInt)
-{
- if (pInt != Int10Current) {
- if (!MapCurrentInt10(pInt))
- return -1;
- Int10Current = pInt;
- }
- X86_EAX = (CARD32) pInt->ax;
- X86_EBX = (CARD32) pInt->bx;
- X86_ECX = (CARD32) pInt->cx;
- X86_EDX = (CARD32) pInt->dx;
- X86_ESI = (CARD32) pInt->si;
- X86_EDI = (CARD32) pInt->di;
- X86_EBP = (CARD32) pInt->bp;
- X86_ESP = 0x1000; X86_SS = pInt->stackseg >> 4;
- X86_EIP = 0x0600; X86_CS = 0x0; /* address of 'hlt' */
- X86_DS = 0x40; /* standard pc ds */
- X86_ES = pInt->es;
- X86_FS = 0;
- X86_GS = 0;
- X86_EFLAGS = X86_IF_MASK | X86_IOPL_MASK;
-#if defined (_PC)
- if (pInt->Flags & SET_BIOS_SCRATCH)
- SetResetBIOSVars(pInt, TRUE);
-#endif
- return xf86BlockSIGIO();
-}
-
-void
-finish_int(xf86Int10InfoPtr pInt, int sig)
-{
- xf86UnblockSIGIO(sig);
- pInt->ax = (CARD32) X86_EAX;
- pInt->bx = (CARD32) X86_EBX;
- pInt->cx = (CARD32) X86_ECX;
- pInt->dx = (CARD32) X86_EDX;
- pInt->si = (CARD32) X86_ESI;
- pInt->di = (CARD32) X86_EDI;
- pInt->es = (CARD16) X86_ES;
- pInt->bp = (CARD32) X86_EBP;
- pInt->flags = (CARD32) X86_FLAGS;
-#if defined (_PC)
- if (pInt->Flags & RESTORE_BIOS_SCRATCH)
- SetResetBIOSVars(pInt, FALSE);
-#endif
-}
-
-/* general software interrupt handler */
-CARD32
-getIntVect(xf86Int10InfoPtr pInt,int num)
-{
- return MEM_RW(pInt, num << 2) + (MEM_RW(pInt, (num << 2) + 2) << 4);
-}
-
-void
-pushw(xf86Int10InfoPtr pInt, CARD16 val)
-{
- X86_ESP -= 2;
- MEM_WW(pInt, ((CARD32) X86_SS << 4) + X86_SP, val);
-}
-
-int
-run_bios_int(int num, xf86Int10InfoPtr pInt)
-{
- CARD32 eflags;
-#ifndef _PC
- /* check if bios vector is initialized */
- if (MEM_RW(pInt, (num << 2) + 2) == (SYS_BIOS >> 4)) { /* SYS_BIOS_SEG ?*/
-
- if (num == 21 && X86_AH == 0x4e) {
- xf86DrvMsg(pInt->scrnIndex, X_NOTICE,
- "Failing Find-Matching-File on non-PC"
- " (int 21, func 4e)\n");
- X86_AX = 2;
- SET_FLAG(F_CF);
- return 1;
- } else {
- xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "Ignoring int 0x%02x call\n", num);
- if (xf86GetVerbosity() > 3) {
- dump_registers(pInt);
- stack_trace(pInt);
- }
- return 1;
- }
- }
-#endif
-#ifdef PRINT_INT
- ErrorF("calling card BIOS at: ");
-#endif
- eflags = X86_EFLAGS;
-#if 0
- eflags = eflags | IF_MASK;
- X86_EFLAGS = X86_EFLAGS & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK);
-#endif
- pushw(pInt, eflags);
- pushw(pInt, X86_CS);
- pushw(pInt, X86_IP);
- X86_CS = MEM_RW(pInt, (num << 2) + 2);
- X86_IP = MEM_RW(pInt, num << 2);
-#ifdef PRINT_INT
- ErrorF("0x%x:%lx\n", X86_CS, X86_EIP);
-#endif
- return 1;
-}
-
-/* Debugging stuff */
-void
-dump_code(xf86Int10InfoPtr pInt)
-{
- int i;
- unsigned long lina = SEG_ADR((CARD32), X86_CS, IP);
-
- xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, "code at 0x%8.8lx:\n", lina);
- for (i=0; i<0x10; i++)
- xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i));
- xf86ErrorFVerb(3, "\n");
- for (; i<0x20; i++)
- xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i));
- xf86ErrorFVerb(3, "\n");
-}
-
-void
-dump_registers(xf86Int10InfoPtr pInt)
-{
- xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "EAX=0x%8.8lx, EBX=0x%8.8lx, ECX=0x%8.8lx, EDX=0x%8.8lx\n",
- (unsigned long)X86_EAX, (unsigned long)X86_EBX,
- (unsigned long)X86_ECX, (unsigned long)X86_EDX);
- xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "ESP=0x%8.8lx, EBP=0x%8.8lx, ESI=0x%8.8lx, EDI=0x%8.8lx\n",
- (unsigned long)X86_ESP, (unsigned long)X86_EBP,
- (unsigned long)X86_ESI, (unsigned long)X86_EDI);
- xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "CS=0x%4.4x, SS=0x%4.4x,"
- " DS=0x%4.4x, ES=0x%4.4x, FS=0x%4.4x, GS=0x%4.4x\n",
- X86_CS, X86_SS, X86_DS, X86_ES, X86_FS, X86_GS);
- xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3,
- "EIP=0x%8.8lx, EFLAGS=0x%8.8lx\n",
- (unsigned long)X86_EIP, (unsigned long)X86_EFLAGS);
-}
-
-void
-stack_trace(xf86Int10InfoPtr pInt)
-{
- int i = 0;
- unsigned long stack = SEG_ADR((CARD32), X86_SS, SP);
- unsigned long tail = (CARD32)((X86_SS << 4) + 0x1000);
-
- if (stack >= tail) return;
-
- xf86MsgVerb(X_INFO, 3, "stack at 0x%8.8lx:\n", stack);
- for (; stack < tail; stack++) {
- xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, stack));
- i = (i + 1) % 0x10;
- if (!i)
- xf86ErrorFVerb(3, "\n");
- }
- if (i)
- xf86ErrorFVerb(3, "\n");
-}
-
-int
-port_rep_inb(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -1 : 1;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_insb(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- MEM_WB(pInt, dst, x_inb(port));
- dst += inc;
- }
- return dst - base;
-}
-
-int
-port_rep_inw(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -2 : 2;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_insw(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- MEM_WW(pInt, dst, x_inw(port));
- dst += inc;
- }
- return dst - base;
-}
-
-int
-port_rep_inl(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -4 : 4;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_insl(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- MEM_WL(pInt, dst, x_inl(port));
- dst += inc;
- }
- return dst - base;
-}
-
-int
-port_rep_outb(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -1 : 1;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_outb(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- x_outb(port, MEM_RB(pInt, dst));
- dst += inc;
- }
- return dst - base;
-}
-
-int
-port_rep_outw(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -2 : 2;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_outw(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- x_outw(port, MEM_RW(pInt, dst));
- dst += inc;
- }
- return dst - base;
-}
-
-int
-port_rep_outl(xf86Int10InfoPtr pInt,
- CARD16 port, CARD32 base, int d_f, CARD32 count)
-{
- register int inc = d_f ? -4 : 4;
- CARD32 dst = base;
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" rep_outl(%#x) %ld bytes at %8.8lx %s\n",
- port, count, base, d_f ? "up" : "down");
- while (count--) {
- x_outl(port, MEM_RL(pInt, dst));
- dst += inc;
- }
- return dst - base;
-}
-
-CARD8
-x_inb(CARD16 port)
-{
- CARD8 val;
-
- if (port == 0x40) {
- Int10Current->inb40time++;
- val = (CARD8)(Int10Current->inb40time >>
- ((Int10Current->inb40time & 1) << 3));
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inb(%#x) = %2.2x\n", port, val);
-#ifdef __NOT_YET__
- } else if (port < 0x0100) { /* Don't interfere with mainboard */
- val = 0;
- xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "inb 0x%4.4x\n", port);
- if (xf86GetVerbosity() > 3) {
- dump_registers(Int10Current);
- stack_trace(Int10Current);
- }
-#endif /* __NOT_YET__ */
- } else if (!pciCfg1inb(port, &val)) {
- val = inb(Int10Current->ioBase + port);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inb(%#x) = %2.2x\n", port, val);
- }
- return val;
-}
-
-CARD16
-x_inw(CARD16 port)
-{
- CARD16 val;
-
- if (port == 0x5c) {
- struct timeval tv;
-
- /*
- * Emulate a PC98's timer. Typical resolution is 3.26 usec.
- * Approximate this by dividing by 3.
- */
- X_GETTIMEOFDAY(&tv);
- val = (CARD16)(tv.tv_usec / 3);
- } else if (!pciCfg1inw(port, &val)) {
- val = inw(Int10Current->ioBase + port);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inw(%#x) = %4.4x\n", port, val);
- }
- return val;
-}
-
-void
-x_outb(CARD16 port, CARD8 val)
-{
- if ((port == 0x43) && (val == 0)) {
- struct timeval tv;
- /*
- * Emulate a PC's timer 0. Such timers typically have a resolution of
- * some .838 usec per tick, but this can only provide 1 usec per tick.
- * (Not that this matters much, given inherent emulation delays.) Use
- * the bottom bit as a byte select. See inb(0x40) above.
- */
- X_GETTIMEOFDAY(&tv);
- Int10Current->inb40time = (CARD16)(tv.tv_usec | 1);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" outb(%#x, %2.2x)\n", port, val);
-#ifdef __NOT_YET__
- } else if (port < 0x0100) { /* Don't interfere with mainboard */
- xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2,
- "outb 0x%4.4x,0x%2.2x\n", port, val);
- if (xf86GetVerbosity() > 3) {
- dump_registers(Int10Current);
- stack_trace(Int10Current);
- }
-#endif /* __NOT_YET__ */
- } else if (!pciCfg1outb(port, val)) {
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" outb(%#x, %2.2x)\n", port, val);
- outb(Int10Current->ioBase + port, val);
- }
-}
-
-void
-x_outw(CARD16 port, CARD16 val)
-{
-
- if (!pciCfg1outw(port, val)) {
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" outw(%#x, %4.4x)\n", port, val);
- outw(Int10Current->ioBase + port, val);
- }
-}
-
-CARD32
-x_inl(CARD16 port)
-{
- CARD32 val;
-
- if (!pciCfg1in(port, &val)) {
- val = inl(Int10Current->ioBase + port);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" inl(%#x) = %8.8lx\n", port, val);
- }
- return val;
-}
-
-void
-x_outl(CARD16 port, CARD32 val)
-{
- if (!pciCfg1out(port, val)) {
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" outl(%#x, %8.8lx)\n", port, val);
- outl(Int10Current->ioBase + port, val);
- }
-}
-
-CARD8
-Mem_rb(CARD32 addr)
-{
- return (*Int10Current->mem->rb)(Int10Current, addr);
-}
-
-CARD16
-Mem_rw(CARD32 addr)
-{
- return (*Int10Current->mem->rw)(Int10Current, addr);
-}
-
-CARD32
-Mem_rl(CARD32 addr)
-{
- return (*Int10Current->mem->rl)(Int10Current, addr);
-}
-
-void
-Mem_wb(CARD32 addr, CARD8 val)
-{
- (*Int10Current->mem->wb)(Int10Current, addr, val);
-}
-
-void
-Mem_ww(CARD32 addr, CARD16 val)
-{
- (*Int10Current->mem->ww)(Int10Current, addr, val);
-}
-
-void
-Mem_wl(CARD32 addr, CARD32 val)
-{
- (*Int10Current->mem->wl)(Int10Current, addr, val);
-}
-
-static CARD32 PciCfg1Addr = 0;
-
-#define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK))
-#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK))
-#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11)
-#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
-
-#define PCI_OFFSET(x) ((x) & 0x000000ff)
-#define PCI_TAG(x) ((x) & 0x7fffff00)
-
-static struct pci_device*
-pci_device_for_cfg_address (CARD32 addr)
-{
- struct pci_device *dev = NULL;
- PCITAG tag = PCI_TAG(addr);
- struct pci_slot_match slot_match = {
- .domain = PCI_DOM_FROM_TAG(tag),
- .bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)),
- .dev = PCI_DEV_FROM_TAG(tag),
- .func = PCI_FUNC_FROM_TAG(tag),
- .match_data = 0
- };
-
- struct pci_device_iterator *iter =
- pci_slot_match_iterator_create (&slot_match);
-
- if (iter)
- dev = pci_device_next(iter);
-
- pci_iterator_destroy(iter);
-
- return dev;
-}
-
-static int
-pciCfg1in(CARD16 addr, CARD32 *val)
-{
- if (addr == 0xCF8) {
- *val = PciCfg1Addr;
- return 1;
- }
- if (addr == 0xCFC) {
- pci_device_cfg_read_u32(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr));
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_inl(%#lx) = %8.8lx\n", PciCfg1Addr, *val);
- return 1;
- }
- return 0;
-}
-
-static int
-pciCfg1out(CARD16 addr, CARD32 val)
-{
- if (addr == 0xCF8) {
- PciCfg1Addr = val;
- return 1;
- }
- if (addr == 0xCFC) {
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_outl(%#lx, %8.8lx)\n", PciCfg1Addr, val);
- pci_device_cfg_write_u32(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr));
- return 1;
- }
- return 0;
-}
-
-static int
-pciCfg1inw(CARD16 addr, CARD16 *val)
-{
- int shift;
-
- if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- *val = (PciCfg1Addr >> shift) & 0xffff;
- return 1;
- }
- if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- pci_device_cfg_read_u16(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_inw(%#lx) = %4.4x\n", PciCfg1Addr + offset, *val);
- return 1;
- }
- return 0;
-}
-
-static int
-pciCfg1outw(CARD16 addr, CARD16 val)
-{
- int shift;
-
- if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- PciCfg1Addr &= ~(0xffff << shift);
- PciCfg1Addr |= ((CARD32) val) << shift;
- return 1;
- }
- if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_outw(%#lx, %4.4x)\n", PciCfg1Addr + offset, val);
- pci_device_cfg_write_u16(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- return 1;
- }
- return 0;
-}
-
-static int
-pciCfg1inb(CARD16 addr, CARD8 *val)
-{
- int shift;
-
- if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- *val = (PciCfg1Addr >> shift) & 0xff;
- return 1;
- }
- if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- pci_device_cfg_read_u8(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_inb(%#lx) = %2.2x\n", PciCfg1Addr + offset, *val);
- return 1;
- }
- return 0;
-}
-
-static int
-pciCfg1outb(CARD16 addr, CARD8 val)
-{
- int shift;
-
- if ((addr >= 0xCF8) && (addr <= 0xCFB)) {
- shift = (addr - 0xCF8) * 8;
- PciCfg1Addr &= ~(0xff << shift);
- PciCfg1Addr |= ((CARD32) val) << shift;
- return 1;
- }
- if ((addr >= 0xCFC) && (addr <= 0xCFF)) {
- const unsigned offset = addr - 0xCFC;
-
- if (PRINT_PORT && DEBUG_IO_TRACE())
- ErrorF(" cfg_outb(%#lx, %2.2x)\n", PciCfg1Addr + offset, val);
- pci_device_cfg_write_u8(pci_device_for_cfg_address(PciCfg1Addr),
- val, PCI_OFFSET(PciCfg1Addr) + offset);
- return 1;
- }
- return 0;
-}
-
-CARD8
-bios_checksum(const CARD8 *start, int size)
-{
- CARD8 sum = 0;
-
- while (size-- > 0)
- sum += *start++;
- return sum;
-}
-
-/*
- * Lock/Unlock legacy VGA. Some Bioses try to be very clever and make
- * an attempt to detect a legacy ISA card. If they find one they might
- * act very strange: for example they might configure the card as a
- * monochrome card. This might cause some drivers to choke.
- * To avoid this we attempt legacy VGA by writing to all know VGA
- * disable registers before we call the BIOS initialization and
- * restore the original values afterwards. In beween we hold our
- * breath. To get to a (possibly exising) ISA card need to disable
- * our current PCI card.
- */
-/*
- * This is just for booting: we just want to catch pure
- * legacy vga therefore we don't worry about mmio etc.
- * This stuff should really go into vgaHW.c. However then
- * the driver would have to load the vga-module prior to
- * doing int10.
- */
-void
-LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
-{
- vga->save_msr = inb(pInt->ioBase + 0x03CC);
- vga->save_vse = inb(pInt->ioBase + 0x03C3);
-#ifndef __ia64__
- vga->save_46e8 = inb(pInt->ioBase + 0x46E8);
-#endif
- vga->save_pos102 = inb(pInt->ioBase + 0x0102);
- outb(pInt->ioBase + 0x03C2, ~(CARD8)0x03 & vga->save_msr);
- outb(pInt->ioBase + 0x03C3, ~(CARD8)0x01 & vga->save_vse);
-#ifndef __ia64__
- outb(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8);
-#endif
- outb(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102);
-}
-
-void
-UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga)
-{
- outb(pInt->ioBase + 0x0102, vga->save_pos102);
-#ifndef __ia64__
- outb(pInt->ioBase + 0x46E8, vga->save_46e8);
-#endif
- outb(pInt->ioBase + 0x03C3, vga->save_vse);
- outb(pInt->ioBase + 0x03C2, vga->save_msr);
-}
-
-#if defined (_PC)
-static void
-SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set)
-{
- int pagesize = getpagesize();
- unsigned char* base = xf86MapVidMem(pInt->scrnIndex,
- VIDMEM_MMIO, 0, pagesize);
- int i;
-
- if (set) {
- for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
- MEM_WW(pInt, i, *(base + i));
- } else {
- for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++)
- *(base + i) = MEM_RW(pInt, i);
- }
-
- xf86UnMapVidMem(pInt->scrnIndex,base,pagesize);
-}
-
-void
-xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save)
-{
- int pagesize = getpagesize();
- unsigned char* base;
- int i;
-
- if (!xf86IsEntityPrimary(pInt->entityIndex)
- || (!save && !pInt->BIOSScratch))
- return;
-
- base = xf86MapVidMem(pInt->scrnIndex, VIDMEM_MMIO, 0, pagesize);
- base += BIOS_SCRATCH_OFF;
- if (save) {
- if ((pInt->BIOSScratch
- = xnfalloc(BIOS_SCRATCH_LEN)))
- for (i = 0; i < BIOS_SCRATCH_LEN; i++)
- *(((char*)pInt->BIOSScratch + i)) = *(base + i);
- } else {
- if (pInt->BIOSScratch) {
- for (i = 0; i < BIOS_SCRATCH_LEN; i++)
- *(base + i) = *(pInt->BIOSScratch + i);
- free(pInt->BIOSScratch);
- pInt->BIOSScratch = NULL;
- }
- }
-
- xf86UnMapVidMem(pInt->scrnIndex,base - BIOS_SCRATCH_OFF ,pagesize);
-}
-#endif
-
-xf86Int10InfoPtr
-xf86InitInt10(int entityIndex)
-{
- return xf86ExtendedInitInt10(entityIndex, 0);
-}
+/* + * XFree86 int10 module + * execute BIOS int 10h calls in x86 real mode environment + * Copyright 1999 Egbert Eich + * + * Part of this code was inspired by the VBIOS POSTing code in DOSEMU + * developed by the "DOSEMU-Development-Team" + */ + +/* + * To debug port accesses define PRINT_PORT to 1. + * Note! You also have to comment out ioperm() + * in xf86EnableIO(). Otherwise we won't trap + * on PIO. + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#define PRINT_PORT 0 + +#include <unistd.h> + +#include <X11/Xos.h> +#include "xf86.h" +#include "xf86_OSproc.h" +#include "compiler.h" +#define _INT10_PRIVATE +#include "int10Defines.h" +#include "xf86int10.h" +#include "Pci.h" +#ifdef _X86EMU +#include "x86emu/x86emui.h" +#else +#define DEBUG_IO_TRACE() 0 +#endif +#include <pciaccess.h> + +static int pciCfg1in(CARD16 addr, CARD32 *val); +static int pciCfg1out(CARD16 addr, CARD32 val); +static int pciCfg1inw(CARD16 addr, CARD16 *val); +static int pciCfg1outw(CARD16 addr, CARD16 val); +static int pciCfg1inb(CARD16 addr, CARD8 *val); +static int pciCfg1outb(CARD16 addr, CARD8 val); +#if defined (_PC) +static void SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set); +#endif + +#define REG pInt + +int +setup_int(xf86Int10InfoPtr pInt) +{ + if (pInt != Int10Current) { + if (!MapCurrentInt10(pInt)) + return -1; + Int10Current = pInt; + } + X86_EAX = (CARD32) pInt->ax; + X86_EBX = (CARD32) pInt->bx; + X86_ECX = (CARD32) pInt->cx; + X86_EDX = (CARD32) pInt->dx; + X86_ESI = (CARD32) pInt->si; + X86_EDI = (CARD32) pInt->di; + X86_EBP = (CARD32) pInt->bp; + X86_ESP = 0x1000; X86_SS = pInt->stackseg >> 4; + X86_EIP = 0x0600; X86_CS = 0x0; /* address of 'hlt' */ + X86_DS = 0x40; /* standard pc ds */ + X86_ES = pInt->es; + X86_FS = 0; + X86_GS = 0; + X86_EFLAGS = X86_IF_MASK | X86_IOPL_MASK; +#if defined (_PC) + if (pInt->Flags & SET_BIOS_SCRATCH) + SetResetBIOSVars(pInt, TRUE); +#endif + OsBlockSignals(); + return 0; +} + +void +finish_int(xf86Int10InfoPtr pInt, int sig) +{ + OsReleaseSignals(); + pInt->ax = (CARD32) X86_EAX; + pInt->bx = (CARD32) X86_EBX; + pInt->cx = (CARD32) X86_ECX; + pInt->dx = (CARD32) X86_EDX; + pInt->si = (CARD32) X86_ESI; + pInt->di = (CARD32) X86_EDI; + pInt->es = (CARD16) X86_ES; + pInt->bp = (CARD32) X86_EBP; + pInt->flags = (CARD32) X86_FLAGS; +#if defined (_PC) + if (pInt->Flags & RESTORE_BIOS_SCRATCH) + SetResetBIOSVars(pInt, FALSE); +#endif +} + +/* general software interrupt handler */ +CARD32 +getIntVect(xf86Int10InfoPtr pInt,int num) +{ + return MEM_RW(pInt, num << 2) + (MEM_RW(pInt, (num << 2) + 2) << 4); +} + +void +pushw(xf86Int10InfoPtr pInt, CARD16 val) +{ + X86_ESP -= 2; + MEM_WW(pInt, ((CARD32) X86_SS << 4) + X86_SP, val); +} + +int +run_bios_int(int num, xf86Int10InfoPtr pInt) +{ + CARD32 eflags; +#ifndef _PC + /* check if bios vector is initialized */ + if (MEM_RW(pInt, (num << 2) + 2) == (SYS_BIOS >> 4)) { /* SYS_BIOS_SEG ?*/ + + if (num == 21 && X86_AH == 0x4e) { + xf86DrvMsg(pInt->scrnIndex, X_NOTICE, + "Failing Find-Matching-File on non-PC" + " (int 21, func 4e)\n"); + X86_AX = 2; + SET_FLAG(F_CF); + return 1; + } else { + xf86DrvMsgVerb(pInt->scrnIndex, X_NOT_IMPLEMENTED, 2, + "Ignoring int 0x%02x call\n", num); + if (xf86GetVerbosity() > 3) { + dump_registers(pInt); + stack_trace(pInt); + } + return 1; + } + } +#endif +#ifdef PRINT_INT + ErrorF("calling card BIOS at: "); +#endif + eflags = X86_EFLAGS; +#if 0 + eflags = eflags | IF_MASK; + X86_EFLAGS = X86_EFLAGS & ~(VIF_MASK | TF_MASK | IF_MASK | NT_MASK); +#endif + pushw(pInt, eflags); + pushw(pInt, X86_CS); + pushw(pInt, X86_IP); + X86_CS = MEM_RW(pInt, (num << 2) + 2); + X86_IP = MEM_RW(pInt, num << 2); +#ifdef PRINT_INT + ErrorF("0x%x:%lx\n", X86_CS, X86_EIP); +#endif + return 1; +} + +/* Debugging stuff */ +void +dump_code(xf86Int10InfoPtr pInt) +{ + int i; + unsigned long lina = SEG_ADR((CARD32), X86_CS, IP); + + xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, "code at 0x%8.8lx:\n", lina); + for (i=0; i<0x10; i++) + xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i)); + xf86ErrorFVerb(3, "\n"); + for (; i<0x20; i++) + xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, lina + i)); + xf86ErrorFVerb(3, "\n"); +} + +void +dump_registers(xf86Int10InfoPtr pInt) +{ + xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, + "EAX=0x%8.8lx, EBX=0x%8.8lx, ECX=0x%8.8lx, EDX=0x%8.8lx\n", + (unsigned long)X86_EAX, (unsigned long)X86_EBX, + (unsigned long)X86_ECX, (unsigned long)X86_EDX); + xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, + "ESP=0x%8.8lx, EBP=0x%8.8lx, ESI=0x%8.8lx, EDI=0x%8.8lx\n", + (unsigned long)X86_ESP, (unsigned long)X86_EBP, + (unsigned long)X86_ESI, (unsigned long)X86_EDI); + xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, + "CS=0x%4.4x, SS=0x%4.4x," + " DS=0x%4.4x, ES=0x%4.4x, FS=0x%4.4x, GS=0x%4.4x\n", + X86_CS, X86_SS, X86_DS, X86_ES, X86_FS, X86_GS); + xf86DrvMsgVerb(pInt->scrnIndex, X_INFO, 3, + "EIP=0x%8.8lx, EFLAGS=0x%8.8lx\n", + (unsigned long)X86_EIP, (unsigned long)X86_EFLAGS); +} + +void +stack_trace(xf86Int10InfoPtr pInt) +{ + int i = 0; + unsigned long stack = SEG_ADR((CARD32), X86_SS, SP); + unsigned long tail = (CARD32)((X86_SS << 4) + 0x1000); + + if (stack >= tail) return; + + xf86MsgVerb(X_INFO, 3, "stack at 0x%8.8lx:\n", stack); + for (; stack < tail; stack++) { + xf86ErrorFVerb(3, " %2.2x", MEM_RB(pInt, stack)); + i = (i + 1) % 0x10; + if (!i) + xf86ErrorFVerb(3, "\n"); + } + if (i) + xf86ErrorFVerb(3, "\n"); +} + +int +port_rep_inb(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -1 : 1; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_insb(%#x) %ld bytes at %8.8lx %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + MEM_WB(pInt, dst, x_inb(port)); + dst += inc; + } + return dst - base; +} + +int +port_rep_inw(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -2 : 2; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_insw(%#x) %ld bytes at %8.8lx %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + MEM_WW(pInt, dst, x_inw(port)); + dst += inc; + } + return dst - base; +} + +int +port_rep_inl(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -4 : 4; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_insl(%#x) %ld bytes at %8.8lx %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + MEM_WL(pInt, dst, x_inl(port)); + dst += inc; + } + return dst - base; +} + +int +port_rep_outb(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -1 : 1; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_outb(%#x) %ld bytes at %8.8lx %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + x_outb(port, MEM_RB(pInt, dst)); + dst += inc; + } + return dst - base; +} + +int +port_rep_outw(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -2 : 2; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_outw(%#x) %ld bytes at %8.8lx %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + x_outw(port, MEM_RW(pInt, dst)); + dst += inc; + } + return dst - base; +} + +int +port_rep_outl(xf86Int10InfoPtr pInt, + CARD16 port, CARD32 base, int d_f, CARD32 count) +{ + register int inc = d_f ? -4 : 4; + CARD32 dst = base; + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" rep_outl(%#x) %ld bytes at %8.8lx %s\n", + port, count, base, d_f ? "up" : "down"); + while (count--) { + x_outl(port, MEM_RL(pInt, dst)); + dst += inc; + } + return dst - base; +} + +CARD8 +x_inb(CARD16 port) +{ + CARD8 val; + + if (port == 0x40) { + Int10Current->inb40time++; + val = (CARD8)(Int10Current->inb40time >> + ((Int10Current->inb40time & 1) << 3)); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" inb(%#x) = %2.2x\n", port, val); +#ifdef __NOT_YET__ + } else if (port < 0x0100) { /* Don't interfere with mainboard */ + val = 0; + xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2, + "inb 0x%4.4x\n", port); + if (xf86GetVerbosity() > 3) { + dump_registers(Int10Current); + stack_trace(Int10Current); + } +#endif /* __NOT_YET__ */ + } else if (!pciCfg1inb(port, &val)) { + val = inb(Int10Current->ioBase + port); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" inb(%#x) = %2.2x\n", port, val); + } + return val; +} + +CARD16 +x_inw(CARD16 port) +{ + CARD16 val; + + if (port == 0x5c) { + struct timeval tv; + + /* + * Emulate a PC98's timer. Typical resolution is 3.26 usec. + * Approximate this by dividing by 3. + */ + X_GETTIMEOFDAY(&tv); + val = (CARD16)(tv.tv_usec / 3); + } else if (!pciCfg1inw(port, &val)) { + val = inw(Int10Current->ioBase + port); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" inw(%#x) = %4.4x\n", port, val); + } + return val; +} + +void +x_outb(CARD16 port, CARD8 val) +{ + if ((port == 0x43) && (val == 0)) { + struct timeval tv; + /* + * Emulate a PC's timer 0. Such timers typically have a resolution of + * some .838 usec per tick, but this can only provide 1 usec per tick. + * (Not that this matters much, given inherent emulation delays.) Use + * the bottom bit as a byte select. See inb(0x40) above. + */ + X_GETTIMEOFDAY(&tv); + Int10Current->inb40time = (CARD16)(tv.tv_usec | 1); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" outb(%#x, %2.2x)\n", port, val); +#ifdef __NOT_YET__ + } else if (port < 0x0100) { /* Don't interfere with mainboard */ + xf86DrvMsgVerb(Int10Current->scrnIndex, X_NOT_IMPLEMENTED, 2, + "outb 0x%4.4x,0x%2.2x\n", port, val); + if (xf86GetVerbosity() > 3) { + dump_registers(Int10Current); + stack_trace(Int10Current); + } +#endif /* __NOT_YET__ */ + } else if (!pciCfg1outb(port, val)) { + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" outb(%#x, %2.2x)\n", port, val); + outb(Int10Current->ioBase + port, val); + } +} + +void +x_outw(CARD16 port, CARD16 val) +{ + + if (!pciCfg1outw(port, val)) { + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" outw(%#x, %4.4x)\n", port, val); + outw(Int10Current->ioBase + port, val); + } +} + +CARD32 +x_inl(CARD16 port) +{ + CARD32 val; + + if (!pciCfg1in(port, &val)) { + val = inl(Int10Current->ioBase + port); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" inl(%#x) = %8.8lx\n", port, val); + } + return val; +} + +void +x_outl(CARD16 port, CARD32 val) +{ + if (!pciCfg1out(port, val)) { + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" outl(%#x, %8.8lx)\n", port, val); + outl(Int10Current->ioBase + port, val); + } +} + +CARD8 +Mem_rb(CARD32 addr) +{ + return (*Int10Current->mem->rb)(Int10Current, addr); +} + +CARD16 +Mem_rw(CARD32 addr) +{ + return (*Int10Current->mem->rw)(Int10Current, addr); +} + +CARD32 +Mem_rl(CARD32 addr) +{ + return (*Int10Current->mem->rl)(Int10Current, addr); +} + +void +Mem_wb(CARD32 addr, CARD8 val) +{ + (*Int10Current->mem->wb)(Int10Current, addr, val); +} + +void +Mem_ww(CARD32 addr, CARD16 val) +{ + (*Int10Current->mem->ww)(Int10Current, addr, val); +} + +void +Mem_wl(CARD32 addr, CARD32 val) +{ + (*Int10Current->mem->wl)(Int10Current, addr, val); +} + +static CARD32 PciCfg1Addr = 0; + +#define PCI_DOM_FROM_TAG(tag) (((tag) >> 24) & (PCI_DOM_MASK)) +#define PCI_BUS_FROM_TAG(tag) (((tag) >> 16) & (PCI_DOMBUS_MASK)) +#define PCI_DEV_FROM_TAG(tag) (((tag) & 0x0000f800u) >> 11) +#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8) + +#define PCI_OFFSET(x) ((x) & 0x000000ff) +#define PCI_TAG(x) ((x) & 0x7fffff00) + +static struct pci_device* +pci_device_for_cfg_address (CARD32 addr) +{ + struct pci_device *dev = NULL; + PCITAG tag = PCI_TAG(addr); + struct pci_slot_match slot_match = { + .domain = PCI_DOM_FROM_TAG(tag), + .bus = PCI_BUS_NO_DOMAIN(PCI_BUS_FROM_TAG(tag)), + .dev = PCI_DEV_FROM_TAG(tag), + .func = PCI_FUNC_FROM_TAG(tag), + .match_data = 0 + }; + + struct pci_device_iterator *iter = + pci_slot_match_iterator_create (&slot_match); + + if (iter) + dev = pci_device_next(iter); + + pci_iterator_destroy(iter); + + return dev; +} + +static int +pciCfg1in(CARD16 addr, CARD32 *val) +{ + if (addr == 0xCF8) { + *val = PciCfg1Addr; + return 1; + } + if (addr == 0xCFC) { + pci_device_cfg_read_u32(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr)); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_inl(%#lx) = %8.8lx\n", PciCfg1Addr, *val); + return 1; + } + return 0; +} + +static int +pciCfg1out(CARD16 addr, CARD32 val) +{ + if (addr == 0xCF8) { + PciCfg1Addr = val; + return 1; + } + if (addr == 0xCFC) { + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_outl(%#lx, %8.8lx)\n", PciCfg1Addr, val); + pci_device_cfg_write_u32(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr)); + return 1; + } + return 0; +} + +static int +pciCfg1inw(CARD16 addr, CARD16 *val) +{ + int shift; + + if ((addr >= 0xCF8) && (addr <= 0xCFB)) { + shift = (addr - 0xCF8) * 8; + *val = (PciCfg1Addr >> shift) & 0xffff; + return 1; + } + if ((addr >= 0xCFC) && (addr <= 0xCFF)) { + const unsigned offset = addr - 0xCFC; + + pci_device_cfg_read_u16(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_inw(%#lx) = %4.4x\n", PciCfg1Addr + offset, *val); + return 1; + } + return 0; +} + +static int +pciCfg1outw(CARD16 addr, CARD16 val) +{ + int shift; + + if ((addr >= 0xCF8) && (addr <= 0xCFB)) { + shift = (addr - 0xCF8) * 8; + PciCfg1Addr &= ~(0xffff << shift); + PciCfg1Addr |= ((CARD32) val) << shift; + return 1; + } + if ((addr >= 0xCFC) && (addr <= 0xCFF)) { + const unsigned offset = addr - 0xCFC; + + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_outw(%#lx, %4.4x)\n", PciCfg1Addr + offset, val); + pci_device_cfg_write_u16(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); + return 1; + } + return 0; +} + +static int +pciCfg1inb(CARD16 addr, CARD8 *val) +{ + int shift; + + if ((addr >= 0xCF8) && (addr <= 0xCFB)) { + shift = (addr - 0xCF8) * 8; + *val = (PciCfg1Addr >> shift) & 0xff; + return 1; + } + if ((addr >= 0xCFC) && (addr <= 0xCFF)) { + const unsigned offset = addr - 0xCFC; + + pci_device_cfg_read_u8(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_inb(%#lx) = %2.2x\n", PciCfg1Addr + offset, *val); + return 1; + } + return 0; +} + +static int +pciCfg1outb(CARD16 addr, CARD8 val) +{ + int shift; + + if ((addr >= 0xCF8) && (addr <= 0xCFB)) { + shift = (addr - 0xCF8) * 8; + PciCfg1Addr &= ~(0xff << shift); + PciCfg1Addr |= ((CARD32) val) << shift; + return 1; + } + if ((addr >= 0xCFC) && (addr <= 0xCFF)) { + const unsigned offset = addr - 0xCFC; + + if (PRINT_PORT && DEBUG_IO_TRACE()) + ErrorF(" cfg_outb(%#lx, %2.2x)\n", PciCfg1Addr + offset, val); + pci_device_cfg_write_u8(pci_device_for_cfg_address(PciCfg1Addr), + val, PCI_OFFSET(PciCfg1Addr) + offset); + return 1; + } + return 0; +} + +CARD8 +bios_checksum(const CARD8 *start, int size) +{ + CARD8 sum = 0; + + while (size-- > 0) + sum += *start++; + return sum; +} + +/* + * Lock/Unlock legacy VGA. Some Bioses try to be very clever and make + * an attempt to detect a legacy ISA card. If they find one they might + * act very strange: for example they might configure the card as a + * monochrome card. This might cause some drivers to choke. + * To avoid this we attempt legacy VGA by writing to all know VGA + * disable registers before we call the BIOS initialization and + * restore the original values afterwards. In beween we hold our + * breath. To get to a (possibly exising) ISA card need to disable + * our current PCI card. + */ +/* + * This is just for booting: we just want to catch pure + * legacy vga therefore we don't worry about mmio etc. + * This stuff should really go into vgaHW.c. However then + * the driver would have to load the vga-module prior to + * doing int10. + */ +void +LockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga) +{ + vga->save_msr = inb(pInt->ioBase + 0x03CC); + vga->save_vse = inb(pInt->ioBase + 0x03C3); +#ifndef __ia64__ + vga->save_46e8 = inb(pInt->ioBase + 0x46E8); +#endif + vga->save_pos102 = inb(pInt->ioBase + 0x0102); + outb(pInt->ioBase + 0x03C2, ~(CARD8)0x03 & vga->save_msr); + outb(pInt->ioBase + 0x03C3, ~(CARD8)0x01 & vga->save_vse); +#ifndef __ia64__ + outb(pInt->ioBase + 0x46E8, ~(CARD8)0x08 & vga->save_46e8); +#endif + outb(pInt->ioBase + 0x0102, ~(CARD8)0x01 & vga->save_pos102); +} + +void +UnlockLegacyVGA(xf86Int10InfoPtr pInt, legacyVGAPtr vga) +{ + outb(pInt->ioBase + 0x0102, vga->save_pos102); +#ifndef __ia64__ + outb(pInt->ioBase + 0x46E8, vga->save_46e8); +#endif + outb(pInt->ioBase + 0x03C3, vga->save_vse); + outb(pInt->ioBase + 0x03C2, vga->save_msr); +} + +#if defined (_PC) +static void +SetResetBIOSVars(xf86Int10InfoPtr pInt, Bool set) +{ + int pagesize = getpagesize(); + unsigned char* base = xf86MapVidMem(pInt->scrnIndex, + VIDMEM_MMIO, 0, pagesize); + int i; + + if (set) { + for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++) + MEM_WW(pInt, i, *(base + i)); + } else { + for (i = BIOS_SCRATCH_OFF; i < BIOS_SCRATCH_END; i++) + *(base + i) = MEM_RW(pInt, i); + } + + xf86UnMapVidMem(pInt->scrnIndex,base,pagesize); +} + +void +xf86Int10SaveRestoreBIOSVars(xf86Int10InfoPtr pInt, Bool save) +{ + int pagesize = getpagesize(); + unsigned char* base; + int i; + + if (!xf86IsEntityPrimary(pInt->entityIndex) + || (!save && !pInt->BIOSScratch)) + return; + + base = xf86MapVidMem(pInt->scrnIndex, VIDMEM_MMIO, 0, pagesize); + base += BIOS_SCRATCH_OFF; + if (save) { + if ((pInt->BIOSScratch + = xnfalloc(BIOS_SCRATCH_LEN))) + for (i = 0; i < BIOS_SCRATCH_LEN; i++) + *(((char*)pInt->BIOSScratch + i)) = *(base + i); + } else { + if (pInt->BIOSScratch) { + for (i = 0; i < BIOS_SCRATCH_LEN; i++) + *(base + i) = *(pInt->BIOSScratch + i); + free(pInt->BIOSScratch); + pInt->BIOSScratch = NULL; + } + } + + xf86UnMapVidMem(pInt->scrnIndex,base - BIOS_SCRATCH_OFF ,pagesize); +} +#endif + +xf86Int10InfoPtr +xf86InitInt10(int entityIndex) +{ + return xf86ExtendedInitInt10(entityIndex, 0); +} diff --git a/xorg-server/hw/xfree86/loader/loader.c b/xorg-server/hw/xfree86/loader/loader.c index dce3b22f6..159b61198 100644 --- a/xorg-server/hw/xfree86/loader/loader.c +++ b/xorg-server/hw/xfree86/loader/loader.c @@ -1,228 +1,208 @@ -/*
- * Copyright 1995-1998 by Metro Link, 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 Metro Link, Inc. not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Metro Link, Inc. makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL METRO LINK, INC. 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 (c) 1997-2003 by The XFree86 Project, Inc.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of the copyright holder(s)
- * and author(s) shall not be used in advertising or otherwise to promote
- * the sale, use or other dealings in this Software without prior written
- * authorization from the copyright holder(s) and author(s).
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <string.h>
-#include <stdarg.h>
-
-#include "os.h"
-#include "loader.h"
-#include "loaderProcs.h"
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "compiler.h"
-
-#ifdef HAVE_DLFCN_H
-
-#include <dlfcn.h>
-#include <X11/Xos.h>
-
-#if defined(DL_LAZY)
-#define DLOPEN_LAZY DL_LAZY
-#elif defined(RTLD_LAZY)
-#define DLOPEN_LAZY RTLD_LAZY
-#elif defined(__FreeBSD__)
-#define DLOPEN_LAZY 1
-#else
-#define DLOPEN_LAZY 0
-#endif
-
-#if defined(LD_GLOBAL)
-#define DLOPEN_GLOBAL LD_GLOBAL
-#elif defined(RTLD_GLOBAL)
-#define DLOPEN_GLOBAL RTLD_GLOBAL
-#else
-#define DLOPEN_GLOBAL 0
-#endif
-
-#else
-#error i have no dynamic linker and i must scream
-#endif
-
-extern void *xorg_symbols[];
-
-void
-LoaderInit(void)
-{
- xf86MsgVerb(X_INFO, 2, "Loader magic: %p\n", (void *)xorg_symbols);
- xf86MsgVerb(X_INFO, 2, "Module ABI versions:\n");
- xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC,
- GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion),
- GET_ABI_MINOR(LoaderVersionInfo.ansicVersion));
- xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_VIDEODRV,
- GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion),
- GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion));
- xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_XINPUT,
- GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion),
- GET_ABI_MINOR(LoaderVersionInfo.xinputVersion));
- xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_EXTENSION,
- GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion),
- GET_ABI_MINOR(LoaderVersionInfo.extensionVersion));
-
-#if defined(__UNIXWARE__) && !defined(__GNUC__)
- /* For UnixWare we need to load the C Runtime libraries which are
- * normally auto-linked by the compiler. Otherwise we are bound to
- * see unresolved symbols when trying to use the type "long long".
- * Obviously, this does not apply if the GNU C compiler is used.
- */
- {
- int errmaj, errmin, wasLoaded; /* place holders */
- char *xcrtpath = DEFAULT_MODULE_PATH "/libcrt.a";
- char *uwcrtpath = "/usr/ccs/lib/libcrt.a";
- char *path;
- struct stat st;
-
- if(stat(xcrtpath, &st) < 0)
- path = uwcrtpath; /* fallback: try to get libcrt.a from the uccs */
- else
- path = xcrtpath; /* get the libcrt.a we compiled with */
- LoaderOpen (path, &errmaj, &errmin, &wasLoaded, 0);
- }
-#endif
-}
-
-/* Public Interface to the loader. */
-
-void *
-LoaderOpen(const char *module, int *errmaj, int *errmin)
-{
- void *ret;
-
-#if defined(DEBUG)
- ErrorF("LoaderOpen(%s)\n", module);
-#endif
-
- xf86Msg(X_INFO, "Loading %s\n", module);
-
- if (!(ret = dlopen(module, DLOPEN_LAZY | DLOPEN_GLOBAL))) {
- xf86Msg(X_ERROR, "Failed to load %s: %s\n", module, dlerror());
- if (errmaj)
- *errmaj = LDR_NOLOAD;
- if (errmin)
- *errmin = LDR_NOLOAD;
- return NULL;
- }
-
- return ret;
-}
-
-void *
-LoaderSymbol(const char *name)
-{
- static void *global_scope = NULL;
- void *p;
-
- p = dlsym(RTLD_DEFAULT, name);
- if (p != NULL)
- return p;
-
- if (!global_scope)
- global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL);
-
- if (global_scope)
- return dlsym(global_scope, name);
-
- return NULL;
-}
-
-void
-LoaderUnload(const char *name, void *handle)
-{
- xf86Msg(X_INFO, "Unloading %s\n", name);
- if (handle)
- dlclose(handle);
-}
-
-unsigned long LoaderOptions = 0;
-
-void
-LoaderSetOptions(unsigned long opts)
-{
- LoaderOptions |= opts;
-}
-
-Bool
-LoaderShouldIgnoreABI(void)
-{
- return (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) != 0;
-}
-
-int
-LoaderGetABIVersion(const char *abiclass)
-{
- struct {
- const char *name;
- int version;
- } classes[] = {
- { ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion },
- { ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion },
- { ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion },
- { ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion },
- { ABI_CLASS_FONT, LoaderVersionInfo.fontVersion },
- { NULL, 0 }
- };
- int i;
-
- for(i = 0; classes[i].name; i++) {
- if(!strcmp(classes[i].name, abiclass)) {
- return classes[i].version;
- }
- }
-
- return 0;
-}
+/* + * Copyright 1995-1998 by Metro Link, 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 Metro Link, Inc. not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Metro Link, Inc. makes no + * representations about the suitability of this software for any purpose. + * It is provided "as is" without express or implied warranty. + * + * METRO LINK, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL METRO LINK, INC. 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 (c) 1997-2003 by The XFree86 Project, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/types.h> +#include <unistd.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <string.h> +#include <stdarg.h> + +#include "os.h" +#include "loader.h" +#include "loaderProcs.h" +#include "xf86.h" +#include "xf86Priv.h" +#include "compiler.h" + +#ifdef HAVE_DLFCN_H + +#include <dlfcn.h> +#include <X11/Xos.h> + +#if defined(DL_LAZY) +#define DLOPEN_LAZY DL_LAZY +#elif defined(RTLD_LAZY) +#define DLOPEN_LAZY RTLD_LAZY +#elif defined(__FreeBSD__) +#define DLOPEN_LAZY 1 +#else +#define DLOPEN_LAZY 0 +#endif + +#if defined(LD_GLOBAL) +#define DLOPEN_GLOBAL LD_GLOBAL +#elif defined(RTLD_GLOBAL) +#define DLOPEN_GLOBAL RTLD_GLOBAL +#else +#define DLOPEN_GLOBAL 0 +#endif + +#else +#error i have no dynamic linker and i must scream +#endif + +extern void *xorg_symbols[]; + +void +LoaderInit(void) +{ + xf86MsgVerb(X_INFO, 2, "Loader magic: %p\n", (void *)xorg_symbols); + xf86MsgVerb(X_INFO, 2, "Module ABI versions:\n"); + xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_ANSIC, + GET_ABI_MAJOR(LoaderVersionInfo.ansicVersion), + GET_ABI_MINOR(LoaderVersionInfo.ansicVersion)); + xf86ErrorFVerb(2, "\t%s: %d.%d\n", ABI_CLASS_VIDEODRV, + GET_ABI_MAJOR(LoaderVersionInfo.videodrvVersion), + GET_ABI_MINOR(LoaderVersionInfo.videodrvVersion)); + xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_XINPUT, + GET_ABI_MAJOR(LoaderVersionInfo.xinputVersion), + GET_ABI_MINOR(LoaderVersionInfo.xinputVersion)); + xf86ErrorFVerb(2, "\t%s : %d.%d\n", ABI_CLASS_EXTENSION, + GET_ABI_MAJOR(LoaderVersionInfo.extensionVersion), + GET_ABI_MINOR(LoaderVersionInfo.extensionVersion)); + +} + +/* Public Interface to the loader. */ + +void * +LoaderOpen(const char *module, int *errmaj, int *errmin) +{ + void *ret; + +#if defined(DEBUG) + ErrorF("LoaderOpen(%s)\n", module); +#endif + + xf86Msg(X_INFO, "Loading %s\n", module); + + if (!(ret = dlopen(module, DLOPEN_LAZY | DLOPEN_GLOBAL))) { + xf86Msg(X_ERROR, "Failed to load %s: %s\n", module, dlerror()); + if (errmaj) + *errmaj = LDR_NOLOAD; + if (errmin) + *errmin = LDR_NOLOAD; + return NULL; + } + + return ret; +} + +void * +LoaderSymbol(const char *name) +{ + static void *global_scope = NULL; + void *p; + + p = dlsym(RTLD_DEFAULT, name); + if (p != NULL) + return p; + + if (!global_scope) + global_scope = dlopen(NULL, DLOPEN_LAZY | DLOPEN_GLOBAL); + + if (global_scope) + return dlsym(global_scope, name); + + return NULL; +} + +void +LoaderUnload(const char *name, void *handle) +{ + xf86Msg(X_INFO, "Unloading %s\n", name); + if (handle) + dlclose(handle); +} + +unsigned long LoaderOptions = 0; + +void +LoaderSetOptions(unsigned long opts) +{ + LoaderOptions |= opts; +} + +Bool +LoaderShouldIgnoreABI(void) +{ + return (LoaderOptions & LDR_OPT_ABI_MISMATCH_NONFATAL) != 0; +} + +int +LoaderGetABIVersion(const char *abiclass) +{ + struct { + const char *name; + int version; + } classes[] = { + { ABI_CLASS_ANSIC, LoaderVersionInfo.ansicVersion }, + { ABI_CLASS_VIDEODRV, LoaderVersionInfo.videodrvVersion }, + { ABI_CLASS_XINPUT, LoaderVersionInfo.xinputVersion }, + { ABI_CLASS_EXTENSION, LoaderVersionInfo.extensionVersion }, + { ABI_CLASS_FONT, LoaderVersionInfo.fontVersion }, + { NULL, 0 } + }; + int i; + + for(i = 0; classes[i].name; i++) { + if(!strcmp(classes[i].name, abiclass)) { + return classes[i].version; + } + } + + return 0; +} diff --git a/xorg-server/hw/xfree86/loader/os.c b/xorg-server/hw/xfree86/loader/os.c index 5acce0024..6b5ac7e86 100644 --- a/xorg-server/hw/xfree86/loader/os.c +++ b/xorg-server/hw/xfree86/loader/os.c @@ -50,8 +50,6 @@ #define OSNAME "openbsd" #elif defined(__GNU__) #define OSNAME "hurd" -#elif defined(__SCO__) -#define OSNAME "sco" #elif defined(SVR4) && defined(sun) #define OSNAME "solaris" #elif defined(SVR5) diff --git a/xorg-server/hw/xfree86/loader/sdksyms.sh b/xorg-server/hw/xfree86/loader/sdksyms.sh index c25aaf010..f60b8ed74 100644 --- a/xorg-server/hw/xfree86/loader/sdksyms.sh +++ b/xorg-server/hw/xfree86/loader/sdksyms.sh @@ -1,420 +1,424 @@ -#!/bin/sh
-
-cat > sdksyms.c << EOF
-/* This file is automatically generated by sdksyms.sh. */
-#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-
-/* These must be included first */
-#include "misc.h"
-#include "miscstruct.h"
-
-
-/* render/Makefile.am */
-#include "picture.h"
-#include "mipict.h"
-#include "glyphstr.h"
-#include "picturestr.h"
-
-
-/* fb/Makefile.am -- module */
-/*
-#include "fb.h"
-#include "fbrop.h"
-#include "fboverlay.h"
-#include "wfbrename.h"
-#include "fbpict.h"
- */
-
-
-/* miext/shadow/Makefile.am -- module */
-/*
-#include "shadow.h"
- */
-
-
-/* miext/damage/Makefile.am */
-#include "damage.h"
-#include "damagestr.h"
-
-/* miext/sync/Makefile.am */
-#include "misync.h"
-#include "misyncstr.h"
-
-/* Xext/Makefile.am -- half is module, half is builtin */
-/*
-#include "xvdix.h"
-#include "xvmcext.h"
- */
-#include "geext.h"
-#include "geint.h"
-#include "shmint.h"
-#include "syncsdk.h"
-#if XINERAMA
-# include "panoramiXsrv.h"
-# include "panoramiX.h"
-#endif
-
-
-/* hw/xfree86/int10/Makefile.am -- module */
-/*
-#include "xf86int10.h"
- */
-
-
-/* hw/xfree86/i2c/Makefile.am -- "mostly" modules */
-#include "xf86i2c.h"
-/*
-#include "bt829.h"
-#include "fi1236.h"
-#include "msp3430.h"
-#include "tda8425.h"
-#include "tda9850.h"
-#include "tda9885.h"
-#include "uda1380.h"
-#include "i2c_def.h"
- */
-
-
-/* hw/xfree86/modes/Makefile.am */
-#include "xf86Crtc.h"
-#include "xf86Modes.h"
-#include "xf86RandR12.h"
-/* #include "xf86Rename.h" */
-
-
-/* hw/xfree86/ddc/Makefile.am */
-#include "edid.h"
-#include "xf86DDC.h"
-
-
-/* hw/xfree86/dri2/Makefile.am -- module */
-/*
-#if DRI2
-# include "dri2.h"
-#endif
- */
-
-
-/* hw/xfree86/vgahw/Makefile.am -- module */
-/*
-#include "vgaHW.h"
- */
-
-
-/* hw/xfree86/fbdevhw/Makefile.am -- module */
-/*
-#include "fbdevhw.h"
- */
-
-
-/* hw/xfree86/common/Makefile.am */
-#include "compiler.h"
-#include "fourcc.h"
-#include "xf86.h"
-#include "xf86Module.h"
-#include "xf86Opt.h"
-#include "xf86PciInfo.h"
-#include "xf86Priv.h"
-#include "xf86Privstr.h"
-#include "xf86cmap.h"
-#include "xf86fbman.h"
-#include "xf86str.h"
-#include "xf86Xinput.h"
-#include "xf86VGAarbiter.h"
-#include "xisb.h"
-#if XV
-# include "xf86xv.h"
-# include "xf86xvmc.h"
-# include "xf86xvpriv.h"
-#endif
-/* XF86VidMode code is in libextmod module */
-/*
-#if XF86VIDMODE
-# include "vidmodeproc.h"
-#endif
- */
-#include "xorgVersion.h"
-#if defined(__sparc__) || defined(__sparc)
-# include "xf86sbusBus.h"
-#endif
-
-
-/* hw/xfree86/ramdac/Makefile.am */
-#include "BT.h"
-#include "IBM.h"
-#include "TI.h"
-#include "xf86Cursor.h"
-#include "xf86RamDac.h"
-
-
-/* hw/xfree86/shadowfb/Makefile.am -- module */
-/*
-#include "shadowfb.h"
- */
-
-
-/* hw/xfree86/os-support/solaris/Makefile.am */
-#if defined(sun386)
-# include "agpgart.h"
-#endif
-
-
-/* hw/xfree86/os-support/Makefile.am */
-#include "xf86_OSproc.h"
-#include "xf86_OSlib.h"
-
-
-/* hw/xfree86/os-support/bus/Makefile.am */
-#include "xf86Pci.h"
-#if defined(__sparc__) || defined(__sparc)
-# include "xf86Sbus.h"
-#endif
-
-
-/* hw/xfree86/xaa/Makefile.am -- module */
-/*
-#include "xaa.h"
-#include "xaalocal.h"
-#include "xaarop.h"
- */
-
-
-/* hw/xfree86/dixmods/extmod/Makefile.am -- module */
-/*
-#include "dgaproc.h"
- */
-
-
-/* hw/xfree86/parser/Makefile.am */
-#include "xf86Parser.h"
-#include "xf86Optrec.h"
-
-
-/* hw/xfree86/vbe/Makefile.am -- module */
-/*
-#include "vbe.h"
-#include "vbeModes.h"
- */
-
-
-/* hw/xfree86/dri/Makefile.am -- module */
-/*
-#if XF86DRI
-# include "dri.h"
-# include "sarea.h"
-# include "dristruct.h"
-#endif
- */
-
-
-/* mi/Makefile.am */
-#include "micmap.h"
-#include "miline.h"
-#include "mipointer.h"
-#include "mi.h"
-#include "mibstore.h"
-#include "migc.h"
-#include "mipointrst.h"
-#include "mizerarc.h"
-#include "micoord.h"
-#include "mifillarc.h"
-#include "mispans.h"
-#include "miwideline.h"
-#include "mistruct.h"
-#include "mifpoly.h"
-#include "mioverlay.h"
-
-
-/* randr/Makefile.am */
-#include "randrstr.h"
-#include "rrtransform.h"
-
-
-/* dbe/Makefile.am -- module */
-/*
-#include "dbestruct.h"
- */
-
-
-/* exa/Makefile.am -- module */
-/*
-#include "exa.h"
- */
-
-
-/* xfixes/Makefile.am */
-#include "xfixes.h"
-
-
-/* include/Makefile.am */
-#include "XIstubs.h"
-#include "Xprintf.h"
-#include "closestr.h"
-#include "closure.h"
-#include "colormap.h"
-#include "colormapst.h"
-#include "hotplug.h"
-#include "cursor.h"
-#include "cursorstr.h"
-#include "dix.h"
-#include "dixaccess.h"
-#include "dixevents.h"
-#include "dixfont.h"
-#include "dixfontstr.h"
-#include "dixgrabs.h"
-#include "dixstruct.h"
-#include "exevents.h"
-#include "extension.h"
-#include "extinit.h"
-#include "extnsionst.h"
-#include "gc.h"
-#include "gcstruct.h"
-#include "globals.h"
-#include "input.h"
-#include "inputstr.h"
-/* already included */
-/*
-#include "misc.h"
-#include "miscstruct.h"
- */
-#include "opaque.h"
-#include "os.h"
-#include "pixmap.h"
-#include "pixmapstr.h"
-#include "privates.h"
-#include "property.h"
-#include "propertyst.h"
-#include "ptrveloc.h"
-#include "region.h"
-#include "regionstr.h"
-#include "registry.h"
-#include "resource.h"
-#include "rgb.h"
-#include "screenint.h"
-#include "scrnintstr.h"
-#include "selection.h"
-#include "servermd.h"
-#include "site.h"
-#include "swaprep.h"
-#include "swapreq.h"
-#include "validate.h"
-#include "window.h"
-#include "windowstr.h"
-#include "xace.h"
-#include "xkbfile.h"
-#include "xkbsrv.h"
-#include "xkbstr.h"
-#include "xkbrules.h"
-#include "xserver-properties.h"
-
-EOF
-
-topdir=$1
-shift
-LC_ALL=C
-export LC_ALL
-${CPP:-cpp} "$@" -DXorgLoader sdksyms.c | ${AWK:-awk} -v topdir=$topdir '
-BEGIN {
- sdk = 0;
- print("/*");
- print(" * These symbols are referenced to ensure they");
- print(" * will be available in the X Server binary.");
- print(" */");
- printf("/* topdir=%s */\n", topdir);
- print("_X_HIDDEN void *xorg_symbols[] = {");
-
- printf("sdksyms.c:") > "sdksyms.dep";
-}
-/^# [0-9]+ "/ {
- # Process text after a include in a relative path or when the
- # processed file has a basename matching $top_srcdir.
- # Note that indexing starts at 1; 0 means no match, and there
- # is a starting ".
- sdk = $3 !~ /^"\// || index($3, topdir) == 2;
-
- if (sdk && $3 ~ /\.h"$/) {
- # remove quotes
- gsub(/"/, "", $3);
- line = $2;
- header = $3;
- if (! headers[$3]) {
- printf(" \\\n %s", $3) >> "sdksyms.dep";
- headers[$3] = 1;
- }
- }
- next;
-}
-
-/^extern[ ]/ {
- if (sdk) {
- n = 3;
-
- # skip attribute, if any
- while ($n ~ /^(__attribute__|__global)/ ||
- # skip modifiers, if any
- $n ~ /^\*?(unsigned|const|volatile|struct)$/ ||
- # skip pointer
- $n ~ /\*$/)
- n++;
-
- # type specifier may not be set, as in
- # extern _X_EXPORT unsigned name(...)
- if ($n !~ /[^a-zA-Z0-9_]/)
- n++;
-
- # match
- # extern _X_EXPORT type (* name[])(...)
- if ($n ~ /^[^a-zA-Z0-9_]+$/)
- n++;
-
- # match
- # extern _X_EXPORT const name *const ...
- if ($n ~ /^([^a-zA-Z0-9_]+)?const$/)
- n++;
-
- # actual name may be in the next line, as in
- # extern _X_EXPORT type
- # possibly ending with a *
- # name(...)
- if ($n == "" || $n ~ /^\*+$/) {
- getline;
- n = 1;
- }
-
- # dont modify $0 or $n
- symbol = $n;
-
- # remove starting non word chars
- sub(/^[^a-zA-Z0-9_]+/, "",symbol);
-
- # remove from first non word to end of line
- sub(/[^a-zA-Z0-9_].*/, "", symbol);
-
- #print;
- printf(" (void *) &%-50s /* %s:%s */\n", symbol ",", header, line);
- }
-}
-
-{
- line++;
-}
-
-END {
- print("};");
-
- print("") >> "sdksyms.dep";
-}' > _sdksyms.c
-
-STATUS=$?
-
-cat _sdksyms.c >> sdksyms.c
-rm _sdksyms.c
-
-[ $? != 0 ] && exit $?
-
-exit $STATUS
+#!/bin/sh + +cat > sdksyms.c << EOF +/* This file is automatically generated by sdksyms.sh. */ +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#endif + + +/* These must be included first */ +#include "misc.h" +#include "miscstruct.h" + + +/* render/Makefile.am */ +#include "picture.h" +#include "mipict.h" +#include "glyphstr.h" +#include "picturestr.h" + + +/* fb/Makefile.am -- module */ +/* +#include "fb.h" +#include "fbrop.h" +#include "fboverlay.h" +#include "wfbrename.h" +#include "fbpict.h" + */ + + +/* miext/shadow/Makefile.am -- module */ +/* +#include "shadow.h" + */ + + +/* miext/damage/Makefile.am */ +#include "damage.h" +#include "damagestr.h" + +/* miext/sync/Makefile.am */ +#include "misync.h" +#include "misyncstr.h" + +/* Xext/Makefile.am -- half is module, half is builtin */ +/* +#include "xvdix.h" +#include "xvmcext.h" + */ +#include "geext.h" +#include "geint.h" +#include "shmint.h" +#include "syncsdk.h" +#if XINERAMA +# include "panoramiXsrv.h" +# include "panoramiX.h" +#endif + + +/* hw/xfree86/int10/Makefile.am -- module */ +/* +#include "xf86int10.h" + */ + + +/* hw/xfree86/i2c/Makefile.am -- "mostly" modules */ +#include "xf86i2c.h" +/* +#include "bt829.h" +#include "fi1236.h" +#include "msp3430.h" +#include "tda8425.h" +#include "tda9850.h" +#include "tda9885.h" +#include "uda1380.h" +#include "i2c_def.h" + */ + + +/* hw/xfree86/modes/Makefile.am */ +#include "xf86Crtc.h" +#include "xf86Modes.h" +#include "xf86RandR12.h" +/* #include "xf86Rename.h" */ + + +/* hw/xfree86/ddc/Makefile.am */ +#include "edid.h" +#include "xf86DDC.h" + + +/* hw/xfree86/dri2/Makefile.am -- module */ +/* +#if DRI2 +# include "dri2.h" +#endif + */ + + +/* hw/xfree86/vgahw/Makefile.am -- module */ +/* +#include "vgaHW.h" + */ + + +/* hw/xfree86/fbdevhw/Makefile.am -- module */ +/* +#include "fbdevhw.h" + */ + + +/* hw/xfree86/common/Makefile.am */ +#include "compiler.h" +#include "fourcc.h" +#include "xf86.h" +#include "xf86Module.h" +#include "xf86Opt.h" +#include "xf86PciInfo.h" +#include "xf86Priv.h" +#include "xf86Privstr.h" +#include "xf86cmap.h" +#include "xf86fbman.h" +#include "xf86str.h" +#include "xf86Xinput.h" +#include "xf86VGAarbiter.h" +#include "xisb.h" +#if XV +# include "xf86xv.h" +# include "xf86xvmc.h" +# include "xf86xvpriv.h" +#endif +/* XF86VidMode code is in libextmod module */ +/* +#if XF86VIDMODE +# include "vidmodeproc.h" +#endif + */ +#include "xorgVersion.h" +#if defined(__sparc__) || defined(__sparc) +# include "xf86sbusBus.h" +#endif + + +/* hw/xfree86/ramdac/Makefile.am */ +#include "BT.h" +#include "IBM.h" +#include "TI.h" +#include "xf86Cursor.h" +#include "xf86RamDac.h" + + +/* hw/xfree86/shadowfb/Makefile.am -- module */ +/* +#include "shadowfb.h" + */ + + +/* hw/xfree86/os-support/solaris/Makefile.am */ +#if defined(sun386) +# include "agpgart.h" +#endif + + +/* hw/xfree86/os-support/Makefile.am */ +#include "xf86_OSproc.h" +#include "xf86_OSlib.h" + + +/* hw/xfree86/os-support/bus/Makefile.am */ +#include "xf86Pci.h" +#if defined(__sparc__) || defined(__sparc) +# include "xf86Sbus.h" +#endif + + +/* hw/xfree86/xaa/Makefile.am -- module */ +/* +#include "xaa.h" +#include "xaalocal.h" +#include "xaarop.h" + */ + + +/* hw/xfree86/dixmods/extmod/Makefile.am -- module */ +/* +#include "dgaproc.h" + */ + + +/* hw/xfree86/parser/Makefile.am */ +#include "xf86Parser.h" +#include "xf86Optrec.h" + + +/* hw/xfree86/vbe/Makefile.am -- module */ +/* +#include "vbe.h" +#include "vbeModes.h" + */ + + +/* hw/xfree86/dri/Makefile.am -- module */ +/* +#if XF86DRI +# include "dri.h" +# include "sarea.h" +# include "dristruct.h" +#endif + */ + + +/* mi/Makefile.am */ +#include "micmap.h" +#include "miline.h" +#include "mipointer.h" +#include "mi.h" +#include "mibstore.h" +#include "migc.h" +#include "mipointrst.h" +#include "mizerarc.h" +#include "micoord.h" +#include "mifillarc.h" +#include "mispans.h" +#include "miwideline.h" +#include "mistruct.h" +#include "mifpoly.h" +#include "mioverlay.h" + + +/* randr/Makefile.am */ +#include "randrstr.h" +#include "rrtransform.h" + + +/* dbe/Makefile.am -- module */ +/* +#include "dbestruct.h" + */ + + +/* exa/Makefile.am -- module */ +/* +#include "exa.h" + */ + + +/* xfixes/Makefile.am */ +#include "xfixes.h" + + +/* include/Makefile.am */ +#include "XIstubs.h" +#include "Xprintf.h" +#include "closestr.h" +#include "closure.h" +#include "colormap.h" +#include "colormapst.h" +#include "hotplug.h" +#include "cursor.h" +#include "cursorstr.h" +#include "dix.h" +#include "dixaccess.h" +#include "dixevents.h" +#include "dixfont.h" +#include "dixfontstr.h" +#include "dixgrabs.h" +#include "dixstruct.h" +#include "exevents.h" +#include "extension.h" +#include "extinit.h" +#include "extnsionst.h" +#include "gc.h" +#include "gcstruct.h" +#include "globals.h" +#include "input.h" +#include "inputstr.h" +/* already included */ +/* +#include "misc.h" +#include "miscstruct.h" + */ +#include "opaque.h" +#include "os.h" +#include "pixmap.h" +#include "pixmapstr.h" +#include "privates.h" +#include "property.h" +#include "propertyst.h" +#include "ptrveloc.h" +#include "region.h" +#include "regionstr.h" +#include "registry.h" +#include "resource.h" +#include "rgb.h" +#include "screenint.h" +#include "scrnintstr.h" +#include "selection.h" +#include "servermd.h" +#include "site.h" +#include "swaprep.h" +#include "swapreq.h" +#include "validate.h" +#include "window.h" +#include "windowstr.h" +#include "xace.h" +#include "xkbfile.h" +#include "xkbsrv.h" +#include "xkbstr.h" +#include "xkbrules.h" +#include "xserver-properties.h" + +EOF + +topdir=$1 +shift +LC_ALL=C +export LC_ALL +${CPP:-cpp} "$@" -DXorgLoader sdksyms.c | ${AWK:-awk} -v topdir=$topdir ' +BEGIN { + sdk = 0; + print("/*"); + print(" * These symbols are referenced to ensure they"); + print(" * will be available in the X Server binary."); + print(" */"); + printf("/* topdir=%s */\n", topdir); + print("_X_HIDDEN void *xorg_symbols[] = {"); + + printf("sdksyms.c:") > "sdksyms.dep"; +} +/^# [0-9]+ "/ { + # Process text after a include in a relative path or when the + # processed file has a basename matching $top_srcdir. + # Note that indexing starts at 1; 0 means no match, and there + # is a starting ". + sdk = $3 !~ /^"\// || index($3, topdir) == 2; + + if (sdk && $3 ~ /\.h"$/) { + # remove quotes + gsub(/"/, "", $3); + line = $2; + header = $3; + if (! headers[$3]) { + printf(" \\\n %s", $3) >> "sdksyms.dep"; + headers[$3] = 1; + } + } + next; +} + +/^extern[ ]/ { + if (sdk) { + n = 3; + + # skip attribute, if any + while ($n ~ /^(__attribute__|__global)/ || + # skip modifiers, if any + $n ~ /^\*?(unsigned|const|volatile|struct)$/ || + # skip pointer + $n ~ /^[a-zA-Z0-9_]*\*$/) + n++; + + # type specifier may not be set, as in + # extern _X_EXPORT unsigned name(...) + if ($n !~ /[^a-zA-Z0-9_]/) + n++; + + # go back if we are at the parameter list already + if ($n ~ /^[(]([^*].*)?$/) + n--; + + # match + # extern _X_EXPORT type (* name[])(...) + if ($n ~ /^[^a-zA-Z0-9_]+$/) + n++; + + # match + # extern _X_EXPORT const name *const ... + if ($n ~ /^([^a-zA-Z0-9_]+)?const$/) + n++; + + # actual name may be in the next line, as in + # extern _X_EXPORT type + # possibly ending with a * + # name(...) + if ($n == "" || $n ~ /^\*+$/) { + getline; + n = 1; + } + + # dont modify $0 or $n + symbol = $n; + + # remove starting non word chars + sub(/^[^a-zA-Z0-9_]+/, "",symbol); + + # remove from first non word to end of line + sub(/[^a-zA-Z0-9_].*/, "", symbol); + + #print; + printf(" (void *) &%-50s /* %s:%s */\n", symbol ",", header, line); + } +} + +{ + line++; +} + +END { + print("};"); + + print("") >> "sdksyms.dep"; +}' > _sdksyms.c + +STATUS=$? + +cat _sdksyms.c >> sdksyms.c +rm _sdksyms.c + +[ $? != 0 ] && exit $? + +exit $STATUS diff --git a/xorg-server/hw/xfree86/modes/xf86EdidModes.c b/xorg-server/hw/xfree86/modes/xf86EdidModes.c index f8cd9a0ca..d9ece7a14 100644 --- a/xorg-server/hw/xfree86/modes/xf86EdidModes.c +++ b/xorg-server/hw/xfree86/modes/xf86EdidModes.c @@ -1,1211 +1,1216 @@ -/*
- * Copyright 2006 Luc Verhaegen.
- * Copyright 2008 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, sub license,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * @file This file covers code to convert a xf86MonPtr containing EDID-probed
- * information into a list of modes, including applying monitor-specific
- * quirks to fix broken EDID data.
- */
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#else
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#endif
-
-#define _PARSE_EDID_
-#include "xf86.h"
-#include "xf86DDC.h"
-#include <X11/Xatom.h>
-#include "property.h"
-#include "propertyst.h"
-#include "xf86Crtc.h"
-#include <string.h>
-#include <math.h>
-
-static void handle_detailed_rblank(struct detailed_monitor_section *det_mon,
- void *data)
-{
- if (det_mon->type == DS_RANGES)
- if (det_mon->section.ranges.supported_blanking & CVT_REDUCED)
- *(Bool*)data = TRUE;
-}
-
-static Bool
-xf86MonitorSupportsReducedBlanking(xf86MonPtr DDC)
-{
- /* EDID 1.4 explicitly defines RB support */
- if (DDC->ver.revision >= 4) {
- Bool ret = FALSE;
-
- xf86ForEachDetailedBlock(DDC, handle_detailed_rblank, &ret);
- return ret;
- }
-
- /* For anything older, assume digital means RB support. Boo. */
- if (DDC->features.input_type)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC)
-{
- /* Belinea 10 15 55 */
- if (memcmp (DDC->vendor.name, "MAX", 4) == 0 &&
- ((DDC->vendor.prod_id == 1516) ||
- (DDC->vendor.prod_id == 0x77e)))
- return TRUE;
-
- /* Acer AL1706 */
- if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
- DDC->vendor.prod_id == 44358)
- return TRUE;
-
- /* Bug #10814: Samsung SyncMaster 225BW */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 596)
- return TRUE;
-
- /* Bug #10545: Samsung SyncMaster 226BW */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 638)
- return TRUE;
-
- /* Acer F51 */
- if (memcmp (DDC->vendor.name, "API", 4) == 0 &&
- DDC->vendor.prod_id == 0x7602)
- return TRUE;
-
-
- return FALSE;
-}
-
-static Bool quirk_prefer_large_75 (int scrnIndex, xf86MonPtr DDC)
-{
- /* Bug #11603: Funai Electronics PM36B */
- if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
- DDC->vendor.prod_id == 13600)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_detailed_h_in_cm (int scrnIndex, xf86MonPtr DDC)
-{
- /* Bug #11603: Funai Electronics PM36B */
- if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
- DDC->vendor.prod_id == 13600)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_detailed_v_in_cm (int scrnIndex, xf86MonPtr DDC)
-{
- /* Bug #11603: Funai Electronics PM36B */
- if (memcmp (DDC->vendor.name, "FCM", 4) == 0 &&
- DDC->vendor.prod_id == 13600)
- return TRUE;
-
- /* Bug #21000: LGPhilipsLCD LP154W01-TLAJ */
- if (memcmp (DDC->vendor.name, "LPL", 4) == 0 &&
- DDC->vendor.prod_id == 47360)
- return TRUE;
-
- /* Bug #10304: LGPhilipsLCD LP154W01-A5 */
- if (memcmp(DDC->vendor.name, "LPL", 4) == 0 &&
- DDC->vendor.prod_id == 0)
- return TRUE;
-
- /* Bug #24482: LGPhilipsLCD LP154W01-TLA1 */
- if (memcmp(DDC->vendor.name, "LPL", 4) == 0 &&
- DDC->vendor.prod_id == 0x2a00)
- return TRUE;
-
- /* Bug #21750: Samsung Syncmaster 2333HD */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 1157)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_detailed_use_maximum_size (int scrnIndex, xf86MonPtr DDC)
-{
- /* Bug #21324: Iiyama Vision Master 450 */
- if (memcmp (DDC->vendor.name, "IVM", 4) == 0 &&
- DDC->vendor.prod_id == 6400)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_135_clock_too_high (int scrnIndex, xf86MonPtr DDC)
-{
- /* Envision Peripherals, Inc. EN-7100e. See bug #9550. */
- if (memcmp (DDC->vendor.name, "EPI", 4) == 0 &&
- DDC->vendor.prod_id == 59264)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_first_detailed_preferred (int scrnIndex, xf86MonPtr DDC)
-{
- /* Philips 107p5 CRT. Reported on xorg@ with pastebin. */
- if (memcmp (DDC->vendor.name, "PHL", 4) == 0 &&
- DDC->vendor.prod_id == 57364)
- return TRUE;
-
- /* Proview AY765C 17" LCD. See bug #15160*/
- if (memcmp (DDC->vendor.name, "PTS", 4) == 0 &&
- DDC->vendor.prod_id == 765)
- return TRUE;
-
- /* ACR of some sort RH #284231 */
- if (memcmp (DDC->vendor.name, "ACR", 4) == 0 &&
- DDC->vendor.prod_id == 2423)
- return TRUE;
-
- /* Peacock Ergovision 19. See rh#492359 */
- if (memcmp (DDC->vendor.name, "PEA", 4) == 0 &&
- DDC->vendor.prod_id == 9003)
- return TRUE;
-
- return FALSE;
-}
-
-static Bool quirk_detailed_sync_pp(int scrnIndex, xf86MonPtr DDC)
-{
- /* Bug #12439: Samsung SyncMaster 205BW */
- if (memcmp (DDC->vendor.name, "SAM", 4) == 0 &&
- DDC->vendor.prod_id == 541)
- return TRUE;
- return FALSE;
-}
-
-/* This should probably be made more generic */
-static Bool quirk_dvi_single_link(int scrnIndex, xf86MonPtr DDC)
-{
- /* Red Hat bug #453106: Apple 23" Cinema Display */
- if (memcmp (DDC->vendor.name, "APL", 4) == 0 &&
- DDC->vendor.prod_id == 0x921c)
- return TRUE;
- return FALSE;
-}
-
-typedef struct {
- Bool (*detect) (int scrnIndex, xf86MonPtr DDC);
- ddc_quirk_t quirk;
- char *description;
-} ddc_quirk_map_t;
-
-static const ddc_quirk_map_t ddc_quirks[] = {
- {
- quirk_prefer_large_60, DDC_QUIRK_PREFER_LARGE_60,
- "Detailed timing is not preferred, use largest mode at 60Hz"
- },
- {
- quirk_135_clock_too_high, DDC_QUIRK_135_CLOCK_TOO_HIGH,
- "Recommended 135MHz pixel clock is too high"
- },
- {
- quirk_prefer_large_75, DDC_QUIRK_PREFER_LARGE_75,
- "Detailed timing is not preferred, use largest mode at 75Hz"
- },
- {
- quirk_detailed_h_in_cm, DDC_QUIRK_DETAILED_H_IN_CM,
- "Detailed timings give horizontal size in cm."
- },
- {
- quirk_detailed_v_in_cm, DDC_QUIRK_DETAILED_V_IN_CM,
- "Detailed timings give vertical size in cm."
- },
- {
- quirk_detailed_use_maximum_size, DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE,
- "Use maximum size instead of detailed timing sizes."
- },
- {
- quirk_first_detailed_preferred, DDC_QUIRK_FIRST_DETAILED_PREFERRED,
- "First detailed timing was not marked as preferred."
- },
- {
- quirk_detailed_sync_pp, DDC_QUIRK_DETAILED_SYNC_PP,
- "Use +hsync +vsync for detailed timing."
- },
- {
- quirk_dvi_single_link, DDC_QUIRK_DVI_SINGLE_LINK,
- "Forcing maximum pixel clock to single DVI link."
- },
- {
- NULL, DDC_QUIRK_NONE,
- "No known quirks"
- },
-};
-
-/*
- * These more or less come from the DMT spec. The 720x400 modes are
- * inferred from historical 80x25 practice. The 640x480@67 and 832x624@75
- * modes are old-school Mac modes. The EDID spec says the 1152x864@75 mode
- * should be 1152x870, again for the Mac, but instead we use the x864 DMT
- * mode.
- *
- * The DMT modes have been fact-checked; the rest are mild guesses.
- */
-#define MODEPREFIX NULL, NULL, NULL, 0, M_T_DRIVER
-#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0
-
-static const DisplayModeRec DDCEstablishedModes[17] = {
- { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */
- { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */
- { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */
- { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */
- { MODEPREFIX, 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */
- { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */
- { MODEPREFIX, 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */
- { MODEPREFIX, 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */
- { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */
- { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */
- { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */
- { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */
- { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */
- { MODEPREFIX, 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */
- { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */
- { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */
- { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */
-};
-
-static DisplayModePtr
-DDCModesFromEstablished(int scrnIndex, struct established_timings *timing,
- ddc_quirk_t quirks)
-{
- DisplayModePtr Modes = NULL, Mode = NULL;
- CARD32 bits = (timing->t1) | (timing->t2 << 8) |
- ((timing->t_manu & 0x80) << 9);
- int i;
-
- for (i = 0; i < 17; i++) {
- if (bits & (0x01 << i)) {
- Mode = xf86DuplicateMode(&DDCEstablishedModes[i]);
- Modes = xf86ModesAdd(Modes, Mode);
- }
- }
-
- return Modes;
-}
-
-/* Autogenerated from the DMT spec */
-const DisplayModeRec DMTModes[] = {
- { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 350, 382, 385, 445, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x350@85Hz */
- { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 400, 401, 404, 445, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 640x400@85Hz */
- { MODEPREFIX, 35500, 720, 756, 828, 936, 0, 400, 401, 404, 446, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@85Hz */
- { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */
- { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */
- { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */
- { MODEPREFIX, 36000, 640, 696, 752, 832, 0, 480, 481, 484, 509, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@85Hz */
- { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */
- { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */
- { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */
- { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */
- { MODEPREFIX, 56250, 800, 832, 896, 1048, 0, 600, 601, 604, 631, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@85Hz */
- { MODEPREFIX, 73250, 800, 848, 880, 960, 0, 600, 603, 607, 636, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 800x600@120Hz RB */
- { MODEPREFIX, 33750, 848, 864, 976, 1088, 0, 480, 486, 494, 517, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 848x480@60Hz */
- { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz (interlaced) */
- { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */
- { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */
- { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */
- { MODEPREFIX, 94500, 1024, 1072, 1168, 1376, 0, 768, 769, 772, 808, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@85Hz */
- { MODEPREFIX, 115500, 1024, 1072, 1104, 1184, 0, 768, 771, 775, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@120Hz RB */
- { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */
- { MODEPREFIX, 68250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 790, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@60Hz RB */
- { MODEPREFIX, 79500, 1280, 1344, 1472, 1664, 0, 768, 771, 778, 798, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@60Hz */
- { MODEPREFIX, 102250, 1280, 1360, 1488, 1696, 0, 768, 771, 778, 805, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@75Hz */
- { MODEPREFIX, 117500, 1280, 1360, 1496, 1712, 0, 768, 771, 778, 809, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@85Hz */
- { MODEPREFIX, 140250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@120Hz RB */
- { MODEPREFIX, 71000, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 823, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@60Hz RB */
- { MODEPREFIX, 83500, 1280, 1352, 1480, 1680, 0, 800, 803, 809, 831, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@60Hz */
- { MODEPREFIX, 106500, 1280, 1360, 1488, 1696, 0, 800, 803, 809, 838, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@75Hz */
- { MODEPREFIX, 122500, 1280, 1360, 1496, 1712, 0, 800, 803, 809, 843, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@85Hz */
- { MODEPREFIX, 146250, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 847, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@120Hz RB */
- { MODEPREFIX, 108000, 1280, 1376, 1488, 1800, 0, 960, 961, 964, 1000, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@60Hz */
- { MODEPREFIX, 148500, 1280, 1344, 1504, 1728, 0, 960, 961, 964, 1011, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@85Hz */
- { MODEPREFIX, 175500, 1280, 1328, 1360, 1440, 0, 960, 963, 967, 1017, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x960@120Hz RB */
- { MODEPREFIX, 108000, 1280, 1328, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@60Hz */
- { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */
- { MODEPREFIX, 157500, 1280, 1344, 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@85Hz */
- { MODEPREFIX, 187250, 1280, 1328, 1360, 1440, 0, 1024, 1027, 1034, 1084, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x1024@120Hz RB */
- { MODEPREFIX, 85500, 1360, 1424, 1536, 1792, 0, 768, 771, 777, 795, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1360x768@60Hz */
- { MODEPREFIX, 148250, 1360, 1408, 1440, 1520, 0, 768, 771, 776, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1360x768@120Hz RB */
- { MODEPREFIX, 101000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@60Hz RB */
- { MODEPREFIX, 121750, 1400, 1488, 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@60Hz */
- { MODEPREFIX, 156000, 1400, 1504, 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@75Hz */
- { MODEPREFIX, 179500, 1400, 1504, 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@85Hz */
- { MODEPREFIX, 208000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@120Hz RB */
- { MODEPREFIX, 88750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 926, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@60Hz RB */
- { MODEPREFIX, 106500, 1440, 1520, 1672, 1904, 0, 900, 903, 909, 934, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@60Hz */
- { MODEPREFIX, 136750, 1440, 1536, 1688, 1936, 0, 900, 903, 909, 942, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@75Hz */
- { MODEPREFIX, 157000, 1440, 1544, 1696, 1952, 0, 900, 903, 909, 948, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@85Hz */
- { MODEPREFIX, 182750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 953, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@120Hz RB */
- { MODEPREFIX, 162000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@60Hz */
- { MODEPREFIX, 175500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@65Hz */
- { MODEPREFIX, 189000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@70Hz */
- { MODEPREFIX, 202500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@75Hz */
- { MODEPREFIX, 229500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@85Hz */
- { MODEPREFIX, 268250, 1600, 1648, 1680, 1760, 0, 1200, 1203, 1207, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1600x1200@120Hz RB */
- { MODEPREFIX, 119000, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@60Hz RB */
- { MODEPREFIX, 146250, 1680, 1784, 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@60Hz */
- { MODEPREFIX, 187000, 1680, 1800, 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@75Hz */
- { MODEPREFIX, 214750, 1680, 1808, 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@85Hz */
- { MODEPREFIX, 245500, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@120Hz RB */
- { MODEPREFIX, 204750, 1792, 1920, 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@60Hz */
- { MODEPREFIX, 261000, 1792, 1888, 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@75Hz */
- { MODEPREFIX, 333250, 1792, 1840, 1872, 1952, 0, 1344, 1347, 1351, 1423, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1792x1344@120Hz RB */
- { MODEPREFIX, 218250, 1856, 1952, 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@60Hz */
- { MODEPREFIX, 288000, 1856, 1984, 2208, 2560, 0, 1392, 1393, 1396, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@75Hz */
- { MODEPREFIX, 356500, 1856, 1904, 1936, 2016, 0, 1392, 1395, 1399, 1474, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1856x1392@120Hz RB */
- { MODEPREFIX, 154000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1235, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@60Hz RB */
- { MODEPREFIX, 193250, 1920, 2056, 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@60Hz */
- { MODEPREFIX, 245250, 1920, 2056, 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@75Hz */
- { MODEPREFIX, 281250, 1920, 2064, 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@85Hz */
- { MODEPREFIX, 317000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@120Hz RB */
- { MODEPREFIX, 234000, 1920, 2048, 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@60Hz */
- { MODEPREFIX, 297000, 1920, 2064, 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@75Hz */
- { MODEPREFIX, 380500, 1920, 1968, 2000, 2080, 0, 1440, 1443, 1447, 1525, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1440@120Hz RB */
- { MODEPREFIX, 268500, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1646, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@60Hz RB */
- { MODEPREFIX, 348500, 2560, 2752, 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@60Hz */
- { MODEPREFIX, 443250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@75Hz */
- { MODEPREFIX, 505250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@85Hz */
- { MODEPREFIX, 552750, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1694, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@120Hz RB */
-};
-
-#define LEVEL_DMT 0
-#define LEVEL_GTF 1
-#define LEVEL_CVT 2
-
-static int
-MonitorStandardTimingLevel(xf86MonPtr DDC)
-{
- if (DDC->ver.revision >= 2) {
- if (DDC->ver.revision >= 4 && CVT_SUPPORTED(DDC->features.msc)) {
- return LEVEL_CVT;
- }
- return LEVEL_GTF;
- }
- return LEVEL_DMT;
-}
-
-static int
-ModeRefresh(const DisplayModeRec *mode)
-{
- return (int)(xf86ModeVRefresh(mode) + 0.5);
-}
-
-/*
- * If rb is not set, then we'll not consider reduced-blanking modes as
- * part of the DMT pool. For the 'standard' EDID mode descriptor there's
- * no way to specify whether the mode should be RB or not.
- */
-DisplayModePtr
-FindDMTMode(int hsize, int vsize, int refresh, Bool rb)
-{
- int i;
- const DisplayModeRec *ret;
-
- for (i = 0; i < sizeof(DMTModes) / sizeof(DisplayModeRec); i++) {
- ret = &DMTModes[i];
-
- if (!rb && xf86ModeIsReduced(ret))
- continue;
-
- if (ret->HDisplay == hsize &&
- ret->VDisplay == vsize &&
- refresh == ModeRefresh(ret))
- return xf86DuplicateMode(ret);
- }
-
- return NULL;
-}
-
-/*
- * Appendix B of the EDID 1.4 spec defines the right thing to do here.
- * If the timing given here matches a mode defined in the VESA DMT standard,
- * we _must_ use that. If the device supports CVT modes, then we should
- * generate a CVT timing. If both of the above fail, use GTF.
- *
- * There are some wrinkles here. EDID 1.1 and 1.0 sinks can't really
- * "support" GTF, since it wasn't a standard yet; so if they ask for a
- * timing in this section that isn't defined in DMT, returning a GTF mode
- * may not actually be valid. EDID 1.3 sinks often report support for
- * some CVT modes, but they are not required to support CVT timings for
- * modes in the standard timing descriptor, so we should _not_ treat them
- * as CVT-compliant (unless specified in an extension block I suppose).
- *
- * EDID 1.4 requires that all sink devices support both GTF and CVT timings
- * for modes in this section, but does say that CVT is preferred.
- */
-static DisplayModePtr
-DDCModesFromStandardTiming(struct std_timings *timing, ddc_quirk_t quirks,
- int timing_level, Bool rb)
-{
- DisplayModePtr Modes = NULL, Mode = NULL;
- int i, hsize, vsize, refresh;
-
- for (i = 0; i < STD_TIMINGS; i++) {
- hsize = timing[i].hsize;
- vsize = timing[i].vsize;
- refresh = timing[i].refresh;
-
- /* HDTV hack, because you can't say 1366 */
- if (refresh == 60 &&
- ((hsize == 1360 && vsize == 765) ||
- (hsize == 1368 && vsize == 769))) {
- Mode = xf86CVTMode(1366, 768, 60, FALSE, FALSE);
- Mode->HDisplay = 1366;
- Mode->HSyncStart--;
- Mode->HSyncEnd--;
- } else if (hsize && vsize && refresh) {
- Mode = FindDMTMode(hsize, vsize, refresh, rb);
-
- if (!Mode) {
- if (timing_level == LEVEL_CVT)
- /* pass rb here too? */
- Mode = xf86CVTMode(hsize, vsize, refresh, FALSE, FALSE);
- else if (timing_level == LEVEL_GTF)
- Mode = xf86GTFMode(hsize, vsize, refresh, FALSE, FALSE);
- }
-
- }
-
- if (Mode) {
- Mode->type = M_T_DRIVER;
- Modes = xf86ModesAdd(Modes, Mode);
- }
- Mode = NULL;
- }
-
- return Modes;
-}
-
-static void
-DDCModeDoInterlaceQuirks(DisplayModePtr mode)
-{
- /*
- * EDID is delightfully ambiguous about how interlaced modes are to be
- * encoded. X's internal representation is of frame height, but some
- * HDTV detailed timings are encoded as field height.
- *
- * The format list here is from CEA, in frame size. Technically we
- * should be checking refresh rate too. Whatever.
- */
- static const struct {
- int w, h;
- } cea_interlaced[] = {
- { 1920, 1080 },
- { 720, 480 },
- { 1440, 480 },
- { 2880, 480 },
- { 720, 576 },
- { 1440, 576 },
- { 2880, 576 },
- };
- static const int n_modes = sizeof(cea_interlaced)/sizeof(cea_interlaced[0]);
- int i;
-
- for (i = 0; i < n_modes; i++) {
- if ((mode->HDisplay == cea_interlaced[i].w) &&
- (mode->VDisplay == cea_interlaced[i].h / 2)) {
- mode->VDisplay *= 2;
- mode->VSyncStart *= 2;
- mode->VSyncEnd *= 2;
- mode->VTotal *= 2;
- mode->VTotal |= 1;
- }
- }
-
- mode->Flags |= V_INTERLACE;
-}
-
-/*
- *
- */
-static DisplayModePtr
-DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing,
- Bool preferred, ddc_quirk_t quirks)
-{
- DisplayModePtr Mode;
-
- /*
- * Refuse to create modes that are insufficiently large. 64 is a random
- * number, maybe the spec says something about what the minimum is. In
- * particular I see this frequently with _old_ EDID, 1.0 or so, so maybe
- * our parser is just being too aggresive there.
- */
- if (timing->h_active < 64 || timing->v_active < 64) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "%s: Ignoring tiny %dx%d mode\n", __func__,
- timing->h_active, timing->v_active);
- return NULL;
- }
-
- /* We don't do stereo */
- if (timing->stereo) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "%s: Ignoring: We don't handle stereo.\n", __func__);
- return NULL;
- }
-
- /* We only do seperate sync currently */
- if (timing->sync != 0x03) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "%s: %dx%d Warning: We only handle separate"
- " sync.\n", __func__, timing->h_active, timing->v_active);
- }
-
- Mode = xnfcalloc(1, sizeof(DisplayModeRec));
-
- Mode->type = M_T_DRIVER;
- if (preferred)
- Mode->type |= M_T_PREFERRED;
-
- if( ( quirks & DDC_QUIRK_135_CLOCK_TOO_HIGH ) &&
- timing->clock == 135000000 )
- Mode->Clock = 108880;
- else
- Mode->Clock = timing->clock / 1000.0;
-
- Mode->HDisplay = timing->h_active;
- Mode->HSyncStart = timing->h_active + timing->h_sync_off;
- Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width;
- Mode->HTotal = timing->h_active + timing->h_blanking;
-
- Mode->VDisplay = timing->v_active;
- Mode->VSyncStart = timing->v_active + timing->v_sync_off;
- Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width;
- Mode->VTotal = timing->v_active + timing->v_blanking;
-
- /* perform basic check on the detail timing */
- if (Mode->HSyncEnd > Mode->HTotal || Mode->VSyncEnd > Mode->VTotal) {
- free(Mode);
- return NULL;
- }
-
- /* We ignore h/v_size and h/v_border for now. */
-
- if (timing->interlaced)
- DDCModeDoInterlaceQuirks(Mode);
-
- if (quirks & DDC_QUIRK_DETAILED_SYNC_PP)
- Mode->Flags |= V_PVSYNC | V_PHSYNC;
- else {
- if (timing->misc & 0x02)
- Mode->Flags |= V_PVSYNC;
- else
- Mode->Flags |= V_NVSYNC;
-
- if (timing->misc & 0x01)
- Mode->Flags |= V_PHSYNC;
- else
- Mode->Flags |= V_NHSYNC;
- }
-
- xf86SetModeDefaultName(Mode);
-
- return Mode;
-}
-
-static DisplayModePtr
-DDCModesFromCVT(int scrnIndex, struct cvt_timings *t)
-{
- DisplayModePtr modes = NULL;
- int i;
-
- for (i = 0; i < 4; i++) {
- if (t[i].height) {
- if (t[i].rates & 0x10)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 50, 0, 0));
- if (t[i].rates & 0x08)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 60, 0, 0));
- if (t[i].rates & 0x04)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 75, 0, 0));
- if (t[i].rates & 0x02)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 85, 0, 0));
- if (t[i].rates & 0x01)
- modes = xf86ModesAdd(modes,
- xf86CVTMode(t[i].width, t[i].height, 60, 1, 0));
- } else break;
- }
-
- return modes;
-}
-
-static const struct {
- short w;
- short h;
- short r;
- short rb;
-} EstIIIModes[] = {
- /* byte 6 */
- { 640, 350, 85, 0 },
- { 640, 400, 85, 0 },
- { 720, 400, 85, 0 },
- { 640, 480, 85, 0 },
- { 848, 480, 60, 0 },
- { 800, 600, 85, 0 },
- { 1024, 768, 85, 0 },
- { 1152, 864, 75, 0 },
- /* byte 7 */
- { 1280, 768, 60, 1 },
- { 1280, 768, 60, 0 },
- { 1280, 768, 75, 0 },
- { 1280, 768, 85, 0 },
- { 1280, 960, 60, 0 },
- { 1280, 960, 85, 0 },
- { 1280, 1024, 60, 0 },
- { 1280, 1024, 85, 0 },
- /* byte 8 */
- { 1360, 768, 60, 0 },
- { 1440, 900, 60, 1 },
- { 1440, 900, 60, 0 },
- { 1440, 900, 75, 0 },
- { 1440, 900, 85, 0 },
- { 1400, 1050, 60, 1 },
- { 1400, 1050, 60, 0 },
- { 1400, 1050, 75, 0 },
- /* byte 9 */
- { 1400, 1050, 85, 0 },
- { 1680, 1050, 60, 1 },
- { 1680, 1050, 60, 0 },
- { 1680, 1050, 75, 0 },
- { 1680, 1050, 85, 0 },
- { 1600, 1200, 60, 0 },
- { 1600, 1200, 65, 0 },
- { 1600, 1200, 70, 0 },
- /* byte 10 */
- { 1600, 1200, 75, 0 },
- { 1600, 1200, 85, 0 },
- { 1792, 1344, 60, 0 },
- { 1792, 1344, 85, 0 },
- { 1856, 1392, 60, 0 },
- { 1856, 1392, 75, 0 },
- { 1920, 1200, 60, 1 },
- { 1920, 1200, 60, 0 },
- /* byte 11 */
- { 1920, 1200, 75, 0 },
- { 1920, 1200, 85, 0 },
- { 1920, 1440, 60, 0 },
- { 1920, 1440, 75, 0 },
-};
-
-static DisplayModePtr
-DDCModesFromEstIII(unsigned char *est)
-{
- DisplayModePtr modes = NULL;
- int i, j, m;
-
- for (i = 0; i < 6; i++) {
- for (j = 7; j > 0; j--) {
- if (est[i] & (1 << j)) {
- m = (i * 8) + (7 - j);
- modes = xf86ModesAdd(modes,
- FindDMTMode(EstIIIModes[m].w,
- EstIIIModes[m].h,
- EstIIIModes[m].r,
- EstIIIModes[m].rb));
- }
- }
- }
-
- return modes;
-}
-
-/*
- * This is only valid when the sink claims to be continuous-frequency
- * but does not supply a detailed range descriptor. Such sinks are
- * arguably broken. Currently the mode validation code isn't aware of
- * this; the non-RANDR code even punts the decision of optional sync
- * range checking to the driver. Loss.
- */
-static void
-DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes)
-{
- DisplayModePtr Mode = Modes;
-
- if (!Monitor || !Modes)
- return;
-
- /* set up the ranges for scanning through the modes */
- Monitor->nHsync = 1;
- Monitor->hsync[0].lo = 1024.0;
- Monitor->hsync[0].hi = 0.0;
-
- Monitor->nVrefresh = 1;
- Monitor->vrefresh[0].lo = 1024.0;
- Monitor->vrefresh[0].hi = 0.0;
-
- while (Mode) {
- if (!Mode->HSync)
- Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal);
-
- if (!Mode->VRefresh)
- Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) /
- ((float) (Mode->HTotal * Mode->VTotal));
-
- if (Mode->HSync < Monitor->hsync[0].lo)
- Monitor->hsync[0].lo = Mode->HSync;
-
- if (Mode->HSync > Monitor->hsync[0].hi)
- Monitor->hsync[0].hi = Mode->HSync;
-
- if (Mode->VRefresh < Monitor->vrefresh[0].lo)
- Monitor->vrefresh[0].lo = Mode->VRefresh;
-
- if (Mode->VRefresh > Monitor->vrefresh[0].hi)
- Monitor->vrefresh[0].hi = Mode->VRefresh;
-
- Mode = Mode->next;
- }
-}
-
-ddc_quirk_t
-xf86DDCDetectQuirks(int scrnIndex, xf86MonPtr DDC, Bool verbose)
-{
- ddc_quirk_t quirks;
- int i;
-
- quirks = DDC_QUIRK_NONE;
- for (i = 0; ddc_quirks[i].detect; i++) {
- if (ddc_quirks[i].detect (scrnIndex, DDC)) {
- if (verbose) {
- xf86DrvMsg (scrnIndex, X_INFO, " EDID quirk: %s\n",
- ddc_quirks[i].description);
- }
- quirks |= ddc_quirks[i].quirk;
- }
- }
-
- return quirks;
-}
-
-void xf86DetTimingApplyQuirks(struct detailed_monitor_section *det_mon,
- ddc_quirk_t quirks,
- int hsize, int vsize)
-{
- if (det_mon->type != DT)
- return;
-
- if (quirks & DDC_QUIRK_DETAILED_H_IN_CM)
- det_mon->section.d_timings.h_size *= 10;
-
- if (quirks & DDC_QUIRK_DETAILED_V_IN_CM)
- det_mon->section.d_timings.v_size *= 10;
-
- if (quirks & DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE) {
- det_mon->section.d_timings.h_size = 10 * hsize;
- det_mon->section.d_timings.v_size = 10 * vsize;
- }
-}
-
-/**
- * Applies monitor-specific quirks to the decoded EDID information.
- *
- * Note that some quirks applying to the mode list are still implemented in
- * xf86DDCGetModes.
- */
-void
-xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC)
-{
- ddc_quirk_t quirks = xf86DDCDetectQuirks (scrnIndex, DDC, FALSE);
- int i;
-
- for (i = 0; i < DET_TIMINGS; i++) {
- xf86DetTimingApplyQuirks(DDC->det_mon + i, quirks,
- DDC->features.hsize,
- DDC->features.vsize);
- }
-}
-
-/**
- * Walks the modes list, finding the mode with the largest area which is
- * closest to the target refresh rate, and marks it as the only preferred mode.
-*/
-static void
-xf86DDCSetPreferredRefresh(int scrnIndex, DisplayModePtr modes,
- float target_refresh)
-{
- DisplayModePtr mode, best = modes;
-
- for (mode = modes; mode; mode = mode->next)
- {
- mode->type &= ~M_T_PREFERRED;
-
- if (mode == best) continue;
-
- if (mode->HDisplay * mode->VDisplay >
- best->HDisplay * best->VDisplay)
- {
- best = mode;
- continue;
- }
- if (mode->HDisplay * mode->VDisplay ==
- best->HDisplay * best->VDisplay)
- {
- double mode_refresh = xf86ModeVRefresh (mode);
- double best_refresh = xf86ModeVRefresh (best);
- double mode_dist = fabs(mode_refresh - target_refresh);
- double best_dist = fabs(best_refresh - target_refresh);
-
- if (mode_dist < best_dist)
- {
- best = mode;
- continue;
- }
- }
- }
- if (best)
- best->type |= M_T_PREFERRED;
-}
-
-#define CEA_VIDEO_MODES_NUM 64
-static const DisplayModeRec CEAVideoModes[CEA_VIDEO_MODES_NUM] = {
- { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 1:640x480@60Hz */
- { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 2:720x480@60Hz */
- { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 3:720x480@60Hz */
- { MODEPREFIX, 74250, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 4: 1280x720@60Hz */
- { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 5:1920x1080i@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 6:1440x480i@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 7:1440x480i@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 8:1440x240@60Hz */
- { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 9:1440x240@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 10:2880x480i@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 11:2880x480i@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 12:2880x240@60Hz */
- { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 13:2880x240@60Hz */
- { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 14:1440x480@60Hz */
- { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 15:1440x480@60Hz */
- { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 16:1920x1080@60Hz */
- { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 17:720x576@50Hz */
- { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 18:720x576@50Hz */
- { MODEPREFIX, 74250, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 19: 1280x720@50Hz */
- { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 20:1920x1080i@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 21:1440x576i@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 22:1440x576i@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 23:1440x288@50Hz */
- { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 24:1440x288@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 25:2880x576i@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 26:2880x576i@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 27:2880x288@50Hz */
- { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 28:2880x288@50Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 29:1440x576@50Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 30:1440x576@50Hz */
- { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 31:1920x1080@50Hz */
- { MODEPREFIX, 74250, 1920, 2558, 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 32:1920x1080@24Hz */
- { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 33:1920x1080@25Hz */
- { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 34:1920x1080@30Hz */
- { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 35:2880x480@60Hz */
- { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 36:2880x480@60Hz */
- { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 37:2880x576@50Hz */
- { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 38:2880x576@50Hz */
- { MODEPREFIX, 72000, 1920, 1952, 2120, 2304, 0, 1080, 1126, 1136, 1250, 0, V_PHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 39:1920x1080i@50Hz */
- { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 40:1920x1080i@100Hz */
- { MODEPREFIX, 148500, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 41:1280x720@100Hz */
- { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 42:720x576@100Hz */
- { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 43:720x576@100Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 44:1440x576i@100Hz */
- { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 45:1440x576i@100Hz */
- { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 46:1920x1080i@120Hz */
- { MODEPREFIX, 148500, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 47:1280x720@120Hz */
- { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 48:720x480@120Hz */
- { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 49:720x480@120Hz */
- { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 50:1440x480i@120Hz */
- { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 51:1440x480i@120Hz */
- { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 52:720x576@200Hz */
- { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 53:720x576@200Hz */
- { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 54:1440x576i@200Hz */
- { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 55:1440x576i@200Hz */
- { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 56:720x480@240Hz */
- { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 57:720x480@240Hz */
- { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 58:1440x480i@240 */
- { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 59:1440x480i@240 */
- { MODEPREFIX, 59400, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 60: 1280x720@24Hz */
- { MODEPREFIX, 74250, 3700, 3740, 1430, 3960, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 61: 1280x720@25Hz */
- { MODEPREFIX, 74250, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 62: 1280x720@30Hz */
- { MODEPREFIX, 297000, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 63: 1920x1080@120Hz */
- { MODEPREFIX, 297000, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 64:1920x1080@100Hz */
-};
-
-/* chose mode line by cea short video descriptor*/
-static void handle_cea_svd(struct cea_video_block *video, void *data)
-{
- DisplayModePtr Mode;
- DisplayModePtr *Modes = (DisplayModePtr *) data;
- int vid;
-
- vid = video ->video_code & 0x7f;
- if (vid < CEA_VIDEO_MODES_NUM) {
- Mode = xf86DuplicateMode(CEAVideoModes + vid);
- *Modes = xf86ModesAdd(*Modes, Mode);
- }
-}
-
-static DisplayModePtr
-DDCModesFromCEAExtension(int scrnIndex, xf86MonPtr MonPtr)
-{
- DisplayModePtr Modes = NULL;
-
- xf86ForEachVideoBlock(MonPtr,
- handle_cea_svd,
- &Modes);
-
- return Modes;
-}
-
-struct det_modes_parameter {
- xf86MonPtr DDC;
- ddc_quirk_t quirks;
- DisplayModePtr Modes;
- Bool rb;
- Bool preferred;
- int timing_level;
-};
-
-static void handle_detailed_modes(struct detailed_monitor_section *det_mon,
- void *data)
-{
- DisplayModePtr Mode;
- struct det_modes_parameter *p = (struct det_modes_parameter *)data;
-
- xf86DetTimingApplyQuirks(det_mon,p->quirks,
- p->DDC->features.hsize,
- p->DDC->features.vsize);
-
- switch (det_mon->type) {
- case DT:
- Mode = DDCModeFromDetailedTiming(p->DDC->scrnIndex,
- &det_mon->section.d_timings,
- p->preferred,
- p->quirks);
- p->preferred = FALSE;
- p->Modes = xf86ModesAdd(p->Modes, Mode);
- break;
- case DS_STD_TIMINGS:
- Mode = DDCModesFromStandardTiming(det_mon->section.std_t,
- p->quirks, p->timing_level,p->rb);
- p->Modes = xf86ModesAdd(p->Modes, Mode);
- break;
- case DS_CVT:
- Mode = DDCModesFromCVT(p->DDC->scrnIndex, det_mon->section.cvt);
- p->Modes = xf86ModesAdd(p->Modes, Mode);
- break;
- case DS_EST_III:
- Mode = DDCModesFromEstIII(det_mon->section.est_iii);
- p->Modes = xf86ModesAdd(p->Modes, Mode);
- break;
- default:
- break;
- }
-}
-
-DisplayModePtr
-xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC)
-{
- DisplayModePtr Modes = NULL, Mode;
- ddc_quirk_t quirks;
- Bool preferred, rb;
- int timing_level;
- struct det_modes_parameter p;
-
- xf86DrvMsg (scrnIndex, X_INFO, "EDID vendor \"%s\", prod id %d\n",
- DDC->vendor.name, DDC->vendor.prod_id);
-
- quirks = xf86DDCDetectQuirks(scrnIndex, DDC, TRUE);
-
- preferred = PREFERRED_TIMING_MODE(DDC->features.msc);
- if (DDC->ver.revision >= 4)
- preferred = TRUE;
- if (quirks & DDC_QUIRK_FIRST_DETAILED_PREFERRED)
- preferred = TRUE;
- if (quirks & (DDC_QUIRK_PREFER_LARGE_60 | DDC_QUIRK_PREFER_LARGE_75))
- preferred = FALSE;
-
- rb = xf86MonitorSupportsReducedBlanking(DDC);
-
- timing_level = MonitorStandardTimingLevel(DDC);
-
- p.quirks = quirks;
- p.DDC = DDC;
- p.Modes = Modes;
- p.rb = rb;
- p.preferred = preferred;
- p.timing_level = timing_level;
- xf86ForEachDetailedBlock(DDC, handle_detailed_modes, &p);
- Modes = p.Modes;
-
- /* Add established timings */
- Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1, quirks);
- Modes = xf86ModesAdd(Modes, Mode);
-
- /* Add standard timings */
- Mode = DDCModesFromStandardTiming(DDC->timings2, quirks, timing_level, rb);
- Modes = xf86ModesAdd(Modes, Mode);
-
- /* Add cea-extension mode timings */
- Mode = DDCModesFromCEAExtension(scrnIndex,DDC);
- Modes = xf86ModesAdd(Modes, Mode);
-
- if (quirks & DDC_QUIRK_PREFER_LARGE_60)
- xf86DDCSetPreferredRefresh(scrnIndex, Modes, 60);
-
- if (quirks & DDC_QUIRK_PREFER_LARGE_75)
- xf86DDCSetPreferredRefresh(scrnIndex, Modes, 75);
-
- Modes = xf86PruneDuplicateModes(Modes);
-
- return Modes;
-}
-
-struct det_mon_parameter {
- MonPtr Monitor;
- ddc_quirk_t quirks;
- Bool have_hsync;
- Bool have_vrefresh;
- Bool have_maxpixclock;
-};
-
-static void handle_detailed_monset(struct detailed_monitor_section *det_mon,
- void *data)
-{
- int clock;
- struct det_mon_parameter *p = (struct det_mon_parameter *)data;
- int scrnIndex = ((xf86MonPtr)(p->Monitor->DDC))->scrnIndex;
-
- switch (det_mon->type) {
- case DS_RANGES:
- if (!p->have_hsync) {
- if (!p->Monitor->nHsync)
- xf86DrvMsg(scrnIndex, X_INFO,
- "Using EDID range info for horizontal sync\n");
- p->Monitor->hsync[p->Monitor->nHsync].lo =
- det_mon->section.ranges.min_h;
- p->Monitor->hsync[p->Monitor->nHsync].hi =
- det_mon->section.ranges.max_h;
- p->Monitor->nHsync++;
- } else {
- xf86DrvMsg(scrnIndex, X_INFO,
- "Using hsync ranges from config file\n");
- }
-
- if (!p->have_vrefresh) {
- if (!p->Monitor->nVrefresh)
- xf86DrvMsg(scrnIndex, X_INFO,
- "Using EDID range info for vertical refresh\n");
- p->Monitor->vrefresh[p->Monitor->nVrefresh].lo =
- det_mon->section.ranges.min_v;
- p->Monitor->vrefresh[p->Monitor->nVrefresh].hi =
- det_mon->section.ranges.max_v;
- p->Monitor->nVrefresh++;
- } else {
- xf86DrvMsg(scrnIndex, X_INFO,
- "Using vrefresh ranges from config file\n");
- }
-
- clock = det_mon->section.ranges.max_clock * 1000;
- if (p->quirks & DDC_QUIRK_DVI_SINGLE_LINK)
- clock = min(clock, 165000);
- if (!p->have_maxpixclock && clock > p->Monitor->maxPixClock)
- p->Monitor->maxPixClock = clock;
-
- break;
- default:
- break;
- }
-}
-
-/*
- * Fill out MonPtr with xf86MonPtr information.
- */
-void
-xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC)
-{
- DisplayModePtr Modes = NULL, Mode;
- struct det_mon_parameter p;
-
- if (!Monitor || !DDC)
- return;
-
- Monitor->DDC = DDC;
-
- if (Monitor->widthmm <= 0 || Monitor->heightmm <= 0) {
- Monitor->widthmm = 10 * DDC->features.hsize;
- Monitor->heightmm = 10 * DDC->features.vsize;
- }
-
- Monitor->reducedblanking = xf86MonitorSupportsReducedBlanking(DDC);
-
- Modes = xf86DDCGetModes(scrnIndex, DDC);
-
- /* Go through the detailed monitor sections */
- p.Monitor = Monitor;
- p.quirks = xf86DDCDetectQuirks(scrnIndex, Monitor->DDC, FALSE);
- p.have_hsync = (Monitor->nHsync != 0);
- p.have_vrefresh = (Monitor->nVrefresh != 0);
- p.have_maxpixclock = (Monitor->maxPixClock != 0);
- xf86ForEachDetailedBlock(DDC, handle_detailed_monset, &p);
-
- if (Modes) {
- /* Print Modes */
- xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n");
-
- Mode = Modes;
- while (Mode) {
- xf86PrintModeline(scrnIndex, Mode);
- Mode = Mode->next;
- }
-
- /* Do we still need ranges to be filled in? */
- if (!Monitor->nHsync || !Monitor->nVrefresh)
- DDCGuessRangesFromModes(scrnIndex, Monitor, Modes);
-
- /* look for last Mode */
- Mode = Modes;
-
- while (Mode->next)
- Mode = Mode->next;
-
- /* add to MonPtr */
- if (Monitor->Modes) {
- Monitor->Last->next = Modes;
- Modes->prev = Monitor->Last;
- Monitor->Last = Mode;
- } else {
- Monitor->Modes = Modes;
- Monitor->Last = Mode;
- }
- }
-}
+/* + * Copyright 2006 Luc Verhaegen. + * Copyright 2008 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, sub license, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * @file This file covers code to convert a xf86MonPtr containing EDID-probed + * information into a list of modes, including applying monitor-specific + * quirks to fix broken EDID data. + */ +#ifdef HAVE_XORG_CONFIG_H +#include <xorg-config.h> +#else +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#endif + +#define _PARSE_EDID_ +#include "xf86.h" +#include "xf86DDC.h" +#include <X11/Xatom.h> +#include "property.h" +#include "propertyst.h" +#include "xf86Crtc.h" +#include <string.h> +#include <math.h> + +static void handle_detailed_rblank(struct detailed_monitor_section *det_mon, + void *data) +{ + if (det_mon->type == DS_RANGES) + if (det_mon->section.ranges.supported_blanking & CVT_REDUCED) + *(Bool*)data = TRUE; +} + +static Bool +xf86MonitorSupportsReducedBlanking(xf86MonPtr DDC) +{ + /* EDID 1.4 explicitly defines RB support */ + if (DDC->ver.revision >= 4) { + Bool ret = FALSE; + + xf86ForEachDetailedBlock(DDC, handle_detailed_rblank, &ret); + return ret; + } + + /* For anything older, assume digital means RB support. Boo. */ + if (DDC->features.input_type) + return TRUE; + + return FALSE; +} + +static Bool quirk_prefer_large_60 (int scrnIndex, xf86MonPtr DDC) +{ + /* Belinea 10 15 55 */ + if (memcmp (DDC->vendor.name, "MAX", 4) == 0 && + ((DDC->vendor.prod_id == 1516) || + (DDC->vendor.prod_id == 0x77e))) + return TRUE; + + /* Acer AL1706 */ + if (memcmp (DDC->vendor.name, "ACR", 4) == 0 && + DDC->vendor.prod_id == 44358) + return TRUE; + + /* Bug #10814: Samsung SyncMaster 225BW */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 596) + return TRUE; + + /* Bug #10545: Samsung SyncMaster 226BW */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 638) + return TRUE; + + /* Acer F51 */ + if (memcmp (DDC->vendor.name, "API", 4) == 0 && + DDC->vendor.prod_id == 0x7602) + return TRUE; + + + return FALSE; +} + +static Bool quirk_prefer_large_75 (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #11603: Funai Electronics PM36B */ + if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && + DDC->vendor.prod_id == 13600) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_h_in_cm (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #11603: Funai Electronics PM36B */ + if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && + DDC->vendor.prod_id == 13600) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_v_in_cm (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #11603: Funai Electronics PM36B */ + if (memcmp (DDC->vendor.name, "FCM", 4) == 0 && + DDC->vendor.prod_id == 13600) + return TRUE; + + /* Bug #21000: LGPhilipsLCD LP154W01-TLAJ */ + if (memcmp (DDC->vendor.name, "LPL", 4) == 0 && + DDC->vendor.prod_id == 47360) + return TRUE; + + /* Bug #10304: LGPhilipsLCD LP154W01-A5 */ + if (memcmp(DDC->vendor.name, "LPL", 4) == 0 && + DDC->vendor.prod_id == 0) + return TRUE; + + /* Bug #24482: LGPhilipsLCD LP154W01-TLA1 */ + if (memcmp(DDC->vendor.name, "LPL", 4) == 0 && + DDC->vendor.prod_id == 0x2a00) + return TRUE; + + /* Bug #28414: HP Compaq NC8430 LP154W01-TLA8 */ + if (memcmp (DDC->vendor.name, "LPL", 4) == 0 && + DDC->vendor.prod_id == 5750) + return TRUE; + + /* Bug #21750: Samsung Syncmaster 2333HD */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 1157) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_use_maximum_size (int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #21324: Iiyama Vision Master 450 */ + if (memcmp (DDC->vendor.name, "IVM", 4) == 0 && + DDC->vendor.prod_id == 6400) + return TRUE; + + return FALSE; +} + +static Bool quirk_135_clock_too_high (int scrnIndex, xf86MonPtr DDC) +{ + /* Envision Peripherals, Inc. EN-7100e. See bug #9550. */ + if (memcmp (DDC->vendor.name, "EPI", 4) == 0 && + DDC->vendor.prod_id == 59264) + return TRUE; + + return FALSE; +} + +static Bool quirk_first_detailed_preferred (int scrnIndex, xf86MonPtr DDC) +{ + /* Philips 107p5 CRT. Reported on xorg@ with pastebin. */ + if (memcmp (DDC->vendor.name, "PHL", 4) == 0 && + DDC->vendor.prod_id == 57364) + return TRUE; + + /* Proview AY765C 17" LCD. See bug #15160*/ + if (memcmp (DDC->vendor.name, "PTS", 4) == 0 && + DDC->vendor.prod_id == 765) + return TRUE; + + /* ACR of some sort RH #284231 */ + if (memcmp (DDC->vendor.name, "ACR", 4) == 0 && + DDC->vendor.prod_id == 2423) + return TRUE; + + /* Peacock Ergovision 19. See rh#492359 */ + if (memcmp (DDC->vendor.name, "PEA", 4) == 0 && + DDC->vendor.prod_id == 9003) + return TRUE; + + return FALSE; +} + +static Bool quirk_detailed_sync_pp(int scrnIndex, xf86MonPtr DDC) +{ + /* Bug #12439: Samsung SyncMaster 205BW */ + if (memcmp (DDC->vendor.name, "SAM", 4) == 0 && + DDC->vendor.prod_id == 541) + return TRUE; + return FALSE; +} + +/* This should probably be made more generic */ +static Bool quirk_dvi_single_link(int scrnIndex, xf86MonPtr DDC) +{ + /* Red Hat bug #453106: Apple 23" Cinema Display */ + if (memcmp (DDC->vendor.name, "APL", 4) == 0 && + DDC->vendor.prod_id == 0x921c) + return TRUE; + return FALSE; +} + +typedef struct { + Bool (*detect) (int scrnIndex, xf86MonPtr DDC); + ddc_quirk_t quirk; + char *description; +} ddc_quirk_map_t; + +static const ddc_quirk_map_t ddc_quirks[] = { + { + quirk_prefer_large_60, DDC_QUIRK_PREFER_LARGE_60, + "Detailed timing is not preferred, use largest mode at 60Hz" + }, + { + quirk_135_clock_too_high, DDC_QUIRK_135_CLOCK_TOO_HIGH, + "Recommended 135MHz pixel clock is too high" + }, + { + quirk_prefer_large_75, DDC_QUIRK_PREFER_LARGE_75, + "Detailed timing is not preferred, use largest mode at 75Hz" + }, + { + quirk_detailed_h_in_cm, DDC_QUIRK_DETAILED_H_IN_CM, + "Detailed timings give horizontal size in cm." + }, + { + quirk_detailed_v_in_cm, DDC_QUIRK_DETAILED_V_IN_CM, + "Detailed timings give vertical size in cm." + }, + { + quirk_detailed_use_maximum_size, DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE, + "Use maximum size instead of detailed timing sizes." + }, + { + quirk_first_detailed_preferred, DDC_QUIRK_FIRST_DETAILED_PREFERRED, + "First detailed timing was not marked as preferred." + }, + { + quirk_detailed_sync_pp, DDC_QUIRK_DETAILED_SYNC_PP, + "Use +hsync +vsync for detailed timing." + }, + { + quirk_dvi_single_link, DDC_QUIRK_DVI_SINGLE_LINK, + "Forcing maximum pixel clock to single DVI link." + }, + { + NULL, DDC_QUIRK_NONE, + "No known quirks" + }, +}; + +/* + * These more or less come from the DMT spec. The 720x400 modes are + * inferred from historical 80x25 practice. The 640x480@67 and 832x624@75 + * modes are old-school Mac modes. The EDID spec says the 1152x864@75 mode + * should be 1152x870, again for the Mac, but instead we use the x864 DMT + * mode. + * + * The DMT modes have been fact-checked; the rest are mild guesses. + */ +#define MODEPREFIX NULL, NULL, NULL, 0, M_T_DRIVER +#define MODESUFFIX 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,FALSE,FALSE,0,NULL,0,0.0,0.0 + +static const DisplayModeRec DDCEstablishedModes[17] = { + { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */ + { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */ + { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */ + { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */ + { MODEPREFIX, 30240, 640, 704, 768, 864, 0, 480, 483, 486, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@67Hz */ + { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */ + { MODEPREFIX, 35500, 720, 738, 846, 900, 0, 400, 421, 423, 449, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 720x400@88Hz */ + { MODEPREFIX, 28320, 720, 738, 846, 900, 0, 400, 412, 414, 449, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@70Hz */ + { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */ + { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */ + { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */ + { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */ + { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz */ + { MODEPREFIX, 57284, 832, 864, 928, 1152, 0, 624, 625, 628, 667, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 832x624@75Hz */ + { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */ + { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */ + { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */ +}; + +static DisplayModePtr +DDCModesFromEstablished(int scrnIndex, struct established_timings *timing, + ddc_quirk_t quirks) +{ + DisplayModePtr Modes = NULL, Mode = NULL; + CARD32 bits = (timing->t1) | (timing->t2 << 8) | + ((timing->t_manu & 0x80) << 9); + int i; + + for (i = 0; i < 17; i++) { + if (bits & (0x01 << i)) { + Mode = xf86DuplicateMode(&DDCEstablishedModes[i]); + Modes = xf86ModesAdd(Modes, Mode); + } + } + + return Modes; +} + +/* Autogenerated from the DMT spec */ +const DisplayModeRec DMTModes[] = { + { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 350, 382, 385, 445, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x350@85Hz */ + { MODEPREFIX, 31500, 640, 672, 736, 832, 0, 400, 401, 404, 445, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 640x400@85Hz */ + { MODEPREFIX, 35500, 720, 756, 828, 936, 0, 400, 401, 404, 446, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 720x400@85Hz */ + { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@60Hz */ + { MODEPREFIX, 31500, 640, 664, 704, 832, 0, 480, 489, 492, 520, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@72Hz */ + { MODEPREFIX, 31500, 640, 656, 720, 840, 0, 480, 481, 484, 500, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@75Hz */ + { MODEPREFIX, 36000, 640, 696, 752, 832, 0, 480, 481, 484, 509, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 640x480@85Hz */ + { MODEPREFIX, 36000, 800, 824, 896, 1024, 0, 600, 601, 603, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@56Hz */ + { MODEPREFIX, 40000, 800, 840, 968, 1056, 0, 600, 601, 605, 628, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@60Hz */ + { MODEPREFIX, 50000, 800, 856, 976, 1040, 0, 600, 637, 643, 666, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@72Hz */ + { MODEPREFIX, 49500, 800, 816, 896, 1056, 0, 600, 601, 604, 625, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@75Hz */ + { MODEPREFIX, 56250, 800, 832, 896, 1048, 0, 600, 601, 604, 631, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 800x600@85Hz */ + { MODEPREFIX, 73250, 800, 848, 880, 960, 0, 600, 603, 607, 636, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 800x600@120Hz RB */ + { MODEPREFIX, 33750, 848, 864, 976, 1088, 0, 480, 486, 494, 517, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 848x480@60Hz */ + { MODEPREFIX, 44900, 1024, 1032, 1208, 1264, 0, 768, 768, 772, 817, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* 1024x768@43Hz (interlaced) */ + { MODEPREFIX, 65000, 1024, 1048, 1184, 1344, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@60Hz */ + { MODEPREFIX, 75000, 1024, 1048, 1184, 1328, 0, 768, 771, 777, 806, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@70Hz */ + { MODEPREFIX, 78750, 1024, 1040, 1136, 1312, 0, 768, 769, 772, 800, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@75Hz */ + { MODEPREFIX, 94500, 1024, 1072, 1168, 1376, 0, 768, 769, 772, 808, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1024x768@85Hz */ + { MODEPREFIX, 115500, 1024, 1072, 1104, 1184, 0, 768, 771, 775, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1024x768@120Hz RB */ + { MODEPREFIX, 108000, 1152, 1216, 1344, 1600, 0, 864, 865, 868, 900, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1152x864@75Hz */ + { MODEPREFIX, 68250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 790, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@60Hz RB */ + { MODEPREFIX, 79500, 1280, 1344, 1472, 1664, 0, 768, 771, 778, 798, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@60Hz */ + { MODEPREFIX, 102250, 1280, 1360, 1488, 1696, 0, 768, 771, 778, 805, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@75Hz */ + { MODEPREFIX, 117500, 1280, 1360, 1496, 1712, 0, 768, 771, 778, 809, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x768@85Hz */ + { MODEPREFIX, 140250, 1280, 1328, 1360, 1440, 0, 768, 771, 778, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x768@120Hz RB */ + { MODEPREFIX, 71000, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 823, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@60Hz RB */ + { MODEPREFIX, 83500, 1280, 1352, 1480, 1680, 0, 800, 803, 809, 831, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@60Hz */ + { MODEPREFIX, 106500, 1280, 1360, 1488, 1696, 0, 800, 803, 809, 838, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@75Hz */ + { MODEPREFIX, 122500, 1280, 1360, 1496, 1712, 0, 800, 803, 809, 843, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x800@85Hz */ + { MODEPREFIX, 146250, 1280, 1328, 1360, 1440, 0, 800, 803, 809, 847, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x800@120Hz RB */ + { MODEPREFIX, 108000, 1280, 1376, 1488, 1800, 0, 960, 961, 964, 1000, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@60Hz */ + { MODEPREFIX, 148500, 1280, 1344, 1504, 1728, 0, 960, 961, 964, 1011, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x960@85Hz */ + { MODEPREFIX, 175500, 1280, 1328, 1360, 1440, 0, 960, 963, 967, 1017, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x960@120Hz RB */ + { MODEPREFIX, 108000, 1280, 1328, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@60Hz */ + { MODEPREFIX, 135000, 1280, 1296, 1440, 1688, 0, 1024, 1025, 1028, 1066, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@75Hz */ + { MODEPREFIX, 157500, 1280, 1344, 1504, 1728, 0, 1024, 1025, 1028, 1072, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1280x1024@85Hz */ + { MODEPREFIX, 187250, 1280, 1328, 1360, 1440, 0, 1024, 1027, 1034, 1084, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1280x1024@120Hz RB */ + { MODEPREFIX, 85500, 1360, 1424, 1536, 1792, 0, 768, 771, 777, 795, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1360x768@60Hz */ + { MODEPREFIX, 148250, 1360, 1408, 1440, 1520, 0, 768, 771, 776, 813, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1360x768@120Hz RB */ + { MODEPREFIX, 101000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@60Hz RB */ + { MODEPREFIX, 121750, 1400, 1488, 1632, 1864, 0, 1050, 1053, 1057, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@60Hz */ + { MODEPREFIX, 156000, 1400, 1504, 1648, 1896, 0, 1050, 1053, 1057, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@75Hz */ + { MODEPREFIX, 179500, 1400, 1504, 1656, 1912, 0, 1050, 1053, 1057, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1400x1050@85Hz */ + { MODEPREFIX, 208000, 1400, 1448, 1480, 1560, 0, 1050, 1053, 1057, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1400x1050@120Hz RB */ + { MODEPREFIX, 88750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 926, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@60Hz RB */ + { MODEPREFIX, 106500, 1440, 1520, 1672, 1904, 0, 900, 903, 909, 934, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@60Hz */ + { MODEPREFIX, 136750, 1440, 1536, 1688, 1936, 0, 900, 903, 909, 942, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@75Hz */ + { MODEPREFIX, 157000, 1440, 1544, 1696, 1952, 0, 900, 903, 909, 948, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1440x900@85Hz */ + { MODEPREFIX, 182750, 1440, 1488, 1520, 1600, 0, 900, 903, 909, 953, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1440x900@120Hz RB */ + { MODEPREFIX, 162000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@60Hz */ + { MODEPREFIX, 175500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@65Hz */ + { MODEPREFIX, 189000, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@70Hz */ + { MODEPREFIX, 202500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@75Hz */ + { MODEPREFIX, 229500, 1600, 1664, 1856, 2160, 0, 1200, 1201, 1204, 1250, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* 1600x1200@85Hz */ + { MODEPREFIX, 268250, 1600, 1648, 1680, 1760, 0, 1200, 1203, 1207, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1600x1200@120Hz RB */ + { MODEPREFIX, 119000, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1080, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@60Hz RB */ + { MODEPREFIX, 146250, 1680, 1784, 1960, 2240, 0, 1050, 1053, 1059, 1089, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@60Hz */ + { MODEPREFIX, 187000, 1680, 1800, 1976, 2272, 0, 1050, 1053, 1059, 1099, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@75Hz */ + { MODEPREFIX, 214750, 1680, 1808, 1984, 2288, 0, 1050, 1053, 1059, 1105, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1680x1050@85Hz */ + { MODEPREFIX, 245500, 1680, 1728, 1760, 1840, 0, 1050, 1053, 1059, 1112, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1680x1050@120Hz RB */ + { MODEPREFIX, 204750, 1792, 1920, 2120, 2448, 0, 1344, 1345, 1348, 1394, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@60Hz */ + { MODEPREFIX, 261000, 1792, 1888, 2104, 2456, 0, 1344, 1345, 1348, 1417, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1792x1344@75Hz */ + { MODEPREFIX, 333250, 1792, 1840, 1872, 1952, 0, 1344, 1347, 1351, 1423, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1792x1344@120Hz RB */ + { MODEPREFIX, 218250, 1856, 1952, 2176, 2528, 0, 1392, 1393, 1396, 1439, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@60Hz */ + { MODEPREFIX, 288000, 1856, 1984, 2208, 2560, 0, 1392, 1393, 1396, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1856x1392@75Hz */ + { MODEPREFIX, 356500, 1856, 1904, 1936, 2016, 0, 1392, 1395, 1399, 1474, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1856x1392@120Hz RB */ + { MODEPREFIX, 154000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1235, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@60Hz RB */ + { MODEPREFIX, 193250, 1920, 2056, 2256, 2592, 0, 1200, 1203, 1209, 1245, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@60Hz */ + { MODEPREFIX, 245250, 1920, 2056, 2264, 2608, 0, 1200, 1203, 1209, 1255, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@75Hz */ + { MODEPREFIX, 281250, 1920, 2064, 2272, 2624, 0, 1200, 1203, 1209, 1262, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1200@85Hz */ + { MODEPREFIX, 317000, 1920, 1968, 2000, 2080, 0, 1200, 1203, 1209, 1271, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1200@120Hz RB */ + { MODEPREFIX, 234000, 1920, 2048, 2256, 2600, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@60Hz */ + { MODEPREFIX, 297000, 1920, 2064, 2288, 2640, 0, 1440, 1441, 1444, 1500, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 1920x1440@75Hz */ + { MODEPREFIX, 380500, 1920, 1968, 2000, 2080, 0, 1440, 1443, 1447, 1525, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 1920x1440@120Hz RB */ + { MODEPREFIX, 268500, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1646, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@60Hz RB */ + { MODEPREFIX, 348500, 2560, 2752, 3032, 3504, 0, 1600, 1603, 1609, 1658, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@60Hz */ + { MODEPREFIX, 443250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1672, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@75Hz */ + { MODEPREFIX, 505250, 2560, 2768, 3048, 3536, 0, 1600, 1603, 1609, 1682, 0, V_NHSYNC | V_PVSYNC, MODESUFFIX }, /* 2560x1600@85Hz */ + { MODEPREFIX, 552750, 2560, 2608, 2640, 2720, 0, 1600, 1603, 1609, 1694, 0, V_PHSYNC | V_NVSYNC, MODESUFFIX }, /* 2560x1600@120Hz RB */ +}; + +#define LEVEL_DMT 0 +#define LEVEL_GTF 1 +#define LEVEL_CVT 2 + +static int +MonitorStandardTimingLevel(xf86MonPtr DDC) +{ + if (DDC->ver.revision >= 2) { + if (DDC->ver.revision >= 4 && CVT_SUPPORTED(DDC->features.msc)) { + return LEVEL_CVT; + } + return LEVEL_GTF; + } + return LEVEL_DMT; +} + +static int +ModeRefresh(const DisplayModeRec *mode) +{ + return (int)(xf86ModeVRefresh(mode) + 0.5); +} + +/* + * If rb is not set, then we'll not consider reduced-blanking modes as + * part of the DMT pool. For the 'standard' EDID mode descriptor there's + * no way to specify whether the mode should be RB or not. + */ +DisplayModePtr +FindDMTMode(int hsize, int vsize, int refresh, Bool rb) +{ + int i; + const DisplayModeRec *ret; + + for (i = 0; i < sizeof(DMTModes) / sizeof(DisplayModeRec); i++) { + ret = &DMTModes[i]; + + if (!rb && xf86ModeIsReduced(ret)) + continue; + + if (ret->HDisplay == hsize && + ret->VDisplay == vsize && + refresh == ModeRefresh(ret)) + return xf86DuplicateMode(ret); + } + + return NULL; +} + +/* + * Appendix B of the EDID 1.4 spec defines the right thing to do here. + * If the timing given here matches a mode defined in the VESA DMT standard, + * we _must_ use that. If the device supports CVT modes, then we should + * generate a CVT timing. If both of the above fail, use GTF. + * + * There are some wrinkles here. EDID 1.1 and 1.0 sinks can't really + * "support" GTF, since it wasn't a standard yet; so if they ask for a + * timing in this section that isn't defined in DMT, returning a GTF mode + * may not actually be valid. EDID 1.3 sinks often report support for + * some CVT modes, but they are not required to support CVT timings for + * modes in the standard timing descriptor, so we should _not_ treat them + * as CVT-compliant (unless specified in an extension block I suppose). + * + * EDID 1.4 requires that all sink devices support both GTF and CVT timings + * for modes in this section, but does say that CVT is preferred. + */ +static DisplayModePtr +DDCModesFromStandardTiming(struct std_timings *timing, ddc_quirk_t quirks, + int timing_level, Bool rb) +{ + DisplayModePtr Modes = NULL, Mode = NULL; + int i, hsize, vsize, refresh; + + for (i = 0; i < STD_TIMINGS; i++) { + hsize = timing[i].hsize; + vsize = timing[i].vsize; + refresh = timing[i].refresh; + + /* HDTV hack, because you can't say 1366 */ + if (refresh == 60 && + ((hsize == 1360 && vsize == 765) || + (hsize == 1368 && vsize == 769))) { + Mode = xf86CVTMode(1366, 768, 60, FALSE, FALSE); + Mode->HDisplay = 1366; + Mode->HSyncStart--; + Mode->HSyncEnd--; + } else if (hsize && vsize && refresh) { + Mode = FindDMTMode(hsize, vsize, refresh, rb); + + if (!Mode) { + if (timing_level == LEVEL_CVT) + /* pass rb here too? */ + Mode = xf86CVTMode(hsize, vsize, refresh, FALSE, FALSE); + else if (timing_level == LEVEL_GTF) + Mode = xf86GTFMode(hsize, vsize, refresh, FALSE, FALSE); + } + + } + + if (Mode) { + Mode->type = M_T_DRIVER; + Modes = xf86ModesAdd(Modes, Mode); + } + Mode = NULL; + } + + return Modes; +} + +static void +DDCModeDoInterlaceQuirks(DisplayModePtr mode) +{ + /* + * EDID is delightfully ambiguous about how interlaced modes are to be + * encoded. X's internal representation is of frame height, but some + * HDTV detailed timings are encoded as field height. + * + * The format list here is from CEA, in frame size. Technically we + * should be checking refresh rate too. Whatever. + */ + static const struct { + int w, h; + } cea_interlaced[] = { + { 1920, 1080 }, + { 720, 480 }, + { 1440, 480 }, + { 2880, 480 }, + { 720, 576 }, + { 1440, 576 }, + { 2880, 576 }, + }; + static const int n_modes = sizeof(cea_interlaced)/sizeof(cea_interlaced[0]); + int i; + + for (i = 0; i < n_modes; i++) { + if ((mode->HDisplay == cea_interlaced[i].w) && + (mode->VDisplay == cea_interlaced[i].h / 2)) { + mode->VDisplay *= 2; + mode->VSyncStart *= 2; + mode->VSyncEnd *= 2; + mode->VTotal *= 2; + mode->VTotal |= 1; + } + } + + mode->Flags |= V_INTERLACE; +} + +/* + * + */ +static DisplayModePtr +DDCModeFromDetailedTiming(int scrnIndex, struct detailed_timings *timing, + Bool preferred, ddc_quirk_t quirks) +{ + DisplayModePtr Mode; + + /* + * Refuse to create modes that are insufficiently large. 64 is a random + * number, maybe the spec says something about what the minimum is. In + * particular I see this frequently with _old_ EDID, 1.0 or so, so maybe + * our parser is just being too aggresive there. + */ + if (timing->h_active < 64 || timing->v_active < 64) { + xf86DrvMsg(scrnIndex, X_INFO, + "%s: Ignoring tiny %dx%d mode\n", __func__, + timing->h_active, timing->v_active); + return NULL; + } + + /* We don't do stereo */ + if (timing->stereo) { + xf86DrvMsg(scrnIndex, X_INFO, + "%s: Ignoring: We don't handle stereo.\n", __func__); + return NULL; + } + + /* We only do seperate sync currently */ + if (timing->sync != 0x03) { + xf86DrvMsg(scrnIndex, X_INFO, + "%s: %dx%d Warning: We only handle separate" + " sync.\n", __func__, timing->h_active, timing->v_active); + } + + Mode = xnfcalloc(1, sizeof(DisplayModeRec)); + + Mode->type = M_T_DRIVER; + if (preferred) + Mode->type |= M_T_PREFERRED; + + if( ( quirks & DDC_QUIRK_135_CLOCK_TOO_HIGH ) && + timing->clock == 135000000 ) + Mode->Clock = 108880; + else + Mode->Clock = timing->clock / 1000.0; + + Mode->HDisplay = timing->h_active; + Mode->HSyncStart = timing->h_active + timing->h_sync_off; + Mode->HSyncEnd = Mode->HSyncStart + timing->h_sync_width; + Mode->HTotal = timing->h_active + timing->h_blanking; + + Mode->VDisplay = timing->v_active; + Mode->VSyncStart = timing->v_active + timing->v_sync_off; + Mode->VSyncEnd = Mode->VSyncStart + timing->v_sync_width; + Mode->VTotal = timing->v_active + timing->v_blanking; + + /* perform basic check on the detail timing */ + if (Mode->HSyncEnd > Mode->HTotal || Mode->VSyncEnd > Mode->VTotal) { + free(Mode); + return NULL; + } + + /* We ignore h/v_size and h/v_border for now. */ + + if (timing->interlaced) + DDCModeDoInterlaceQuirks(Mode); + + if (quirks & DDC_QUIRK_DETAILED_SYNC_PP) + Mode->Flags |= V_PVSYNC | V_PHSYNC; + else { + if (timing->misc & 0x02) + Mode->Flags |= V_PVSYNC; + else + Mode->Flags |= V_NVSYNC; + + if (timing->misc & 0x01) + Mode->Flags |= V_PHSYNC; + else + Mode->Flags |= V_NHSYNC; + } + + xf86SetModeDefaultName(Mode); + + return Mode; +} + +static DisplayModePtr +DDCModesFromCVT(int scrnIndex, struct cvt_timings *t) +{ + DisplayModePtr modes = NULL; + int i; + + for (i = 0; i < 4; i++) { + if (t[i].height) { + if (t[i].rates & 0x10) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 50, 0, 0)); + if (t[i].rates & 0x08) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 60, 0, 0)); + if (t[i].rates & 0x04) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 75, 0, 0)); + if (t[i].rates & 0x02) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 85, 0, 0)); + if (t[i].rates & 0x01) + modes = xf86ModesAdd(modes, + xf86CVTMode(t[i].width, t[i].height, 60, 1, 0)); + } else break; + } + + return modes; +} + +static const struct { + short w; + short h; + short r; + short rb; +} EstIIIModes[] = { + /* byte 6 */ + { 640, 350, 85, 0 }, + { 640, 400, 85, 0 }, + { 720, 400, 85, 0 }, + { 640, 480, 85, 0 }, + { 848, 480, 60, 0 }, + { 800, 600, 85, 0 }, + { 1024, 768, 85, 0 }, + { 1152, 864, 75, 0 }, + /* byte 7 */ + { 1280, 768, 60, 1 }, + { 1280, 768, 60, 0 }, + { 1280, 768, 75, 0 }, + { 1280, 768, 85, 0 }, + { 1280, 960, 60, 0 }, + { 1280, 960, 85, 0 }, + { 1280, 1024, 60, 0 }, + { 1280, 1024, 85, 0 }, + /* byte 8 */ + { 1360, 768, 60, 0 }, + { 1440, 900, 60, 1 }, + { 1440, 900, 60, 0 }, + { 1440, 900, 75, 0 }, + { 1440, 900, 85, 0 }, + { 1400, 1050, 60, 1 }, + { 1400, 1050, 60, 0 }, + { 1400, 1050, 75, 0 }, + /* byte 9 */ + { 1400, 1050, 85, 0 }, + { 1680, 1050, 60, 1 }, + { 1680, 1050, 60, 0 }, + { 1680, 1050, 75, 0 }, + { 1680, 1050, 85, 0 }, + { 1600, 1200, 60, 0 }, + { 1600, 1200, 65, 0 }, + { 1600, 1200, 70, 0 }, + /* byte 10 */ + { 1600, 1200, 75, 0 }, + { 1600, 1200, 85, 0 }, + { 1792, 1344, 60, 0 }, + { 1792, 1344, 85, 0 }, + { 1856, 1392, 60, 0 }, + { 1856, 1392, 75, 0 }, + { 1920, 1200, 60, 1 }, + { 1920, 1200, 60, 0 }, + /* byte 11 */ + { 1920, 1200, 75, 0 }, + { 1920, 1200, 85, 0 }, + { 1920, 1440, 60, 0 }, + { 1920, 1440, 75, 0 }, +}; + +static DisplayModePtr +DDCModesFromEstIII(unsigned char *est) +{ + DisplayModePtr modes = NULL; + int i, j, m; + + for (i = 0; i < 6; i++) { + for (j = 7; j > 0; j--) { + if (est[i] & (1 << j)) { + m = (i * 8) + (7 - j); + modes = xf86ModesAdd(modes, + FindDMTMode(EstIIIModes[m].w, + EstIIIModes[m].h, + EstIIIModes[m].r, + EstIIIModes[m].rb)); + } + } + } + + return modes; +} + +/* + * This is only valid when the sink claims to be continuous-frequency + * but does not supply a detailed range descriptor. Such sinks are + * arguably broken. Currently the mode validation code isn't aware of + * this; the non-RANDR code even punts the decision of optional sync + * range checking to the driver. Loss. + */ +static void +DDCGuessRangesFromModes(int scrnIndex, MonPtr Monitor, DisplayModePtr Modes) +{ + DisplayModePtr Mode = Modes; + + if (!Monitor || !Modes) + return; + + /* set up the ranges for scanning through the modes */ + Monitor->nHsync = 1; + Monitor->hsync[0].lo = 1024.0; + Monitor->hsync[0].hi = 0.0; + + Monitor->nVrefresh = 1; + Monitor->vrefresh[0].lo = 1024.0; + Monitor->vrefresh[0].hi = 0.0; + + while (Mode) { + if (!Mode->HSync) + Mode->HSync = ((float) Mode->Clock ) / ((float) Mode->HTotal); + + if (!Mode->VRefresh) + Mode->VRefresh = (1000.0 * ((float) Mode->Clock)) / + ((float) (Mode->HTotal * Mode->VTotal)); + + if (Mode->HSync < Monitor->hsync[0].lo) + Monitor->hsync[0].lo = Mode->HSync; + + if (Mode->HSync > Monitor->hsync[0].hi) + Monitor->hsync[0].hi = Mode->HSync; + + if (Mode->VRefresh < Monitor->vrefresh[0].lo) + Monitor->vrefresh[0].lo = Mode->VRefresh; + + if (Mode->VRefresh > Monitor->vrefresh[0].hi) + Monitor->vrefresh[0].hi = Mode->VRefresh; + + Mode = Mode->next; + } +} + +ddc_quirk_t +xf86DDCDetectQuirks(int scrnIndex, xf86MonPtr DDC, Bool verbose) +{ + ddc_quirk_t quirks; + int i; + + quirks = DDC_QUIRK_NONE; + for (i = 0; ddc_quirks[i].detect; i++) { + if (ddc_quirks[i].detect (scrnIndex, DDC)) { + if (verbose) { + xf86DrvMsg (scrnIndex, X_INFO, " EDID quirk: %s\n", + ddc_quirks[i].description); + } + quirks |= ddc_quirks[i].quirk; + } + } + + return quirks; +} + +void xf86DetTimingApplyQuirks(struct detailed_monitor_section *det_mon, + ddc_quirk_t quirks, + int hsize, int vsize) +{ + if (det_mon->type != DT) + return; + + if (quirks & DDC_QUIRK_DETAILED_H_IN_CM) + det_mon->section.d_timings.h_size *= 10; + + if (quirks & DDC_QUIRK_DETAILED_V_IN_CM) + det_mon->section.d_timings.v_size *= 10; + + if (quirks & DDC_QUIRK_DETAILED_USE_MAXIMUM_SIZE) { + det_mon->section.d_timings.h_size = 10 * hsize; + det_mon->section.d_timings.v_size = 10 * vsize; + } +} + +/** + * Applies monitor-specific quirks to the decoded EDID information. + * + * Note that some quirks applying to the mode list are still implemented in + * xf86DDCGetModes. + */ +void +xf86DDCApplyQuirks(int scrnIndex, xf86MonPtr DDC) +{ + ddc_quirk_t quirks = xf86DDCDetectQuirks (scrnIndex, DDC, FALSE); + int i; + + for (i = 0; i < DET_TIMINGS; i++) { + xf86DetTimingApplyQuirks(DDC->det_mon + i, quirks, + DDC->features.hsize, + DDC->features.vsize); + } +} + +/** + * Walks the modes list, finding the mode with the largest area which is + * closest to the target refresh rate, and marks it as the only preferred mode. +*/ +static void +xf86DDCSetPreferredRefresh(int scrnIndex, DisplayModePtr modes, + float target_refresh) +{ + DisplayModePtr mode, best = modes; + + for (mode = modes; mode; mode = mode->next) + { + mode->type &= ~M_T_PREFERRED; + + if (mode == best) continue; + + if (mode->HDisplay * mode->VDisplay > + best->HDisplay * best->VDisplay) + { + best = mode; + continue; + } + if (mode->HDisplay * mode->VDisplay == + best->HDisplay * best->VDisplay) + { + double mode_refresh = xf86ModeVRefresh (mode); + double best_refresh = xf86ModeVRefresh (best); + double mode_dist = fabs(mode_refresh - target_refresh); + double best_dist = fabs(best_refresh - target_refresh); + + if (mode_dist < best_dist) + { + best = mode; + continue; + } + } + } + if (best) + best->type |= M_T_PREFERRED; +} + +#define CEA_VIDEO_MODES_NUM 64 +static const DisplayModeRec CEAVideoModes[CEA_VIDEO_MODES_NUM] = { + { MODEPREFIX, 25175, 640, 656, 752, 800, 0, 480, 490, 492, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 1:640x480@60Hz */ + { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 2:720x480@60Hz */ + { MODEPREFIX, 27000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 3:720x480@60Hz */ + { MODEPREFIX, 74250, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 4: 1280x720@60Hz */ + { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 5:1920x1080i@60Hz */ + { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 6:1440x480i@60Hz */ + { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 7:1440x480i@60Hz */ + { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 8:1440x240@60Hz */ + { MODEPREFIX, 27000, 1440, 1478, 1602, 1716, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 9:1440x240@60Hz */ + { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 10:2880x480i@60Hz */ + { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 11:2880x480i@60Hz */ + { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 12:2880x240@60Hz */ + { MODEPREFIX, 54000, 2880, 2956, 3204, 3432, 0, 240, 244, 247, 262, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 13:2880x240@60Hz */ + { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 14:1440x480@60Hz */ + { MODEPREFIX, 54000, 1440, 1472, 1596, 1716, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 15:1440x480@60Hz */ + { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 16:1920x1080@60Hz */ + { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 17:720x576@50Hz */ + { MODEPREFIX, 27000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 18:720x576@50Hz */ + { MODEPREFIX, 74250, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 19: 1280x720@50Hz */ + { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 20:1920x1080i@50Hz */ + { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 21:1440x576i@50Hz */ + { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 22:1440x576i@50Hz */ + { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 23:1440x288@50Hz */ + { MODEPREFIX, 27000, 1440, 1464, 1590, 1728, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 24:1440x288@50Hz */ + { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 25:2880x576i@50Hz */ + { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 26:2880x576i@50Hz */ + { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 27:2880x288@50Hz */ + { MODEPREFIX, 54000, 2880, 2928, 3180, 3456, 0, 288, 290, 293, 312, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 28:2880x288@50Hz */ + { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 29:1440x576@50Hz */ + { MODEPREFIX, 54000, 1440, 1464, 1592, 1728, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 30:1440x576@50Hz */ + { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 31:1920x1080@50Hz */ + { MODEPREFIX, 74250, 1920, 2558, 2602, 2750, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 32:1920x1080@24Hz */ + { MODEPREFIX, 74250, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 33:1920x1080@25Hz */ + { MODEPREFIX, 74250, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 34:1920x1080@30Hz */ + { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 35:2880x480@60Hz */ + { MODEPREFIX, 108000, 2880, 2944, 3192, 3432, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 36:2880x480@60Hz */ + { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 37:2880x576@50Hz */ + { MODEPREFIX, 108000, 2880, 2928, 3184, 3456, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 38:2880x576@50Hz */ + { MODEPREFIX, 72000, 1920, 1952, 2120, 2304, 0, 1080, 1126, 1136, 1250, 0, V_PHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 39:1920x1080i@50Hz */ + { MODEPREFIX, 148500, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 40:1920x1080i@100Hz */ + { MODEPREFIX, 148500, 1280, 1720, 1760, 1980, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 41:1280x720@100Hz */ + { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 42:720x576@100Hz */ + { MODEPREFIX, 54000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 43:720x576@100Hz */ + { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 44:1440x576i@100Hz */ + { MODEPREFIX, 54000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 45:1440x576i@100Hz */ + { MODEPREFIX, 148500, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC | V_INTERLACE, MODESUFFIX }, /* VIC 46:1920x1080i@120Hz */ + { MODEPREFIX, 148500, 1280, 1390, 1430, 1650, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 47:1280x720@120Hz */ + { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 48:720x480@120Hz */ + { MODEPREFIX, 54000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 49:720x480@120Hz */ + { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 50:1440x480i@120Hz */ + { MODEPREFIX, 54000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 51:1440x480i@120Hz */ + { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 52:720x576@200Hz */ + { MODEPREFIX, 108000, 720, 732, 796, 864, 0, 576, 581, 586, 625, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 53:720x576@200Hz */ + { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 54:1440x576i@200Hz */ + { MODEPREFIX, 108000, 1440, 1464, 1590, 1728, 0, 576, 580, 586, 625, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 55:1440x576i@200Hz */ + { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 56:720x480@240Hz */ + { MODEPREFIX, 108000, 720, 736, 798, 858, 0, 480, 489, 495, 525, 0, V_NHSYNC | V_NVSYNC, MODESUFFIX }, /* VIC 57:720x480@240Hz */ + { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 58:1440x480i@240 */ + { MODEPREFIX, 108000, 1440, 1478, 1602, 1716, 0, 480, 488, 494, 525, 0, V_NHSYNC | V_NVSYNC | V_INTERLACE, MODESUFFIX },/* VIC 59:1440x480i@240 */ + { MODEPREFIX, 59400, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 60: 1280x720@24Hz */ + { MODEPREFIX, 74250, 3700, 3740, 1430, 3960, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 61: 1280x720@25Hz */ + { MODEPREFIX, 74250, 1280, 3040, 3080, 3300, 0, 720, 725, 730, 750, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 62: 1280x720@30Hz */ + { MODEPREFIX, 297000, 1920, 2008, 2052, 2200, 0, 1080, 1084, 1089, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 63: 1920x1080@120Hz */ + { MODEPREFIX, 297000, 1920, 2448, 2492, 2640, 0, 1080, 1084, 1094, 1125, 0, V_PHSYNC | V_PVSYNC, MODESUFFIX }, /* VIC 64:1920x1080@100Hz */ +}; + +/* chose mode line by cea short video descriptor*/ +static void handle_cea_svd(struct cea_video_block *video, void *data) +{ + DisplayModePtr Mode; + DisplayModePtr *Modes = (DisplayModePtr *) data; + int vid; + + vid = video ->video_code & 0x7f; + if (vid < CEA_VIDEO_MODES_NUM) { + Mode = xf86DuplicateMode(CEAVideoModes + vid); + *Modes = xf86ModesAdd(*Modes, Mode); + } +} + +static DisplayModePtr +DDCModesFromCEAExtension(int scrnIndex, xf86MonPtr MonPtr) +{ + DisplayModePtr Modes = NULL; + + xf86ForEachVideoBlock(MonPtr, + handle_cea_svd, + &Modes); + + return Modes; +} + +struct det_modes_parameter { + xf86MonPtr DDC; + ddc_quirk_t quirks; + DisplayModePtr Modes; + Bool rb; + Bool preferred; + int timing_level; +}; + +static void handle_detailed_modes(struct detailed_monitor_section *det_mon, + void *data) +{ + DisplayModePtr Mode; + struct det_modes_parameter *p = (struct det_modes_parameter *)data; + + xf86DetTimingApplyQuirks(det_mon,p->quirks, + p->DDC->features.hsize, + p->DDC->features.vsize); + + switch (det_mon->type) { + case DT: + Mode = DDCModeFromDetailedTiming(p->DDC->scrnIndex, + &det_mon->section.d_timings, + p->preferred, + p->quirks); + p->preferred = FALSE; + p->Modes = xf86ModesAdd(p->Modes, Mode); + break; + case DS_STD_TIMINGS: + Mode = DDCModesFromStandardTiming(det_mon->section.std_t, + p->quirks, p->timing_level,p->rb); + p->Modes = xf86ModesAdd(p->Modes, Mode); + break; + case DS_CVT: + Mode = DDCModesFromCVT(p->DDC->scrnIndex, det_mon->section.cvt); + p->Modes = xf86ModesAdd(p->Modes, Mode); + break; + case DS_EST_III: + Mode = DDCModesFromEstIII(det_mon->section.est_iii); + p->Modes = xf86ModesAdd(p->Modes, Mode); + break; + default: + break; + } +} + +DisplayModePtr +xf86DDCGetModes(int scrnIndex, xf86MonPtr DDC) +{ + DisplayModePtr Modes = NULL, Mode; + ddc_quirk_t quirks; + Bool preferred, rb; + int timing_level; + struct det_modes_parameter p; + + xf86DrvMsg (scrnIndex, X_INFO, "EDID vendor \"%s\", prod id %d\n", + DDC->vendor.name, DDC->vendor.prod_id); + + quirks = xf86DDCDetectQuirks(scrnIndex, DDC, TRUE); + + preferred = PREFERRED_TIMING_MODE(DDC->features.msc); + if (DDC->ver.revision >= 4) + preferred = TRUE; + if (quirks & DDC_QUIRK_FIRST_DETAILED_PREFERRED) + preferred = TRUE; + if (quirks & (DDC_QUIRK_PREFER_LARGE_60 | DDC_QUIRK_PREFER_LARGE_75)) + preferred = FALSE; + + rb = xf86MonitorSupportsReducedBlanking(DDC); + + timing_level = MonitorStandardTimingLevel(DDC); + + p.quirks = quirks; + p.DDC = DDC; + p.Modes = Modes; + p.rb = rb; + p.preferred = preferred; + p.timing_level = timing_level; + xf86ForEachDetailedBlock(DDC, handle_detailed_modes, &p); + Modes = p.Modes; + + /* Add established timings */ + Mode = DDCModesFromEstablished(scrnIndex, &DDC->timings1, quirks); + Modes = xf86ModesAdd(Modes, Mode); + + /* Add standard timings */ + Mode = DDCModesFromStandardTiming(DDC->timings2, quirks, timing_level, rb); + Modes = xf86ModesAdd(Modes, Mode); + + /* Add cea-extension mode timings */ + Mode = DDCModesFromCEAExtension(scrnIndex,DDC); + Modes = xf86ModesAdd(Modes, Mode); + + if (quirks & DDC_QUIRK_PREFER_LARGE_60) + xf86DDCSetPreferredRefresh(scrnIndex, Modes, 60); + + if (quirks & DDC_QUIRK_PREFER_LARGE_75) + xf86DDCSetPreferredRefresh(scrnIndex, Modes, 75); + + Modes = xf86PruneDuplicateModes(Modes); + + return Modes; +} + +struct det_mon_parameter { + MonPtr Monitor; + ddc_quirk_t quirks; + Bool have_hsync; + Bool have_vrefresh; + Bool have_maxpixclock; +}; + +static void handle_detailed_monset(struct detailed_monitor_section *det_mon, + void *data) +{ + int clock; + struct det_mon_parameter *p = (struct det_mon_parameter *)data; + int scrnIndex = ((xf86MonPtr)(p->Monitor->DDC))->scrnIndex; + + switch (det_mon->type) { + case DS_RANGES: + if (!p->have_hsync) { + if (!p->Monitor->nHsync) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for horizontal sync\n"); + p->Monitor->hsync[p->Monitor->nHsync].lo = + det_mon->section.ranges.min_h; + p->Monitor->hsync[p->Monitor->nHsync].hi = + det_mon->section.ranges.max_h; + p->Monitor->nHsync++; + } else { + xf86DrvMsg(scrnIndex, X_INFO, + "Using hsync ranges from config file\n"); + } + + if (!p->have_vrefresh) { + if (!p->Monitor->nVrefresh) + xf86DrvMsg(scrnIndex, X_INFO, + "Using EDID range info for vertical refresh\n"); + p->Monitor->vrefresh[p->Monitor->nVrefresh].lo = + det_mon->section.ranges.min_v; + p->Monitor->vrefresh[p->Monitor->nVrefresh].hi = + det_mon->section.ranges.max_v; + p->Monitor->nVrefresh++; + } else { + xf86DrvMsg(scrnIndex, X_INFO, + "Using vrefresh ranges from config file\n"); + } + + clock = det_mon->section.ranges.max_clock * 1000; + if (p->quirks & DDC_QUIRK_DVI_SINGLE_LINK) + clock = min(clock, 165000); + if (!p->have_maxpixclock && clock > p->Monitor->maxPixClock) + p->Monitor->maxPixClock = clock; + + break; + default: + break; + } +} + +/* + * Fill out MonPtr with xf86MonPtr information. + */ +void +xf86EdidMonitorSet(int scrnIndex, MonPtr Monitor, xf86MonPtr DDC) +{ + DisplayModePtr Modes = NULL, Mode; + struct det_mon_parameter p; + + if (!Monitor || !DDC) + return; + + Monitor->DDC = DDC; + + if (Monitor->widthmm <= 0 || Monitor->heightmm <= 0) { + Monitor->widthmm = 10 * DDC->features.hsize; + Monitor->heightmm = 10 * DDC->features.vsize; + } + + Monitor->reducedblanking = xf86MonitorSupportsReducedBlanking(DDC); + + Modes = xf86DDCGetModes(scrnIndex, DDC); + + /* Go through the detailed monitor sections */ + p.Monitor = Monitor; + p.quirks = xf86DDCDetectQuirks(scrnIndex, Monitor->DDC, FALSE); + p.have_hsync = (Monitor->nHsync != 0); + p.have_vrefresh = (Monitor->nVrefresh != 0); + p.have_maxpixclock = (Monitor->maxPixClock != 0); + xf86ForEachDetailedBlock(DDC, handle_detailed_monset, &p); + + if (Modes) { + /* Print Modes */ + xf86DrvMsg(scrnIndex, X_INFO, "Printing DDC gathered Modelines:\n"); + + Mode = Modes; + while (Mode) { + xf86PrintModeline(scrnIndex, Mode); + Mode = Mode->next; + } + + /* Do we still need ranges to be filled in? */ + if (!Monitor->nHsync || !Monitor->nVrefresh) + DDCGuessRangesFromModes(scrnIndex, Monitor, Modes); + + /* look for last Mode */ + Mode = Modes; + + while (Mode->next) + Mode = Mode->next; + + /* add to MonPtr */ + if (Monitor->Modes) { + Monitor->Last->next = Modes; + Modes->prev = Monitor->Last; + Monitor->Last = Mode; + } else { + Monitor->Modes = Modes; + Monitor->Last = Mode; + } + } +} diff --git a/xorg-server/hw/xfree86/os-support/Makefile.am b/xorg-server/hw/xfree86/os-support/Makefile.am index c0504d5eb..3af4328ff 100644 --- a/xorg-server/hw/xfree86/os-support/Makefile.am +++ b/xorg-server/hw/xfree86/os-support/Makefile.am @@ -1,26 +1,26 @@ -SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS)
-DIST_SUBDIRS = bsd bus misc linux solaris sco hurd
-
-sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h
-
-EXTRA_DIST = int10Defines.h xf86OSpriv.h
-
-# to get the grouping semantics right, you have to glom these three together
-# as one library, otherwise libtool will actively defeat your attempts to
-# list them multiple times on the link line.
-noinst_LTLIBRARIES = libxorgos.la
-libxorgos_la_SOURCES = xorgos.c
-libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \
- bus/libbus.la \
- misc/libmisc.la
-
-AM_CFLAGS = $(DIX_CFLAGS)
-
-xorgos.c:
- touch $@
-
-DISTCLEANFILES = xorgos.c
-
-# FIXME: These don't seem to be used anywhere
-EXTRA_DIST += \
- shared/bios_devmem.c
+SUBDIRS = bus @XORG_OS_SUBDIR@ misc $(DRI_SUBDIRS) +DIST_SUBDIRS = bsd bus misc linux solaris hurd + +sdk_HEADERS = xf86_OSproc.h xf86_OSlib.h + +EXTRA_DIST = int10Defines.h xf86OSpriv.h + +# to get the grouping semantics right, you have to glom these three together +# as one library, otherwise libtool will actively defeat your attempts to +# list them multiple times on the link line. +noinst_LTLIBRARIES = libxorgos.la +libxorgos_la_SOURCES = xorgos.c +libxorgos_la_LIBADD = @XORG_OS_SUBDIR@/lib@XORG_OS_SUBDIR@.la \ + bus/libbus.la \ + misc/libmisc.la + +AM_CFLAGS = $(DIX_CFLAGS) + +xorgos.c: + touch $@ + +DISTCLEANFILES = xorgos.c + +# FIXME: These don't seem to be used anywhere +EXTRA_DIST += \ + shared/bios_devmem.c diff --git a/xorg-server/hw/xfree86/os-support/sco/Makefile.am b/xorg-server/hw/xfree86/os-support/sco/Makefile.am deleted file mode 100644 index b5d40f7a5..000000000 --- a/xorg-server/hw/xfree86/os-support/sco/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -EXTRA_DIST = \ - VTsw_sco.c \ - sco_init.c \ - sco_iop.c \ - sco_video.c diff --git a/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c b/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c deleted file mode 100644 index c9ef7d5cd..000000000 --- a/xorg-server/hw/xfree86/os-support/sco/VTsw_sco.c +++ /dev/null @@ -1,127 +0,0 @@ -/*
- * Copyright 1993 by David Wexelblat <dwex@goblin.org>
- * Copyright 1993 by David McCullough <davidm@stallion.oz.au>
- *
- * 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 David Wexelblat not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. David Wexelblat makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
- *
- * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL DAVID WEXELBLAT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
- *
- */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-/* For the event driver prototypes */
-#include <sys/event.h>
-#include <mouse.h>
-
-/*
- * Handle the VT-switching interface for SCO
- */
-
-/*
- * This function is the signal handler for the VT-switching signal. It
- * is only referenced inside the OS-support layer. NOTE: we do NOT need
- * to re-arm the signal here, since we used sigaction() to set the signal
- * disposition in sco_init.c. If we had used signal(), we would need to
- * re-arm the signal here. All we need to do now is record the fact that
- * we got the signal. XFree86 handles the rest.
- */
-void
-xf86VTRequest(int sig)
-{
- xf86Info.vtRequestsPending = TRUE;
- return;
-}
-
-Bool
-xf86VTSwitchPending(void)
-{
- return xf86Info.vtRequestsPending ? TRUE : FALSE;
-}
-
-/*
- * When we switch away, we need to flush and suspend the event driver
- * before the VT_RELDISP. We also need to get the current LED status
- * and preserve it, so that we can restore it when we come back.
- */
-static int sco_ledstatus = -1;
-static unsigned int sco_ledstate = 0;
-
-Bool
-xf86VTSwitchAway(void)
-{
- ev_flush();
- ev_suspend();
-
- sco_ledstatus = ioctl(xf86Info.consoleFd, KDGETLED, &sco_ledstate);
-
- xf86Info.vtRequestsPending = FALSE;
- if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_TRUE) < 0) {
- return FALSE;
- } else {
- return TRUE;
- }
-}
-
-/*
- * When we come back to the X server, we need to resume the event driver,
- * and we need to restore the LED settings to what they were when we
- * switched away.
- */
-Bool
-xf86VTSwitchTo(void)
-{
- ev_resume();
-
- xf86Info.vtRequestsPending = FALSE;
- if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) {
- return FALSE;
- } else {
- if (sco_ledstatus >= 0) {
- ioctl (xf86Info.consoleFd, KDSETLED, sco_ledstate);
- }
- sco_ledstatus = -1;
-
- /*
- * Convince the console driver this screen is in graphics mode,
- * otherwise it assumes it can do more to the screen than it should.
- */
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
- ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
- }
-
- return TRUE;
- }
-}
-
-Bool
-xf86VTActivate(int vtno)
-{
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, vtno - 1) < 0) {
- return FALSE;
- }
-
- return TRUE;
-}
diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_init.c b/xorg-server/hw/xfree86/os-support/sco/sco_init.c deleted file mode 100644 index fd4c898dd..000000000 --- a/xorg-server/hw/xfree86/os-support/sco/sco_init.c +++ /dev/null @@ -1,294 +0,0 @@ -/*
- * Copyright 2001-2005 by J. Kean Johnston <jkj@sco.com>
- *
- * 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 J. Kean Johnston not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. J. Kean Johnston makes no
- * representations about the suitability of this software for any purpose.
- * It is provided "as is" without express or implied warranty.
- *
- * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL J. KEAN JOHNSTON 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.
- */
-
-/* Re-written May 2001 to represent the current state of reality */
-
-#ifdef HAVE_XORG_CONFIG_H
-#include <xorg-config.h>
-#endif
-
-#include <X11/X.h>
-#include <X11/Xmd.h>
-
-#include "compiler.h"
-
-#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
-
-static Bool KeepTty = FALSE;
-static int VTnum = -1;
-static char vtdevice[48];
-static int sco_console_mode = -1;
-
-extern Bool mpxLock;
-
-void
-xf86OpenConsole(void)
-{
- int i, ioctl_ret;
- struct vt_mode VT;
- struct vid_info vidinf;
- struct sigaction sigvtsw;
- char *ttn;
-
- if (serverGeneration == 1) {
- /* check if we're run with euid==0 */
- if (geteuid() != 0) {
- FatalError("xf86OpenConsole: Server must be setuid root\n");
- }
-
- /* If we are run in the background we will get SIGTTOU. Ignore it. */
- OsSignal (SIGTTOU, SIG_IGN);
-
- /*
- * Set up the virtual terminal (multiscreen in SCO parlance).
- * For the actual console itself, screens are numbered from
- * 1 to (usually) 16. However, it is possible to have a nested
- * server, and it is also possible to be on a multi-console
- * system such as MaxSpeed or SunRiver. Therefore, we should
- * not make any assumptions about the TTY name we are on, and
- * instead we rely on ttyname() to give us the real TTY name.
- * Previously, we tried to determine the TTY name manually.
- * This is wrong. The only time we need to futz with the TTY name
- * is if we were given the name of a TTY to run on explicity on
- * the command line.
- */
-
- if (VTnum == -1) {
- /*
- * No device was specified. We need to query the kernel to see which
- * console device we are on (and in fact if we are on a console at all).
- */
- ttn = ttyname (1);
-
- if (ttn == (char *)0) {
- FatalError ("xf86OpenConsole: Could not determine TTY name: %s\n",
- strerror(errno));
- }
- strlcpy (vtdevice, ttn, sizeof(vtdevice));
- } else if (VTnum >= 0) {
- snprintf (vtdevice, sizeof(vtdevice), "/dev/tty%02d", VTnum);
- }
-
- /*
- * Now we can dispose of stdin/stdout
- */
- fclose (stdin);
- fclose (stdout);
-
- if ((xf86Info.consoleFd = open(vtdevice, O_RDWR | O_NDELAY, 0)) < 0) {
- FatalError("xf86OpenConsole: Cannot open %s: %s\n", vtdevice,
- strerror(errno));
- }
-
- /*
- * We make 100% sure we use the correct VT number. This can get ugly
- * where there are multi-consoles in use, so we make sure we query
- * the kernel for the correct VT number. It knows best, we don't.
- */
- vidinf.size = sizeof(vidinf);
- if (ioctl (xf86Info.consoleFd, CONS_GETINFO, &vidinf) < 0) {
- FatalError ("xf86OpenConsole: %s not a console device "
- "or error querying device: %s\n", vtdevice, strerror (errno));
- }
- xf86Info.vtno = vidinf.m_num;
- VTnum = vidinf.m_num + 1; /* 0-based */
-
- ErrorF("(using VT%02d device %s)\n\n", VTnum, vtdevice);
-
- /* We activate the console just in case its not the one we are on */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
- }
-
- /* Disassociate from controling TTY */
- if (!KeepTty) {
- setpgrp();
- }
-
- /*
- * Now we get the current mode that the console device is in. We will
- * use this later when we close the console device to restore it to
- * that same mode.
- */
- if ((sco_console_mode = ioctl(xf86Info.consoleFd, CONS_GET, 0L)) < 0) {
- FatalError("xf86OpenConsole: CONS_GET failed on console (%s)\n",
- strerror(errno));
- }
-
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) {
- FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n", strerror(errno));
- }
-
- sigvtsw.sa_handler = xf86VTRequest;
- sigfillset(&sigvtsw.sa_mask);
- sigvtsw.sa_flags = 0;
-
- /* NOTE: Using sigaction means we dont have to re-arm the signal */
- sigaction(SIGUSR1, &sigvtsw, NULL);
-
- VT.mode = VT_PROCESS;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
- VT.frsig = SIGINT; /* Not implemented */
- VT.waitv = 0;
-
- /*
- * The SCO X server tries the following call 5 times. Lets do the same
- * thing. It shouldn't really be required but sometimes things take a
- * while to settle down when switching screens. *helpless shrug* I know
- * its sucks but ...
- */
-
- ioctl_ret = 0;
- for (i = 0; i < 5; i++) {
- ioctl_ret = ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
- if (ioctl_ret >= 0)
- break;
- usleep(999999); /* Dont use nap() - it forces linking with -lx */
- }
-
- if (ioctl_ret < 0) {
- FatalError("xf86OpenConsole: VT_SETMODE failed (%s)\n", strerror(errno));
- }
-
- /*
- * Convince the console driver we are in graphics mode.
- */
- if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0) {
- ErrorF("Failed to set graphics mode (%s)\n", strerror(errno));
- }
- } else { /* serverGeneration != 1 */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0) {
- ErrorF("xf86OpenConsole: VT_ACTIVATE failed (%s)\n", strerror(errno));
- }
- }
-}
-
-/*
- * Restore the console to its previous state. This may cause flicker if
- * the screen was previous in a graphics mode, because we first set it
- * to text mode. This has the advantage of getting the console driver
- * to do a soft reset on the card, which really does help settle the
- * video card down again after coming out of Xfree86.
- */
-void
-xf86CloseConsole(void)
-{
- struct vt_mode VT;
- struct sigaction sigvtsw;
-
- /* Set text mode (possibly briefly) */
- ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT0);
-
- /* Restore the original mode */
- if (sco_console_mode != -1) {
- ioctl(xf86Info.consoleFd, MODESWITCH | sco_console_mode, 0L);
- }
-
- ioctl(xf86Info.consoleFd, VT_RELDISP, 1); /* Release the display */
-
- sigvtsw.sa_handler = SIG_DFL;
- sigfillset(&sigvtsw.sa_mask);
- sigvtsw.sa_flags = 0;
-
- sigaction(SIGUSR1, &sigvtsw, NULL);
-
- VT.mode = VT_AUTO;
- VT.waitv = 0;
- VT.relsig = SIGUSR1;
- VT.acqsig = SIGUSR1;
- VT.frsig = SIGINT;
- ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* Revert to auto handling */
-
- close(xf86Info.consoleFd); /* We're done with the device */
-}
-
-int
-xf86ProcessArgument(int argc, char *argv[], int i)
-{
- /*
- * Keep server from detaching from controlling tty. This is useful
- * when debugging (so the server can receive keyboard signals).
- */
- if (!strcmp(argv[i], "-keeptty")) {
- KeepTty = TRUE;
- return 1;
- }
-
- /*
- * By default, the X server wants to bind itself to CPU 0. This makes
- * sure that the server has full access to the I/O ports at IOPL 3.
- * Some SMP systems have trouble with I/O on CPU's other than 0. If,
- * however, you have a system that is well behaved, you can specify
- * this argument and let the scheduler decide which CPU the server
- * should run on.
- */
- if (!strcmp(argv[i], "-nompxlock")) {
- mpxLock = FALSE;
- return 1;
- }
-
- /*
- * Specify the VT number to run on (NOT the device).
- */
- if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
- if (sscanf(argv[i], "vt%2d", &VTnum) == 0) {
- UseMsg();
- VTnum = -1;
- return 0;
- }
- if (VTnum <= 0) {
- UseMsg();
- VTnum = -1;
- return 0;
- }
- return 1;
- }
-
- /*
- * Use a device the user specifies.
- */
- if (!strcmp(argv[i], "-crt")) {
- if (++i > argc) {
- UseMsg();
- VTnum = -1;
- return 0;
- } else {
- VTnum = -2;
- strlcpy (vtdevice, argv[i], sizeof(vtdevice));
- return 2;
- }
- }
- return 0;
-}
-
-void
-xf86UseMsg(void)
-{
- ErrorF("vtXX use the specified VT number\n");
- ErrorF("-crt DEVICE use the specified VT device\n");
- ErrorF("-nompxlock dont bind X server to CPU 0\n");
- ErrorF("-keeptty ");
- ErrorF("don't detach controlling tty (for debugging only)\n");
-}
diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_iop.c b/xorg-server/hw/xfree86/os-support/sco/sco_iop.c deleted file mode 100644 index 3da4fcf3a..000000000 --- a/xorg-server/hw/xfree86/os-support/sco/sco_iop.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2001 by J. Kean Johnston <jkj@caldera.com> - * - * 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 J. Kean Johnston not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. J. Kean Johnston makes no - * representations about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL J. KEAN JOHNSTON BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> - -#include "compiler.h" - -#define _NEED_SYSI86 -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86OSpriv.h" -#include "xf86_OSlib.h" - - -/***************************************************************************/ -/* I/O Permissions section */ -/***************************************************************************/ - -/* - * There is a right way and a wrong way of doing this. Unfortunately, we - * are forced to do it the wrong way. The right way is to be told the range - * or ranges of I/O ports the driver(s) need access to, in order to use the - * CONS_IOPERM ioctl() to grant access only to those ports we care about. - * This way we can guarantee some small level of stability because a driver - * does not have access to all ports (which would mean it could play with - * the PIT and thus affect scheduling times, or a whole slew of other - * nasty things). However, because XFree86 currently only enables or disables - * ALL port access, we need to run at IOPL 3, which basically means the - * X Server runs at the same level as the kernel. You can image why this is - * unsafe. Oh, and this is not a problem unique to OSR5, other OSes are - * affected by this as well. - * - * So, for the time being, we change our IOPL until such time as the XFree86 - * architecture is changed to allow for tighter control of I/O ports. If and - * when it is, then the CONS_ADDIOP/DELIOP ioctl() should be used to enable - * or disable access to the desired ports. - */ - -extern long sysi86 (int cmd, ...); - -static Bool IOEnabled = FALSE; - -Bool -xf86EnableIO(void) -{ - if (IOEnabled) - return TRUE; - - if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) { - xf86Msg(X_WARNING,"Failed to set IOPL for extended I/O\n"); - return FALSE; - } - - IOEnabled = TRUE; - return TRUE; -} - -void -xf86DisableIO(void) -{ - if (!IOEnabled) - return; - - sysi86(SI86V86, V86SC_IOPL, 0); - IOEnabled = FALSE; -} diff --git a/xorg-server/hw/xfree86/os-support/sco/sco_video.c b/xorg-server/hw/xfree86/os-support/sco/sco_video.c deleted file mode 100644 index f63b71df8..000000000 --- a/xorg-server/hw/xfree86/os-support/sco/sco_video.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * Copyright 2001 by J. Kean Johnston <jkj@sco.com> - * - * 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 J. Kean Johnston not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. J. Kean Johnston makes no - * representations about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - * - * J. KEAN JOHNSTON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL J. KEAN JOHNSTON 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. - */ - -/* Re-written May 2001 to represent the current state of reality */ - -/* - * This file contains the completely re-written SCO OpenServer video - * routines for XFree86 4.x. Much of this is based on the SCO X server - * code (which is an X11R5 server) and will probably only work on - * OpenServer versions 5.0.5, 5.0.6 and later. Please send me (jkj@sco.com) - * email if you have any questions. - * - * Ideally, you should use OSR5.0.6A or later, with the updated console - * driver for 5.0.6A (its the default driver in 5.0.7 and later). - * However, if you are running on an older system, this code will detect - * that and adjust accordingly. - */ - -#ifdef HAVE_XORG_CONFIG_H -#include <xorg-config.h> -#endif - -#include <X11/X.h> -#include "input.h" -#include "scrnintstr.h" - -#define _NEED_SYSI86 -#include "xf86.h" -#include "xf86Priv.h" -#include "xf86OSpriv.h" -#include "xf86_OSlib.h" - -#include <sys/ci/ciioctl.h> -#define MPXNAME "/dev/atp1" -#define BASECPU 1 - -Bool mpxLock = TRUE; - -#define USE_VASMETHOD 1 - -/***************************************************************************/ -/* Video Memory Mapping section */ -/***************************************************************************/ - -static int sco_mcdone = 0, sco_ismc = 0; - -/***************************************************************************/ -/* - * To map the video memory, we first need to see if we are on a multi-console - * system. If we are, we need to try to use an existing video class in the - * kernel. We do this by retrieving the list of currently defined classes - * (via the new CONS_GETCLASS ioctl()) to see if we have a class that will - * match the range of memory we desire. If we can't find one, we have an - * error and we abort. - * - * If we are not using a multi-console, we can simply use mmap() to map in - * the frame buffer, using the classs-access method as a fall-back only if - * the mmap() fails (it shouldn't). We always set the appropriate pointers - * in the config structure to point ot the right function to map and unmap - * the video memory. An alternative to using mmap() is to use the new - * CONS_ADDVAS call, which will use vasmalloc() and vasbind() in the kernel - * to map the physical address to a virtual one, which it then returns. - * I am not 100% sure if this is faster or not, but it may prove easier to - * debug things. Just to be on the safe side, I have included both methods - * here, and the mmap() method can be used by setting USE_VASMETHOD to 0 - * above. - */ - -#if !defined(CONS_ADDVAS) -# undef USE_VASMETHOD -# define USE_VASMETHOD 0 -#endif - -static int -scoIsMultiConsole (void) -{ - int x; - - if (sco_mcdone) - return sco_ismc; - x = access ("/usr/lib/vidconf/.multiconsole", F_OK); - if (x == 0) - sco_ismc = 1; - sco_mcdone = 1; - return sco_ismc; -} - -/* - * This maps memory using mmap() - */ -static pointer -mapVidMemMMAP(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - int fd; - unsigned long realBase, alignOff; - pointer base; - - fd = open (DEV_MEM, (flags & VIDMEM_READONLY) ? O_RDONLY : O_RDWR); - if (fd < 0) { - FatalError("xf86MapVidMem: failed to open %s (%s)\n", DEV_MEM, - strerror(errno)); - return 0; /* NOTREACHED */ - } - - realBase = Base & ~(getpagesize() - 1); - alignOff = Base - realBase; - - DebugF("base: %lx, realBase: %lx, alignOff: %lx\n", Base,realBase,alignOff); - - base = mmap((caddr_t)0, Size + alignOff, - (flags & VIDMEM_READONLY) ? PROT_READ : (PROT_READ | PROT_WRITE), - MAP_SHARED, fd, (off_t)realBase); - close(fd); - if (base == MAP_FAILED) { - FatalError("xf86MapVidMem: Could not mmap framebuffer (0x%08x,0x%x) (%s)\n", - Base, Size, strerror(errno)); - return 0; /* NOTREACHED */ - } - - DebugF("base: %lx aligned base: %lx\n",base, base + alignOff); - return (pointer)((char *)base + alignOff); -} - -#if (USE_VASMETHOD) -/* - * This maps memory using the virtual address space (VAS) console calls. - */ -static pointer -mapVidMemVAS(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - struct vidvasmem vas; - pointer base; - - vas.base = (long)Base; - vas.size = (long)Size; - - base = (pointer)ioctl (xf86Info.consoleFd, CONS_ADDVAS, &vas); - if (base == (pointer)-1) { - return mapVidMemMMAP(ScreenNum, Base, Size, flags); - } - return base; -} -#endif /* USE_VASMETHOD */ - -struct vidclass vidclasslist[] = { - { "VBE", "", 0xf0000000, 0x2000000, 0 }, - { "P9000", "", 0xc0000000, 0x400000, 0 }, - { "TULIP", "", 0x80000000, 0x400000, 0 }, - { "VIPER", "", 0xa0000000, 0x400000, 0 }, - { "S3T", "", 0xa0000000, 0x200000, 0 }, - { "S3DT", "", 0x4000000, 0x400000, 0 }, - { "MGA", "", 0x2200000, 0x4000, 0 }, - { "CLVGA", "", 0xa0000, 0x20000, 0 }, - { "OLIVE", "", 0xd8000000, 0x400000, 0 }, - { "S3C", "", 0xa0000, 0x10000, 0 }, - { "MGAVLB", "", 0xac000, 0x34000, 0 }, - { "ATI8514", "", 0xFF000, 0x1000, 0 }, - { "GXREGS", "", 0xb0000, 0x10000, 0 }, - { "GX", "", 0xa0000, 0x10000, 0 }, - { "CT64300", "", 0xa0000000, 0x400000, 0 }, - { "SVGA", "", 0xa0000, 0x20000, 0 }, - { "S3V", "", 0xa0000000, 0x400000, 0 }, - { "8514A", "", 0xFF000, 0x1000, 0 }, - { "VGA", "", 0xa0000, 0x10000, 0 }, - { 0 } -}; - -static pointer -mapVidMemVC(int ScreenNum, unsigned long Base, unsigned long Size, int flags) -{ - struct vidclass *vcp; - char *class = NULL; - pointer base; - - for (vcp = vidclasslist; vcp->name; vcp++) { - if ((vcp->base == Base) && (vcp->size == Size)) { - class = vcp->name; - break; - } - } - - if (class == NULL) { - /* - * As a fall-back, we will try and use the mmap() approach. This may - * prove to be the wrong thing to do, but time and testing will tell. - */ - ErrorF("xf86MapVidMem: No class map defined for (0x%08x,0x%08x)\n", Base, Size); -#if USE_VASMETHOD - return mapVidMemVAS(ScreenNum, Base, Size, flags); -#else /* !USE_VASMETHOD */ - return mapVidMemMMAP(ScreenNum, Base, Size, flags); -#endif - } - - /* - * We found a suitable class. Try and use it. - */ - base = (pointer)ioctl(xf86Info.consoleFd, MAP_CLASS, class); - if ((int)base == -1) { - FatalError("xf86MapVidMem: Failed to map video memory class `%s'\n", class); - return 0; /* NOTREACHED */ - } - - return base; -} - -/* - * Unmapping the video memory is easy. We always call munmap(), as it is - * safe to do so even if we haven't actually mapped in any pages via mmap(). - * In the case where we used the video class, we don't need to do anything - * as the kernel will clean up the TSS when we exit, and will undo the - * vasbind() that was done when the class was originally mapped. If we used - * vasmap, we simply undo the map. Again, it is benign to call vasunmap - * even if we got the frame buffer via some other mechanism (like mmap). - */ - -static void -unmapVidMem(int ScreenNum, pointer Base, unsigned long Size) -{ -#if USE_VASMETHOD - struct vidvasmem vas; - int x; - - vas.base = (long)Base; - vas.size = (long)Size; - - x = ioctl (xf86Info.consoleFd, CONS_DELVAS, &vas); - if (x == 0) - return; -#endif /* USE_VASMETHOD */ - - munmap(Base, Size); -} - -/* - * Set things up to point to our local functions. When the kernel gets - * MTRR support, we will need to add the required functions for that - * here too. MTRR support will most likely appear in 5.0.8 or 5.1.0. - * - * We also want to lock the X server process to the base CPU in an MPX - * system, since we will be going to IOPL 3. Most engine drivers can cope - * with I/O access on any CPU but there are a few (AST Manhattan I believe) - * that can't, so the server needs to be locked to CPU0. - */ -void -xf86OSInitVidMem(VidMemInfoPtr pVidMem) -{ - int mpx_fd; - - if (scoIsMultiConsole ()) { - pVidMem->mapMem = mapVidMemVC; - } else { -#if USE_VASMETHOD - pVidMem->mapMem = mapVidMemVAS; -#else - pVidMem->mapMem = mapVidMemMMAP; -#endif - } - - pVidMem->unmapMem = unmapVidMem; - pVidMem->linearSupported = TRUE; - pVidMem->initialised = TRUE; - - if (mpxLock && (mpx_fd = open (MPXNAME, O_RDONLY)) > 0) { - if (ioctl (mpx_fd, ACPU_XLOCK, BASECPU) < 0) - ErrorF ("xf86OSInitVidMem: Can not bind to CPU 0 (%s)\n", - strerror(errno)); - close (mpx_fd); - } -} - diff --git a/xorg-server/hw/xfree86/os-support/xf86_OSlib.h b/xorg-server/hw/xfree86/os-support/xf86_OSlib.h index c53fc0dac..3b646da70 100644 --- a/xorg-server/hw/xfree86/os-support/xf86_OSlib.h +++ b/xorg-server/hw/xfree86/os-support/xf86_OSlib.h @@ -85,22 +85,11 @@ /**************************************************************************/ #if (defined(SYSV) || defined(SVR4)) && \ (defined(sun) || defined(__i386__)) -# ifdef SCO325 -# ifndef _SVID3 -# define _SVID3 -# endif -# ifndef _NO_STATIC -# define _NO_STATIC -# endif -# endif # include <sys/ioctl.h> # include <signal.h> # include <termio.h> # include <sys/stat.h> # include <sys/types.h> -# if defined(__SCO__) -# include <sys/param.h> -# endif # include <errno.h> @@ -140,15 +129,7 @@ # if !defined(sun) # include <sys/emap.h> # endif -# if defined(SCO325) -# include <sys/vtkd.h> -# include <sys/console.h> -# include <sys/scankbd.h> -# include <sys/vid.h> -# define LED_CAP CLKED -# define LED_NUM NLKED -# define LED_SCR SLKED -# elif defined(HAS_USL_VTS) +# if defined(HAS_USL_VTS) # if !defined(sun) # include <sys/at_ansi.h> # endif @@ -177,20 +158,12 @@ # define VT_ACKACQ 2 # endif /* !VT_ACKACQ */ -# if defined(__SCO__) -# include <sys/sysmacros.h> -# define POSIX_TTY -# endif /* __SCO__ */ -# if defined(SVR4) || defined(SCO325) +# if defined(SVR4) # include <sys/mman.h> # if !(defined(sun) && defined (SVR4)) # define DEV_MEM "/dev/pmem" # endif -# ifdef SCO325 -# undef DEV_MEM -# define DEV_MEM "/dev/mem" -# endif # define CLEARDTR_SUPPORT # define POSIX_TTY # endif /* SVR4 */ diff --git a/xorg-server/hw/xfree86/parser/Makefile.am b/xorg-server/hw/xfree86/parser/Makefile.am index 6fe7b87c1..fb5d49e88 100644 --- a/xorg-server/hw/xfree86/parser/Makefile.am +++ b/xorg-server/hw/xfree86/parser/Makefile.am @@ -1,51 +1,51 @@ -if INSTALL_LIBXF86CONFIG
-noinst_LTLIBRARIES = libxf86config_internal.la
-lib_LIBRARIES = libxf86config.a
-LIBHEADERS = \
- xf86Optrec.h \
- xf86Parser.h
-else
-noinst_LTLIBRARIES = libxf86config_internal.la
-endif
-
-INTERNAL_SOURCES= \
- Device.c \
- Files.c \
- Flags.c \
- Input.c \
- InputClass.c \
- Layout.c \
- Module.c \
- Video.c \
- Monitor.c \
- Pointer.c \
- Screen.c \
- Vendor.c \
- read.c \
- scan.c \
- write.c \
- DRI.c \
- Extensions.c
-
-libxf86config_internal_la_SOURCES = \
- $(INTERNAL_SOURCES)
-
-libxf86config_a_SOURCES = \
- $(TOP_SRCDIR)/os/xprintf.c \
- $(INTERNAL_SOURCES)
-libxf86config_a_CFLAGS = $(AM_CFLAGS)
-
-AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) \
- -DSYSCONFDIR=\"$(sysconfdir)\" \
- -DDATADIR=\"$(datadir)\"
-
-EXTRA_DIST = \
- Configint.h \
- configProcs.h \
- xf86Optrec.h \
- xf86Parser.h \
- xf86tokens.h
-
-sdk_HEADERS = \
- xf86Parser.h \
- xf86Optrec.h
+if INSTALL_LIBXF86CONFIG +noinst_LTLIBRARIES = libxf86config_internal.la +lib_LIBRARIES = libxf86config.a +LIBHEADERS = \ + xf86Optrec.h \ + xf86Parser.h +else +noinst_LTLIBRARIES = libxf86config_internal.la +endif + +INTERNAL_SOURCES= \ + Device.c \ + Files.c \ + Flags.c \ + Input.c \ + InputClass.c \ + Layout.c \ + Module.c \ + Video.c \ + Monitor.c \ + Pointer.c \ + Screen.c \ + Vendor.c \ + read.c \ + scan.c \ + write.c \ + DRI.c \ + Extensions.c + +libxf86config_internal_la_SOURCES = \ + $(INTERNAL_SOURCES) + +libxf86config_a_SOURCES = \ + $(top_srcdir)/os/xprintf.c \ + $(INTERNAL_SOURCES) +libxf86config_a_CFLAGS = $(AM_CFLAGS) + +AM_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) \ + -DSYSCONFDIR=\"$(sysconfdir)\" \ + -DDATADIR=\"$(datadir)\" + +EXTRA_DIST = \ + Configint.h \ + configProcs.h \ + xf86Optrec.h \ + xf86Parser.h \ + xf86tokens.h + +sdk_HEADERS = \ + xf86Parser.h \ + xf86Optrec.h diff --git a/xorg-server/os/access.c b/xorg-server/os/access.c index bb857a0f3..4684b6466 100644 --- a/xorg-server/os/access.c +++ b/xorg-server/os/access.c @@ -1,2102 +1,2098 @@ -/***********************************************************
-
-Copyright 1987, 1998 The Open Group
-
-All rights reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, and/or sell copies of the Software, and to permit persons
-to whom the Software is furnished to do so, provided that the above
-copyright notice(s) and this permission notice appear in all copies of
-the Software and that both the above copyright notice(s) and this
-permission notice appear in supporting documentation.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
-OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
-HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
-INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
-FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
-NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
-WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-Except as contained in this notice, the name of a copyright holder
-shall not be used in advertising or otherwise to promote the sale, use
-or other dealings in this Software without prior written authorization
-of the copyright holder.
-
-X Window System is a trademark of 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 (c) 2004, 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#ifdef WIN32
-#include <X11/Xwinsock.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#define XSERV_t
-#define TRANS_SERVER
-#define TRANS_REOPEN
-#include <X11/Xtrans/Xtrans.h>
-#include <X11/Xauth.h>
-#include <X11/X.h>
-#include <X11/Xproto.h>
-#include "misc.h"
-#include "site.h"
-#include <errno.h>
-#include <sys/types.h>
-#ifndef WIN32
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <ctype.h>
-
-#if defined(TCPCONN) || defined(STREAMSCONN) || defined(__SCO__)
-#include <netinet/in.h>
-#endif /* TCPCONN || STREAMSCONN || __SCO__ */
-
-#ifdef HAS_GETPEERUCRED
-# include <ucred.h>
-# ifdef sun
-# include <zone.h>
-# endif
-#endif
-
-#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__)
-# include <sys/utsname.h>
-#endif
-#if defined(SYSV) && defined(__i386__)
-# include <sys/stream.h>
-#endif
-#ifdef __GNU__
-#undef SIOCGIFCONF
-#include <netdb.h>
-#else /*!__GNU__*/
-# include <net/if.h>
-#endif /*__GNU__ */
-
-#ifdef SVR4
-#include <sys/sockio.h>
-#include <sys/stropts.h>
-#endif
-
-#include <netdb.h>
-
-#ifdef CSRG_BASED
-#include <sys/param.h>
-#if (BSD >= 199103)
-#define VARIABLE_IFREQ
-#endif
-#endif
-
-#ifdef BSD44SOCKETS
-#ifndef VARIABLE_IFREQ
-#define VARIABLE_IFREQ
-#endif
-#endif
-
-#ifdef HAS_GETIFADDRS
-#include <ifaddrs.h>
-#endif
-
-/* Solaris provides an extended interface SIOCGLIFCONF. Other systems
- * may have this as well, but the code has only been tested on Solaris
- * so far, so we only enable it there. Other platforms may be added as
- * needed.
- *
- * Test for Solaris commented out -- TSI @ UQV 2003.06.13
- */
-#ifdef SIOCGLIFCONF
-/* #if defined(sun) */
-#define USE_SIOCGLIFCONF
-/* #endif */
-#endif
-
-#endif /* WIN32 */
-
-#ifndef PATH_MAX
-#include <sys/param.h>
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-#endif
-
-#ifdef __SCO__
-/* The system defined value is wrong. MAXPATHLEN is set in sco5.cf. */
-#undef PATH_MAX
-#endif
-
-#define X_INCLUDE_NETDB_H
-#include <X11/Xos_r.h>
-
-#include "dixstruct.h"
-#include "osdep.h"
-
-#include "xace.h"
-
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-
-Bool defeatAccessControl = FALSE;
-
-#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len)
-#define acopy(a1, a2, len) memmove((char *)(a2), (char *)(a1), len)
-#define addrEqual(fam, address, length, host) \
- ((fam) == (host)->family &&\
- (length) == (host)->len &&\
- !acmp (address, (host)->addr, length))
-
-static int ConvertAddr(struct sockaddr * /*saddr*/,
- int * /*len*/,
- pointer * /*addr*/);
-
-static int CheckAddr(int /*family*/,
- const void * /*pAddr*/,
- unsigned /*length*/);
-
-static Bool NewHost(int /*family*/,
- const void * /*addr*/,
- int /*len*/,
- int /* addingLocalHosts */);
-
-/* XFree86 bug #156: To keep track of which hosts were explicitly requested in
- /etc/X<display>.hosts, we've added a requested field to the HOST struct,
- and a LocalHostRequested variable. These default to FALSE, but are set
- to TRUE in ResetHosts when reading in /etc/X<display>.hosts. They are
- checked in DisableLocalHost(), which is called to disable the default
- local host entries when stronger authentication is turned on. */
-
-typedef struct _host {
- short family;
- short len;
- unsigned char *addr;
- struct _host *next;
- int requested;
-} HOST;
-
-#define MakeHost(h,l) (h)=malloc(sizeof *(h)+(l));\
- if (h) { \
- (h)->addr=(unsigned char *) ((h) + 1);\
- (h)->requested = FALSE; \
- }
-#define FreeHost(h) free(h)
-static HOST *selfhosts = NULL;
-static HOST *validhosts = NULL;
-static int AccessEnabled = DEFAULT_ACCESS_CONTROL;
-static int LocalHostEnabled = FALSE;
-static int LocalHostRequested = FALSE;
-static int UsingXdmcp = FALSE;
-
-/* FamilyServerInterpreted implementation */
-static Bool siAddrMatch(int family, pointer addr, int len, HOST *host,
- ClientPtr client);
-static int siCheckAddr(const char *addrString, int length);
-static void siTypesInitialize(void);
-
-/*
- * called when authorization is not enabled to add the
- * local host to the access list
- */
-
-void
-EnableLocalHost (void)
-{
- if (!UsingXdmcp)
- {
- LocalHostEnabled = TRUE;
- AddLocalHosts ();
- }
-}
-
-/*
- * called when authorization is enabled to keep us secure
- */
-void
-DisableLocalHost (void)
-{
- HOST *self;
-
- if (!LocalHostRequested) /* Fix for XFree86 bug #156 */
- LocalHostEnabled = FALSE;
- for (self = selfhosts; self; self = self->next) {
- if (!self->requested) /* Fix for XFree86 bug #156 */
- (void) RemoveHost ((ClientPtr)NULL, self->family, self->len, (pointer)self->addr);
- }
-}
-
-/*
- * called at init time when XDMCP will be used; xdmcp always
- * adds local hosts manually when needed
- */
-
-void
-AccessUsingXdmcp (void)
-{
- UsingXdmcp = TRUE;
- LocalHostEnabled = FALSE;
-}
-
-
-#if defined(SVR4) && !defined(SCO325) && !defined(sun) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF)
-
-/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */
-
-static int
-ifioctl (int fd, int cmd, char *arg)
-{
- struct strioctl ioc;
- int ret;
-
- memset((char *) &ioc, 0, sizeof(ioc));
- ioc.ic_cmd = cmd;
- ioc.ic_timout = 0;
- if (cmd == SIOCGIFCONF)
- {
- ioc.ic_len = ((struct ifconf *) arg)->ifc_len;
- ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf;
- }
- else
- {
- ioc.ic_len = sizeof(struct ifreq);
- ioc.ic_dp = arg;
- }
- ret = ioctl(fd, I_STR, (char *) &ioc);
- if (ret >= 0 && cmd == SIOCGIFCONF)
-#ifdef SVR4
- ((struct ifconf *) arg)->ifc_len = ioc.ic_len;
-#endif
- return ret;
-}
-#else /* Case sun, SCO325 and others */
-#define ifioctl ioctl
-#endif
-
-/*
- * DefineSelf (fd):
- *
- * Define this host for access control. Find all the hosts the OS knows about
- * for this fd and add them to the selfhosts list.
- */
-
-#if !defined(SIOCGIFCONF)
-void
-DefineSelf (int fd)
-{
-#if !defined(TCPCONN) && !defined(STREAMSCONN) && !defined(UNIXCONN)
- return;
-#else
- register int n;
- int len;
- caddr_t addr;
- int family;
- register HOST *host;
-
-#ifndef WIN32
- struct utsname name;
-#else
- struct {
- char nodename[512];
- } name;
-#endif
-
- register struct hostent *hp;
-
- union {
- struct sockaddr sa;
- struct sockaddr_in in;
-#if defined(IPv6) && defined(AF_INET6)
- struct sockaddr_in6 in6;
-#endif
- } saddr;
-
- struct sockaddr_in *inetaddr;
- struct sockaddr_in6 *inet6addr;
- struct sockaddr_in broad_addr;
-#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
- _Xgethostbynameparams hparams;
-#endif
-
- /* Why not use gethostname()? Well, at least on my system, I've had to
- * make an ugly kernel patch to get a name longer than 8 characters, and
- * uname() lets me access to the whole string (it smashes release, you
- * see), whereas gethostname() kindly truncates it for me.
- */
-#ifndef WIN32
- uname(&name);
-#else
- gethostname(name.nodename, sizeof(name.nodename));
-#endif
-
- hp = _XGethostbyname(name.nodename, hparams);
- if (hp != NULL)
- {
- #ifdef h_addr
- #define hp_addr *list
- char **list;
-
- /* iterate over the addresses */
- for (list = hp->h_addr_list; *list; list++)
- #else
- #define hp_addr hp->h_addr
- #endif
- {
- saddr.sa.sa_family = hp->h_addrtype;
- switch (hp->h_addrtype) {
- case AF_INET:
- inetaddr = (struct sockaddr_in *) (&(saddr.sa));
- acopy ( hp_addr, &(inetaddr->sin_addr), hp->h_length);
- len = sizeof(saddr.sa);
- break;
-#if defined(IPv6) && defined(AF_INET6)
- case AF_INET6:
- inet6addr = (struct sockaddr_in6 *) (&(saddr.sa));
- acopy ( hp_addr, &(inet6addr->sin6_addr), hp->h_length);
- len = sizeof(saddr.in6);
- break;
-#endif
- default:
- goto DefineLocalHost;
- }
- family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr);
- if ( family != -1 && family != FamilyLocal )
- {
- for (host = selfhosts;
- host && !addrEqual (family, addr, len, host);
- host = host->next) ;
- if (!host)
- {
- /* add this host to the host list. */
- MakeHost(host,len)
- if (host)
- {
- host->family = family;
- host->len = len;
- acopy ( addr, host->addr, len);
- host->next = selfhosts;
- selfhosts = host;
- }
- #ifdef XDMCP
- /*
- * If this is an Internet Address, but not the localhost
- * address (127.0.0.1), nor the bogus address (0.0.0.0),
- * register it.
- */
- if (family == FamilyInternet &&
- !(len == 4 &&
- ((addr[0] == 127) ||
- (addr[0] == 0 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 0)))
- )
- {
- XdmcpRegisterConnection (family, (char *)addr, len);
- broad_addr = *inetaddr;
- ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
- htonl (INADDR_BROADCAST);
- XdmcpRegisterBroadcastAddress ((struct sockaddr_in *)
- &broad_addr);
- }
- #if defined(IPv6) && defined(AF_INET6)
- else if (family == FamilyInternet6 &&
- !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)))
- {
- XdmcpRegisterConnection (family, (char *)addr, len);
- }
- #endif
-
- #endif /* XDMCP */
- }
- }
- }
- }
- /*
- * now add a host of family FamilyLocalHost...
- */
-DefineLocalHost:
- for (host = selfhosts;
- host && !addrEqual(FamilyLocalHost, "", 0, host);
- host = host->next);
- if (!host)
- {
- MakeHost(host, 0);
- if (host)
- {
- host->family = FamilyLocalHost;
- host->len = 0;
- acopy("", host->addr, 0);
- host->next = selfhosts;
- selfhosts = host;
- }
- }
-#endif /* !TCPCONN && !STREAMSCONN && !UNIXCONN */
-}
-
-#else
-
-#ifdef USE_SIOCGLIFCONF
-#define ifr_type struct lifreq
-#else
-#define ifr_type struct ifreq
-#endif
-
-#ifdef VARIABLE_IFREQ
-#define ifr_size(p) (sizeof (struct ifreq) + \
- (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \
- p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0))
-#define ifraddr_size(a) (a.sa_len)
-#else
-#define ifr_size(p) (sizeof (ifr_type))
-#define ifraddr_size(a) (sizeof (a))
-#endif
-
-#if defined(IPv6) && defined(AF_INET6)
-#include <arpa/inet.h>
-#endif
-
-#if defined(IPv6) && defined(AF_INET6)
-static void
-in6_fillscopeid(struct sockaddr_in6 *sin6)
-{
-#if defined(__KAME__)
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
- sin6->sin6_scope_id =
- ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]);
- sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0;
- }
-#endif
-}
-#endif
-
-void
-DefineSelf (int fd)
-{
-#ifndef HAS_GETIFADDRS
- char *cp, *cplim;
-# ifdef USE_SIOCGLIFCONF
- struct sockaddr_storage buf[16];
- struct lifconf ifc;
- register struct lifreq *ifr;
-# ifdef SIOCGLIFNUM
- struct lifnum ifn;
-# endif
-# else /* !USE_SIOCGLIFCONF */
- char buf[2048];
- struct ifconf ifc;
- register struct ifreq *ifr;
-# endif
- void * bufptr = buf;
-#else /* HAS_GETIFADDRS */
- struct ifaddrs * ifap, *ifr;
-#endif
- int len;
- unsigned char * addr;
- int family;
- register HOST *host;
-
-#ifndef HAS_GETIFADDRS
-
- len = sizeof(buf);
-
-#ifdef USE_SIOCGLIFCONF
-
-#ifdef SIOCGLIFNUM
- ifn.lifn_family = AF_UNSPEC;
- ifn.lifn_flags = 0;
- if (ioctl (fd, SIOCGLIFNUM, (char *) &ifn) < 0)
- Error ("Getting interface count");
- if (len < (ifn.lifn_count * sizeof(struct lifreq))) {
- len = ifn.lifn_count * sizeof(struct lifreq);
- bufptr = malloc(len);
- }
-#endif
-
- ifc.lifc_family = AF_UNSPEC;
- ifc.lifc_flags = 0;
- ifc.lifc_len = len;
- ifc.lifc_buf = bufptr;
-
-#define IFC_IOCTL_REQ SIOCGLIFCONF
-#define IFC_IFC_REQ ifc.lifc_req
-#define IFC_IFC_LEN ifc.lifc_len
-#define IFR_IFR_ADDR ifr->lifr_addr
-#define IFR_IFR_NAME ifr->lifr_name
-
-#else /* Use SIOCGIFCONF */
- ifc.ifc_len = len;
- ifc.ifc_buf = bufptr;
-
-#define IFC_IOCTL_REQ SIOCGIFCONF
-#define IFC_IFC_REQ ifc.ifc_req
-#define IFC_IFC_LEN ifc.ifc_len
-#define IFR_IFR_ADDR ifr->ifr_addr
-#define IFR_IFR_NAME ifr->ifr_name
-#endif
-
- if (ifioctl (fd, IFC_IOCTL_REQ, (pointer) &ifc) < 0)
- Error ("Getting interface configuration (4)");
-
- cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN;
-
- for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr))
- {
- ifr = (ifr_type *) cp;
- len = ifraddr_size (IFR_IFR_ADDR);
- family = ConvertAddr ((struct sockaddr *) &IFR_IFR_ADDR,
- &len, (pointer *)&addr);
- if (family == -1 || family == FamilyLocal)
- continue;
-#if defined(IPv6) && defined(AF_INET6)
- if (family == FamilyInternet6)
- in6_fillscopeid((struct sockaddr_in6 *)&IFR_IFR_ADDR);
-#endif
- for (host = selfhosts;
- host && !addrEqual (family, addr, len, host);
- host = host->next)
- ;
- if (host)
- continue;
- MakeHost(host,len)
- if (host)
- {
- host->family = family;
- host->len = len;
- acopy(addr, host->addr, len);
- host->next = selfhosts;
- selfhosts = host;
- }
-#ifdef XDMCP
- {
-#ifdef USE_SIOCGLIFCONF
- struct sockaddr_storage broad_addr;
-#else
- struct sockaddr broad_addr;
-#endif
-
- /*
- * If this isn't an Internet Address, don't register it.
- */
- if (family != FamilyInternet
-#if defined(IPv6) && defined(AF_INET6)
- && family != FamilyInternet6
-#endif
- )
- continue;
-
- /*
- * ignore 'localhost' entries as they're not useful
- * on the other end of the wire
- */
- if (family == FamilyInternet &&
- addr[0] == 127 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 1)
- continue;
-#if defined(IPv6) && defined(AF_INET6)
- else if (family == FamilyInternet6 &&
- IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
- continue;
-#endif
-
- /*
- * Ignore '0.0.0.0' entries as they are
- * returned by some OSes for unconfigured NICs but they are
- * not useful on the other end of the wire.
- */
- if (len == 4 &&
- addr[0] == 0 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 0)
- continue;
-
- XdmcpRegisterConnection (family, (char *)addr, len);
-
-#if defined(IPv6) && defined(AF_INET6)
- /* IPv6 doesn't support broadcasting, so we drop out here */
- if (family == FamilyInternet6)
- continue;
-#endif
-
- broad_addr = IFR_IFR_ADDR;
-
- ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr =
- htonl (INADDR_BROADCAST);
-#if defined(USE_SIOCGLIFCONF) && defined(SIOCGLIFBRDADDR)
- {
- struct lifreq broad_req;
-
- broad_req = *ifr;
- if (ioctl (fd, SIOCGLIFFLAGS, (char *) &broad_req) != -1 &&
- (broad_req.lifr_flags & IFF_BROADCAST) &&
- (broad_req.lifr_flags & IFF_UP)
- )
- {
- broad_req = *ifr;
- if (ioctl (fd, SIOCGLIFBRDADDR, &broad_req) != -1)
- broad_addr = broad_req.lifr_broadaddr;
- else
- continue;
- }
- else
- continue;
- }
-
-#elif defined(SIOCGIFBRDADDR)
- {
- struct ifreq broad_req;
-
- broad_req = *ifr;
- if (ifioctl (fd, SIOCGIFFLAGS, (pointer) &broad_req) != -1 &&
- (broad_req.ifr_flags & IFF_BROADCAST) &&
- (broad_req.ifr_flags & IFF_UP)
- )
- {
- broad_req = *ifr;
- if (ifioctl (fd, SIOCGIFBRDADDR, (pointer) &broad_req) != -1)
- broad_addr = broad_req.ifr_addr;
- else
- continue;
- }
- else
- continue;
- }
-#endif /* SIOCGIFBRDADDR */
- XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) &broad_addr);
- }
-#endif /* XDMCP */
- }
- if (bufptr != buf)
- free(bufptr);
-#else /* HAS_GETIFADDRS */
- if (getifaddrs(&ifap) < 0) {
- ErrorF("Warning: getifaddrs returns %s\n", strerror(errno));
- return;
- }
- for (ifr = ifap; ifr != NULL; ifr = ifr->ifa_next) {
- if (!ifr->ifa_addr)
- continue;
- len = sizeof(*(ifr->ifa_addr));
- family = ConvertAddr((struct sockaddr *) ifr->ifa_addr, &len,
- (pointer *)&addr);
- if (family == -1 || family == FamilyLocal)
- continue;
-#if defined(IPv6) && defined(AF_INET6)
- if (family == FamilyInternet6)
- in6_fillscopeid((struct sockaddr_in6 *)ifr->ifa_addr);
-#endif
-
- for (host = selfhosts;
- host != NULL && !addrEqual(family, addr, len, host);
- host = host->next)
- ;
- if (host != NULL)
- continue;
- MakeHost(host, len);
- if (host != NULL) {
- host->family = family;
- host->len = len;
- acopy(addr, host->addr, len);
- host->next = selfhosts;
- selfhosts = host;
- }
-#ifdef XDMCP
- {
- /*
- * If this isn't an Internet Address, don't register it.
- */
- if (family != FamilyInternet
-#if defined(IPv6) && defined(AF_INET6)
- && family != FamilyInternet6
-#endif
- )
- continue;
-
- /*
- * ignore 'localhost' entries as they're not useful
- * on the other end of the wire
- */
- if (ifr->ifa_flags & IFF_LOOPBACK)
- continue;
-
- if (family == FamilyInternet &&
- addr[0] == 127 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 1)
- continue;
-
- /*
- * Ignore '0.0.0.0' entries as they are
- * returned by some OSes for unconfigured NICs but they are
- * not useful on the other end of the wire.
- */
- if (len == 4 &&
- addr[0] == 0 && addr[1] == 0 &&
- addr[2] == 0 && addr[3] == 0)
- continue;
-#if defined(IPv6) && defined(AF_INET6)
- else if (family == FamilyInternet6 &&
- IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))
- continue;
-#endif
- XdmcpRegisterConnection(family, (char *)addr, len);
-#if defined(IPv6) && defined(AF_INET6)
- if (family == FamilyInternet6)
- /* IPv6 doesn't support broadcasting, so we drop out here */
- continue;
-#endif
- if ((ifr->ifa_flags & IFF_BROADCAST) &&
- (ifr->ifa_flags & IFF_UP) &&
- ifr->ifa_broadaddr)
- XdmcpRegisterBroadcastAddress(
- (struct sockaddr_in *) ifr->ifa_broadaddr);
- else
- continue;
- }
-#endif /* XDMCP */
-
- } /* for */
- freeifaddrs(ifap);
-#endif /* HAS_GETIFADDRS */
-
- /*
- * add something of FamilyLocalHost
- */
- for (host = selfhosts;
- host && !addrEqual(FamilyLocalHost, "", 0, host);
- host = host->next);
- if (!host)
- {
- MakeHost(host, 0);
- if (host)
- {
- host->family = FamilyLocalHost;
- host->len = 0;
- acopy("", host->addr, 0);
- host->next = selfhosts;
- selfhosts = host;
- }
- }
-}
-#endif /* hpux && !HAS_IFREQ */
-
-#ifdef XDMCP
-void
-AugmentSelf(pointer from, int len)
-{
- int family;
- pointer addr;
- register HOST *host;
-
- family = ConvertAddr(from, &len, (pointer *)&addr);
- if (family == -1 || family == FamilyLocal)
- return;
- for (host = selfhosts; host; host = host->next)
- {
- if (addrEqual(family, addr, len, host))
- return;
- }
- MakeHost(host,len)
- if (!host)
- return;
- host->family = family;
- host->len = len;
- acopy(addr, host->addr, len);
- host->next = selfhosts;
- selfhosts = host;
-}
-#endif
-
-void
-AddLocalHosts (void)
-{
- HOST *self;
-
- for (self = selfhosts; self; self = self->next)
- /* Fix for XFree86 bug #156: pass addingLocal = TRUE to
- * NewHost to tell that we are adding the default local
- * host entries and not to flag the entries as being
- * explicitely requested */
- (void) NewHost (self->family, self->addr, self->len, TRUE);
-}
-
-/* Reset access control list to initial hosts */
-void
-ResetHosts (char *display)
-{
- register HOST *host;
- char lhostname[120], ohostname[120];
- char *hostname = ohostname;
- char fname[PATH_MAX + 1];
- int fnamelen;
- FILE *fd;
- char *ptr;
- int i, hostlen;
-#if (defined(TCPCONN) || defined(STREAMSCONN) ) && \
- (!defined(IPv6) || !defined(AF_INET6))
- union {
- struct sockaddr sa;
-#if defined(TCPCONN) || defined(STREAMSCONN)
- struct sockaddr_in in;
-#endif /* TCPCONN || STREAMSCONN */
- } saddr;
-#endif
- int family = 0;
- pointer addr;
- int len;
-
- siTypesInitialize();
- AccessEnabled = defeatAccessControl ? FALSE : DEFAULT_ACCESS_CONTROL;
- LocalHostEnabled = FALSE;
- while ((host = validhosts) != 0)
- {
- validhosts = host->next;
- FreeHost (host);
- }
-
-#if defined WIN32 && defined __MINGW32__
-#define ETC_HOST_PREFIX "X"
-#else
-#define ETC_HOST_PREFIX "/etc/X"
-#endif
-#define ETC_HOST_SUFFIX ".hosts"
- fnamelen = strlen(ETC_HOST_PREFIX) + strlen(ETC_HOST_SUFFIX) +
- strlen(display) + 1;
- if (fnamelen > sizeof(fname))
- FatalError("Display name `%s' is too long\n", display);
- snprintf(fname, sizeof(fname), ETC_HOST_PREFIX "%s" ETC_HOST_SUFFIX,
- display);
-
- if ((fd = fopen (fname, "r")) != 0)
- {
- while (fgets (ohostname, sizeof (ohostname), fd))
- {
- family = FamilyWild;
- if (*ohostname == '#')
- continue;
- if ((ptr = strchr(ohostname, '\n')) != 0)
- *ptr = 0;
- hostlen = strlen(ohostname) + 1;
- for (i = 0; i < hostlen; i++)
- lhostname[i] = tolower(ohostname[i]);
- hostname = ohostname;
- if (!strncmp("local:", lhostname, 6))
- {
- family = FamilyLocalHost;
- NewHost(family, "", 0, FALSE);
- LocalHostRequested = TRUE; /* Fix for XFree86 bug #156 */
- }
-#if defined(TCPCONN) || defined(STREAMSCONN)
- else if (!strncmp("inet:", lhostname, 5))
- {
- family = FamilyInternet;
- hostname = ohostname + 5;
- }
-#if defined(IPv6) && defined(AF_INET6)
- else if (!strncmp("inet6:", lhostname, 6))
- {
- family = FamilyInternet6;
- hostname = ohostname + 6;
- }
-#endif
-#endif
-#ifdef SECURE_RPC
- else if (!strncmp("nis:", lhostname, 4))
- {
- family = FamilyNetname;
- hostname = ohostname + 4;
- }
-#endif
- else if (!strncmp("si:", lhostname, 3))
- {
- family = FamilyServerInterpreted;
- hostname = ohostname + 3;
- hostlen -= 3;
- }
-
-
- if (family == FamilyServerInterpreted)
- {
- len = siCheckAddr(hostname, hostlen);
- if (len >= 0) {
- NewHost(family, hostname, len, FALSE);
- }
- }
- else
-#ifdef SECURE_RPC
- if ((family == FamilyNetname) || (strchr(hostname, '@')))
- {
- SecureRPCInit ();
- (void) NewHost (FamilyNetname, hostname, strlen (hostname), FALSE);
- }
- else
-#endif /* SECURE_RPC */
-#if defined(TCPCONN) || defined(STREAMSCONN)
- {
-#if defined(IPv6) && defined(AF_INET6)
- if ( (family == FamilyInternet) || (family == FamilyInternet6) ||
- (family == FamilyWild) )
- {
- struct addrinfo *addresses;
- struct addrinfo *a;
- int f;
-
- if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
- for (a = addresses ; a != NULL ; a = a->ai_next) {
- len = a->ai_addrlen;
- f = ConvertAddr(a->ai_addr,&len,(pointer *)&addr);
- if ( (family == f) ||
- ((family == FamilyWild) && (f != -1)) ) {
- NewHost(f, addr, len, FALSE);
- }
- }
- freeaddrinfo(addresses);
- }
- }
-#else
-#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
- _Xgethostbynameparams hparams;
-#endif
- register struct hostent *hp;
-
- /* host name */
- if ((family == FamilyInternet &&
- ((hp = _XGethostbyname(hostname, hparams)) != 0)) ||
- ((hp = _XGethostbyname(hostname, hparams)) != 0))
- {
- saddr.sa.sa_family = hp->h_addrtype;
- len = sizeof(saddr.sa);
- if ((family = ConvertAddr (&saddr.sa, &len, (pointer *)&addr)) != -1)
- {
-#ifdef h_addr /* new 4.3bsd version of gethostent */
- char **list;
-
- /* iterate over the addresses */
- for (list = hp->h_addr_list; *list; list++)
- (void) NewHost (family, (pointer)*list, len, FALSE);
-#else
- (void) NewHost (family, (pointer)hp->h_addr, len, FALSE);
-#endif
- }
- }
-#endif /* IPv6 */
- }
-#endif /* TCPCONN || STREAMSCONN */
- family = FamilyWild;
- }
- fclose (fd);
- }
-}
-
-/* Is client on the local host */
-Bool LocalClient(ClientPtr client)
-{
- int alen, family, notused;
- Xtransaddr *from = NULL;
- pointer addr;
- register HOST *host;
-
- if (!client->osPrivate)
- return FALSE;
- if (!((OsCommPtr)client->osPrivate)->trans_conn)
- return FALSE;
-
- if (!_XSERVTransGetPeerAddr (((OsCommPtr)client->osPrivate)->trans_conn,
- ¬used, &alen, &from))
- {
- family = ConvertAddr ((struct sockaddr *) from,
- &alen, (pointer *)&addr);
- if (family == -1)
- {
- free(from);
- return FALSE;
- }
- if (family == FamilyLocal)
- {
- free(from);
- return TRUE;
- }
- for (host = selfhosts; host; host = host->next)
- {
- if (addrEqual (family, addr, alen, host))
- return TRUE;
- }
- free(from);
- }
- return FALSE;
-}
-
-/*
- * Return the uid and gid of a connected local client
- *
- * Used by XShm to test access rights to shared memory segments
- */
-int
-LocalClientCred(ClientPtr client, int *pUid, int *pGid)
-{
- LocalClientCredRec *lcc;
- int ret = GetLocalClientCreds(client, &lcc);
-
- if (ret == 0) {
-#ifdef HAVE_GETZONEID /* only local if in the same zone */
- if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) {
- FreeLocalClientCreds(lcc);
- return -1;
- }
-#endif
- if ((lcc->fieldsSet & LCC_UID_SET) && (pUid != NULL))
- *pUid = lcc->euid;
- if ((lcc->fieldsSet & LCC_GID_SET) && (pGid != NULL))
- *pGid = lcc->egid;
- FreeLocalClientCreds(lcc);
- }
- return ret;
-}
-
-/*
- * Return the uid and all gids of a connected local client
- * Allocates a LocalClientCredRec - caller must call FreeLocalClientCreds
- *
- * Used by localuser & localgroup ServerInterpreted access control forms below
- * Used by AuthAudit to log who local connections came from
- */
-int
-GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp)
-{
-#if defined(HAS_GETPEEREID) || defined(HAS_GETPEERUCRED) || defined(SO_PEERCRED)
- int fd;
- XtransConnInfo ci;
- LocalClientCredRec *lcc;
-#ifdef HAS_GETPEEREID
- uid_t uid;
- gid_t gid;
-#elif defined(HAS_GETPEERUCRED)
- ucred_t *peercred = NULL;
- const gid_t *gids;
-#elif defined(SO_PEERCRED)
- struct ucred peercred;
- socklen_t so_len = sizeof(peercred);
-#endif
-
- if (client == NULL)
- return -1;
- ci = ((OsCommPtr)client->osPrivate)->trans_conn;
-#if !(defined(sun) && defined(HAS_GETPEERUCRED))
- /* Most implementations can only determine peer credentials for Unix
- * domain sockets - Solaris getpeerucred can work with a bit more, so
- * we just let it tell us if the connection type is supported or not
- */
- if (!_XSERVTransIsLocal(ci)) {
- return -1;
- }
-#endif
-
- *lccp = calloc(1, sizeof(LocalClientCredRec));
- if (*lccp == NULL)
- return -1;
- lcc = *lccp;
-
- fd = _XSERVTransGetConnectionNumber(ci);
-#ifdef HAS_GETPEEREID
- if (getpeereid(fd, &uid, &gid) == -1) {
- FreeLocalClientCreds(lcc);
- return -1;
- }
- lcc->euid = uid;
- lcc->egid = gid;
- lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET;
- return 0;
-#elif defined(HAS_GETPEERUCRED)
- if (getpeerucred(fd, &peercred) < 0) {
- FreeLocalClientCreds(lcc);
- return -1;
- }
- lcc->euid = ucred_geteuid(peercred);
- if (lcc->euid != -1)
- lcc->fieldsSet |= LCC_UID_SET;
- lcc->egid = ucred_getegid(peercred);
- if (lcc->egid != -1)
- lcc->fieldsSet |= LCC_GID_SET;
- lcc->pid = ucred_getpid(peercred);
- if (lcc->pid != -1)
- lcc->fieldsSet |= LCC_PID_SET;
-#ifdef HAVE_GETZONEID
- lcc->zoneid = ucred_getzoneid(peercred);
- if (lcc->zoneid != -1)
- lcc->fieldsSet |= LCC_ZID_SET;
-#endif
- lcc->nSuppGids = ucred_getgroups(peercred, &gids);
- if (lcc->nSuppGids > 0) {
- lcc->pSuppGids = calloc(lcc->nSuppGids, sizeof(int));
- if (lcc->pSuppGids == NULL) {
- lcc->nSuppGids = 0;
- } else {
- int i;
- for (i = 0 ; i < lcc->nSuppGids; i++) {
- (lcc->pSuppGids)[i] = (int) gids[i];
- }
- }
- } else {
- lcc->nSuppGids = 0;
- }
- ucred_free(peercred);
- return 0;
-#elif defined(SO_PEERCRED)
- if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) == -1) {
- FreeLocalClientCreds(lcc);
- return -1;
- }
- lcc->euid = peercred.uid;
- lcc->egid = peercred.gid;
- lcc->pid = peercred.pid;
- lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET | LCC_PID_SET;
- return 0;
-#endif
-#else
- /* No system call available to get the credentials of the peer */
-#define NO_LOCAL_CLIENT_CRED
- return -1;
-#endif
-}
-
-void
-FreeLocalClientCreds(LocalClientCredRec *lcc)
-{
- if (lcc != NULL) {
- if (lcc->nSuppGids > 0) {
- free(lcc->pSuppGids);
- }
- free(lcc);
- }
-}
-
-static int
-AuthorizedClient(ClientPtr client)
-{
- int rc;
-
- if (!client || defeatAccessControl)
- return Success;
-
- /* untrusted clients can't change host access */
- rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess);
- if (rc != Success)
- return rc;
-
- return LocalClient(client) ? Success : BadAccess;
-}
-
-/* Add a host to the access control list. This is the external interface
- * called from the dispatcher */
-
-int
-AddHost (ClientPtr client,
- int family,
- unsigned length, /* of bytes in pAddr */
- const void * pAddr)
-{
- int rc, len;
-
- rc = AuthorizedClient(client);
- if (rc != Success)
- return rc;
- switch (family) {
- case FamilyLocalHost:
- len = length;
- LocalHostEnabled = TRUE;
- break;
-#ifdef SECURE_RPC
- case FamilyNetname:
- len = length;
- SecureRPCInit ();
- break;
-#endif
- case FamilyInternet:
-#if defined(IPv6) && defined(AF_INET6)
- case FamilyInternet6:
-#endif
- case FamilyDECnet:
- case FamilyChaos:
- case FamilyServerInterpreted:
- if ((len = CheckAddr (family, pAddr, length)) < 0)
- {
- client->errorValue = length;
- return BadValue;
- }
- break;
- case FamilyLocal:
- default:
- client->errorValue = family;
- return BadValue;
- }
- if (NewHost (family, pAddr, len, FALSE))
- return Success;
- return BadAlloc;
-}
-
-Bool
-ForEachHostInFamily (int family,
- Bool (*func)(
- unsigned char * /* addr */,
- short /* len */,
- pointer /* closure */),
- pointer closure)
-{
- HOST *host;
-
- for (host = validhosts; host; host = host->next)
- if (family == host->family && func (host->addr, host->len, closure))
- return TRUE;
- return FALSE;
-}
-
-/* Add a host to the access control list. This is the internal interface
- * called when starting or resetting the server */
-static Bool
-NewHost (int family,
- const void * addr,
- int len,
- int addingLocalHosts)
-{
- register HOST *host;
-
- for (host = validhosts; host; host = host->next)
- {
- if (addrEqual (family, addr, len, host))
- return TRUE;
- }
- if (!addingLocalHosts) { /* Fix for XFree86 bug #156 */
- for (host = selfhosts; host; host = host->next) {
- if (addrEqual (family, addr, len, host)) {
- host->requested = TRUE;
- break;
- }
- }
- }
- MakeHost(host,len)
- if (!host)
- return FALSE;
- host->family = family;
- host->len = len;
- acopy(addr, host->addr, len);
- host->next = validhosts;
- validhosts = host;
- return TRUE;
-}
-
-/* Remove a host from the access control list */
-
-int
-RemoveHost (
- ClientPtr client,
- int family,
- unsigned length, /* of bytes in pAddr */
- pointer pAddr)
-{
- int rc, len;
- register HOST *host, **prev;
-
- rc = AuthorizedClient(client);
- if (rc != Success)
- return rc;
- switch (family) {
- case FamilyLocalHost:
- len = length;
- LocalHostEnabled = FALSE;
- break;
-#ifdef SECURE_RPC
- case FamilyNetname:
- len = length;
- break;
-#endif
- case FamilyInternet:
-#if defined(IPv6) && defined(AF_INET6)
- case FamilyInternet6:
-#endif
- case FamilyDECnet:
- case FamilyChaos:
- case FamilyServerInterpreted:
- if ((len = CheckAddr (family, pAddr, length)) < 0)
- {
- client->errorValue = length;
- return BadValue;
- }
- break;
- case FamilyLocal:
- default:
- client->errorValue = family;
- return BadValue;
- }
- for (prev = &validhosts;
- (host = *prev) && (!addrEqual (family, pAddr, len, host));
- prev = &host->next)
- ;
- if (host)
- {
- *prev = host->next;
- FreeHost (host);
- }
- return Success;
-}
-
-/* Get all hosts in the access control list */
-int
-GetHosts (
- pointer *data,
- int *pnHosts,
- int *pLen,
- BOOL *pEnabled)
-{
- int len;
- register int n = 0;
- register unsigned char *ptr;
- register HOST *host;
- int nHosts = 0;
-
- *pEnabled = AccessEnabled ? EnableAccess : DisableAccess;
- for (host = validhosts; host; host = host->next)
- {
- nHosts++;
- n += pad_to_int32(host->len) + sizeof(xHostEntry);
- }
- if (n)
- {
- *data = ptr = malloc(n);
- if (!ptr)
- {
- return BadAlloc;
- }
- for (host = validhosts; host; host = host->next)
- {
- len = host->len;
- ((xHostEntry *)ptr)->family = host->family;
- ((xHostEntry *)ptr)->length = len;
- ptr += sizeof(xHostEntry);
- acopy (host->addr, ptr, len);
- ptr += pad_to_int32(len);
- }
- } else {
- *data = NULL;
- }
- *pnHosts = nHosts;
- *pLen = n;
- return Success;
-}
-
-/* Check for valid address family and length, and return address length. */
-
-/*ARGSUSED*/
-static int
-CheckAddr (
- int family,
- const void * pAddr,
- unsigned length)
-{
- int len;
-
- switch (family)
- {
-#if defined(TCPCONN) || defined(STREAMSCONN)
- case FamilyInternet:
- if (length == sizeof (struct in_addr))
- len = length;
- else
- len = -1;
- break;
-#if defined(IPv6) && defined(AF_INET6)
- case FamilyInternet6:
- if (length == sizeof (struct in6_addr))
- len = length;
- else
- len = -1;
- break;
-#endif
-#endif
- case FamilyServerInterpreted:
- len = siCheckAddr(pAddr, length);
- break;
- default:
- len = -1;
- }
- return len;
-}
-
-/* Check if a host is not in the access control list.
- * Returns 1 if host is invalid, 0 if we've found it. */
-
-int
-InvalidHost (
- register struct sockaddr *saddr,
- int len,
- ClientPtr client)
-{
- int family;
- pointer addr;
- register HOST *selfhost, *host;
-
- if (!AccessEnabled) /* just let them in */
- return 0;
- family = ConvertAddr (saddr, &len, (pointer *)&addr);
- if (family == -1)
- return 1;
- if (family == FamilyLocal)
- {
- if (!LocalHostEnabled)
- {
- /*
- * check to see if any local address is enabled. This
- * implicitly enables local connections.
- */
- for (selfhost = selfhosts; selfhost; selfhost=selfhost->next)
- {
- for (host = validhosts; host; host=host->next)
- {
- if (addrEqual (selfhost->family, selfhost->addr,
- selfhost->len, host))
- return 0;
- }
- }
- } else
- return 0;
- }
- for (host = validhosts; host; host = host->next)
- {
- if ((host->family == FamilyServerInterpreted)) {
- if (siAddrMatch (family, addr, len, host, client)) {
- return 0;
- }
- } else {
- if (addrEqual (family, addr, len, host))
- return 0;
- }
-
- }
- return 1;
-}
-
-static int
-ConvertAddr (
- register struct sockaddr *saddr,
- int *len,
- pointer *addr)
-{
- if (*len == 0)
- return FamilyLocal;
- switch (saddr->sa_family)
- {
- case AF_UNSPEC:
-#if defined(UNIXCONN) || defined(LOCALCONN)
- case AF_UNIX:
-#endif
- return FamilyLocal;
-#if defined(TCPCONN) || defined(STREAMSCONN)
- case AF_INET:
-#ifdef WIN32
- if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr)
- return FamilyLocal;
-#endif
- *len = sizeof (struct in_addr);
- *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr);
- return FamilyInternet;
-#if defined(IPv6) && defined(AF_INET6)
- case AF_INET6:
- {
- struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr;
- if (IN6_IS_ADDR_V4MAPPED(&(saddr6->sin6_addr))) {
- *len = sizeof (struct in_addr);
- *addr = (pointer) &(saddr6->sin6_addr.s6_addr[12]);
- return FamilyInternet;
- } else {
- *len = sizeof (struct in6_addr);
- *addr = (pointer) &(saddr6->sin6_addr);
- return FamilyInternet6;
- }
- }
-#endif
-#endif
- default:
- return -1;
- }
-}
-
-int
-ChangeAccessControl(
- ClientPtr client,
- int fEnabled)
-{
- int rc = AuthorizedClient(client);
- if (rc != Success)
- return rc;
- AccessEnabled = fEnabled;
- return Success;
-}
-
-/* returns FALSE if xhost + in effect, else TRUE */
-int
-GetAccessControl(void)
-{
- return AccessEnabled;
-}
-
-/*****************************************************************************
- * FamilyServerInterpreted host entry implementation
- *
- * Supports an extensible system of host types which the server can interpret
- * See the IPv6 extensions to the X11 protocol spec for the definition.
- *
- * Currently supported schemes:
- *
- * hostname - hostname as defined in IETF RFC 2396
- * ipv6 - IPv6 literal address as defined in IETF RFC's 3513 and <TBD>
- *
- * See xc/doc/specs/SIAddresses for formal definitions of each type.
- */
-
-/* These definitions and the siTypeAdd function could be exported in the
- * future to enable loading additional host types, but that was not done for
- * the initial implementation.
- */
-typedef Bool (*siAddrMatchFunc)(int family, pointer addr, int len,
- const char *siAddr, int siAddrlen, ClientPtr client, void *siTypePriv);
-typedef int (*siCheckAddrFunc)(const char *addrString, int length,
- void *siTypePriv);
-
-struct siType {
- struct siType * next;
- const char * typeName;
- siAddrMatchFunc addrMatch;
- siCheckAddrFunc checkAddr;
- void * typePriv; /* Private data for type routines */
-};
-
-static struct siType *siTypeList;
-
-static int
-siTypeAdd(const char *typeName, siAddrMatchFunc addrMatch,
- siCheckAddrFunc checkAddr, void *typePriv)
-{
- struct siType *s, *p;
-
- if ((typeName == NULL) || (addrMatch == NULL) || (checkAddr == NULL))
- return BadValue;
-
- for (s = siTypeList, p = NULL; s != NULL ; p = s, s = s->next) {
- if (strcmp(typeName, s->typeName) == 0) {
- s->addrMatch = addrMatch;
- s->checkAddr = checkAddr;
- s->typePriv = typePriv;
- return Success;
- }
- }
-
- s = malloc(sizeof(struct siType));
- if (s == NULL)
- return BadAlloc;
-
- if (p == NULL)
- siTypeList = s;
- else
- p->next = s;
-
- s->next = NULL;
- s->typeName = typeName;
- s->addrMatch = addrMatch;
- s->checkAddr = checkAddr;
- s->typePriv = typePriv;
- return Success;
-}
-
-/* Checks to see if a host matches a server-interpreted host entry */
-static Bool
-siAddrMatch(int family, pointer addr, int len, HOST *host, ClientPtr client)
-{
- Bool matches = FALSE;
- struct siType *s;
- const char *valueString;
- int addrlen;
-
- valueString = (const char *) memchr(host->addr, '\0', host->len);
- if (valueString != NULL) {
- for (s = siTypeList; s != NULL ; s = s->next) {
- if (strcmp((char *) host->addr, s->typeName) == 0) {
- addrlen = host->len - (strlen((char *)host->addr) + 1);
- matches = s->addrMatch(family, addr, len,
- valueString + 1, addrlen, client, s->typePriv);
- break;
- }
- }
-#ifdef FAMILY_SI_DEBUG
- ErrorF(
- "Xserver: siAddrMatch(): type = %s, value = %*.*s -- %s\n",
- host->addr, addrlen, addrlen, valueString + 1,
- (matches) ? "accepted" : "rejected");
-#endif
- }
- return matches;
-}
-
-static int
-siCheckAddr(const char *addrString, int length)
-{
- const char *valueString;
- int addrlen, typelen;
- int len = -1;
- struct siType *s;
-
- /* Make sure there is a \0 byte inside the specified length
- to separate the address type from the address value. */
- valueString = (const char *) memchr(addrString, '\0', length);
- if (valueString != NULL) {
- /* Make sure the first string is a recognized address type,
- * and the second string is a valid address of that type.
- */
- typelen = strlen(addrString) + 1;
- addrlen = length - typelen;
-
- for (s = siTypeList; s != NULL ; s = s->next) {
- if (strcmp(addrString, s->typeName) == 0) {
- len = s->checkAddr(valueString + 1, addrlen, s->typePriv);
- if (len >= 0) {
- len += typelen;
- }
- break;
- }
- }
-#ifdef FAMILY_SI_DEBUG
- {
- const char *resultMsg;
-
- if (s == NULL) {
- resultMsg = "type not registered";
- } else {
- if (len == -1)
- resultMsg = "rejected";
- else
- resultMsg = "accepted";
- }
-
- ErrorF("Xserver: siCheckAddr(): type = %s, value = %*.*s, len = %d -- %s\n",
- addrString, addrlen, addrlen, valueString + 1, len, resultMsg);
- }
-#endif
- }
- return len;
-}
-
-
-/***
- * Hostname server-interpreted host type
- *
- * Stored as hostname string, explicitly defined to be resolved ONLY
- * at access check time, to allow for hosts with dynamic addresses
- * but static hostnames, such as found in some DHCP & mobile setups.
- *
- * Hostname must conform to IETF RFC 2396 sec. 3.2.2, which defines it as:
- * hostname = *( domainlabel "." ) toplabel [ "." ]
- * domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
- * toplabel = alpha | alpha *( alphanum | "-" ) alphanum
- */
-
-#ifdef NI_MAXHOST
-# define SI_HOSTNAME_MAXLEN NI_MAXHOST
-#else
-# ifdef MAXHOSTNAMELEN
-# define SI_HOSTNAME_MAXLEN MAXHOSTNAMELEN
-# else
-# define SI_HOSTNAME_MAXLEN 256
-# endif
-#endif
-
-static Bool
-siHostnameAddrMatch(int family, pointer addr, int len,
- const char *siAddr, int siAddrLen, ClientPtr client, void *typePriv)
-{
- Bool res = FALSE;
-
-/* Currently only supports checking against IPv4 & IPv6 connections, but
- * support for other address families, such as DECnet, could be added if
- * desired.
- */
-#if defined(IPv6) && defined(AF_INET6)
- if ((family == FamilyInternet) || (family == FamilyInternet6)) {
- char hostname[SI_HOSTNAME_MAXLEN];
- struct addrinfo *addresses;
- struct addrinfo *a;
- int f, hostaddrlen;
- pointer hostaddr;
-
- if (siAddrLen >= sizeof(hostname))
- return FALSE;
-
- strncpy(hostname, siAddr, siAddrLen);
- hostname[siAddrLen] = '\0';
-
- if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) {
- for (a = addresses ; a != NULL ; a = a->ai_next) {
- hostaddrlen = a->ai_addrlen;
- f = ConvertAddr(a->ai_addr,&hostaddrlen,&hostaddr);
- if ((f == family) && (len == hostaddrlen) &&
- (acmp (addr, hostaddr, len) == 0) ) {
- res = TRUE;
- break;
- }
- }
- freeaddrinfo(addresses);
- }
- }
-#else /* IPv6 not supported, use gethostbyname instead for IPv4 */
- if (family == FamilyInternet) {
- register struct hostent *hp;
-#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
- _Xgethostbynameparams hparams;
-#endif
- char hostname[SI_HOSTNAME_MAXLEN];
- int f, hostaddrlen;
- pointer hostaddr;
- const char **addrlist;
-
- if (siAddrLen >= sizeof(hostname))
- return FALSE;
-
- strncpy(hostname, siAddr, siAddrLen);
- hostname[siAddrLen] = '\0';
-
- if ((hp = _XGethostbyname(hostname, hparams)) != NULL) {
-#ifdef h_addr /* new 4.3bsd version of gethostent */
- /* iterate over the addresses */
- for (addrlist = hp->h_addr_list; *addrlist; addrlist++)
-#else
- addrlist = &hp->h_addr;
-#endif
- {
- struct sockaddr_in sin;
-
- sin.sin_family = hp->h_addrtype;
- acopy ( *addrlist, &(sin.sin_addr), hp->h_length);
- hostaddrlen = sizeof(sin);
- f = ConvertAddr ((struct sockaddr *)&sin,
- &hostaddrlen, &hostaddr);
- if ((f == family) && (len == hostaddrlen) &&
- (acmp (addr, hostaddr, len) == 0) ) {
- res = TRUE;
- break;
- }
- }
- }
- }
-#endif
- return res;
-}
-
-
-static int
-siHostnameCheckAddr(const char *valueString, int length, void *typePriv)
-{
- /* Check conformance of hostname to RFC 2396 sec. 3.2.2 definition.
- * We do not use ctype functions here to avoid locale-specific
- * character sets. Hostnames must be pure ASCII.
- */
- int len = length;
- int i;
- Bool dotAllowed = FALSE;
- Bool dashAllowed = FALSE;
-
- if ((length <= 0) || (length >= SI_HOSTNAME_MAXLEN)) {
- len = -1;
- } else {
- for (i = 0; i < length; i++) {
- char c = valueString[i];
-
- if (c == 0x2E) { /* '.' */
- if (dotAllowed == FALSE) {
- len = -1;
- break;
- } else {
- dotAllowed = FALSE;
- dashAllowed = FALSE;
- }
- } else if (c == 0x2D) { /* '-' */
- if (dashAllowed == FALSE) {
- len = -1;
- break;
- } else {
- dotAllowed = FALSE;
- }
- } else if (((c >= 0x30) && (c <= 0x3A)) /* 0-9 */ ||
- ((c >= 0x61) && (c <= 0x7A)) /* a-z */ ||
- ((c >= 0x41) && (c <= 0x5A)) /* A-Z */) {
- dotAllowed = TRUE;
- dashAllowed = TRUE;
- } else { /* Invalid character */
- len = -1;
- break;
- }
- }
- }
- return len;
-}
-
-#if defined(IPv6) && defined(AF_INET6)
-/***
- * "ipv6" server interpreted type
- *
- * Currently supports only IPv6 literal address as specified in IETF RFC 3513
- *
- * Once draft-ietf-ipv6-scoping-arch-00.txt becomes an RFC, support will be
- * added for the scoped address format it specifies.
- */
-
-/* Maximum length of an IPv6 address string - increase when adding support
- * for scoped address qualifiers. Includes room for trailing NUL byte.
- */
-#define SI_IPv6_MAXLEN INET6_ADDRSTRLEN
-
-static Bool
-siIPv6AddrMatch(int family, pointer addr, int len,
- const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv)
-{
- struct in6_addr addr6;
- char addrbuf[SI_IPv6_MAXLEN];
-
- if ((family != FamilyInternet6) || (len != sizeof(addr6)))
- return FALSE;
-
- memcpy(addrbuf, siAddr, siAddrlen);
- addrbuf[siAddrlen] = '\0';
-
- if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) {
- perror("inet_pton");
- return FALSE;
- }
-
- if (memcmp(addr, &addr6, len) == 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-static int
-siIPv6CheckAddr(const char *addrString, int length, void *typePriv)
-{
- int len;
-
- /* Minimum length is 3 (smallest legal address is "::1") */
- if (length < 3) {
- /* Address is too short! */
- len = -1;
- } else if (length >= SI_IPv6_MAXLEN) {
- /* Address is too long! */
- len = -1;
- } else {
- /* Assume inet_pton is sufficient validation */
- struct in6_addr addr6;
- char addrbuf[SI_IPv6_MAXLEN];
-
- memcpy(addrbuf, addrString, length);
- addrbuf[length] = '\0';
-
- if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) {
- perror("inet_pton");
- len = -1;
- } else {
- len = length;
- }
- }
- return len;
-}
-#endif /* IPv6 */
-
-#if !defined(NO_LOCAL_CLIENT_CRED)
-/***
- * "localuser" & "localgroup" server interpreted types
- *
- * Allows local connections from a given local user or group
- */
-
-#include <pwd.h>
-#include <grp.h>
-
-#define LOCAL_USER 1
-#define LOCAL_GROUP 2
-
-typedef struct {
- int credType;
-} siLocalCredPrivRec, *siLocalCredPrivPtr;
-
-static siLocalCredPrivRec siLocalUserPriv = { LOCAL_USER };
-static siLocalCredPrivRec siLocalGroupPriv = { LOCAL_GROUP };
-
-static Bool
-siLocalCredGetId(const char *addr, int len, siLocalCredPrivPtr lcPriv, int *id)
-{
- Bool parsedOK = FALSE;
- char *addrbuf = malloc(len + 1);
-
- if (addrbuf == NULL) {
- return FALSE;
- }
-
- memcpy(addrbuf, addr, len);
- addrbuf[len] = '\0';
-
- if (addr[0] == '#') { /* numeric id */
- char *cp;
- errno = 0;
- *id = strtol(addrbuf + 1, &cp, 0);
- if ((errno == 0) && (cp != (addrbuf+1))) {
- parsedOK = TRUE;
- }
- } else { /* non-numeric name */
- if (lcPriv->credType == LOCAL_USER) {
- struct passwd *pw = getpwnam(addrbuf);
-
- if (pw != NULL) {
- *id = (int) pw->pw_uid;
- parsedOK = TRUE;
- }
- } else { /* group */
- struct group *gr = getgrnam(addrbuf);
-
- if (gr != NULL) {
- *id = (int) gr->gr_gid;
- parsedOK = TRUE;
- }
- }
- }
-
- free(addrbuf);
- return parsedOK;
-}
-
-static Bool
-siLocalCredAddrMatch(int family, pointer addr, int len,
- const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv)
-{
- int siAddrId;
- LocalClientCredRec *lcc;
- siLocalCredPrivPtr lcPriv = (siLocalCredPrivPtr) typePriv;
-
- if (GetLocalClientCreds(client, &lcc) == -1) {
- return FALSE;
- }
-
-#ifdef HAVE_GETZONEID /* Ensure process is in the same zone */
- if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) {
- FreeLocalClientCreds(lcc);
- return FALSE;
- }
-#endif
-
- if (siLocalCredGetId(siAddr, siAddrlen, lcPriv, &siAddrId) == FALSE) {
- FreeLocalClientCreds(lcc);
- return FALSE;
- }
-
- if (lcPriv->credType == LOCAL_USER) {
- if ((lcc->fieldsSet & LCC_UID_SET) && (lcc->euid == siAddrId)) {
- FreeLocalClientCreds(lcc);
- return TRUE;
- }
- } else {
- if ((lcc->fieldsSet & LCC_GID_SET) && (lcc->egid == siAddrId)) {
- FreeLocalClientCreds(lcc);
- return TRUE;
- }
- if (lcc->pSuppGids != NULL) {
- int i;
-
- for (i = 0 ; i < lcc->nSuppGids; i++) {
- if (lcc->pSuppGids[i] == siAddrId) {
- FreeLocalClientCreds(lcc);
- return TRUE;
- }
- }
- }
- }
- FreeLocalClientCreds(lcc);
- return FALSE;
-}
-
-static int
-siLocalCredCheckAddr(const char *addrString, int length, void *typePriv)
-{
- int len = length;
- int id;
-
- if (siLocalCredGetId(addrString, length,
- (siLocalCredPrivPtr)typePriv, &id) == FALSE) {
- len = -1;
- }
- return len;
-}
-#endif /* localuser */
-
-static void
-siTypesInitialize(void)
-{
- siTypeAdd("hostname", siHostnameAddrMatch, siHostnameCheckAddr, NULL);
-#if defined(IPv6) && defined(AF_INET6)
- siTypeAdd("ipv6", siIPv6AddrMatch, siIPv6CheckAddr, NULL);
-#endif
-#if !defined(NO_LOCAL_CLIENT_CRED)
- siTypeAdd("localuser", siLocalCredAddrMatch, siLocalCredCheckAddr,
- &siLocalUserPriv);
- siTypeAdd("localgroup", siLocalCredAddrMatch, siLocalCredCheckAddr,
- &siLocalGroupPriv);
-#endif
-}
+/*********************************************************** + +Copyright 1987, 1998 The Open Group + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, and/or sell copies of the Software, and to permit persons +to whom the Software is furnished to do so, provided that the above +copyright notice(s) and this permission notice appear in all copies of +the Software and that both the above copyright notice(s) and this +permission notice appear in supporting documentation. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL +INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING +FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, +NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION +WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, use +or other dealings in this Software without prior written authorization +of the copyright holder. + +X Window System is a trademark of 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 (c) 2004, 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. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#ifdef WIN32 +#include <X11/Xwinsock.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#define XSERV_t +#define TRANS_SERVER +#define TRANS_REOPEN +#include <X11/Xtrans/Xtrans.h> +#include <X11/Xauth.h> +#include <X11/X.h> +#include <X11/Xproto.h> +#include "misc.h" +#include "site.h" +#include <errno.h> +#include <sys/types.h> +#ifndef WIN32 +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <ctype.h> + +#if defined(TCPCONN) || defined(STREAMSCONN) +#include <netinet/in.h> +#endif /* TCPCONN || STREAMSCONN */ + +#ifdef HAS_GETPEERUCRED +# include <ucred.h> +# ifdef sun +# include <zone.h> +# endif +#endif + +#if defined(SVR4) || (defined(SYSV) && defined(__i386__)) || defined(__GNU__) +# include <sys/utsname.h> +#endif +#if defined(SYSV) && defined(__i386__) +# include <sys/stream.h> +#endif +#ifdef __GNU__ +#undef SIOCGIFCONF +#include <netdb.h> +#else /*!__GNU__*/ +# include <net/if.h> +#endif /*__GNU__ */ + +#ifdef SVR4 +#include <sys/sockio.h> +#include <sys/stropts.h> +#endif + +#include <netdb.h> + +#ifdef CSRG_BASED +#include <sys/param.h> +#if (BSD >= 199103) +#define VARIABLE_IFREQ +#endif +#endif + +#ifdef BSD44SOCKETS +#ifndef VARIABLE_IFREQ +#define VARIABLE_IFREQ +#endif +#endif + +#ifdef HAS_GETIFADDRS +#include <ifaddrs.h> +#endif + +/* Solaris provides an extended interface SIOCGLIFCONF. Other systems + * may have this as well, but the code has only been tested on Solaris + * so far, so we only enable it there. Other platforms may be added as + * needed. + * + * Test for Solaris commented out -- TSI @ UQV 2003.06.13 + */ +#ifdef SIOCGLIFCONF +/* #if defined(sun) */ +#define USE_SIOCGLIFCONF +/* #endif */ +#endif + +#endif /* WIN32 */ + +#ifndef PATH_MAX +#include <sys/param.h> +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else +#define PATH_MAX 1024 +#endif +#endif +#endif + + +#define X_INCLUDE_NETDB_H +#include <X11/Xos_r.h> + +#include "dixstruct.h" +#include "osdep.h" + +#include "xace.h" + +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else +#define PATH_MAX 1024 +#endif +#endif + +Bool defeatAccessControl = FALSE; + +#define acmp(a1, a2, len) memcmp((char *)(a1), (char *)(a2), len) +#define acopy(a1, a2, len) memmove((char *)(a2), (char *)(a1), len) +#define addrEqual(fam, address, length, host) \ + ((fam) == (host)->family &&\ + (length) == (host)->len &&\ + !acmp (address, (host)->addr, length)) + +static int ConvertAddr(struct sockaddr * /*saddr*/, + int * /*len*/, + pointer * /*addr*/); + +static int CheckAddr(int /*family*/, + const void * /*pAddr*/, + unsigned /*length*/); + +static Bool NewHost(int /*family*/, + const void * /*addr*/, + int /*len*/, + int /* addingLocalHosts */); + +/* XFree86 bug #156: To keep track of which hosts were explicitly requested in + /etc/X<display>.hosts, we've added a requested field to the HOST struct, + and a LocalHostRequested variable. These default to FALSE, but are set + to TRUE in ResetHosts when reading in /etc/X<display>.hosts. They are + checked in DisableLocalHost(), which is called to disable the default + local host entries when stronger authentication is turned on. */ + +typedef struct _host { + short family; + short len; + unsigned char *addr; + struct _host *next; + int requested; +} HOST; + +#define MakeHost(h,l) (h)=malloc(sizeof *(h)+(l));\ + if (h) { \ + (h)->addr=(unsigned char *) ((h) + 1);\ + (h)->requested = FALSE; \ + } +#define FreeHost(h) free(h) +static HOST *selfhosts = NULL; +static HOST *validhosts = NULL; +static int AccessEnabled = DEFAULT_ACCESS_CONTROL; +static int LocalHostEnabled = FALSE; +static int LocalHostRequested = FALSE; +static int UsingXdmcp = FALSE; + +/* FamilyServerInterpreted implementation */ +static Bool siAddrMatch(int family, pointer addr, int len, HOST *host, + ClientPtr client); +static int siCheckAddr(const char *addrString, int length); +static void siTypesInitialize(void); + +/* + * called when authorization is not enabled to add the + * local host to the access list + */ + +void +EnableLocalHost (void) +{ + if (!UsingXdmcp) + { + LocalHostEnabled = TRUE; + AddLocalHosts (); + } +} + +/* + * called when authorization is enabled to keep us secure + */ +void +DisableLocalHost (void) +{ + HOST *self; + + if (!LocalHostRequested) /* Fix for XFree86 bug #156 */ + LocalHostEnabled = FALSE; + for (self = selfhosts; self; self = self->next) { + if (!self->requested) /* Fix for XFree86 bug #156 */ + (void) RemoveHost ((ClientPtr)NULL, self->family, self->len, (pointer)self->addr); + } +} + +/* + * called at init time when XDMCP will be used; xdmcp always + * adds local hosts manually when needed + */ + +void +AccessUsingXdmcp (void) +{ + UsingXdmcp = TRUE; + LocalHostEnabled = FALSE; +} + + +#if defined(SVR4) && !defined(sun) && defined(SIOCGIFCONF) && !defined(USE_SIOCGLIFCONF) + +/* Deal with different SIOCGIFCONF ioctl semantics on these OSs */ + +static int +ifioctl (int fd, int cmd, char *arg) +{ + struct strioctl ioc; + int ret; + + memset((char *) &ioc, 0, sizeof(ioc)); + ioc.ic_cmd = cmd; + ioc.ic_timout = 0; + if (cmd == SIOCGIFCONF) + { + ioc.ic_len = ((struct ifconf *) arg)->ifc_len; + ioc.ic_dp = ((struct ifconf *) arg)->ifc_buf; + } + else + { + ioc.ic_len = sizeof(struct ifreq); + ioc.ic_dp = arg; + } + ret = ioctl(fd, I_STR, (char *) &ioc); + if (ret >= 0 && cmd == SIOCGIFCONF) +#ifdef SVR4 + ((struct ifconf *) arg)->ifc_len = ioc.ic_len; +#endif + return ret; +} +#else +#define ifioctl ioctl +#endif + +/* + * DefineSelf (fd): + * + * Define this host for access control. Find all the hosts the OS knows about + * for this fd and add them to the selfhosts list. + */ + +#if !defined(SIOCGIFCONF) +void +DefineSelf (int fd) +{ +#if !defined(TCPCONN) && !defined(STREAMSCONN) && !defined(UNIXCONN) + return; +#else + register int n; + int len; + caddr_t addr; + int family; + register HOST *host; + +#ifndef WIN32 + struct utsname name; +#else + struct { + char nodename[512]; + } name; +#endif + + register struct hostent *hp; + + union { + struct sockaddr sa; + struct sockaddr_in in; +#if defined(IPv6) && defined(AF_INET6) + struct sockaddr_in6 in6; +#endif + } saddr; + + struct sockaddr_in *inetaddr; + struct sockaddr_in6 *inet6addr; + struct sockaddr_in broad_addr; +#ifdef XTHREADS_NEEDS_BYNAMEPARAMS + _Xgethostbynameparams hparams; +#endif + + /* Why not use gethostname()? Well, at least on my system, I've had to + * make an ugly kernel patch to get a name longer than 8 characters, and + * uname() lets me access to the whole string (it smashes release, you + * see), whereas gethostname() kindly truncates it for me. + */ +#ifndef WIN32 + uname(&name); +#else + gethostname(name.nodename, sizeof(name.nodename)); +#endif + + hp = _XGethostbyname(name.nodename, hparams); + if (hp != NULL) + { + #ifdef h_addr + #define hp_addr *list + char **list; + + /* iterate over the addresses */ + for (list = hp->h_addr_list; *list; list++) + #else + #define hp_addr hp->h_addr + #endif + { + saddr.sa.sa_family = hp->h_addrtype; + switch (hp->h_addrtype) { + case AF_INET: + inetaddr = (struct sockaddr_in *) (&(saddr.sa)); + acopy ( hp_addr, &(inetaddr->sin_addr), hp->h_length); + len = sizeof(saddr.sa); + break; +#if defined(IPv6) && defined(AF_INET6) + case AF_INET6: + inet6addr = (struct sockaddr_in6 *) (&(saddr.sa)); + acopy ( hp_addr, &(inet6addr->sin6_addr), hp->h_length); + len = sizeof(saddr.in6); + break; +#endif + default: + goto DefineLocalHost; + } + family = ConvertAddr ( &(saddr.sa), &len, (pointer *)&addr); + if ( family != -1 && family != FamilyLocal ) + { + for (host = selfhosts; + host && !addrEqual (family, addr, len, host); + host = host->next) ; + if (!host) + { + /* add this host to the host list. */ + MakeHost(host,len) + if (host) + { + host->family = family; + host->len = len; + acopy ( addr, host->addr, len); + host->next = selfhosts; + selfhosts = host; + } + #ifdef XDMCP + /* + * If this is an Internet Address, but not the localhost + * address (127.0.0.1), nor the bogus address (0.0.0.0), + * register it. + */ + if (family == FamilyInternet && + !(len == 4 && + ((addr[0] == 127) || + (addr[0] == 0 && addr[1] == 0 && + addr[2] == 0 && addr[3] == 0))) + ) + { + XdmcpRegisterConnection (family, (char *)addr, len); + broad_addr = *inetaddr; + ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr = + htonl (INADDR_BROADCAST); + XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) + &broad_addr); + } + #if defined(IPv6) && defined(AF_INET6) + else if (family == FamilyInternet6 && + !(IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr))) + { + XdmcpRegisterConnection (family, (char *)addr, len); + } + #endif + + #endif /* XDMCP */ + } + } + } + } + /* + * now add a host of family FamilyLocalHost... + */ +DefineLocalHost: + for (host = selfhosts; + host && !addrEqual(FamilyLocalHost, "", 0, host); + host = host->next); + if (!host) + { + MakeHost(host, 0); + if (host) + { + host->family = FamilyLocalHost; + host->len = 0; + acopy("", host->addr, 0); + host->next = selfhosts; + selfhosts = host; + } + } +#endif /* !TCPCONN && !STREAMSCONN && !UNIXCONN */ +} + +#else + +#ifdef USE_SIOCGLIFCONF +#define ifr_type struct lifreq +#else +#define ifr_type struct ifreq +#endif + +#ifdef VARIABLE_IFREQ +#define ifr_size(p) (sizeof (struct ifreq) + \ + (p->ifr_addr.sa_len > sizeof (p->ifr_addr) ? \ + p->ifr_addr.sa_len - sizeof (p->ifr_addr) : 0)) +#define ifraddr_size(a) (a.sa_len) +#else +#define ifr_size(p) (sizeof (ifr_type)) +#define ifraddr_size(a) (sizeof (a)) +#endif + +#if defined(IPv6) && defined(AF_INET6) +#include <arpa/inet.h> +#endif + +#if defined(IPv6) && defined(AF_INET6) +static void +in6_fillscopeid(struct sockaddr_in6 *sin6) +{ +#if defined(__KAME__) + if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { + sin6->sin6_scope_id = + ntohs(*(u_int16_t *)&sin6->sin6_addr.s6_addr[2]); + sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0; + } +#endif +} +#endif + +void +DefineSelf (int fd) +{ +#ifndef HAS_GETIFADDRS + char *cp, *cplim; +# ifdef USE_SIOCGLIFCONF + struct sockaddr_storage buf[16]; + struct lifconf ifc; + register struct lifreq *ifr; +# ifdef SIOCGLIFNUM + struct lifnum ifn; +# endif +# else /* !USE_SIOCGLIFCONF */ + char buf[2048]; + struct ifconf ifc; + register struct ifreq *ifr; +# endif + void * bufptr = buf; +#else /* HAS_GETIFADDRS */ + struct ifaddrs * ifap, *ifr; +#endif + int len; + unsigned char * addr; + int family; + register HOST *host; + +#ifndef HAS_GETIFADDRS + + len = sizeof(buf); + +#ifdef USE_SIOCGLIFCONF + +#ifdef SIOCGLIFNUM + ifn.lifn_family = AF_UNSPEC; + ifn.lifn_flags = 0; + if (ioctl (fd, SIOCGLIFNUM, (char *) &ifn) < 0) + Error ("Getting interface count"); + if (len < (ifn.lifn_count * sizeof(struct lifreq))) { + len = ifn.lifn_count * sizeof(struct lifreq); + bufptr = malloc(len); + } +#endif + + ifc.lifc_family = AF_UNSPEC; + ifc.lifc_flags = 0; + ifc.lifc_len = len; + ifc.lifc_buf = bufptr; + +#define IFC_IOCTL_REQ SIOCGLIFCONF +#define IFC_IFC_REQ ifc.lifc_req +#define IFC_IFC_LEN ifc.lifc_len +#define IFR_IFR_ADDR ifr->lifr_addr +#define IFR_IFR_NAME ifr->lifr_name + +#else /* Use SIOCGIFCONF */ + ifc.ifc_len = len; + ifc.ifc_buf = bufptr; + +#define IFC_IOCTL_REQ SIOCGIFCONF +#define IFC_IFC_REQ ifc.ifc_req +#define IFC_IFC_LEN ifc.ifc_len +#define IFR_IFR_ADDR ifr->ifr_addr +#define IFR_IFR_NAME ifr->ifr_name +#endif + + if (ifioctl (fd, IFC_IOCTL_REQ, (pointer) &ifc) < 0) + Error ("Getting interface configuration (4)"); + + cplim = (char *) IFC_IFC_REQ + IFC_IFC_LEN; + + for (cp = (char *) IFC_IFC_REQ; cp < cplim; cp += ifr_size (ifr)) + { + ifr = (ifr_type *) cp; + len = ifraddr_size (IFR_IFR_ADDR); + family = ConvertAddr ((struct sockaddr *) &IFR_IFR_ADDR, + &len, (pointer *)&addr); + if (family == -1 || family == FamilyLocal) + continue; +#if defined(IPv6) && defined(AF_INET6) + if (family == FamilyInternet6) + in6_fillscopeid((struct sockaddr_in6 *)&IFR_IFR_ADDR); +#endif + for (host = selfhosts; + host && !addrEqual (family, addr, len, host); + host = host->next) + ; + if (host) + continue; + MakeHost(host,len) + if (host) + { + host->family = family; + host->len = len; + acopy(addr, host->addr, len); + host->next = selfhosts; + selfhosts = host; + } +#ifdef XDMCP + { +#ifdef USE_SIOCGLIFCONF + struct sockaddr_storage broad_addr; +#else + struct sockaddr broad_addr; +#endif + + /* + * If this isn't an Internet Address, don't register it. + */ + if (family != FamilyInternet +#if defined(IPv6) && defined(AF_INET6) + && family != FamilyInternet6 +#endif + ) + continue; + + /* + * ignore 'localhost' entries as they're not useful + * on the other end of the wire + */ + if (family == FamilyInternet && + addr[0] == 127 && addr[1] == 0 && + addr[2] == 0 && addr[3] == 1) + continue; +#if defined(IPv6) && defined(AF_INET6) + else if (family == FamilyInternet6 && + IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)) + continue; +#endif + + /* + * Ignore '0.0.0.0' entries as they are + * returned by some OSes for unconfigured NICs but they are + * not useful on the other end of the wire. + */ + if (len == 4 && + addr[0] == 0 && addr[1] == 0 && + addr[2] == 0 && addr[3] == 0) + continue; + + XdmcpRegisterConnection (family, (char *)addr, len); + +#if defined(IPv6) && defined(AF_INET6) + /* IPv6 doesn't support broadcasting, so we drop out here */ + if (family == FamilyInternet6) + continue; +#endif + + broad_addr = IFR_IFR_ADDR; + + ((struct sockaddr_in *) &broad_addr)->sin_addr.s_addr = + htonl (INADDR_BROADCAST); +#if defined(USE_SIOCGLIFCONF) && defined(SIOCGLIFBRDADDR) + { + struct lifreq broad_req; + + broad_req = *ifr; + if (ioctl (fd, SIOCGLIFFLAGS, (char *) &broad_req) != -1 && + (broad_req.lifr_flags & IFF_BROADCAST) && + (broad_req.lifr_flags & IFF_UP) + ) + { + broad_req = *ifr; + if (ioctl (fd, SIOCGLIFBRDADDR, &broad_req) != -1) + broad_addr = broad_req.lifr_broadaddr; + else + continue; + } + else + continue; + } + +#elif defined(SIOCGIFBRDADDR) + { + struct ifreq broad_req; + + broad_req = *ifr; + if (ifioctl (fd, SIOCGIFFLAGS, (pointer) &broad_req) != -1 && + (broad_req.ifr_flags & IFF_BROADCAST) && + (broad_req.ifr_flags & IFF_UP) + ) + { + broad_req = *ifr; + if (ifioctl (fd, SIOCGIFBRDADDR, (pointer) &broad_req) != -1) + broad_addr = broad_req.ifr_addr; + else + continue; + } + else + continue; + } +#endif /* SIOCGIFBRDADDR */ + XdmcpRegisterBroadcastAddress ((struct sockaddr_in *) &broad_addr); + } +#endif /* XDMCP */ + } + if (bufptr != buf) + free(bufptr); +#else /* HAS_GETIFADDRS */ + if (getifaddrs(&ifap) < 0) { + ErrorF("Warning: getifaddrs returns %s\n", strerror(errno)); + return; + } + for (ifr = ifap; ifr != NULL; ifr = ifr->ifa_next) { + if (!ifr->ifa_addr) + continue; + len = sizeof(*(ifr->ifa_addr)); + family = ConvertAddr((struct sockaddr *) ifr->ifa_addr, &len, + (pointer *)&addr); + if (family == -1 || family == FamilyLocal) + continue; +#if defined(IPv6) && defined(AF_INET6) + if (family == FamilyInternet6) + in6_fillscopeid((struct sockaddr_in6 *)ifr->ifa_addr); +#endif + + for (host = selfhosts; + host != NULL && !addrEqual(family, addr, len, host); + host = host->next) + ; + if (host != NULL) + continue; + MakeHost(host, len); + if (host != NULL) { + host->family = family; + host->len = len; + acopy(addr, host->addr, len); + host->next = selfhosts; + selfhosts = host; + } +#ifdef XDMCP + { + /* + * If this isn't an Internet Address, don't register it. + */ + if (family != FamilyInternet +#if defined(IPv6) && defined(AF_INET6) + && family != FamilyInternet6 +#endif + ) + continue; + + /* + * ignore 'localhost' entries as they're not useful + * on the other end of the wire + */ + if (ifr->ifa_flags & IFF_LOOPBACK) + continue; + + if (family == FamilyInternet && + addr[0] == 127 && addr[1] == 0 && + addr[2] == 0 && addr[3] == 1) + continue; + + /* + * Ignore '0.0.0.0' entries as they are + * returned by some OSes for unconfigured NICs but they are + * not useful on the other end of the wire. + */ + if (len == 4 && + addr[0] == 0 && addr[1] == 0 && + addr[2] == 0 && addr[3] == 0) + continue; +#if defined(IPv6) && defined(AF_INET6) + else if (family == FamilyInternet6 && + IN6_IS_ADDR_LOOPBACK((struct in6_addr *)addr)) + continue; +#endif + XdmcpRegisterConnection(family, (char *)addr, len); +#if defined(IPv6) && defined(AF_INET6) + if (family == FamilyInternet6) + /* IPv6 doesn't support broadcasting, so we drop out here */ + continue; +#endif + if ((ifr->ifa_flags & IFF_BROADCAST) && + (ifr->ifa_flags & IFF_UP) && + ifr->ifa_broadaddr) + XdmcpRegisterBroadcastAddress( + (struct sockaddr_in *) ifr->ifa_broadaddr); + else + continue; + } +#endif /* XDMCP */ + + } /* for */ + freeifaddrs(ifap); +#endif /* HAS_GETIFADDRS */ + + /* + * add something of FamilyLocalHost + */ + for (host = selfhosts; + host && !addrEqual(FamilyLocalHost, "", 0, host); + host = host->next); + if (!host) + { + MakeHost(host, 0); + if (host) + { + host->family = FamilyLocalHost; + host->len = 0; + acopy("", host->addr, 0); + host->next = selfhosts; + selfhosts = host; + } + } +} +#endif /* hpux && !HAS_IFREQ */ + +#ifdef XDMCP +void +AugmentSelf(pointer from, int len) +{ + int family; + pointer addr; + register HOST *host; + + family = ConvertAddr(from, &len, (pointer *)&addr); + if (family == -1 || family == FamilyLocal) + return; + for (host = selfhosts; host; host = host->next) + { + if (addrEqual(family, addr, len, host)) + return; + } + MakeHost(host,len) + if (!host) + return; + host->family = family; + host->len = len; + acopy(addr, host->addr, len); + host->next = selfhosts; + selfhosts = host; +} +#endif + +void +AddLocalHosts (void) +{ + HOST *self; + + for (self = selfhosts; self; self = self->next) + /* Fix for XFree86 bug #156: pass addingLocal = TRUE to + * NewHost to tell that we are adding the default local + * host entries and not to flag the entries as being + * explicitely requested */ + (void) NewHost (self->family, self->addr, self->len, TRUE); +} + +/* Reset access control list to initial hosts */ +void +ResetHosts (char *display) +{ + register HOST *host; + char lhostname[120], ohostname[120]; + char *hostname = ohostname; + char fname[PATH_MAX + 1]; + int fnamelen; + FILE *fd; + char *ptr; + int i, hostlen; +#if (defined(TCPCONN) || defined(STREAMSCONN) ) && \ + (!defined(IPv6) || !defined(AF_INET6)) + union { + struct sockaddr sa; +#if defined(TCPCONN) || defined(STREAMSCONN) + struct sockaddr_in in; +#endif /* TCPCONN || STREAMSCONN */ + } saddr; +#endif + int family = 0; + pointer addr; + int len; + + siTypesInitialize(); + AccessEnabled = defeatAccessControl ? FALSE : DEFAULT_ACCESS_CONTROL; + LocalHostEnabled = FALSE; + while ((host = validhosts) != 0) + { + validhosts = host->next; + FreeHost (host); + } + +#if defined WIN32 && defined __MINGW32__ +#define ETC_HOST_PREFIX "X" +#else +#define ETC_HOST_PREFIX "/etc/X" +#endif +#define ETC_HOST_SUFFIX ".hosts" + fnamelen = strlen(ETC_HOST_PREFIX) + strlen(ETC_HOST_SUFFIX) + + strlen(display) + 1; + if (fnamelen > sizeof(fname)) + FatalError("Display name `%s' is too long\n", display); + snprintf(fname, sizeof(fname), ETC_HOST_PREFIX "%s" ETC_HOST_SUFFIX, + display); + + if ((fd = fopen (fname, "r")) != 0) + { + while (fgets (ohostname, sizeof (ohostname), fd)) + { + family = FamilyWild; + if (*ohostname == '#') + continue; + if ((ptr = strchr(ohostname, '\n')) != 0) + *ptr = 0; + hostlen = strlen(ohostname) + 1; + for (i = 0; i < hostlen; i++) + lhostname[i] = tolower(ohostname[i]); + hostname = ohostname; + if (!strncmp("local:", lhostname, 6)) + { + family = FamilyLocalHost; + NewHost(family, "", 0, FALSE); + LocalHostRequested = TRUE; /* Fix for XFree86 bug #156 */ + } +#if defined(TCPCONN) || defined(STREAMSCONN) + else if (!strncmp("inet:", lhostname, 5)) + { + family = FamilyInternet; + hostname = ohostname + 5; + } +#if defined(IPv6) && defined(AF_INET6) + else if (!strncmp("inet6:", lhostname, 6)) + { + family = FamilyInternet6; + hostname = ohostname + 6; + } +#endif +#endif +#ifdef SECURE_RPC + else if (!strncmp("nis:", lhostname, 4)) + { + family = FamilyNetname; + hostname = ohostname + 4; + } +#endif + else if (!strncmp("si:", lhostname, 3)) + { + family = FamilyServerInterpreted; + hostname = ohostname + 3; + hostlen -= 3; + } + + + if (family == FamilyServerInterpreted) + { + len = siCheckAddr(hostname, hostlen); + if (len >= 0) { + NewHost(family, hostname, len, FALSE); + } + } + else +#ifdef SECURE_RPC + if ((family == FamilyNetname) || (strchr(hostname, '@'))) + { + SecureRPCInit (); + (void) NewHost (FamilyNetname, hostname, strlen (hostname), FALSE); + } + else +#endif /* SECURE_RPC */ +#if defined(TCPCONN) || defined(STREAMSCONN) + { +#if defined(IPv6) && defined(AF_INET6) + if ( (family == FamilyInternet) || (family == FamilyInternet6) || + (family == FamilyWild) ) + { + struct addrinfo *addresses; + struct addrinfo *a; + int f; + + if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) { + for (a = addresses ; a != NULL ; a = a->ai_next) { + len = a->ai_addrlen; + f = ConvertAddr(a->ai_addr,&len,(pointer *)&addr); + if ( (family == f) || + ((family == FamilyWild) && (f != -1)) ) { + NewHost(f, addr, len, FALSE); + } + } + freeaddrinfo(addresses); + } + } +#else +#ifdef XTHREADS_NEEDS_BYNAMEPARAMS + _Xgethostbynameparams hparams; +#endif + register struct hostent *hp; + + /* host name */ + if ((family == FamilyInternet && + ((hp = _XGethostbyname(hostname, hparams)) != 0)) || + ((hp = _XGethostbyname(hostname, hparams)) != 0)) + { + saddr.sa.sa_family = hp->h_addrtype; + len = sizeof(saddr.sa); + if ((family = ConvertAddr (&saddr.sa, &len, (pointer *)&addr)) != -1) + { +#ifdef h_addr /* new 4.3bsd version of gethostent */ + char **list; + + /* iterate over the addresses */ + for (list = hp->h_addr_list; *list; list++) + (void) NewHost (family, (pointer)*list, len, FALSE); +#else + (void) NewHost (family, (pointer)hp->h_addr, len, FALSE); +#endif + } + } +#endif /* IPv6 */ + } +#endif /* TCPCONN || STREAMSCONN */ + family = FamilyWild; + } + fclose (fd); + } +} + +/* Is client on the local host */ +Bool LocalClient(ClientPtr client) +{ + int alen, family, notused; + Xtransaddr *from = NULL; + pointer addr; + register HOST *host; + + if (!client->osPrivate) + return FALSE; + if (!((OsCommPtr)client->osPrivate)->trans_conn) + return FALSE; + + if (!_XSERVTransGetPeerAddr (((OsCommPtr)client->osPrivate)->trans_conn, + ¬used, &alen, &from)) + { + family = ConvertAddr ((struct sockaddr *) from, + &alen, (pointer *)&addr); + if (family == -1) + { + free(from); + return FALSE; + } + if (family == FamilyLocal) + { + free(from); + return TRUE; + } + for (host = selfhosts; host; host = host->next) + { + if (addrEqual (family, addr, alen, host)) + return TRUE; + } + free(from); + } + return FALSE; +} + +/* + * Return the uid and gid of a connected local client + * + * Used by XShm to test access rights to shared memory segments + */ +int +LocalClientCred(ClientPtr client, int *pUid, int *pGid) +{ + LocalClientCredRec *lcc; + int ret = GetLocalClientCreds(client, &lcc); + + if (ret == 0) { +#ifdef HAVE_GETZONEID /* only local if in the same zone */ + if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) { + FreeLocalClientCreds(lcc); + return -1; + } +#endif + if ((lcc->fieldsSet & LCC_UID_SET) && (pUid != NULL)) + *pUid = lcc->euid; + if ((lcc->fieldsSet & LCC_GID_SET) && (pGid != NULL)) + *pGid = lcc->egid; + FreeLocalClientCreds(lcc); + } + return ret; +} + +/* + * Return the uid and all gids of a connected local client + * Allocates a LocalClientCredRec - caller must call FreeLocalClientCreds + * + * Used by localuser & localgroup ServerInterpreted access control forms below + * Used by AuthAudit to log who local connections came from + */ +int +GetLocalClientCreds(ClientPtr client, LocalClientCredRec **lccp) +{ +#if defined(HAS_GETPEEREID) || defined(HAS_GETPEERUCRED) || defined(SO_PEERCRED) + int fd; + XtransConnInfo ci; + LocalClientCredRec *lcc; +#ifdef HAS_GETPEEREID + uid_t uid; + gid_t gid; +#elif defined(HAS_GETPEERUCRED) + ucred_t *peercred = NULL; + const gid_t *gids; +#elif defined(SO_PEERCRED) + struct ucred peercred; + socklen_t so_len = sizeof(peercred); +#endif + + if (client == NULL) + return -1; + ci = ((OsCommPtr)client->osPrivate)->trans_conn; +#if !(defined(sun) && defined(HAS_GETPEERUCRED)) + /* Most implementations can only determine peer credentials for Unix + * domain sockets - Solaris getpeerucred can work with a bit more, so + * we just let it tell us if the connection type is supported or not + */ + if (!_XSERVTransIsLocal(ci)) { + return -1; + } +#endif + + *lccp = calloc(1, sizeof(LocalClientCredRec)); + if (*lccp == NULL) + return -1; + lcc = *lccp; + + fd = _XSERVTransGetConnectionNumber(ci); +#ifdef HAS_GETPEEREID + if (getpeereid(fd, &uid, &gid) == -1) { + FreeLocalClientCreds(lcc); + return -1; + } + lcc->euid = uid; + lcc->egid = gid; + lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET; + return 0; +#elif defined(HAS_GETPEERUCRED) + if (getpeerucred(fd, &peercred) < 0) { + FreeLocalClientCreds(lcc); + return -1; + } + lcc->euid = ucred_geteuid(peercred); + if (lcc->euid != -1) + lcc->fieldsSet |= LCC_UID_SET; + lcc->egid = ucred_getegid(peercred); + if (lcc->egid != -1) + lcc->fieldsSet |= LCC_GID_SET; + lcc->pid = ucred_getpid(peercred); + if (lcc->pid != -1) + lcc->fieldsSet |= LCC_PID_SET; +#ifdef HAVE_GETZONEID + lcc->zoneid = ucred_getzoneid(peercred); + if (lcc->zoneid != -1) + lcc->fieldsSet |= LCC_ZID_SET; +#endif + lcc->nSuppGids = ucred_getgroups(peercred, &gids); + if (lcc->nSuppGids > 0) { + lcc->pSuppGids = calloc(lcc->nSuppGids, sizeof(int)); + if (lcc->pSuppGids == NULL) { + lcc->nSuppGids = 0; + } else { + int i; + for (i = 0 ; i < lcc->nSuppGids; i++) { + (lcc->pSuppGids)[i] = (int) gids[i]; + } + } + } else { + lcc->nSuppGids = 0; + } + ucred_free(peercred); + return 0; +#elif defined(SO_PEERCRED) + if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &peercred, &so_len) == -1) { + FreeLocalClientCreds(lcc); + return -1; + } + lcc->euid = peercred.uid; + lcc->egid = peercred.gid; + lcc->pid = peercred.pid; + lcc->fieldsSet = LCC_UID_SET | LCC_GID_SET | LCC_PID_SET; + return 0; +#endif +#else + /* No system call available to get the credentials of the peer */ +#define NO_LOCAL_CLIENT_CRED + return -1; +#endif +} + +void +FreeLocalClientCreds(LocalClientCredRec *lcc) +{ + if (lcc != NULL) { + if (lcc->nSuppGids > 0) { + free(lcc->pSuppGids); + } + free(lcc); + } +} + +static int +AuthorizedClient(ClientPtr client) +{ + int rc; + + if (!client || defeatAccessControl) + return Success; + + /* untrusted clients can't change host access */ + rc = XaceHook(XACE_SERVER_ACCESS, client, DixManageAccess); + if (rc != Success) + return rc; + + return LocalClient(client) ? Success : BadAccess; +} + +/* Add a host to the access control list. This is the external interface + * called from the dispatcher */ + +int +AddHost (ClientPtr client, + int family, + unsigned length, /* of bytes in pAddr */ + const void * pAddr) +{ + int rc, len; + + rc = AuthorizedClient(client); + if (rc != Success) + return rc; + switch (family) { + case FamilyLocalHost: + len = length; + LocalHostEnabled = TRUE; + break; +#ifdef SECURE_RPC + case FamilyNetname: + len = length; + SecureRPCInit (); + break; +#endif + case FamilyInternet: +#if defined(IPv6) && defined(AF_INET6) + case FamilyInternet6: +#endif + case FamilyDECnet: + case FamilyChaos: + case FamilyServerInterpreted: + if ((len = CheckAddr (family, pAddr, length)) < 0) + { + client->errorValue = length; + return BadValue; + } + break; + case FamilyLocal: + default: + client->errorValue = family; + return BadValue; + } + if (NewHost (family, pAddr, len, FALSE)) + return Success; + return BadAlloc; +} + +Bool +ForEachHostInFamily (int family, + Bool (*func)( + unsigned char * /* addr */, + short /* len */, + pointer /* closure */), + pointer closure) +{ + HOST *host; + + for (host = validhosts; host; host = host->next) + if (family == host->family && func (host->addr, host->len, closure)) + return TRUE; + return FALSE; +} + +/* Add a host to the access control list. This is the internal interface + * called when starting or resetting the server */ +static Bool +NewHost (int family, + const void * addr, + int len, + int addingLocalHosts) +{ + register HOST *host; + + for (host = validhosts; host; host = host->next) + { + if (addrEqual (family, addr, len, host)) + return TRUE; + } + if (!addingLocalHosts) { /* Fix for XFree86 bug #156 */ + for (host = selfhosts; host; host = host->next) { + if (addrEqual (family, addr, len, host)) { + host->requested = TRUE; + break; + } + } + } + MakeHost(host,len) + if (!host) + return FALSE; + host->family = family; + host->len = len; + acopy(addr, host->addr, len); + host->next = validhosts; + validhosts = host; + return TRUE; +} + +/* Remove a host from the access control list */ + +int +RemoveHost ( + ClientPtr client, + int family, + unsigned length, /* of bytes in pAddr */ + pointer pAddr) +{ + int rc, len; + register HOST *host, **prev; + + rc = AuthorizedClient(client); + if (rc != Success) + return rc; + switch (family) { + case FamilyLocalHost: + len = length; + LocalHostEnabled = FALSE; + break; +#ifdef SECURE_RPC + case FamilyNetname: + len = length; + break; +#endif + case FamilyInternet: +#if defined(IPv6) && defined(AF_INET6) + case FamilyInternet6: +#endif + case FamilyDECnet: + case FamilyChaos: + case FamilyServerInterpreted: + if ((len = CheckAddr (family, pAddr, length)) < 0) + { + client->errorValue = length; + return BadValue; + } + break; + case FamilyLocal: + default: + client->errorValue = family; + return BadValue; + } + for (prev = &validhosts; + (host = *prev) && (!addrEqual (family, pAddr, len, host)); + prev = &host->next) + ; + if (host) + { + *prev = host->next; + FreeHost (host); + } + return Success; +} + +/* Get all hosts in the access control list */ +int +GetHosts ( + pointer *data, + int *pnHosts, + int *pLen, + BOOL *pEnabled) +{ + int len; + register int n = 0; + register unsigned char *ptr; + register HOST *host; + int nHosts = 0; + + *pEnabled = AccessEnabled ? EnableAccess : DisableAccess; + for (host = validhosts; host; host = host->next) + { + nHosts++; + n += pad_to_int32(host->len) + sizeof(xHostEntry); + } + if (n) + { + *data = ptr = malloc(n); + if (!ptr) + { + return BadAlloc; + } + for (host = validhosts; host; host = host->next) + { + len = host->len; + ((xHostEntry *)ptr)->family = host->family; + ((xHostEntry *)ptr)->length = len; + ptr += sizeof(xHostEntry); + acopy (host->addr, ptr, len); + ptr += pad_to_int32(len); + } + } else { + *data = NULL; + } + *pnHosts = nHosts; + *pLen = n; + return Success; +} + +/* Check for valid address family and length, and return address length. */ + +/*ARGSUSED*/ +static int +CheckAddr ( + int family, + const void * pAddr, + unsigned length) +{ + int len; + + switch (family) + { +#if defined(TCPCONN) || defined(STREAMSCONN) + case FamilyInternet: + if (length == sizeof (struct in_addr)) + len = length; + else + len = -1; + break; +#if defined(IPv6) && defined(AF_INET6) + case FamilyInternet6: + if (length == sizeof (struct in6_addr)) + len = length; + else + len = -1; + break; +#endif +#endif + case FamilyServerInterpreted: + len = siCheckAddr(pAddr, length); + break; + default: + len = -1; + } + return len; +} + +/* Check if a host is not in the access control list. + * Returns 1 if host is invalid, 0 if we've found it. */ + +int +InvalidHost ( + register struct sockaddr *saddr, + int len, + ClientPtr client) +{ + int family; + pointer addr; + register HOST *selfhost, *host; + + if (!AccessEnabled) /* just let them in */ + return 0; + family = ConvertAddr (saddr, &len, (pointer *)&addr); + if (family == -1) + return 1; + if (family == FamilyLocal) + { + if (!LocalHostEnabled) + { + /* + * check to see if any local address is enabled. This + * implicitly enables local connections. + */ + for (selfhost = selfhosts; selfhost; selfhost=selfhost->next) + { + for (host = validhosts; host; host=host->next) + { + if (addrEqual (selfhost->family, selfhost->addr, + selfhost->len, host)) + return 0; + } + } + } else + return 0; + } + for (host = validhosts; host; host = host->next) + { + if ((host->family == FamilyServerInterpreted)) { + if (siAddrMatch (family, addr, len, host, client)) { + return 0; + } + } else { + if (addrEqual (family, addr, len, host)) + return 0; + } + + } + return 1; +} + +static int +ConvertAddr ( + register struct sockaddr *saddr, + int *len, + pointer *addr) +{ + if (*len == 0) + return FamilyLocal; + switch (saddr->sa_family) + { + case AF_UNSPEC: +#if defined(UNIXCONN) || defined(LOCALCONN) + case AF_UNIX: +#endif + return FamilyLocal; +#if defined(TCPCONN) || defined(STREAMSCONN) + case AF_INET: +#ifdef WIN32 + if (16777343 == *(long*)&((struct sockaddr_in *) saddr)->sin_addr) + return FamilyLocal; +#endif + *len = sizeof (struct in_addr); + *addr = (pointer) &(((struct sockaddr_in *) saddr)->sin_addr); + return FamilyInternet; +#if defined(IPv6) && defined(AF_INET6) + case AF_INET6: + { + struct sockaddr_in6 *saddr6 = (struct sockaddr_in6 *) saddr; + if (IN6_IS_ADDR_V4MAPPED(&(saddr6->sin6_addr))) { + *len = sizeof (struct in_addr); + *addr = (pointer) &(saddr6->sin6_addr.s6_addr[12]); + return FamilyInternet; + } else { + *len = sizeof (struct in6_addr); + *addr = (pointer) &(saddr6->sin6_addr); + return FamilyInternet6; + } + } +#endif +#endif + default: + return -1; + } +} + +int +ChangeAccessControl( + ClientPtr client, + int fEnabled) +{ + int rc = AuthorizedClient(client); + if (rc != Success) + return rc; + AccessEnabled = fEnabled; + return Success; +} + +/* returns FALSE if xhost + in effect, else TRUE */ +int +GetAccessControl(void) +{ + return AccessEnabled; +} + +/***************************************************************************** + * FamilyServerInterpreted host entry implementation + * + * Supports an extensible system of host types which the server can interpret + * See the IPv6 extensions to the X11 protocol spec for the definition. + * + * Currently supported schemes: + * + * hostname - hostname as defined in IETF RFC 2396 + * ipv6 - IPv6 literal address as defined in IETF RFC's 3513 and <TBD> + * + * See xc/doc/specs/SIAddresses for formal definitions of each type. + */ + +/* These definitions and the siTypeAdd function could be exported in the + * future to enable loading additional host types, but that was not done for + * the initial implementation. + */ +typedef Bool (*siAddrMatchFunc)(int family, pointer addr, int len, + const char *siAddr, int siAddrlen, ClientPtr client, void *siTypePriv); +typedef int (*siCheckAddrFunc)(const char *addrString, int length, + void *siTypePriv); + +struct siType { + struct siType * next; + const char * typeName; + siAddrMatchFunc addrMatch; + siCheckAddrFunc checkAddr; + void * typePriv; /* Private data for type routines */ +}; + +static struct siType *siTypeList; + +static int +siTypeAdd(const char *typeName, siAddrMatchFunc addrMatch, + siCheckAddrFunc checkAddr, void *typePriv) +{ + struct siType *s, *p; + + if ((typeName == NULL) || (addrMatch == NULL) || (checkAddr == NULL)) + return BadValue; + + for (s = siTypeList, p = NULL; s != NULL ; p = s, s = s->next) { + if (strcmp(typeName, s->typeName) == 0) { + s->addrMatch = addrMatch; + s->checkAddr = checkAddr; + s->typePriv = typePriv; + return Success; + } + } + + s = malloc(sizeof(struct siType)); + if (s == NULL) + return BadAlloc; + + if (p == NULL) + siTypeList = s; + else + p->next = s; + + s->next = NULL; + s->typeName = typeName; + s->addrMatch = addrMatch; + s->checkAddr = checkAddr; + s->typePriv = typePriv; + return Success; +} + +/* Checks to see if a host matches a server-interpreted host entry */ +static Bool +siAddrMatch(int family, pointer addr, int len, HOST *host, ClientPtr client) +{ + Bool matches = FALSE; + struct siType *s; + const char *valueString; + int addrlen; + + valueString = (const char *) memchr(host->addr, '\0', host->len); + if (valueString != NULL) { + for (s = siTypeList; s != NULL ; s = s->next) { + if (strcmp((char *) host->addr, s->typeName) == 0) { + addrlen = host->len - (strlen((char *)host->addr) + 1); + matches = s->addrMatch(family, addr, len, + valueString + 1, addrlen, client, s->typePriv); + break; + } + } +#ifdef FAMILY_SI_DEBUG + ErrorF( + "Xserver: siAddrMatch(): type = %s, value = %*.*s -- %s\n", + host->addr, addrlen, addrlen, valueString + 1, + (matches) ? "accepted" : "rejected"); +#endif + } + return matches; +} + +static int +siCheckAddr(const char *addrString, int length) +{ + const char *valueString; + int addrlen, typelen; + int len = -1; + struct siType *s; + + /* Make sure there is a \0 byte inside the specified length + to separate the address type from the address value. */ + valueString = (const char *) memchr(addrString, '\0', length); + if (valueString != NULL) { + /* Make sure the first string is a recognized address type, + * and the second string is a valid address of that type. + */ + typelen = strlen(addrString) + 1; + addrlen = length - typelen; + + for (s = siTypeList; s != NULL ; s = s->next) { + if (strcmp(addrString, s->typeName) == 0) { + len = s->checkAddr(valueString + 1, addrlen, s->typePriv); + if (len >= 0) { + len += typelen; + } + break; + } + } +#ifdef FAMILY_SI_DEBUG + { + const char *resultMsg; + + if (s == NULL) { + resultMsg = "type not registered"; + } else { + if (len == -1) + resultMsg = "rejected"; + else + resultMsg = "accepted"; + } + + ErrorF("Xserver: siCheckAddr(): type = %s, value = %*.*s, len = %d -- %s\n", + addrString, addrlen, addrlen, valueString + 1, len, resultMsg); + } +#endif + } + return len; +} + + +/*** + * Hostname server-interpreted host type + * + * Stored as hostname string, explicitly defined to be resolved ONLY + * at access check time, to allow for hosts with dynamic addresses + * but static hostnames, such as found in some DHCP & mobile setups. + * + * Hostname must conform to IETF RFC 2396 sec. 3.2.2, which defines it as: + * hostname = *( domainlabel "." ) toplabel [ "." ] + * domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum + * toplabel = alpha | alpha *( alphanum | "-" ) alphanum + */ + +#ifdef NI_MAXHOST +# define SI_HOSTNAME_MAXLEN NI_MAXHOST +#else +# ifdef MAXHOSTNAMELEN +# define SI_HOSTNAME_MAXLEN MAXHOSTNAMELEN +# else +# define SI_HOSTNAME_MAXLEN 256 +# endif +#endif + +static Bool +siHostnameAddrMatch(int family, pointer addr, int len, + const char *siAddr, int siAddrLen, ClientPtr client, void *typePriv) +{ + Bool res = FALSE; + +/* Currently only supports checking against IPv4 & IPv6 connections, but + * support for other address families, such as DECnet, could be added if + * desired. + */ +#if defined(IPv6) && defined(AF_INET6) + if ((family == FamilyInternet) || (family == FamilyInternet6)) { + char hostname[SI_HOSTNAME_MAXLEN]; + struct addrinfo *addresses; + struct addrinfo *a; + int f, hostaddrlen; + pointer hostaddr; + + if (siAddrLen >= sizeof(hostname)) + return FALSE; + + strncpy(hostname, siAddr, siAddrLen); + hostname[siAddrLen] = '\0'; + + if (getaddrinfo(hostname, NULL, NULL, &addresses) == 0) { + for (a = addresses ; a != NULL ; a = a->ai_next) { + hostaddrlen = a->ai_addrlen; + f = ConvertAddr(a->ai_addr,&hostaddrlen,&hostaddr); + if ((f == family) && (len == hostaddrlen) && + (acmp (addr, hostaddr, len) == 0) ) { + res = TRUE; + break; + } + } + freeaddrinfo(addresses); + } + } +#else /* IPv6 not supported, use gethostbyname instead for IPv4 */ + if (family == FamilyInternet) { + register struct hostent *hp; +#ifdef XTHREADS_NEEDS_BYNAMEPARAMS + _Xgethostbynameparams hparams; +#endif + char hostname[SI_HOSTNAME_MAXLEN]; + int f, hostaddrlen; + pointer hostaddr; + const char **addrlist; + + if (siAddrLen >= sizeof(hostname)) + return FALSE; + + strncpy(hostname, siAddr, siAddrLen); + hostname[siAddrLen] = '\0'; + + if ((hp = _XGethostbyname(hostname, hparams)) != NULL) { +#ifdef h_addr /* new 4.3bsd version of gethostent */ + /* iterate over the addresses */ + for (addrlist = hp->h_addr_list; *addrlist; addrlist++) +#else + addrlist = &hp->h_addr; +#endif + { + struct sockaddr_in sin; + + sin.sin_family = hp->h_addrtype; + acopy ( *addrlist, &(sin.sin_addr), hp->h_length); + hostaddrlen = sizeof(sin); + f = ConvertAddr ((struct sockaddr *)&sin, + &hostaddrlen, &hostaddr); + if ((f == family) && (len == hostaddrlen) && + (acmp (addr, hostaddr, len) == 0) ) { + res = TRUE; + break; + } + } + } + } +#endif + return res; +} + + +static int +siHostnameCheckAddr(const char *valueString, int length, void *typePriv) +{ + /* Check conformance of hostname to RFC 2396 sec. 3.2.2 definition. + * We do not use ctype functions here to avoid locale-specific + * character sets. Hostnames must be pure ASCII. + */ + int len = length; + int i; + Bool dotAllowed = FALSE; + Bool dashAllowed = FALSE; + + if ((length <= 0) || (length >= SI_HOSTNAME_MAXLEN)) { + len = -1; + } else { + for (i = 0; i < length; i++) { + char c = valueString[i]; + + if (c == 0x2E) { /* '.' */ + if (dotAllowed == FALSE) { + len = -1; + break; + } else { + dotAllowed = FALSE; + dashAllowed = FALSE; + } + } else if (c == 0x2D) { /* '-' */ + if (dashAllowed == FALSE) { + len = -1; + break; + } else { + dotAllowed = FALSE; + } + } else if (((c >= 0x30) && (c <= 0x3A)) /* 0-9 */ || + ((c >= 0x61) && (c <= 0x7A)) /* a-z */ || + ((c >= 0x41) && (c <= 0x5A)) /* A-Z */) { + dotAllowed = TRUE; + dashAllowed = TRUE; + } else { /* Invalid character */ + len = -1; + break; + } + } + } + return len; +} + +#if defined(IPv6) && defined(AF_INET6) +/*** + * "ipv6" server interpreted type + * + * Currently supports only IPv6 literal address as specified in IETF RFC 3513 + * + * Once draft-ietf-ipv6-scoping-arch-00.txt becomes an RFC, support will be + * added for the scoped address format it specifies. + */ + +/* Maximum length of an IPv6 address string - increase when adding support + * for scoped address qualifiers. Includes room for trailing NUL byte. + */ +#define SI_IPv6_MAXLEN INET6_ADDRSTRLEN + +static Bool +siIPv6AddrMatch(int family, pointer addr, int len, + const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv) +{ + struct in6_addr addr6; + char addrbuf[SI_IPv6_MAXLEN]; + + if ((family != FamilyInternet6) || (len != sizeof(addr6))) + return FALSE; + + memcpy(addrbuf, siAddr, siAddrlen); + addrbuf[siAddrlen] = '\0'; + + if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) { + perror("inet_pton"); + return FALSE; + } + + if (memcmp(addr, &addr6, len) == 0) { + return TRUE; + } else { + return FALSE; + } +} + +static int +siIPv6CheckAddr(const char *addrString, int length, void *typePriv) +{ + int len; + + /* Minimum length is 3 (smallest legal address is "::1") */ + if (length < 3) { + /* Address is too short! */ + len = -1; + } else if (length >= SI_IPv6_MAXLEN) { + /* Address is too long! */ + len = -1; + } else { + /* Assume inet_pton is sufficient validation */ + struct in6_addr addr6; + char addrbuf[SI_IPv6_MAXLEN]; + + memcpy(addrbuf, addrString, length); + addrbuf[length] = '\0'; + + if (inet_pton(AF_INET6, addrbuf, &addr6) != 1) { + perror("inet_pton"); + len = -1; + } else { + len = length; + } + } + return len; +} +#endif /* IPv6 */ + +#if !defined(NO_LOCAL_CLIENT_CRED) +/*** + * "localuser" & "localgroup" server interpreted types + * + * Allows local connections from a given local user or group + */ + +#include <pwd.h> +#include <grp.h> + +#define LOCAL_USER 1 +#define LOCAL_GROUP 2 + +typedef struct { + int credType; +} siLocalCredPrivRec, *siLocalCredPrivPtr; + +static siLocalCredPrivRec siLocalUserPriv = { LOCAL_USER }; +static siLocalCredPrivRec siLocalGroupPriv = { LOCAL_GROUP }; + +static Bool +siLocalCredGetId(const char *addr, int len, siLocalCredPrivPtr lcPriv, int *id) +{ + Bool parsedOK = FALSE; + char *addrbuf = malloc(len + 1); + + if (addrbuf == NULL) { + return FALSE; + } + + memcpy(addrbuf, addr, len); + addrbuf[len] = '\0'; + + if (addr[0] == '#') { /* numeric id */ + char *cp; + errno = 0; + *id = strtol(addrbuf + 1, &cp, 0); + if ((errno == 0) && (cp != (addrbuf+1))) { + parsedOK = TRUE; + } + } else { /* non-numeric name */ + if (lcPriv->credType == LOCAL_USER) { + struct passwd *pw = getpwnam(addrbuf); + + if (pw != NULL) { + *id = (int) pw->pw_uid; + parsedOK = TRUE; + } + } else { /* group */ + struct group *gr = getgrnam(addrbuf); + + if (gr != NULL) { + *id = (int) gr->gr_gid; + parsedOK = TRUE; + } + } + } + + free(addrbuf); + return parsedOK; +} + +static Bool +siLocalCredAddrMatch(int family, pointer addr, int len, + const char *siAddr, int siAddrlen, ClientPtr client, void *typePriv) +{ + int siAddrId; + LocalClientCredRec *lcc; + siLocalCredPrivPtr lcPriv = (siLocalCredPrivPtr) typePriv; + + if (GetLocalClientCreds(client, &lcc) == -1) { + return FALSE; + } + +#ifdef HAVE_GETZONEID /* Ensure process is in the same zone */ + if ((lcc->fieldsSet & LCC_ZID_SET) && (lcc->zoneid != getzoneid())) { + FreeLocalClientCreds(lcc); + return FALSE; + } +#endif + + if (siLocalCredGetId(siAddr, siAddrlen, lcPriv, &siAddrId) == FALSE) { + FreeLocalClientCreds(lcc); + return FALSE; + } + + if (lcPriv->credType == LOCAL_USER) { + if ((lcc->fieldsSet & LCC_UID_SET) && (lcc->euid == siAddrId)) { + FreeLocalClientCreds(lcc); + return TRUE; + } + } else { + if ((lcc->fieldsSet & LCC_GID_SET) && (lcc->egid == siAddrId)) { + FreeLocalClientCreds(lcc); + return TRUE; + } + if (lcc->pSuppGids != NULL) { + int i; + + for (i = 0 ; i < lcc->nSuppGids; i++) { + if (lcc->pSuppGids[i] == siAddrId) { + FreeLocalClientCreds(lcc); + return TRUE; + } + } + } + } + FreeLocalClientCreds(lcc); + return FALSE; +} + +static int +siLocalCredCheckAddr(const char *addrString, int length, void *typePriv) +{ + int len = length; + int id; + + if (siLocalCredGetId(addrString, length, + (siLocalCredPrivPtr)typePriv, &id) == FALSE) { + len = -1; + } + return len; +} +#endif /* localuser */ + +static void +siTypesInitialize(void) +{ + siTypeAdd("hostname", siHostnameAddrMatch, siHostnameCheckAddr, NULL); +#if defined(IPv6) && defined(AF_INET6) + siTypeAdd("ipv6", siIPv6AddrMatch, siIPv6CheckAddr, NULL); +#endif +#if !defined(NO_LOCAL_CLIENT_CRED) + siTypeAdd("localuser", siLocalCredAddrMatch, siLocalCredCheckAddr, + &siLocalUserPriv); + siTypeAdd("localgroup", siLocalCredAddrMatch, siLocalCredCheckAddr, + &siLocalGroupPriv); +#endif +} diff --git a/xorg-server/os/osinit.c b/xorg-server/os/osinit.c index 6ecf0821c..f27a5b8f3 100644 --- a/xorg-server/os/osinit.c +++ b/xorg-server/os/osinit.c @@ -1,321 +1,318 @@ -/***********************************************************
-
-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.
-
-******************************************************************/
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <stdio.h>
-#include <X11/X.h>
-#include "os.h"
-#include "osdep.h"
-#include <X11/Xos.h>
-#include <signal.h>
-#include <errno.h>
-#ifdef HAVE_DLFCN_H
-# include <dlfcn.h>
-#endif
-#ifdef HAVE_BACKTRACE
-#include <execinfo.h>
-#endif
-
-
-#include "dixstruct.h"
-
-#ifndef PATH_MAX
-#ifdef MAXPATHLEN
-#define PATH_MAX MAXPATHLEN
-#else
-#define PATH_MAX 1024
-#endif
-#endif
-
-#if defined(__SCO__)
-#include <sys/wait.h>
-#endif
-
-#if !defined(SYSV) && !defined(WIN32)
-#include <sys/resource.h>
-#endif
-
-#ifndef ADMPATH
-#define ADMPATH "/usr/adm/X%smsgs"
-#endif
-
-extern char *display;
-#ifdef RLIMIT_DATA
-int limitDataSpace = -1;
-#endif
-#ifdef RLIMIT_STACK
-int limitStackSpace = -1;
-#endif
-#ifdef RLIMIT_NOFILE
-int limitNoFile = -1;
-#endif
-
-static OsSigWrapperPtr OsSigWrapper = NULL;
-
-OsSigWrapperPtr
-OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper)
-{
- OsSigWrapperPtr oldSigWrapper = OsSigWrapper;
-
- OsSigWrapper = newSigWrapper;
-
- return oldSigWrapper;
-}
-
-/*
- * OsSigHandler --
- * Catch unexpected signals and exit or continue cleanly.
- */
-static void
-#ifdef SA_SIGINFO
-OsSigHandler(int signo, siginfo_t *sip, void *unused)
-#else
-OsSigHandler(int signo)
-#endif
-{
-#ifdef RTLD_DI_SETSIGNAL
- const char *dlerr = dlerror();
-
- if (dlerr) {
- LogMessage(X_ERROR, "Dynamic loader error: %s\n", dlerr);
- }
-#endif /* RTLD_DI_SETSIGNAL */
-
- if (OsSigWrapper != NULL) {
- if (OsSigWrapper(signo) == 0) {
- /* ddx handled signal and wants us to continue */
- return;
- }
- }
-
- /* log, cleanup, and abort */
- xorg_backtrace();
-
-#ifdef SA_SIGINFO
- if (sip->si_code == SI_USER) {
- ErrorF("Recieved signal %d sent by process %ld, uid %ld\n",
- signo, (long) sip->si_pid, (long) sip->si_uid);
- } else {
- switch (signo) {
- case SIGSEGV:
- case SIGBUS:
- case SIGILL:
- case SIGFPE:
- ErrorF("%s at address %p\n", strsignal(signo), sip->si_addr);
- }
- }
-#endif
-
- FatalError("Caught signal %d (%s). Server aborting\n",
- signo, strsignal(signo));
-}
-
-void
-OsInit(void)
-{
- static Bool been_here = FALSE;
- static char* devnull = "/dev/null";
- char fname[PATH_MAX];
-
- if (!been_here) {
-#ifndef _MSC_VER
- struct sigaction act, oact;
- int i;
- int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS,
- SIGSYS,
- SIGXCPU,
- SIGXFSZ,
-#ifdef SIGEMT
- SIGEMT,
-#endif
- 0 /* must be last */ };
- sigemptyset(&act.sa_mask);
-#ifdef SA_SIGINFO
- act.sa_sigaction = OsSigHandler;
- act.sa_flags = SA_SIGINFO;
-#else
- act.sa_handler = OsSigHandler;
- act.sa_flags = 0;
-#endif
- for (i = 0; siglist[i] != 0; i++) {
- if (sigaction(siglist[i], &act, &oact)) {
- ErrorF("failed to install signal handler for signal %d: %s\n",
- siglist[i], strerror(errno));
- }
- }
-#ifdef HAVE_BACKTRACE
- /*
- * initialize the backtracer, since the ctor calls dlopen(), which
- * calls malloc(), which isn't signal-safe.
- */
- do {
- void *array;
- backtrace(&array, 1);
- } while (0);
-#endif
-
-#ifdef RTLD_DI_SETSIGNAL
- /* Tell runtime linker to send a signal we can catch instead of SIGKILL
- * for failures to load libraries/modules at runtime so we can clean up
- * after ourselves.
- */
- int failure_signal = SIGQUIT;
- dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal);
-#endif
-#endif
-#if !defined(__SCO__) && !defined(__CYGWIN__) && !defined(__UNIXWARE__)
- fclose(stdin);
- fclose(stdout);
-#endif
- /*
- * If a write of zero bytes to stderr returns non-zero, i.e. -1,
- * then writing to stderr failed, and we'll write somewhere else
- * instead. (Apparently this never happens in the Real World.)
- */
- if (write (2, fname, 0) == -1)
- {
- FILE *err;
-
- if (strlen (display) + strlen (ADMPATH) + 1 < sizeof fname)
- sprintf (fname, ADMPATH, display);
- else
- strcpy (fname, devnull);
- /*
- * uses stdio to avoid os dependencies here,
- * a real os would use
- * open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666)
- */
- if (!(err = fopen (fname, "a+")))
- err = fopen (devnull, "w");
- if (err && (fileno(err) != 2)) {
- dup2 (fileno (err), 2);
- fclose (err);
- }
-#if defined(SYSV) || defined(SVR4) || defined(WIN32) || defined(__CYGWIN__)
- {
- static char buf[BUFSIZ];
- setvbuf (stderr, buf, _IOLBF, BUFSIZ);
- }
-#else
- setlinebuf(stderr);
-#endif
- }
-
-#ifndef _MSC_VER
- if (getpgrp () == 0)
- setpgid (0, 0);
-#endif
-
-#ifdef RLIMIT_DATA
- if (limitDataSpace >= 0)
- {
- struct rlimit rlim;
-
- if (!getrlimit(RLIMIT_DATA, &rlim))
- {
- if ((limitDataSpace > 0) && (limitDataSpace < rlim.rlim_max))
- rlim.rlim_cur = limitDataSpace;
- else
- rlim.rlim_cur = rlim.rlim_max;
- (void)setrlimit(RLIMIT_DATA, &rlim);
- }
- }
-#endif
-#ifdef RLIMIT_STACK
- if (limitStackSpace >= 0)
- {
- struct rlimit rlim;
-
- if (!getrlimit(RLIMIT_STACK, &rlim))
- {
- if ((limitStackSpace > 0) && (limitStackSpace < rlim.rlim_max))
- rlim.rlim_cur = limitStackSpace;
- else
- rlim.rlim_cur = rlim.rlim_max;
- (void)setrlimit(RLIMIT_STACK, &rlim);
- }
- }
-#endif
-#ifdef RLIMIT_NOFILE
- if (limitNoFile >= 0)
- {
- struct rlimit rlim;
-
- if (!getrlimit(RLIMIT_NOFILE, &rlim))
- {
- if ((limitNoFile > 0) && (limitNoFile < rlim.rlim_max))
- rlim.rlim_cur = limitNoFile;
- else
- rlim.rlim_cur = rlim.rlim_max;
- (void)setrlimit(RLIMIT_NOFILE, &rlim);
- }
- }
-#endif
- LockServer();
- been_here = TRUE;
- }
- TimerInit();
- OsVendorInit();
- /*
- * No log file by default. OsVendorInit() should call LogInit() with the
- * log file name if logging to a file is desired.
- */
- LogInit(NULL, NULL);
- SmartScheduleInit ();
-}
-
-void
-OsCleanup(Bool terminating)
-{
- if (terminating)
- {
- UnlockServer();
- }
-}
+/*********************************************************** + +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. + +******************************************************************/ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <stdio.h> +#include <X11/X.h> +#include "os.h" +#include "osdep.h" +#include <X11/Xos.h> +#include <signal.h> +#include <errno.h> +#ifdef HAVE_DLFCN_H +# include <dlfcn.h> +#endif +#ifdef HAVE_BACKTRACE +#include <execinfo.h> +#endif + + +#include "dixstruct.h" + +#ifndef PATH_MAX +#ifdef MAXPATHLEN +#define PATH_MAX MAXPATHLEN +#else +#define PATH_MAX 1024 +#endif +#endif + + +#if !defined(SYSV) && !defined(WIN32) +#include <sys/resource.h> +#endif + +#ifndef ADMPATH +#define ADMPATH "/usr/adm/X%smsgs" +#endif + +extern char *display; +#ifdef RLIMIT_DATA +int limitDataSpace = -1; +#endif +#ifdef RLIMIT_STACK +int limitStackSpace = -1; +#endif +#ifdef RLIMIT_NOFILE +int limitNoFile = -1; +#endif + +static OsSigWrapperPtr OsSigWrapper = NULL; + +OsSigWrapperPtr +OsRegisterSigWrapper(OsSigWrapperPtr newSigWrapper) +{ + OsSigWrapperPtr oldSigWrapper = OsSigWrapper; + + OsSigWrapper = newSigWrapper; + + return oldSigWrapper; +} + +/* + * OsSigHandler -- + * Catch unexpected signals and exit or continue cleanly. + */ +static void +#ifdef SA_SIGINFO +OsSigHandler(int signo, siginfo_t *sip, void *unused) +#else +OsSigHandler(int signo) +#endif +{ +#ifdef RTLD_DI_SETSIGNAL + const char *dlerr = dlerror(); + + if (dlerr) { + LogMessage(X_ERROR, "Dynamic loader error: %s\n", dlerr); + } +#endif /* RTLD_DI_SETSIGNAL */ + + if (OsSigWrapper != NULL) { + if (OsSigWrapper(signo) == 0) { + /* ddx handled signal and wants us to continue */ + return; + } + } + + /* log, cleanup, and abort */ + xorg_backtrace(); + +#ifdef SA_SIGINFO + if (sip->si_code == SI_USER) { + ErrorF("Recieved signal %d sent by process %ld, uid %ld\n", + signo, (long) sip->si_pid, (long) sip->si_uid); + } else { + switch (signo) { + case SIGSEGV: + case SIGBUS: + case SIGILL: + case SIGFPE: + ErrorF("%s at address %p\n", strsignal(signo), sip->si_addr); + } + } +#endif + + FatalError("Caught signal %d (%s). Server aborting\n", + signo, strsignal(signo)); +} + +void +OsInit(void) +{ + static Bool been_here = FALSE; + static char* devnull = "/dev/null"; + char fname[PATH_MAX]; + + if (!been_here) { +#ifndef _MSC_VER + struct sigaction act, oact; + int i; + int siglist[] = { SIGSEGV, SIGQUIT, SIGILL, SIGFPE, SIGBUS, + SIGSYS, + SIGXCPU, + SIGXFSZ, +#ifdef SIGEMT + SIGEMT, +#endif + 0 /* must be last */ }; + sigemptyset(&act.sa_mask); +#ifdef SA_SIGINFO + act.sa_sigaction = OsSigHandler; + act.sa_flags = SA_SIGINFO; +#else + act.sa_handler = OsSigHandler; + act.sa_flags = 0; +#endif + for (i = 0; siglist[i] != 0; i++) { + if (sigaction(siglist[i], &act, &oact)) { + ErrorF("failed to install signal handler for signal %d: %s\n", + siglist[i], strerror(errno)); + } + } +#ifdef HAVE_BACKTRACE + /* + * initialize the backtracer, since the ctor calls dlopen(), which + * calls malloc(), which isn't signal-safe. + */ + do { + void *array; + backtrace(&array, 1); + } while (0); +#endif + +#ifdef RTLD_DI_SETSIGNAL + /* Tell runtime linker to send a signal we can catch instead of SIGKILL + * for failures to load libraries/modules at runtime so we can clean up + * after ourselves. + */ + int failure_signal = SIGQUIT; + dlinfo(RTLD_SELF, RTLD_DI_SETSIGNAL, &failure_signal); +#endif +#endif +#if !defined(__CYGWIN__) + fclose(stdin); + fclose(stdout); +#endif + /* + * If a write of zero bytes to stderr returns non-zero, i.e. -1, + * then writing to stderr failed, and we'll write somewhere else + * instead. (Apparently this never happens in the Real World.) + */ + if (write (2, fname, 0) == -1) + { + FILE *err; + + if (strlen (display) + strlen (ADMPATH) + 1 < sizeof fname) + sprintf (fname, ADMPATH, display); + else + strcpy (fname, devnull); + /* + * uses stdio to avoid os dependencies here, + * a real os would use + * open (fname, O_WRONLY|O_APPEND|O_CREAT, 0666) + */ + if (!(err = fopen (fname, "a+"))) + err = fopen (devnull, "w"); + if (err && (fileno(err) != 2)) { + dup2 (fileno (err), 2); + fclose (err); + } +#if defined(SYSV) || defined(SVR4) || defined(WIN32) || defined(__CYGWIN__) + { + static char buf[BUFSIZ]; + setvbuf (stderr, buf, _IOLBF, BUFSIZ); + } +#else + setlinebuf(stderr); +#endif + } + +#ifndef _MSC_VER + if (getpgrp () == 0) + setpgid (0, 0); +#endif + +#ifdef RLIMIT_DATA + if (limitDataSpace >= 0) + { + struct rlimit rlim; + + if (!getrlimit(RLIMIT_DATA, &rlim)) + { + if ((limitDataSpace > 0) && (limitDataSpace < rlim.rlim_max)) + rlim.rlim_cur = limitDataSpace; + else + rlim.rlim_cur = rlim.rlim_max; + (void)setrlimit(RLIMIT_DATA, &rlim); + } + } +#endif +#ifdef RLIMIT_STACK + if (limitStackSpace >= 0) + { + struct rlimit rlim; + + if (!getrlimit(RLIMIT_STACK, &rlim)) + { + if ((limitStackSpace > 0) && (limitStackSpace < rlim.rlim_max)) + rlim.rlim_cur = limitStackSpace; + else + rlim.rlim_cur = rlim.rlim_max; + (void)setrlimit(RLIMIT_STACK, &rlim); + } + } +#endif +#ifdef RLIMIT_NOFILE + if (limitNoFile >= 0) + { + struct rlimit rlim; + + if (!getrlimit(RLIMIT_NOFILE, &rlim)) + { + if ((limitNoFile > 0) && (limitNoFile < rlim.rlim_max)) + rlim.rlim_cur = limitNoFile; + else + rlim.rlim_cur = rlim.rlim_max; + (void)setrlimit(RLIMIT_NOFILE, &rlim); + } + } +#endif + LockServer(); + been_here = TRUE; + } + TimerInit(); + OsVendorInit(); + /* + * No log file by default. OsVendorInit() should call LogInit() with the + * log file name if logging to a file is desired. + */ + LogInit(NULL, NULL); + SmartScheduleInit (); +} + +void +OsCleanup(Bool terminating) +{ + if (terminating) + { + UnlockServer(); + } +} diff --git a/xorg-server/os/xprintf.c b/xorg-server/os/xprintf.c index ed2fa3d3b..cc5a9b355 100644 --- a/xorg-server/os/xprintf.c +++ b/xorg-server/os/xprintf.c @@ -1,233 +1,233 @@ -/**
- * @file
- *
- * @section DESCRIPTION
- *
- * These functions provide a portable implementation of the common (but not
- * yet universal) asprintf & vasprintf routines to allocate a buffer big
- * enough to sprintf the arguments to. The XNF variants terminate the server
- * if the allocation fails.
- */
-/*
- * Copyright (c) 2004 Alexander Gottwald
- *
- * 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.
- */
-/*
- * 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <X11/Xos.h>
-#include "os.h"
-#include <stdarg.h>
-#include <stdio.h>
-
-#ifdef asprintf
-# undef asprintf
-#endif
-#ifdef vasprintf
-# undef vasprintf
-#endif
-
-#ifndef va_copy
-# ifdef __va_copy
-# define va_copy __va_copy
-# else
-# ifndef _MSC_VER
-# error "no working va_copy was found"
-# endif
-# endif
-#endif
-
-/**
- * Varargs sprintf that allocates a string buffer the right size for
- * the pattern & data provided and prints the requested data to it.
- *
- * @param ret Pointer to which the newly allocated buffer is written
- * (contents undefined on error)
- * @param format printf style format string
- * @param va variable argument list
- * @return size of allocated buffer, or -1 on error.
- */
-int
-Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
-{
-#ifdef HAVE_VASPRINTF
- return vasprintf(ret, format, va);
-#else
- int size;
-
-#ifdef _MSC_VER
- size = vsnprintf(NULL, 0, format, va);
-#else
- va_list va2;
-
- va_copy(va2, va);
- size = vsnprintf(NULL, 0, format, va2);
- va_end(va2);
-#endif
-
- *ret = malloc(size + 1);
- if (*ret == NULL)
- return -1;
-
- vsnprintf(*ret, size + 1, format, va);
- (*ret)[size] = 0;
- return size;
-#endif
-}
-
-#ifndef HAVE_VASPRINTF
-# define vasprintf Xvasprintf
-#endif
-
-/**
- * sprintf that allocates a string buffer the right size for
- * the pattern & data provided and prints the requested data to it.
- *
- * @param ret Pointer to which the newly allocated buffer is written
- * (contents undefined on error)
- * @param format printf style format string
- * @param ... arguments for specified format
- * @return size of allocated buffer, or -1 on error.
- */
-int
-Xasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
-{
- int size;
- va_list va;
- va_start(va, format);
- size = vasprintf(ret, format, va);
- va_end(va);
- return size;
-}
-
-/**
- * Varargs sprintf that allocates a string buffer the right size for
- * the pattern & data provided and prints the requested data to it.
- * On failure, issues a FatalError message and aborts the server.
- *
- * @param ret Pointer to which the newly allocated buffer is written
- * (contents undefined on error)
- * @param format printf style format string
- * @param va variable argument list
- * @return size of allocated buffer
- */
-int
-XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va)
-{
- int size = vasprintf(ret, format, va);
- if ((size == -1) || (*ret == NULL)) {
- Error("XNFvasprintf");
- FatalError("XNFvasprintf failed");
- }
- return size;
-}
-
-/**
- * sprintf that allocates a string buffer the right size for
- * the pattern & data provided and prints the requested data to it.
- * On failure, issues a FatalError message and aborts the server.
- *
- * @param ret Pointer to which the newly allocated buffer is written
- * (contents undefined on error)
- * @param format printf style format string
- * @param ... arguments for specified format
- * @return size of allocated buffer
- */
-int
-XNFasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...)
-{
- int size;
- va_list va;
- va_start(va, format);
- size = XNFvasprintf(ret, format, va);
- va_end(va);
- return size;
-}
-
-/* Old api, now deprecated, may be removed in the future */
-char *
-Xvprintf(const char *format, va_list va)
-{
- char *ret;
-
- if (vasprintf(&ret, format, va) == -1)
- ret = NULL;
-
- return ret;
-}
-
-char *Xprintf(const char *format, ...)
-{
- char *ret;
- va_list va;
- va_start(va, format);
- if (vasprintf(&ret, format, va) == -1)
- ret = NULL;
- va_end(va);
- return ret;
-}
-
-char *
-XNFvprintf(const char *format, va_list va)
-{
- char *ret;
-
- XNFvasprintf(&ret, format, va);
-
- return ret;
-}
-
-char *XNFprintf(const char *format, ...)
-{
- char *ret;
- va_list va;
- va_start(va, format);
- XNFvasprintf(&ret, format, va);
- va_end(va);
- return ret;
-}
+/** + * @file + * + * @section DESCRIPTION + * + * These functions provide a portable implementation of the common (but not + * yet universal) asprintf & vasprintf routines to allocate a buffer big + * enough to sprintf the arguments to. The XNF variants terminate the server + * if the allocation fails. + */ +/* + * Copyright (c) 2004 Alexander Gottwald + * + * 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. + */ +/* + * 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. + */ + +#ifdef HAVE_DIX_CONFIG_H +#include <dix-config.h> +#endif + +#include <X11/Xos.h> +#include "os.h" +#include <stdarg.h> +#include <stdio.h> + +#ifdef asprintf +# undef asprintf +#endif +#ifdef vasprintf +# undef vasprintf +#endif + +#ifndef va_copy +# ifdef __va_copy +# define va_copy __va_copy +# else +# ifndef _MSC_VER +# error "no working va_copy was found" +# endif +# endif +#endif + +/** + * Varargs sprintf that allocates a string buffer the right size for + * the pattern & data provided and prints the requested data to it. + * + * @param ret Pointer to which the newly allocated buffer is written + * (contents undefined on error) + * @param format printf style format string + * @param va variable argument list + * @return size of allocated buffer, or -1 on error. + */ +int +Xvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va) +{ +#ifdef HAVE_VASPRINTF + return vasprintf(ret, format, va); +#else + int size; + +#ifdef _MSC_VER + size = vsnprintf(NULL, 0, format, va); +#else + va_list va2; + + va_copy(va2, va); + size = vsnprintf(NULL, 0, format, va2); + va_end(va2); +#endif + + *ret = malloc(size + 1); + if (*ret == NULL) + return -1; + + vsnprintf(*ret, size + 1, format, va); + (*ret)[size] = 0; + return size; +#endif +} + +#ifndef HAVE_VASPRINTF +# define vasprintf Xvasprintf +#endif + +/** + * sprintf that allocates a string buffer the right size for + * the pattern & data provided and prints the requested data to it. + * + * @param ret Pointer to which the newly allocated buffer is written + * (contents undefined on error) + * @param format printf style format string + * @param ... arguments for specified format + * @return size of allocated buffer, or -1 on error. + */ +int +Xasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...) +{ + int size; + va_list va; + va_start(va, format); + size = vasprintf(ret, format, va); + va_end(va); + return size; +} + +/** + * Varargs sprintf that allocates a string buffer the right size for + * the pattern & data provided and prints the requested data to it. + * On failure, issues a FatalError message and aborts the server. + * + * @param ret Pointer to which the newly allocated buffer is written + * (contents undefined on error) + * @param format printf style format string + * @param va variable argument list + * @return size of allocated buffer + */ +int +XNFvasprintf(char **ret, const char * _X_RESTRICT_KYWD format, va_list va) +{ + int size = vasprintf(ret, format, va); + if ((size == -1) || (*ret == NULL)) { + Error("XNFvasprintf"); + FatalError("XNFvasprintf failed"); + } + return size; +} + +/** + * sprintf that allocates a string buffer the right size for + * the pattern & data provided and prints the requested data to it. + * On failure, issues a FatalError message and aborts the server. + * + * @param ret Pointer to which the newly allocated buffer is written + * (contents undefined on error) + * @param format printf style format string + * @param ... arguments for specified format + * @return size of allocated buffer + */ +int +XNFasprintf(char ** ret, const char * _X_RESTRICT_KYWD format, ...) +{ + int size; + va_list va; + va_start(va, format); + size = XNFvasprintf(ret, format, va); + va_end(va); + return size; +} + +/* Old api, now deprecated, may be removed in the future */ +char * +Xvprintf(const char *format, va_list va) +{ + char *ret; + + if (vasprintf(&ret, format, va) == -1) + ret = NULL; + + return ret; +} + +char *Xprintf(const char *format, ...) +{ + char *ret; + va_list va; + va_start(va, format); + if (vasprintf(&ret, format, va) == -1) + ret = NULL; + va_end(va); + return ret; +} + +char * +XNFvprintf(const char *format, va_list va) +{ + char *ret; + + XNFvasprintf(&ret, format, va); + + return ret; +} + +char *XNFprintf(const char *format, ...) +{ + char *ret; + va_list va; + va_start(va, format); + XNFvasprintf(&ret, format, va); + va_end(va); + return ret; +} diff --git a/xorg-server/randr/rrscreen.c b/xorg-server/randr/rrscreen.c index 996ca3234..973991e20 100644 --- a/xorg-server/randr/rrscreen.c +++ b/xorg-server/randr/rrscreen.c @@ -1,1030 +1,1042 @@ -/*
- * Copyright © 2006 Keith Packard
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the name of the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include "randrstr.h"
-
-static const int padlength[4] = {0, 3, 2, 1};
-/* From render.h */
-#ifndef SubPixelUnknown
-#define SubPixelUnknown 0
-#endif
-
-
-static CARD16
-RR10CurrentSizeID (ScreenPtr pScreen);
-
-/*
- * Edit connection information block so that new clients
- * see the current screen size on connect
- */
-static void
-RREditConnectionInfo (ScreenPtr pScreen)
-{
- xConnSetup *connSetup;
- char *vendor;
- xPixmapFormat *formats;
- xWindowRoot *root;
- xDepth *depth;
- xVisualType *visual;
- int screen = 0;
- int d;
-
- connSetup = (xConnSetup *) ConnectionInfo;
- vendor = (char *) connSetup + sizeof (xConnSetup);
- formats = (xPixmapFormat *) ((char *) vendor +
- connSetup->nbytesVendor +
- padlength[connSetup->nbytesVendor & 3]);
- root = (xWindowRoot *) ((char *) formats +
- sizeof (xPixmapFormat) * screenInfo.numPixmapFormats);
- while (screen != pScreen->myNum)
- {
- depth = (xDepth *) ((char *) root +
- sizeof (xWindowRoot));
- for (d = 0; d < root->nDepths; d++)
- {
- visual = (xVisualType *) ((char *) depth +
- sizeof (xDepth));
- depth = (xDepth *) ((char *) visual +
- depth->nVisuals * sizeof (xVisualType));
- }
- root = (xWindowRoot *) ((char *) depth);
- screen++;
- }
- root->pixWidth = pScreen->width;
- root->pixHeight = pScreen->height;
- root->mmWidth = pScreen->mmWidth;
- root->mmHeight = pScreen->mmHeight;
-}
-
-void
-RRSendConfigNotify (ScreenPtr pScreen)
-{
- WindowPtr pWin = pScreen->root;
- xEvent event;
-
- event.u.u.type = ConfigureNotify;
- event.u.configureNotify.window = pWin->drawable.id;
- event.u.configureNotify.aboveSibling = None;
- event.u.configureNotify.x = 0;
- event.u.configureNotify.y = 0;
-
- /* XXX xinerama stuff ? */
-
- event.u.configureNotify.width = pWin->drawable.width;
- event.u.configureNotify.height = pWin->drawable.height;
- event.u.configureNotify.borderWidth = wBorderWidth (pWin);
- event.u.configureNotify.override = pWin->overrideRedirect;
- DeliverEvents(pWin, &event, 1, NullWindow);
-}
-
-void
-RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen)
-{
- rrScrPriv (pScreen);
- xRRScreenChangeNotifyEvent se;
- RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL;
- WindowPtr pRoot = pScreen->root;
-
- se.type = RRScreenChangeNotify + RREventBase;
- se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0);
- se.timestamp = pScrPriv->lastSetTime.milliseconds;
- se.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
- se.root = pRoot->drawable.id;
- se.window = pWin->drawable.id;
- se.subpixelOrder = PictureGetSubpixelOrder (pScreen);
-
- se.sizeID = RR10CurrentSizeID (pScreen);
-
- if (se.rotation & (RR_Rotate_90 | RR_Rotate_270)) {
- se.widthInPixels = pScreen->height;
- se.heightInPixels = pScreen->width;
- se.widthInMillimeters = pScreen->mmHeight;
- se.heightInMillimeters = pScreen->mmWidth;
- } else {
- se.widthInPixels = pScreen->width;
- se.heightInPixels = pScreen->height;
- se.widthInMillimeters = pScreen->mmWidth;
- se.heightInMillimeters = pScreen->mmHeight;
- }
-
- WriteEventsToClient (client, 1, (xEvent *) &se);
-}
-
-/*
- * Notify the extension that the screen size has been changed.
- * The driver is responsible for calling this whenever it has changed
- * the size of the screen
- */
-void
-RRScreenSizeNotify (ScreenPtr pScreen)
-{
- rrScrPriv(pScreen);
- /*
- * Deliver ConfigureNotify events when root changes
- * pixel size
- */
- if (pScrPriv->width == pScreen->width &&
- pScrPriv->height == pScreen->height &&
- pScrPriv->mmWidth == pScreen->mmWidth &&
- pScrPriv->mmHeight == pScreen->mmHeight)
- return;
-
- pScrPriv->width = pScreen->width;
- pScrPriv->height = pScreen->height;
- pScrPriv->mmWidth = pScreen->mmWidth;
- pScrPriv->mmHeight = pScreen->mmHeight;
- pScrPriv->changed = TRUE;
-/* pScrPriv->sizeChanged = TRUE; */
-
- RRTellChanged (pScreen);
- RRSendConfigNotify (pScreen);
- RREditConnectionInfo (pScreen);
-
- RRPointerScreenConfigured (pScreen);
- /*
- * Fix pointer bounds and location
- */
- ScreenRestructured (pScreen);
-}
-
-/*
- * Request that the screen be resized
- */
-Bool
-RRScreenSizeSet (ScreenPtr pScreen,
- CARD16 width,
- CARD16 height,
- CARD16 pixWidth,
- CARD16 pixHeight,
- CARD32 mmWidth,
- CARD32 mmHeight)
-{
- rrScrPriv(pScreen);
-
-#if RANDR_12_INTERFACE
- if (pScrPriv->rrScreenSetSize)
- {
- return (*pScrPriv->rrScreenSetSize) (pScreen,
- width, height,
- pixWidth, pixHeight,
- mmWidth, mmHeight);
- }
-#endif
-#if RANDR_10_INTERFACE
- if (pScrPriv->rrSetConfig)
- {
- return TRUE; /* can't set size separately */
- }
-#endif
- return FALSE;
-}
-
-/*
- * Compute an RRScreenConfig from the current screen information
- */
-void
-RRScreenCurrentConfig(ScreenPtr screen,
- RRScreenConfigPtr screen_config)
-{
- PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
- WindowPtr root = screen->root;
-
- screen_config->screen_pixmap_width = screen_pixmap->drawable.width;
- screen_config->screen_pixmap_height = screen_pixmap->drawable.height;
- screen_config->screen_width = root->drawable.width;
- screen_config->screen_height = root->drawable.height;
- screen_config->mm_width = screen->mmWidth;
- screen_config->mm_height = screen->mmHeight;
-}
-
-/*
- * Retrieve valid screen size range
- */
-int
-ProcRRGetScreenSizeRange (ClientPtr client)
-{
- REQUEST(xRRGetScreenSizeRangeReq);
- xRRGetScreenSizeRangeReply rep;
- WindowPtr pWin;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- int rc;
-
- REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- pScreen = pWin->drawable.pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
-
- rep.type = X_Reply;
- rep.pad = 0;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
-
- if (pScrPriv)
- {
- if (!RRGetInfo (pScreen, FALSE))
- return BadAlloc;
- rep.minWidth = pScrPriv->minWidth;
- rep.minHeight = pScrPriv->minHeight;
- rep.maxWidth = pScrPriv->maxWidth;
- rep.maxHeight = pScrPriv->maxHeight;
- }
- else
- {
- rep.maxWidth = rep.minWidth = pScreen->width;
- rep.maxHeight = rep.minHeight = pScreen->height;
- }
- if (client->swapped)
- {
- int n;
-
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swaps(&rep.minWidth, n);
- swaps(&rep.minHeight, n);
- swaps(&rep.maxWidth, n);
- swaps(&rep.maxHeight, n);
- }
- WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep);
- return Success;
-}
-
-int
-ProcRRSetScreenSize (ClientPtr client)
-{
- REQUEST(xRRSetScreenSizeReq);
- WindowPtr pWin;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- int i, rc;
-
- REQUEST_SIZE_MATCH(xRRSetScreenSizeReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- pScreen = pWin->drawable.pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
- if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width)
- {
- client->errorValue = stuff->width;
- return BadValue;
- }
- if (stuff->height < pScrPriv->minHeight ||
- pScrPriv->maxHeight < stuff->height)
- {
- client->errorValue = stuff->height;
- return BadValue;
- }
- for (i = 0; i < pScrPriv->numCrtcs; i++)
- {
- RRCrtcPtr crtc = pScrPriv->crtcs[i];
- RRModePtr mode = crtc->mode;
- if (mode)
- {
- int source_width = mode->mode.width;
- int source_height = mode->mode.height;
- Rotation rotation = crtc->rotation;
-
- if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270)
- {
- source_width = mode->mode.height;
- source_height = mode->mode.width;
- }
-
- if (crtc->x + source_width > stuff->width ||
- crtc->y + source_height > stuff->height)
- return BadMatch;
- }
- }
- if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0)
- {
- client->errorValue = 0;
- return BadValue;
- }
- if (!RRScreenSizeSet (pScreen,
- stuff->width, stuff->height,
- stuff->width, stuff->height,
- stuff->widthInMillimeters,
- stuff->heightInMillimeters))
- {
- return BadMatch;
- }
- return Success;
-}
-
-static int
-rrGetScreenResources(ClientPtr client, Bool query)
-{
- REQUEST(xRRGetScreenResourcesReq);
- xRRGetScreenResourcesReply rep;
- WindowPtr pWin;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- CARD8 *extra;
- unsigned long extraLen;
- int i, n, rc, has_primary = 0;
- RRCrtc *crtcs;
- RROutput *outputs;
- xRRModeInfo *modeinfos;
- CARD8 *names;
-
- REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- pScreen = pWin->drawable.pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
- rep.pad = 0;
-
- if (query && pScrPriv)
- if (!RRGetInfo (pScreen, query))
- return BadAlloc;
-
- if (!pScrPriv)
- {
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.timestamp = currentTime.milliseconds;
- rep.configTimestamp = currentTime.milliseconds;
- rep.nCrtcs = 0;
- rep.nOutputs = 0;
- rep.nModes = 0;
- rep.nbytesNames = 0;
- extra = NULL;
- extraLen = 0;
- }
- else
- {
- RRModePtr *modes;
- int num_modes;
-
- modes = RRModesForScreen (pScreen, &num_modes);
- if (!modes)
- return BadAlloc;
-
- rep.type = X_Reply;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.timestamp = pScrPriv->lastSetTime.milliseconds;
- rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
- rep.nCrtcs = pScrPriv->numCrtcs;
- rep.nOutputs = pScrPriv->numOutputs;
- rep.nModes = num_modes;
- rep.nbytesNames = 0;
-
- for (i = 0; i < num_modes; i++)
- rep.nbytesNames += modes[i]->mode.nameLength;
-
- rep.length = (pScrPriv->numCrtcs +
- pScrPriv->numOutputs +
- num_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) +
- bytes_to_int32(rep.nbytesNames));
-
- extraLen = rep.length << 2;
- if (extraLen)
- {
- extra = malloc(extraLen);
- if (!extra)
- {
- free(modes);
- return BadAlloc;
- }
- }
- else
- extra = NULL;
-
- crtcs = (RRCrtc *) extra;
- outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs);
- modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs);
- names = (CARD8 *) (modeinfos + num_modes);
-
- if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc)
- {
- has_primary = 1;
- crtcs[0] = pScrPriv->primaryOutput->crtc->id;
- if (client->swapped)
- swapl (&crtcs[0], n);
- }
-
- for (i = 0; i < pScrPriv->numCrtcs; i++)
- {
- if (has_primary &&
- pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i])
- {
- has_primary = 0;
- continue;
- }
- crtcs[i + has_primary] = pScrPriv->crtcs[i]->id;
- if (client->swapped)
- swapl (&crtcs[i + has_primary], n);
- }
-
- for (i = 0; i < pScrPriv->numOutputs; i++)
- {
- outputs[i] = pScrPriv->outputs[i]->id;
- if (client->swapped)
- swapl (&outputs[i], n);
- }
-
- for (i = 0; i < num_modes; i++)
- {
- RRModePtr mode = modes[i];
- modeinfos[i] = mode->mode;
- if (client->swapped)
- {
- swapl (&modeinfos[i].id, n);
- swaps (&modeinfos[i].width, n);
- swaps (&modeinfos[i].height, n);
- swapl (&modeinfos[i].dotClock, n);
- swaps (&modeinfos[i].hSyncStart, n);
- swaps (&modeinfos[i].hSyncEnd, n);
- swaps (&modeinfos[i].hTotal, n);
- swaps (&modeinfos[i].hSkew, n);
- swaps (&modeinfos[i].vSyncStart, n);
- swaps (&modeinfos[i].vSyncEnd, n);
- swaps (&modeinfos[i].vTotal, n);
- swaps (&modeinfos[i].nameLength, n);
- swapl (&modeinfos[i].modeFlags, n);
- }
- memcpy (names, mode->name,
- mode->mode.nameLength);
- names += mode->mode.nameLength;
- }
- free(modes);
- assert (bytes_to_int32((char *) names - (char *) extra) == rep.length);
- }
-
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.timestamp, n);
- swapl(&rep.configTimestamp, n);
- swaps(&rep.nCrtcs, n);
- swaps(&rep.nOutputs, n);
- swaps(&rep.nModes, n);
- swaps(&rep.nbytesNames, n);
- }
- WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep);
- if (extraLen)
- {
- WriteToClient (client, extraLen, (char *) extra);
- free(extra);
- }
- return Success;
-}
-
-int
-ProcRRGetScreenResources (ClientPtr client)
-{
- return rrGetScreenResources(client, TRUE);
-}
-
-int
-ProcRRGetScreenResourcesCurrent (ClientPtr client)
-{
- return rrGetScreenResources(client, FALSE);
-}
-
-typedef struct _RR10Data {
- RRScreenSizePtr sizes;
- int nsize;
- int nrefresh;
- int size;
- CARD16 refresh;
-} RR10DataRec, *RR10DataPtr;
-
-/*
- * Convert 1.2 monitor data into 1.0 screen data
- */
-static RR10DataPtr
-RR10GetData (ScreenPtr pScreen, RROutputPtr output)
-{
- RR10DataPtr data;
- RRScreenSizePtr size;
- int nmode = output->numModes + output->numUserModes;
- int o, os, l, r;
- RRScreenRatePtr refresh;
- CARD16 vRefresh;
- RRModePtr mode;
- Bool *used;
-
- /* Make sure there is plenty of space for any combination */
- data = malloc (sizeof (RR10DataRec) +
- sizeof (RRScreenSize) * nmode +
- sizeof (RRScreenRate) * nmode +
- sizeof (Bool) * nmode);
- if (!data)
- return NULL;
- size = (RRScreenSizePtr) (data + 1);
- refresh = (RRScreenRatePtr) (size + nmode);
- used = (Bool *) (refresh + nmode);
- memset (used, '\0', sizeof (Bool) * nmode);
- data->sizes = size;
- data->nsize = 0;
- data->nrefresh = 0;
- data->size = 0;
- data->refresh = 0;
-
- /*
- * find modes not yet listed
- */
- for (o = 0; o < output->numModes + output->numUserModes; o++)
- {
- if (used[o]) continue;
-
- if (o < output->numModes)
- mode = output->modes[o];
- else
- mode = output->userModes[o - output->numModes];
-
- l = data->nsize;
- size[l].id = data->nsize;
- size[l].width = mode->mode.width;
- size[l].height = mode->mode.height;
- if (output->mmWidth && output->mmHeight) {
- size[l].mmWidth = output->mmWidth;
- size[l].mmHeight = output->mmHeight;
- } else {
- size[l].mmWidth = pScreen->mmWidth;
- size[l].mmHeight = pScreen->mmHeight;
- }
- size[l].nRates = 0;
- size[l].pRates = &refresh[data->nrefresh];
- data->nsize++;
-
- /*
- * Find all modes with matching size
- */
- for (os = o; os < output->numModes + output->numUserModes; os++)
- {
- if (os < output->numModes)
- mode = output->modes[os];
- else
- mode = output->userModes[os - output->numModes];
- if (mode->mode.width == size[l].width &&
- mode->mode.height == size[l].height)
- {
- vRefresh = RRVerticalRefresh (&mode->mode);
- used[os] = TRUE;
-
- for (r = 0; r < size[l].nRates; r++)
- if (vRefresh == size[l].pRates[r].rate)
- break;
- if (r == size[l].nRates)
- {
- size[l].pRates[r].rate = vRefresh;
- size[l].pRates[r].mode = mode;
- size[l].nRates++;
- data->nrefresh++;
- }
- if (mode == output->crtc->mode)
- {
- data->size = l;
- data->refresh = vRefresh;
- }
- }
- }
- }
- return data;
-}
-
-int
-ProcRRGetScreenInfo (ClientPtr client)
-{
- REQUEST(xRRGetScreenInfoReq);
- xRRGetScreenInfoReply rep;
- WindowPtr pWin;
- int n, rc;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- CARD8 *extra;
- unsigned long extraLen;
- RROutputPtr output;
-
- REQUEST_SIZE_MATCH(xRRGetScreenInfoReq);
- rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
- if (rc != Success)
- return rc;
-
- pScreen = pWin->drawable.pScreen;
- pScrPriv = rrGetScrPriv(pScreen);
- rep.pad = 0;
-
- if (pScrPriv)
- if (!RRGetInfo (pScreen, TRUE))
- return BadAlloc;
-
- output = RRFirstOutput (pScreen);
-
- if (!pScrPriv || !output)
- {
- rep.type = X_Reply;
- rep.setOfRotations = RR_Rotate_0;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.root = pWin->drawable.pScreen->root->drawable.id;
- rep.timestamp = currentTime.milliseconds;
- rep.configTimestamp = currentTime.milliseconds;
- rep.nSizes = 0;
- rep.sizeID = 0;
- rep.rotation = RR_Rotate_0;
- rep.rate = 0;
- rep.nrateEnts = 0;
- extra = 0;
- extraLen = 0;
- }
- else
- {
- int i, j;
- xScreenSizes *size;
- CARD16 *rates;
- CARD8 *data8;
- Bool has_rate = RRClientKnowsRates (client);
- RR10DataPtr pData;
- RRScreenSizePtr pSize;
-
- pData = RR10GetData (pScreen, output);
- if (!pData)
- return BadAlloc;
-
- rep.type = X_Reply;
- rep.setOfRotations = output->crtc->rotations;
- rep.sequenceNumber = client->sequence;
- rep.length = 0;
- rep.root = pWin->drawable.pScreen->root->drawable.id;
- rep.timestamp = pScrPriv->lastSetTime.milliseconds;
- rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds;
- rep.rotation = output->crtc->rotation;
- rep.nSizes = pData->nsize;
- rep.nrateEnts = pData->nrefresh + pData->nsize;
- rep.sizeID = pData->size;
- rep.rate = pData->refresh;
-
- extraLen = rep.nSizes * sizeof (xScreenSizes);
- if (has_rate)
- extraLen += rep.nrateEnts * sizeof (CARD16);
-
- if (extraLen)
- {
- extra = (CARD8 *) malloc(extraLen);
- if (!extra)
- {
- free(pData);
- return BadAlloc;
- }
- }
- else
- extra = NULL;
-
- /*
- * First comes the size information
- */
- size = (xScreenSizes *) extra;
- rates = (CARD16 *) (size + rep.nSizes);
- for (i = 0; i < pData->nsize; i++)
- {
- pSize = &pData->sizes[i];
- size->widthInPixels = pSize->width;
- size->heightInPixels = pSize->height;
- size->widthInMillimeters = pSize->mmWidth;
- size->heightInMillimeters = pSize->mmHeight;
- if (client->swapped)
- {
- swaps (&size->widthInPixels, n);
- swaps (&size->heightInPixels, n);
- swaps (&size->widthInMillimeters, n);
- swaps (&size->heightInMillimeters, n);
- }
- size++;
- if (has_rate)
- {
- *rates = pSize->nRates;
- if (client->swapped)
- {
- swaps (rates, n);
- }
- rates++;
- for (j = 0; j < pSize->nRates; j++)
- {
- *rates = pSize->pRates[j].rate;
- if (client->swapped)
- {
- swaps (rates, n);
- }
- rates++;
- }
- }
- }
- free(pData);
-
- data8 = (CARD8 *) rates;
-
- if (data8 - (CARD8 *) extra != extraLen)
- FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n",
- (unsigned long)(data8 - (CARD8 *) extra), extraLen);
- rep.length = bytes_to_int32(extraLen);
- }
- if (client->swapped) {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.timestamp, n);
- swaps(&rep.rotation, n);
- swaps(&rep.nSizes, n);
- swaps(&rep.sizeID, n);
- swaps(&rep.rate, n);
- swaps(&rep.nrateEnts, n);
- }
- WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep);
- if (extraLen)
- {
- WriteToClient (client, extraLen, (char *) extra);
- free(extra);
- }
- return Success;
-}
-
-int
-ProcRRSetScreenConfig (ClientPtr client)
-{
- REQUEST(xRRSetScreenConfigReq);
- xRRSetScreenConfigReply rep;
- DrawablePtr pDraw;
- int n, rc;
- ScreenPtr pScreen;
- rrScrPrivPtr pScrPriv;
- TimeStamp time;
- int i;
- Rotation rotation;
- int rate;
- Bool has_rate;
- RROutputPtr output;
- RRCrtcPtr crtc;
- RRModePtr mode;
- RR10DataPtr pData = NULL;
- RRScreenSizePtr pSize;
- int width, height;
-
- UpdateCurrentTime ();
-
- if (RRClientKnowsRates (client))
- {
- REQUEST_SIZE_MATCH (xRRSetScreenConfigReq);
- has_rate = TRUE;
- }
- else
- {
- REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq);
- has_rate = FALSE;
- }
-
- rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess);
- if (rc != Success) {
- client->errorValue = stuff->drawable;
- return rc;
- }
-
- pScreen = pDraw->pScreen;
-
- pScrPriv = rrGetScrPriv(pScreen);
-
- time = ClientTimeToServerTime(stuff->timestamp);
-
- if (!pScrPriv)
- {
- time = currentTime;
- rep.status = RRSetConfigFailed;
- goto sendReply;
- }
- if (!RRGetInfo (pScreen, FALSE))
- return BadAlloc;
-
- output = RRFirstOutput (pScreen);
- if (!output)
- {
- time = currentTime;
- rep.status = RRSetConfigFailed;
- goto sendReply;
- }
-
- crtc = output->crtc;
-
- /*
- * If the client's config timestamp is not the same as the last config
- * timestamp, then the config information isn't up-to-date and
- * can't even be validated.
- *
- * Note that the client only knows about the milliseconds part of the
- * timestamp, so using CompareTimeStamps here would cause randr to suddenly
- * stop working after several hours have passed (freedesktop bug #6502).
- */
- if (stuff->configTimestamp != pScrPriv->lastConfigTime.milliseconds)
- {
- rep.status = RRSetConfigInvalidConfigTime;
- goto sendReply;
- }
-
- pData = RR10GetData (pScreen, output);
- if (!pData)
- return BadAlloc;
-
- if (stuff->sizeID >= pData->nsize)
- {
- /*
- * Invalid size ID
- */
- client->errorValue = stuff->sizeID;
- free(pData);
- return BadValue;
- }
- pSize = &pData->sizes[stuff->sizeID];
-
- /*
- * Validate requested rotation
- */
- rotation = (Rotation) stuff->rotation;
-
- /* test the rotation bits only! */
- switch (rotation & 0xf) {
- case RR_Rotate_0:
- case RR_Rotate_90:
- case RR_Rotate_180:
- case RR_Rotate_270:
- break;
- default:
- /*
- * Invalid rotation
- */
- client->errorValue = stuff->rotation;
- free(pData);
- return BadValue;
- }
-
- if ((~crtc->rotations) & rotation)
- {
- /*
- * requested rotation or reflection not supported by screen
- */
- client->errorValue = stuff->rotation;
- free(pData);
- return BadMatch;
- }
-
- /*
- * Validate requested refresh
- */
- if (has_rate)
- rate = (int) stuff->rate;
- else
- rate = 0;
-
- if (rate)
- {
- for (i = 0; i < pSize->nRates; i++)
- {
- if (pSize->pRates[i].rate == rate)
- break;
- }
- if (i == pSize->nRates)
- {
- /*
- * Invalid rate
- */
- client->errorValue = rate;
- free(pData);
- return BadValue;
- }
- mode = pSize->pRates[i].mode;
- }
- else
- mode = pSize->pRates[0].mode;
-
- /*
- * Make sure the requested set-time is not older than
- * the last set-time
- */
- if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0)
- {
- rep.status = RRSetConfigInvalidTime;
- goto sendReply;
- }
-
- /*
- * If the screen size is changing, adjust all of the other outputs
- * to fit the new size, mirroring as much as possible
- */
- width = mode->mode.width;
- height = mode->mode.height;
- if (rotation & (RR_Rotate_90|RR_Rotate_270))
- {
- width = mode->mode.height;
- height = mode->mode.width;
- }
- if (width != pScreen->width || height != pScreen->height)
- {
- int c;
-
- for (c = 0; c < pScrPriv->numCrtcs; c++)
- {
- if (!RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0,
- 0, NULL, NULL))
- {
- rep.status = RRSetConfigFailed;
- /* XXX recover from failure */
- goto sendReply;
- }
- }
- if (!RRScreenSizeSet (pScreen, width, height, width, height,
- pScreen->mmWidth, pScreen->mmHeight))
- {
- rep.status = RRSetConfigFailed;
- /* XXX recover from failure */
- goto sendReply;
- }
- }
-
- if (!RRCrtcSet (crtc, mode, 0, 0, stuff->rotation, 1, &output, NULL))
- rep.status = RRSetConfigFailed;
- else {
- pScrPriv->lastSetTime = time;
- rep.status = RRSetConfigSuccess;
- }
-
- /*
- * XXX Configure other crtcs to mirror as much as possible
- */
-
-sendReply:
-
- free(pData);
-
- rep.type = X_Reply;
- /* rep.status has already been filled in */
- rep.length = 0;
- rep.sequenceNumber = client->sequence;
-
- rep.newTimestamp = pScrPriv->lastSetTime.milliseconds;
- rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds;
- rep.root = pDraw->pScreen->root->drawable.id;
-
- if (client->swapped)
- {
- swaps(&rep.sequenceNumber, n);
- swapl(&rep.length, n);
- swapl(&rep.newTimestamp, n);
- swapl(&rep.newConfigTimestamp, n);
- swapl(&rep.root, n);
- }
- WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep);
-
- return Success;
-}
-
-static CARD16
-RR10CurrentSizeID (ScreenPtr pScreen)
-{
- CARD16 sizeID = 0xffff;
- RROutputPtr output = RRFirstOutput (pScreen);
-
- if (output)
- {
- RR10DataPtr data = RR10GetData (pScreen, output);
- if (data)
- {
- int i;
- for (i = 0; i < data->nsize; i++)
- if (data->sizes[i].width == pScreen->width &&
- data->sizes[i].height == pScreen->height)
- {
- sizeID = (CARD16) i;
- break;
- }
- free(data);
- }
- }
- return sizeID;
-}
+/* + * Copyright © 2006 Keith Packard + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include "randrstr.h" + +static const int padlength[4] = {0, 3, 2, 1}; +/* From render.h */ +#ifndef SubPixelUnknown +#define SubPixelUnknown 0 +#endif + + +static CARD16 +RR10CurrentSizeID (ScreenPtr pScreen); + +/* + * Edit connection information block so that new clients + * see the current screen size on connect + */ +static void +RREditConnectionInfo (ScreenPtr pScreen) +{ + xConnSetup *connSetup; + char *vendor; + xPixmapFormat *formats; + xWindowRoot *root; + xDepth *depth; + xVisualType *visual; + int screen = 0; + int d; + + connSetup = (xConnSetup *) ConnectionInfo; + vendor = (char *) connSetup + sizeof (xConnSetup); + formats = (xPixmapFormat *) ((char *) vendor + + connSetup->nbytesVendor + + padlength[connSetup->nbytesVendor & 3]); + root = (xWindowRoot *) ((char *) formats + + sizeof (xPixmapFormat) * screenInfo.numPixmapFormats); + while (screen != pScreen->myNum) + { + depth = (xDepth *) ((char *) root + + sizeof (xWindowRoot)); + for (d = 0; d < root->nDepths; d++) + { + visual = (xVisualType *) ((char *) depth + + sizeof (xDepth)); + depth = (xDepth *) ((char *) visual + + depth->nVisuals * sizeof (xVisualType)); + } + root = (xWindowRoot *) ((char *) depth); + screen++; + } + root->pixWidth = pScreen->width; + root->pixHeight = pScreen->height; + root->mmWidth = pScreen->mmWidth; + root->mmHeight = pScreen->mmHeight; +} + +void +RRSendConfigNotify (ScreenPtr pScreen) +{ + WindowPtr pWin = pScreen->root; + xEvent event; + + event.u.u.type = ConfigureNotify; + event.u.configureNotify.window = pWin->drawable.id; + event.u.configureNotify.aboveSibling = None; + event.u.configureNotify.x = 0; + event.u.configureNotify.y = 0; + + /* XXX xinerama stuff ? */ + + event.u.configureNotify.width = pWin->drawable.width; + event.u.configureNotify.height = pWin->drawable.height; + event.u.configureNotify.borderWidth = wBorderWidth (pWin); + event.u.configureNotify.override = pWin->overrideRedirect; + DeliverEvents(pWin, &event, 1, NullWindow); +} + +void +RRDeliverScreenEvent (ClientPtr client, WindowPtr pWin, ScreenPtr pScreen) +{ + rrScrPriv (pScreen); + xRRScreenChangeNotifyEvent se; + RRCrtcPtr crtc = pScrPriv->numCrtcs ? pScrPriv->crtcs[0] : NULL; + WindowPtr pRoot = pScreen->root; + + se.type = RRScreenChangeNotify + RREventBase; + se.rotation = (CARD8) (crtc ? crtc->rotation : RR_Rotate_0); + se.timestamp = pScrPriv->lastSetTime.milliseconds; + se.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + se.root = pRoot->drawable.id; + se.window = pWin->drawable.id; + se.subpixelOrder = PictureGetSubpixelOrder (pScreen); + + se.sizeID = RR10CurrentSizeID (pScreen); + + if (se.rotation & (RR_Rotate_90 | RR_Rotate_270)) { + se.widthInPixels = pScreen->height; + se.heightInPixels = pScreen->width; + se.widthInMillimeters = pScreen->mmHeight; + se.heightInMillimeters = pScreen->mmWidth; + } else { + se.widthInPixels = pScreen->width; + se.heightInPixels = pScreen->height; + se.widthInMillimeters = pScreen->mmWidth; + se.heightInMillimeters = pScreen->mmHeight; + } + + WriteEventsToClient (client, 1, (xEvent *) &se); +} + +/* + * Notify the extension that the screen size has been changed. + * The driver is responsible for calling this whenever it has changed + * the size of the screen + */ +void +RRScreenSizeNotify (ScreenPtr pScreen) +{ + rrScrPriv(pScreen); + /* + * Deliver ConfigureNotify events when root changes + * pixel size + */ + if (pScrPriv->width == pScreen->width && + pScrPriv->height == pScreen->height && + pScrPriv->mmWidth == pScreen->mmWidth && + pScrPriv->mmHeight == pScreen->mmHeight) + return; + + pScrPriv->width = pScreen->width; + pScrPriv->height = pScreen->height; + pScrPriv->mmWidth = pScreen->mmWidth; + pScrPriv->mmHeight = pScreen->mmHeight; + pScrPriv->changed = TRUE; +/* pScrPriv->sizeChanged = TRUE; */ + + RRTellChanged (pScreen); + RRSendConfigNotify (pScreen); + RREditConnectionInfo (pScreen); + + RRPointerScreenConfigured (pScreen); + /* + * Fix pointer bounds and location + */ + ScreenRestructured (pScreen); +} + +/* + * Request that the screen be resized + */ +Bool +RRScreenSizeSet (ScreenPtr pScreen, + CARD16 width, + CARD16 height, + CARD16 pixWidth, + CARD16 pixHeight, + CARD32 mmWidth, + CARD32 mmHeight) +{ + rrScrPriv(pScreen); + +#if RANDR_12_INTERFACE + if (pScrPriv->rrScreenSetSize) + { + return (*pScrPriv->rrScreenSetSize) (pScreen, + width, height, + pixWidth, pixHeight, + mmWidth, mmHeight); + } +#endif +#if RANDR_10_INTERFACE + if (pScrPriv->rrSetConfig) + { + return TRUE; /* can't set size separately */ + } +#endif + return FALSE; +} + +/* + * Compute an RRScreenConfig from the current screen information + */ +void +RRScreenCurrentConfig(ScreenPtr screen, + RRScreenConfigPtr screen_config) +{ + PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen); + WindowPtr root = screen->root; + + screen_config->screen_pixmap_width = screen_pixmap->drawable.width; + screen_config->screen_pixmap_height = screen_pixmap->drawable.height; + screen_config->screen_width = root->drawable.width; + screen_config->screen_height = root->drawable.height; + screen_config->mm_width = screen->mmWidth; + screen_config->mm_height = screen->mmHeight; +} + +/* + * Retrieve valid screen size range + */ +int +ProcRRGetScreenSizeRange (ClientPtr client) +{ + REQUEST(xRRGetScreenSizeRangeReq); + xRRGetScreenSizeRangeReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + int rc; + + REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + + rep.type = X_Reply; + rep.pad = 0; + rep.sequenceNumber = client->sequence; + rep.length = 0; + + if (pScrPriv) + { + if (!RRGetInfo (pScreen, FALSE)) + return BadAlloc; + rep.minWidth = pScrPriv->minWidth; + rep.minHeight = pScrPriv->minHeight; + rep.maxWidth = pScrPriv->maxWidth; + rep.maxHeight = pScrPriv->maxHeight; + } + else + { + rep.maxWidth = rep.minWidth = pScreen->width; + rep.maxHeight = rep.minHeight = pScreen->height; + } + if (client->swapped) + { + int n; + + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swaps(&rep.minWidth, n); + swaps(&rep.minHeight, n); + swaps(&rep.maxWidth, n); + swaps(&rep.maxHeight, n); + } + WriteToClient(client, sizeof(xRRGetScreenSizeRangeReply), (char *)&rep); + return Success; +} + +int +ProcRRSetScreenSize (ClientPtr client) +{ + REQUEST(xRRSetScreenSizeReq); + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + int i, rc; + + REQUEST_SIZE_MATCH(xRRSetScreenSizeReq); + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + if (stuff->width < pScrPriv->minWidth || pScrPriv->maxWidth < stuff->width) + { + client->errorValue = stuff->width; + return BadValue; + } + if (stuff->height < pScrPriv->minHeight || + pScrPriv->maxHeight < stuff->height) + { + client->errorValue = stuff->height; + return BadValue; + } + for (i = 0; i < pScrPriv->numCrtcs; i++) + { + RRCrtcPtr crtc = pScrPriv->crtcs[i]; + RRModePtr mode = crtc->mode; + if (mode) + { + int source_width = mode->mode.width; + int source_height = mode->mode.height; + Rotation rotation = crtc->rotation; + + if (rotation == RR_Rotate_90 || rotation == RR_Rotate_270) + { + source_width = mode->mode.height; + source_height = mode->mode.width; + } + + if (crtc->x + source_width > stuff->width || + crtc->y + source_height > stuff->height) + return BadMatch; + } + } + if (stuff->widthInMillimeters == 0 || stuff->heightInMillimeters == 0) + { + client->errorValue = 0; + return BadValue; + } + if (!RRScreenSizeSet (pScreen, + stuff->width, stuff->height, + stuff->width, stuff->height, + stuff->widthInMillimeters, + stuff->heightInMillimeters)) + { + return BadMatch; + } + return Success; +} + +static int +rrGetScreenResources(ClientPtr client, Bool query) +{ + REQUEST(xRRGetScreenResourcesReq); + xRRGetScreenResourcesReply rep; + WindowPtr pWin; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + CARD8 *extra; + unsigned long extraLen; + int i, n, rc, has_primary = 0; + RRCrtc *crtcs; + RROutput *outputs; + xRRModeInfo *modeinfos; + CARD8 *names; + + REQUEST_SIZE_MATCH(xRRGetScreenResourcesReq); + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + rep.pad = 0; + + if (query && pScrPriv) + if (!RRGetInfo (pScreen, query)) + return BadAlloc; + + if (!pScrPriv) + { + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.timestamp = currentTime.milliseconds; + rep.configTimestamp = currentTime.milliseconds; + rep.nCrtcs = 0; + rep.nOutputs = 0; + rep.nModes = 0; + rep.nbytesNames = 0; + extra = NULL; + extraLen = 0; + } + else + { + RRModePtr *modes; + int num_modes; + + modes = RRModesForScreen (pScreen, &num_modes); + if (!modes) + return BadAlloc; + + rep.type = X_Reply; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + rep.nCrtcs = pScrPriv->numCrtcs; + rep.nOutputs = pScrPriv->numOutputs; + rep.nModes = num_modes; + rep.nbytesNames = 0; + + for (i = 0; i < num_modes; i++) + rep.nbytesNames += modes[i]->mode.nameLength; + + rep.length = (pScrPriv->numCrtcs + + pScrPriv->numOutputs + + num_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) + + bytes_to_int32(rep.nbytesNames)); + + extraLen = rep.length << 2; + if (extraLen) + { + extra = malloc(extraLen); + if (!extra) + { + free(modes); + return BadAlloc; + } + } + else + extra = NULL; + + crtcs = (RRCrtc *) extra; + outputs = (RROutput *) (crtcs + pScrPriv->numCrtcs); + modeinfos = (xRRModeInfo *) (outputs + pScrPriv->numOutputs); + names = (CARD8 *) (modeinfos + num_modes); + + if (pScrPriv->primaryOutput && pScrPriv->primaryOutput->crtc) + { + has_primary = 1; + crtcs[0] = pScrPriv->primaryOutput->crtc->id; + if (client->swapped) + swapl (&crtcs[0], n); + } + + for (i = 0; i < pScrPriv->numCrtcs; i++) + { + if (has_primary && + pScrPriv->primaryOutput->crtc == pScrPriv->crtcs[i]) + { + has_primary = 0; + continue; + } + crtcs[i + has_primary] = pScrPriv->crtcs[i]->id; + if (client->swapped) + swapl (&crtcs[i + has_primary], n); + } + + for (i = 0; i < pScrPriv->numOutputs; i++) + { + outputs[i] = pScrPriv->outputs[i]->id; + if (client->swapped) + swapl (&outputs[i], n); + } + + for (i = 0; i < num_modes; i++) + { + RRModePtr mode = modes[i]; + modeinfos[i] = mode->mode; + if (client->swapped) + { + swapl (&modeinfos[i].id, n); + swaps (&modeinfos[i].width, n); + swaps (&modeinfos[i].height, n); + swapl (&modeinfos[i].dotClock, n); + swaps (&modeinfos[i].hSyncStart, n); + swaps (&modeinfos[i].hSyncEnd, n); + swaps (&modeinfos[i].hTotal, n); + swaps (&modeinfos[i].hSkew, n); + swaps (&modeinfos[i].vSyncStart, n); + swaps (&modeinfos[i].vSyncEnd, n); + swaps (&modeinfos[i].vTotal, n); + swaps (&modeinfos[i].nameLength, n); + swapl (&modeinfos[i].modeFlags, n); + } + memcpy (names, mode->name, + mode->mode.nameLength); + names += mode->mode.nameLength; + } + free(modes); + assert (bytes_to_int32((char *) names - (char *) extra) == rep.length); + } + + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.timestamp, n); + swapl(&rep.configTimestamp, n); + swaps(&rep.nCrtcs, n); + swaps(&rep.nOutputs, n); + swaps(&rep.nModes, n); + swaps(&rep.nbytesNames, n); + } + WriteToClient(client, sizeof(xRRGetScreenResourcesReply), (char *)&rep); + if (extraLen) + { + WriteToClient (client, extraLen, (char *) extra); + free(extra); + } + return Success; +} + +int +ProcRRGetScreenResources (ClientPtr client) +{ + return rrGetScreenResources(client, TRUE); +} + +int +ProcRRGetScreenResourcesCurrent (ClientPtr client) +{ + return rrGetScreenResources(client, FALSE); +} + +typedef struct _RR10Data { + RRScreenSizePtr sizes; + int nsize; + int nrefresh; + int size; + CARD16 refresh; +} RR10DataRec, *RR10DataPtr; + +/* + * Convert 1.2 monitor data into 1.0 screen data + */ +static RR10DataPtr +RR10GetData (ScreenPtr pScreen, RROutputPtr output) +{ + RR10DataPtr data; + RRScreenSizePtr size; + int nmode = output->numModes + output->numUserModes; + int o, os, l, r; + RRScreenRatePtr refresh; + CARD16 vRefresh; + RRModePtr mode; + Bool *used; + + /* Make sure there is plenty of space for any combination */ + data = malloc (sizeof (RR10DataRec) + + sizeof (RRScreenSize) * nmode + + sizeof (RRScreenRate) * nmode + + sizeof (Bool) * nmode); + if (!data) + return NULL; + size = (RRScreenSizePtr) (data + 1); + refresh = (RRScreenRatePtr) (size + nmode); + used = (Bool *) (refresh + nmode); + memset (used, '\0', sizeof (Bool) * nmode); + data->sizes = size; + data->nsize = 0; + data->nrefresh = 0; + data->size = 0; + data->refresh = 0; + + /* + * find modes not yet listed + */ + for (o = 0; o < output->numModes + output->numUserModes; o++) + { + if (used[o]) continue; + + if (o < output->numModes) + mode = output->modes[o]; + else + mode = output->userModes[o - output->numModes]; + + l = data->nsize; + size[l].id = data->nsize; + size[l].width = mode->mode.width; + size[l].height = mode->mode.height; + if (output->mmWidth && output->mmHeight) { + size[l].mmWidth = output->mmWidth; + size[l].mmHeight = output->mmHeight; + } else { + size[l].mmWidth = pScreen->mmWidth; + size[l].mmHeight = pScreen->mmHeight; + } + size[l].nRates = 0; + size[l].pRates = &refresh[data->nrefresh]; + data->nsize++; + + /* + * Find all modes with matching size + */ + for (os = o; os < output->numModes + output->numUserModes; os++) + { + if (os < output->numModes) + mode = output->modes[os]; + else + mode = output->userModes[os - output->numModes]; + if (mode->mode.width == size[l].width && + mode->mode.height == size[l].height) + { + vRefresh = RRVerticalRefresh (&mode->mode); + used[os] = TRUE; + + for (r = 0; r < size[l].nRates; r++) + if (vRefresh == size[l].pRates[r].rate) + break; + if (r == size[l].nRates) + { + size[l].pRates[r].rate = vRefresh; + size[l].pRates[r].mode = mode; + size[l].nRates++; + data->nrefresh++; + } + if (mode == output->crtc->mode) + { + data->size = l; + data->refresh = vRefresh; + } + } + } + } + return data; +} + +int +ProcRRGetScreenInfo (ClientPtr client) +{ + REQUEST(xRRGetScreenInfoReq); + xRRGetScreenInfoReply rep; + WindowPtr pWin; + int n, rc; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + CARD8 *extra; + unsigned long extraLen; + RROutputPtr output; + + REQUEST_SIZE_MATCH(xRRGetScreenInfoReq); + rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess); + if (rc != Success) + return rc; + + pScreen = pWin->drawable.pScreen; + pScrPriv = rrGetScrPriv(pScreen); + rep.pad = 0; + + if (pScrPriv) + if (!RRGetInfo (pScreen, TRUE)) + return BadAlloc; + + output = RRFirstOutput (pScreen); + + if (!pScrPriv || !output) + { + rep.type = X_Reply; + rep.setOfRotations = RR_Rotate_0; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.root = pWin->drawable.pScreen->root->drawable.id; + rep.timestamp = currentTime.milliseconds; + rep.configTimestamp = currentTime.milliseconds; + rep.nSizes = 0; + rep.sizeID = 0; + rep.rotation = RR_Rotate_0; + rep.rate = 0; + rep.nrateEnts = 0; + extra = 0; + extraLen = 0; + } + else + { + int i, j; + xScreenSizes *size; + CARD16 *rates; + CARD8 *data8; + Bool has_rate = RRClientKnowsRates (client); + RR10DataPtr pData; + RRScreenSizePtr pSize; + + pData = RR10GetData (pScreen, output); + if (!pData) + return BadAlloc; + + rep.type = X_Reply; + rep.setOfRotations = output->crtc->rotations; + rep.sequenceNumber = client->sequence; + rep.length = 0; + rep.root = pWin->drawable.pScreen->root->drawable.id; + rep.timestamp = pScrPriv->lastSetTime.milliseconds; + rep.configTimestamp = pScrPriv->lastConfigTime.milliseconds; + rep.rotation = output->crtc->rotation; + rep.nSizes = pData->nsize; + rep.nrateEnts = pData->nrefresh + pData->nsize; + rep.sizeID = pData->size; + rep.rate = pData->refresh; + + extraLen = rep.nSizes * sizeof (xScreenSizes); + if (has_rate) + extraLen += rep.nrateEnts * sizeof (CARD16); + + if (extraLen) + { + extra = (CARD8 *) malloc(extraLen); + if (!extra) + { + free(pData); + return BadAlloc; + } + } + else + extra = NULL; + + /* + * First comes the size information + */ + size = (xScreenSizes *) extra; + rates = (CARD16 *) (size + rep.nSizes); + for (i = 0; i < pData->nsize; i++) + { + pSize = &pData->sizes[i]; + size->widthInPixels = pSize->width; + size->heightInPixels = pSize->height; + size->widthInMillimeters = pSize->mmWidth; + size->heightInMillimeters = pSize->mmHeight; + if (client->swapped) + { + swaps (&size->widthInPixels, n); + swaps (&size->heightInPixels, n); + swaps (&size->widthInMillimeters, n); + swaps (&size->heightInMillimeters, n); + } + size++; + if (has_rate) + { + *rates = pSize->nRates; + if (client->swapped) + { + swaps (rates, n); + } + rates++; + for (j = 0; j < pSize->nRates; j++) + { + *rates = pSize->pRates[j].rate; + if (client->swapped) + { + swaps (rates, n); + } + rates++; + } + } + } + free(pData); + + data8 = (CARD8 *) rates; + + if (data8 - (CARD8 *) extra != extraLen) + FatalError ("RRGetScreenInfo bad extra len %ld != %ld\n", + (unsigned long)(data8 - (CARD8 *) extra), extraLen); + rep.length = bytes_to_int32(extraLen); + } + if (client->swapped) { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.timestamp, n); + swaps(&rep.rotation, n); + swaps(&rep.nSizes, n); + swaps(&rep.sizeID, n); + swaps(&rep.rate, n); + swaps(&rep.nrateEnts, n); + } + WriteToClient(client, sizeof(xRRGetScreenInfoReply), (char *)&rep); + if (extraLen) + { + WriteToClient (client, extraLen, (char *) extra); + free(extra); + } + return Success; +} + +int +ProcRRSetScreenConfig (ClientPtr client) +{ + REQUEST(xRRSetScreenConfigReq); + xRRSetScreenConfigReply rep; + DrawablePtr pDraw; + int n, rc; + ScreenPtr pScreen; + rrScrPrivPtr pScrPriv; + TimeStamp time; + int i; + Rotation rotation; + int rate; + Bool has_rate; + RROutputPtr output; + RRCrtcPtr crtc; + RRModePtr mode; + RR10DataPtr pData = NULL; + RRScreenSizePtr pSize; + int width, height; + + UpdateCurrentTime (); + + if (RRClientKnowsRates (client)) + { + REQUEST_SIZE_MATCH (xRRSetScreenConfigReq); + has_rate = TRUE; + } + else + { + REQUEST_SIZE_MATCH (xRR1_0SetScreenConfigReq); + has_rate = FALSE; + } + + rc = dixLookupDrawable(&pDraw, stuff->drawable, client, 0, DixWriteAccess); + if (rc != Success) { + client->errorValue = stuff->drawable; + return rc; + } + + pScreen = pDraw->pScreen; + + pScrPriv = rrGetScrPriv(pScreen); + + time = ClientTimeToServerTime(stuff->timestamp); + + if (!pScrPriv) + { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; + } + if (!RRGetInfo (pScreen, FALSE)) + return BadAlloc; + + output = RRFirstOutput (pScreen); + if (!output) + { + time = currentTime; + rep.status = RRSetConfigFailed; + goto sendReply; + } + + crtc = output->crtc; + + /* + * If the client's config timestamp is not the same as the last config + * timestamp, then the config information isn't up-to-date and + * can't even be validated. + * + * Note that the client only knows about the milliseconds part of the + * timestamp, so using CompareTimeStamps here would cause randr to suddenly + * stop working after several hours have passed (freedesktop bug #6502). + */ + if (stuff->configTimestamp != pScrPriv->lastConfigTime.milliseconds) + { + rep.status = RRSetConfigInvalidConfigTime; + goto sendReply; + } + + pData = RR10GetData (pScreen, output); + if (!pData) + return BadAlloc; + + if (stuff->sizeID >= pData->nsize) + { + /* + * Invalid size ID + */ + client->errorValue = stuff->sizeID; + free(pData); + return BadValue; + } + pSize = &pData->sizes[stuff->sizeID]; + + /* + * Validate requested rotation + */ + rotation = (Rotation) stuff->rotation; + + /* test the rotation bits only! */ + switch (rotation & 0xf) { + case RR_Rotate_0: + case RR_Rotate_90: + case RR_Rotate_180: + case RR_Rotate_270: + break; + default: + /* + * Invalid rotation + */ + client->errorValue = stuff->rotation; + free(pData); + return BadValue; + } + + if ((~crtc->rotations) & rotation) + { + /* + * requested rotation or reflection not supported by screen + */ + client->errorValue = stuff->rotation; + free(pData); + return BadMatch; + } + + /* + * Validate requested refresh + */ + if (has_rate) + rate = (int) stuff->rate; + else + rate = 0; + + if (rate) + { + for (i = 0; i < pSize->nRates; i++) + { + if (pSize->pRates[i].rate == rate) + break; + } + if (i == pSize->nRates) + { + /* + * Invalid rate + */ + client->errorValue = rate; + free(pData); + return BadValue; + } + mode = pSize->pRates[i].mode; + } + else + mode = pSize->pRates[0].mode; + + /* + * Make sure the requested set-time is not older than + * the last set-time + */ + if (CompareTimeStamps (time, pScrPriv->lastSetTime) < 0) + { + rep.status = RRSetConfigInvalidTime; + goto sendReply; + } + + /* + * If the screen size is changing, adjust all of the other outputs + * to fit the new size, mirroring as much as possible + */ + width = mode->mode.width; + height = mode->mode.height; + if (rotation & (RR_Rotate_90|RR_Rotate_270)) + { + width = mode->mode.height; + height = mode->mode.width; + } + + if (width < pScrPriv->minWidth || pScrPriv->maxWidth < width) { + client->errorValue = width; + free(pData); + return BadValue; + } + if (height < pScrPriv->minHeight || pScrPriv->maxHeight < height) { + client->errorValue = height; + free(pData); + return BadValue; + } + + if (width != pScreen->width || height != pScreen->height) + { + int c; + + for (c = 0; c < pScrPriv->numCrtcs; c++) + { + if (!RRCrtcSet (pScrPriv->crtcs[c], NULL, 0, 0, RR_Rotate_0, + 0, NULL, NULL)) + { + rep.status = RRSetConfigFailed; + /* XXX recover from failure */ + goto sendReply; + } + } + if (!RRScreenSizeSet (pScreen, width, height, width, height, + pScreen->mmWidth, pScreen->mmHeight)) + { + rep.status = RRSetConfigFailed; + /* XXX recover from failure */ + goto sendReply; + } + } + + if (!RRCrtcSet (crtc, mode, 0, 0, stuff->rotation, 1, &output, NULL)) + rep.status = RRSetConfigFailed; + else { + pScrPriv->lastSetTime = time; + rep.status = RRSetConfigSuccess; + } + + /* + * XXX Configure other crtcs to mirror as much as possible + */ + +sendReply: + + free(pData); + + rep.type = X_Reply; + /* rep.status has already been filled in */ + rep.length = 0; + rep.sequenceNumber = client->sequence; + + rep.newTimestamp = pScrPriv->lastSetTime.milliseconds; + rep.newConfigTimestamp = pScrPriv->lastConfigTime.milliseconds; + rep.root = pDraw->pScreen->root->drawable.id; + + if (client->swapped) + { + swaps(&rep.sequenceNumber, n); + swapl(&rep.length, n); + swapl(&rep.newTimestamp, n); + swapl(&rep.newConfigTimestamp, n); + swapl(&rep.root, n); + } + WriteToClient(client, sizeof(xRRSetScreenConfigReply), (char *)&rep); + + return Success; +} + +static CARD16 +RR10CurrentSizeID (ScreenPtr pScreen) +{ + CARD16 sizeID = 0xffff; + RROutputPtr output = RRFirstOutput (pScreen); + + if (output) + { + RR10DataPtr data = RR10GetData (pScreen, output); + if (data) + { + int i; + for (i = 0; i < data->nsize; i++) + if (data->sizes[i].width == pScreen->width && + data->sizes[i].height == pScreen->height) + { + sizeID = (CARD16) i; + break; + } + free(data); + } + } + return sizeID; +} diff --git a/xorg-server/xkeyboard-config/rules/base.xml.in b/xorg-server/xkeyboard-config/rules/base.xml.in index d9faa2d87..8d472719b 100644 --- a/xorg-server/xkeyboard-config/rules/base.xml.in +++ b/xorg-server/xkeyboard-config/rules/base.xml.in @@ -1,5726 +1,5736 @@ -<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE xkbConfigRegistry SYSTEM "xkb.dtd">
-<xkbConfigRegistry>
- <modelList>
- <model>
- <configItem>
- <name>pc101</name>
- <_description>Generic 101-key PC</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>pc102</name>
- <_description>Generic 102-key (Intl) PC</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>pc104</name>
- <_description>Generic 104-key PC</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>pc105</name>
- <_description>Generic 105-key (Intl) PC</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dell101</name>
- <_description>Dell 101-key PC</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>latitude</name>
- <_description>Dell Latitude series laptop</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dellm65</name>
- <_description>Dell Precision M65</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>everex</name>
- <_description>Everex STEPnote</_description>
- <vendor>Everex</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>flexpro</name>
- <_description>Keytronic FlexPro</_description>
- <vendor>Keytronic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoft</name>
- <_description>Microsoft Natural</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>omnikey101</name>
- <_description>Northgate OmniKey 101</_description>
- <vendor>Northgate</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>winbook</name>
- <_description>Winbook Model XP5</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>pc98</name>
- <_description>PC-98xx Series</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>a4techKB21</name>
- <_description>A4Tech KB-21</_description>
- <vendor>A4Tech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>a4techKBS8</name>
- <_description>A4Tech KBS-8</_description>
- <vendor>A4Tech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>a4_rfkb23</name>
- <_description>A4Tech Wireless Desktop RFKB-23</_description>
- <vendor>A4Tech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>airkey</name>
- <_description>Acer AirKey V</_description>
- <vendor>Acer</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>azonaRF2300</name>
- <_description>Azona RF2300 wireless Internet Keyboard</_description>
- <vendor>Azona</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>scorpius</name>
- <_description>Advance Scorpius KI</_description>
- <vendor>Scorpius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>brother</name>
- <_description>Brother Internet Keyboard</_description>
- <vendor>Brother</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc5113rf</name>
- <_description>BTC 5113RF Multimedia</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc5126t</name>
- <_description>BTC 5126T</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc6301urf</name>
- <_description>BTC 6301URF</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc9000</name>
- <_description>BTC 9000</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc9000a</name>
- <_description>BTC 9000A</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc9001ah</name>
- <_description>BTC 9001AH</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc5090</name>
- <_description>BTC 5090</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc9019u</name>
- <_description>BTC 9019U</_description>
- <vendor>BTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>btc9116u</name>
- <_description>BTC 9116U Mini Wireless Internet and Gaming</_description>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherryblue</name>
- <_description>Cherry Blue Line CyBo@rd</_description>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherryblueb</name>
- <_description>Cherry CyMotion Master XPress</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherrybluea</name>
- <_description>Cherry Blue Line CyBo@rd (alternate option)</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherrycyboard</name>
- <_description>Cherry CyBo@rd USB-Hub</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherrycmexpert</name>
- <_description>Cherry CyMotion Expert</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cherrybunlim</name>
- <_description>Cherry B.UNLIMITED</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>chicony</name>
- <_description>Chicony Internet Keyboard</_description>
- <vendor>Chicony</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>chicony0108</name>
- <_description>Chicony KU-0108</_description>
- <vendor>Chicony</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>chicony0420</name>
- <_description>Chicony KU-0420</_description>
- <vendor>Chicony</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>chicony9885</name>
- <_description>Chicony KB-9885</_description>
- <vendor>Chicony</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>compaqeak8</name>
- <_description>Compaq Easy Access Keyboard</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>compaqik7</name>
- <_description>Compaq Internet Keyboard (7 keys)</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>compaqik13</name>
- <_description>Compaq Internet Keyboard (13 keys)</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>compaqik18</name>
- <_description>Compaq Internet Keyboard (18 keys)</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>cymotionlinux</name>
- <_description>Cherry CyMotion Master Linux</_description>
- <vendor>Cherry</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>armada</name>
- <_description>Laptop/notebook Compaq (eg. Armada) Laptop Keyboard</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>presario</name>
- <_description>Laptop/notebook Compaq (eg. Presario) Internet Keyboard</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>ipaq</name>
- <_description>Compaq iPaq Keyboard</_description>
- <vendor>Compaq</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dell</name>
- <_description>Dell</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dellsk8125</name>
- <_description>Dell SK-8125</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dellsk8135</name>
- <_description>Dell SK-8135</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dellusbmm</name>
- <_description>Dell USB Multimedia Keyboard</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>inspiron</name>
- <_description>Dell Laptop/notebook Inspiron 6xxx/8xxx</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>precision_m</name>
- <_description>Dell Laptop/notebook Precision M series</_description>
- <vendor>Dell</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dexxa</name>
- <_description>Dexxa Wireless Desktop Keyboard</_description>
- <vendor>Dexxa</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>diamond</name>
- <_description>Diamond 9801 / 9802 series</_description>
- <vendor>Diamond</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>dtk2000</name>
- <_description>DTK2000</_description>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>ennyah_dkb1008</name>
- <_description>Ennyah DKB-1008</_description>
- <vendor>Ennyah</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>fscaa1667g</name>
- <_description>Fujitsu-Siemens Computers AMILO laptop</_description>
- <vendor>Fujitsu-Siemens</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>genius</name>
- <_description>Genius Comfy KB-16M / Genius MM Keyboard KWD-910</_description>
- <vendor>Genius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>geniuscomfy</name>
- <_description>Genius Comfy KB-12e</_description>
- <vendor>Genius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>geniuscomfy2</name>
- <_description>Genius Comfy KB-21e-Scroll</_description>
- <vendor>Genius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>geniuskb19e</name>
- <_description>Genius KB-19e NB</_description>
- <vendor>Genius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>geniuskkb2050hs</name>
- <_description>Genius KKB-2050HS</_description>
- <vendor>Genius</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>gyration</name>
- <_description>Gyration</_description>
- <vendor>Gyration</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>htcdream</name>
- <_description>HTC Dream</_description>
- <vendor>HTC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>kinesis</name>
- <_description>Kinesis</_description>
- <vendor>Kinesis</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logitech_base</name>
- <_description>Logitech Generic Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logitech_g15</name>
- <_description>Logitech G15 extra keys via G15daemon</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpi6</name>
- <_description>Hewlett-Packard Internet Keyboard</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hp250x</name>
- <_description>Hewlett-Packard SK-250x Multimedia Keyboard</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpxe3gc</name>
- <_description>Hewlett-Packard Omnibook XE3 GC</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpxe3gf</name>
- <_description>Hewlett-Packard Omnibook XE3 GF</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpxt1000</name>
- <_description>Hewlett-Packard Omnibook XT1000</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpdv5</name>
- <_description>Hewlett-Packard Pavilion dv5</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpzt11xx</name>
- <_description>Hewlett-Packard Pavilion ZT11xx</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hp500fa</name>
- <_description>Hewlett-Packard Omnibook 500 FA</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hp5xx</name>
- <_description>Hewlett-Packard Omnibook 5xx</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpnx9020</name>
- <_description>Hewlett-Packard nx9020</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hp6000</name>
- <_description>Hewlett-Packard Omnibook 6000/6100</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>honeywell_euroboard</name>
- <_description>Honeywell Euroboard</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hpmini110</name>
- <_description>Hewlett-Packard Mini 110 Notebook</_description>
- <vendor>Hewlett-Packard</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>rapidaccess</name>
- <_description>IBM Rapid Access</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>rapidaccess2</name>
- <_description>IBM Rapid Access II</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>thinkpad</name>
- <_description>IBM ThinkPad 560Z/600/600E/A22E</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>thinkpad60</name>
- <_description>IBM ThinkPad R60/T60/R61/T61</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>thinkpadz60</name>
- <_description>IBM ThinkPad Z60m/Z60t/Z61m/Z61t</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>ibm_spacesaver</name>
- <_description>IBM Space Saver</_description>
- <vendor>Lenovo (previously IBM)</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiaccess</name>
- <_description>Logitech Access Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiclx300</name>
- <_description>Logitech Cordless Desktop LX-300</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logii350</name>
- <_description>Logitech Internet 350 Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logimel</name>
- <_description>Logitech Media Elite Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicd</name>
- <_description>Logitech Cordless Desktop</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicd_it</name>
- <_description>Logitech Cordless Desktop iTouch</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicd_nav</name>
- <_description>Logitech Cordless Desktop Navigator</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicd_opt</name>
- <_description>Logitech Cordless Desktop Optical</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicda</name>
- <_description>Logitech Cordless Desktop (alternate option)</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicdpa2</name>
- <_description>Logitech Cordless Desktop Pro (alternate option 2)</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicfn</name>
- <_description>Logitech Cordless Freedom/Desktop Navigator</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicdn</name>
- <_description>Logitech Cordless Desktop Navigator</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiitc</name>
- <_description>Logitech iTouch Cordless Keyboard (model Y-RB6)</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiik</name>
- <_description>Logitech Internet Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>itouch</name>
- <_description>Logitech iTouch</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logicink</name>
- <_description>Logitech Internet Navigator Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiex110</name>
- <_description>Logitech Cordless Desktop EX110</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiinkse</name>
- <_description>Logitech iTouch Internet Navigator Keyboard SE</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiinkseusb</name>
- <_description>Logitech iTouch Internet Navigator Keyboard SE (USB)</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiultrax</name>
- <_description>Logitech Ultra-X Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logiultraxc</name>
- <_description>Logitech Ultra-X Cordless Media Desktop Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logidinovo</name>
- <_description>Logitech diNovo Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>logidinovoedge</name>
- <_description>Logitech diNovo Edge Keyboard</_description>
- <vendor>Logitech</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>mx1998</name>
- <_description>Memorex MX1998</_description>
- <vendor>Memorex</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>mx2500</name>
- <_description>Memorex MX2500 EZ-Access Keyboard</_description>
- <vendor>Memorex</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>mx2750</name>
- <_description>Memorex MX2750</_description>
- <vendor>Memorex</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoft7000</name>
- <_description>Microsoft Natural Wireless Ergonomic Keyboard 7000</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftinet</name>
- <_description>Microsoft Internet Keyboard</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftpro</name>
- <_description>Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftprousb</name>
- <_description>Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftprooem</name>
- <_description>Microsoft Natural Keyboard Pro OEM</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>vsonku306</name>
- <_description>ViewSonic KU-306 Internet Keyboard</_description>
- <vendor>ViewSonic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftprose</name>
- <_description>Microsoft Internet Keyboard Pro, Swedish</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftoffice</name>
- <_description>Microsoft Office Keyboard</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftmult</name>
- <_description>Microsoft Wireless Multimedia Keyboard 1.0A</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftelite</name>
- <_description>Microsoft Natural Keyboard Elite</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>microsoftccurve2k</name>
- <_description>Microsoft Comfort Curve Keyboard 2000</_description>
- <vendor>Microsoft Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>oretec</name>
- <_description>Ortek MCK-800 MM/Internet keyboard</_description>
- <vendor>Ortek</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>propeller</name>
- <_description>Propeller Voyager (KTEZ-1000)</_description>
- <vendor>KeyTronic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>qtronix</name>
- <_description>QTronix Scorpius 98N+</_description>
- <vendor>QTronix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>samsung4500</name>
- <_description>Samsung SDM 4500P</_description>
- <vendor>Samsung</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>samsung4510</name>
- <_description>Samsung SDM 4510P</_description>
- <vendor>Samsung</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sanwaskbkg3</name>
- <description>Sanwa Supply SKB-KG3</description>
- <vendor>Sanwa Supply Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sk1300</name>
- <_description>SK-1300</_description>
- <vendor>NEC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sk2500</name>
- <_description>SK-2500</_description>
- <vendor>NEC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sk6200</name>
- <_description>SK-6200</_description>
- <vendor>NEC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sk7100</name>
- <_description>SK-7100</_description>
- <vendor>NEC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sp_inet</name>
- <_description>Super Power Multimedia Keyboard</_description>
- <vendor>Generic</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sven</name>
- <_description>SVEN Ergonomic 2500</_description>
- <vendor>SVEN</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sven303</name>
- <_description>SVEN Slim 303</_description>
- <vendor>SVEN</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>symplon</name>
- <_description>Symplon PaceBook (tablet PC)</_description>
- <vendor>Symplon</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>toshiba_s3000</name>
- <_description>Toshiba Satellite S3000</_description>
- <vendor>Toshiba</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>trust</name>
- <_description>Trust Wireless Keyboard Classic</_description>
- <vendor>Trust</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>trustda</name>
- <_description>Trust Direct Access Keyboard</_description>
- <vendor>Trust</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>trust_slimline</name>
- <_description>Trust Slimline</_description>
- <vendor>Trust</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>tm2020</name>
- <_description>TypeMatrix EZ-Reach 2020</_description>
- <vendor>TypeMatrix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>tm2030PS2</name>
- <_description>TypeMatrix EZ-Reach 2030 PS2</_description>
- <vendor>TypeMatrix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>tm2030USB</name>
- <_description>TypeMatrix EZ-Reach 2030 USB</_description>
- <vendor>TypeMatrix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>tm2030USB-102</name>
- <_description>TypeMatrix EZ-Reach 2030 USB (102/105:EU mode)</_description>
- <vendor>TypeMatrix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>tm2030USB-106</name>
- <_description>TypeMatrix EZ-Reach 2030 USB (106:JP mode)</_description>
- <vendor>TypeMatrix</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>yahoo</name>
- <_description>Yahoo! Internet Keyboard</_description>
- <vendor>Yahoo!</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>macbook78</name>
- <_description>MacBook/MacBook Pro</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>macbook79</name>
- <_description>MacBook/MacBook Pro (Intl)</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>macintosh</name>
- <_description>Macintosh</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>macintosh_old</name>
- <_description>Macintosh Old</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>macintosh_hhk</name>
- <_description>Happy Hacking Keyboard for Mac</_description>
- <vendor>Fujitsu</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>acer_c300</name>
- <_description>Acer C300</_description>
- <vendor>Acer</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>acer_ferrari4k</name>
- <_description>Acer Ferrari 4000</_description>
- <vendor>Acer</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>acer_laptop</name>
- <_description>Acer Laptop</_description>
- <vendor>Acer</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>asus_laptop</name>
- <_description>Asus Laptop</_description>
- <vendor>Asus</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>apple</name>
- <_description>Apple</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>apple_laptop</name>
- <_description>Apple Laptop</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>applealu_ansi</name>
- <_description>Apple Aluminium Keyboard (ANSI)</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>applealu_iso</name>
- <_description>Apple Aluminium Keyboard (ISO)</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>applealu_jis</name>
- <_description>Apple Aluminium Keyboard (JIS)</_description>
- <vendor>Apple</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>silvercrest</name>
- <_description>SILVERCREST Multimedia Wireless Keyboard</_description>
- <vendor>Silvercrest</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>emachines</name>
- <_description>Laptop/notebook eMachines m68xx</_description>
- <vendor>eMachines</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>benqx</name>
- <_description>BenQ X-Touch</_description>
- <vendor>BenQ</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>benqx730</name>
- <_description>BenQ X-Touch 730</_description>
- <vendor>BenQ</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>benqx800</name>
- <_description>BenQ X-Touch 800</_description>
- <vendor>BenQ</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>hhk</name>
- <_description>Happy Hacking Keyboard</_description>
- <vendor>Fujitsu</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>classmate</name>
- <_description>Classmate PC</_description>
- <vendor>Intel</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>olpc</name>
- <_description>OLPC</_description>
- <vendor>OLPC</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>sun6</name>
- <_description>Sun Type 5/6</_description>
- <vendor>Sun Microsystems</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>targa_v811</name>
- <_description>Targa Visionary 811</_description>
- <vendor>Targa</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>unitekkb1925</name>
- <_description>Unitek KB-1925</_description>
- <vendor>Unitek Group</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>compalfl90</name>
- <_description>FL90</_description>
- <vendor>Compal Electronics Inc.</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>creativedw7000</name>
- <_description>Creative Desktop Wireless 7000</_description>
- <vendor>Creative</vendor>
- </configItem>
- </model>
- <model>
- <configItem>
- <name>htcdream</name>
- <_description>Htc Dream phone</_description>
- <vendor>htc</vendor>
- </configItem>
- </model>
- </modelList>
- <layoutList>
- <layout>
- <configItem>
- <name>us</name>
- <_shortDescription>USA</_shortDescription>
- <_description>USA</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>chr</name>
- <_description>Cherokee</_description>
- <languageList><iso639Id>chr</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>euro</name>
- <_description>With EuroSign on 5</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>intl</name>
- <_description>International (with dead keys)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>alt-intl</name>
- <_description>Alternative international</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>colemak</name>
- <_description>Colemak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-intl</name>
- <_description>Dvorak international (with dead keys)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-alt-intl</name>
- <_description>Dvorak alternative international (no dead keys)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-l</name>
- <_description>Left handed Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-r</name>
- <_description>Right handed Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-classic</name>
- <_description>Classic Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvp</name>
- <_description>Programmer Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rus</name>
- <_description>Russian phonetic</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>altgr-intl</name>
- <_description>International (AltGr dead keys)</_description>
- <languageList><iso639Id>eng</iso639Id>
- <iso639Id>fra</iso639Id>
- <iso639Id>ger</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>olpc2</name>
- <_description>Layout toggle on multiply/divide key</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>srp</name>
- <_description>Serbian</_description>
- <languageList><iso639Id>eng</iso639Id>
- <iso639Id>srp</iso639Id> </languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ad</name>
- <_shortDescription>And</_shortDescription>
- <_description>Andorra</_description>
- <languageList><iso639Id>cat</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>af</name>
- <_shortDescription>Afg</_shortDescription>
- <_description>Afghanistan</_description>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>ps</name>
- <_description>Pashto</_description>
- <languageList><iso639Id>pus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>uz</name>
- <_description>Southern Uzbek</_description>
- <languageList><iso639Id>uzb</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>olpc-ps</name>
- <_description>OLPC Pashto</_description>
- <languageList><iso639Id>pus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>olpc-fa</name>
- <_description>OLPC Dari</_description>
- <!-- No ISO code in ISO639-2, only draft ISO693-3 -->
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>olpc-uz</name>
- <_description>OLPC Southern Uzbek</_description>
- <languageList><iso639Id>uzb</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ara</name>
- <_shortDescription>Ara</_shortDescription>
- <_description>Arabic</_description>
- <countryList>
- <iso3166Id>AE</iso3166Id>
- <iso3166Id>BH</iso3166Id>
- <iso3166Id>DZ</iso3166Id>
- <iso3166Id>EG</iso3166Id>
- <iso3166Id>EH</iso3166Id>
- <iso3166Id>JO</iso3166Id>
- <iso3166Id>KW</iso3166Id>
- <iso3166Id>LB</iso3166Id>
- <iso3166Id>LY</iso3166Id>
- <iso3166Id>MA</iso3166Id>
- <iso3166Id>MR</iso3166Id>
- <iso3166Id>OM</iso3166Id>
- <iso3166Id>PS</iso3166Id>
- <iso3166Id>QA</iso3166Id>
- <iso3166Id>SA</iso3166Id>
- <iso3166Id>SD</iso3166Id>
- <iso3166Id>SY</iso3166Id>
- <iso3166Id>TN</iso3166Id>
- <iso3166Id>YE</iso3166Id>
- </countryList>
- <languageList><iso639Id>ara</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>azerty</name>
- <_description>azerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>azerty_digits</name>
- <_description>azerty/digits</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>digits</name>
- <_description>digits</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty</name>
- <_description>qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty_digits</name>
- <_description>qwerty/digits</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>buckwalter</name>
- <_description>Buckwalter</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>al</name>
- <_shortDescription>Alb</_shortDescription>
- <_description>Albania</_description>
- <languageList><iso639Id>alb</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>am</name>
- <_shortDescription>Arm</_shortDescription>
- <_description>Armenia</_description>
- <languageList><iso639Id>hye</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>phonetic-alt</name>
- <_description>Alternative Phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>eastern</name>
- <_description>Eastern</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>western</name>
- <_description>Western</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>eastern-alt</name>
- <_description>Alternative Eastern</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>at</name>
- <_shortDescription>Aut</_shortDescription>
- <_description>Austria</_description>
- <languageList><iso639Id>ger</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>az</name>
- <_shortDescription>Aze</_shortDescription>
- <_description>Azerbaijan</_description>
- <languageList><iso639Id>aze</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>cyrillic</name>
- <_description>Cyrillic</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>by</name>
- <_shortDescription>Blr</_shortDescription>
- <_description>Belarus</_description>
- <languageList><iso639Id>bel</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latin</name>
- <_description>Latin</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>be</name>
- <_shortDescription>Bel</_shortDescription>
- <_description>Belgium</_description>
- <languageList><iso639Id>ger</iso639Id>
- <iso639Id>nld</iso639Id>
- <iso639Id>fra</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>oss</name>
- <_description>Alternative</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss_latin9</name>
- <_description>Alternative, latin-9 only</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss_sundeadkeys</name>
- <_description>Alternative, Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>iso-alternate</name>
- <_description>ISO Alternate</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>wang</name>
- <_description>Wang model 724 azerty</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>bd</name>
- <_shortDescription>Bgd</_shortDescription>
- <_description>Bangladesh</_description>
- <languageList><iso639Id>ben</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>probhat</name>
- <_description>Probhat</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>in</name>
- <_shortDescription>Ind</_shortDescription>
- <_description>India</_description>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>ben</name>
- <_description>Bengali</_description>
- <languageList><iso639Id>ben</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ben_probhat</name>
- <_description>Bengali Probhat</_description>
- <languageList><iso639Id>ben</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>guj</name>
- <_description>Gujarati</_description>
- <languageList><iso639Id>guj</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>guru</name>
- <_description>Gurmukhi</_description>
- <languageList><iso639Id>pan</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>jhelum</name>
- <_description>Gurmukhi Jhelum</_description>
- <languageList><iso639Id>pan</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>kan</name>
- <_description>Kannada</_description>
- <languageList><iso639Id>kan</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mal</name>
- <_description>Malayalam</_description>
- <languageList><iso639Id>mal</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mal_lalitha</name>
- <_description>Malayalam Lalitha</_description>
- <languageList><iso639Id>mal</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ori</name>
- <_description>Oriya</_description>
- <languageList><iso639Id>ori</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam_unicode</name>
- <_description>Tamil Unicode</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam_keyboard_with_numerals</name>
- <_description>Tamil Keyboard with Numerals</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam_TAB</name>
- <_description>Tamil TAB Typewriter</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam_TSCII</name>
- <_description>Tamil TSCII Typewriter</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam</name>
- <_description>Tamil</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tel</name>
- <_description>Telugu</_description>
- <languageList><iso639Id>tel</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>urd-phonetic</name>
- <_description>Urdu, Phonetic</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>urd-phonetic3</name>
- <_description>Urdu, Alternative phonetic</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>urd-winkeys</name>
- <_description>Urdu, Winkeys</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>bolnagri</name>
- <_description>Hindi Bolnagri</_description>
- <languageList><iso639Id>hin</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>hin-wx</name>
- <_description>Hindi Wx</_description>
- <languageList><iso639Id>hin</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>eng</name>
- <_description>English with RupeeSign</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ba</name>
- <_shortDescription>Bih</_shortDescription>
- <_description>Bosnia and Herzegovina</_description>
- <languageList><iso639Id>bos</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>alternatequotes</name>
- <_description> Use guillemets for quotes</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>unicode</name>
- <_description>Use Bosnian digraphs</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>unicodeus</name>
- <_description>US keyboard with Bosnian digraphs</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Bosnian letters</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>br</name>
- <_shortDescription>Bra</_shortDescription>
- <_description>Brazil</_description>
- <languageList><iso639Id>por</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo</name>
- <_description>Nativo</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo-us</name>
- <_description>Nativo for USA keyboards</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo-epo</name>
- <_description>Nativo for Esperanto</_description>
- <languageList><iso639Id>epo</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>bg</name>
- <_shortDescription>Bgr</_shortDescription>
- <_description>Bulgaria</_description>
- <languageList><iso639Id>bul</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Traditional phonetic</_description>
- </configItem>
- </variant>
- </variantList>
- <variantList>
- <variant>
- <configItem>
- <name>bas_phonetic</name>
- <_description>New phonetic</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ma</name>
- <_description>Morocco</_description>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>french</name>
- <_description>French</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh</name>
- <_description>Tifinagh</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh-alt</name>
- <_description>Tifinagh alternative</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh-alt-phonetic</name>
- <_description>Tifinagh alternative phonetic</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh-extended</name>
- <_description>Tifinagh extended</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh-phonetic</name>
- <_description>Tifinagh phonetic</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tifinagh-extended-phonetic</name>
- <_description>Tifinagh extended phonetic</_description>
- <languageList><iso639Id>ber</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mm</name>
- <_shortDescription>Mmr</_shortDescription>
- <_description>Myanmar</_description>
- <languageList><iso639Id>mya</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>ca</name>
- <_shortDescription>Can</_shortDescription>
- <_description>Canada</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>fr-dvorak</name>
- <_description>French Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fr-legacy</name>
- <_description>French (legacy)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>multix</name>
- <_description>Multilingual</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>multi</name>
- <_description>Multilingual, first part</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>multi-2gr</name>
- <_description>Multilingual, second part</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ike</name>
- <_description>Inuktitut</_description>
- <languageList><iso639Id>iku</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>shs</name>
- <_description>Secwepemctsin</_description>
- <!-- No ISO code in ISO639-2, only draft ISO693-3 -->
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>kut</name>
- <_description>Ktunaxa</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>eng</name>
- <_description>English</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>cd</name>
- <_shortDescription>COD</_shortDescription>
- <_description>Congo, Democratic Republic of the</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>cn</name>
- <_shortDescription>Chn</_shortDescription>
- <_description>China</_description>
- <languageList><iso639Id>chi</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>tib</name>
- <_description>Tibetan</_description>
- <languageList><iso639Id>tib</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tib_asciinum</name>
- <_description>Tibetan (with ASCII numerals)</_description>
- <languageList><iso639Id>tib</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>hr</name>
- <_shortDescription>Hrv</_shortDescription>
- <_description>Croatia</_description>
- <languageList><iso639Id>scr</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>alternatequotes</name>
- <_description>Use guillemets for quotes</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>unicode</name>
- <_description>Use Croatian digraphs</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>unicodeus</name>
- <_description>US keyboard with Croatian digraphs</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Croatian letters</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>cz</name>
- <_shortDescription>Cze</_shortDescription>
- <_description>Czechia</_description>
- <languageList><iso639Id>cze</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>bksl</name>
- <_description>With <\|> key</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty</name>
- <_description>qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty_bksl</name>
- <_description>qwerty, extended Backslash</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ucw</name>
- <_description>UCW layout (accented letters only)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-ucw</name>
- <_description>US Dvorak with CZ UCW support</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>dk</name>
- <_shortDescription>Dnk</_shortDescription>
- <_description>Denmark</_description>
- <languageList><iso639Id>dan</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_nodeadkeys</name>
- <_description>Macintosh, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>nl</name>
- <_shortDescription>Nld</_shortDescription>
- <_description>Netherlands</_description>
- <languageList><iso639Id>nld</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>std</name>
- <_description>Standard</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>bt</name>
- <_shortDescription>Btn</_shortDescription>
- <_description>Bhutan</_description>
- <languageList><iso639Id>dzo</iso639Id></languageList>
- </configItem>
- </layout>
- <layout>
- <configItem>
- <name>ee</name>
- <_shortDescription>Est</_shortDescription>
- <_description>Estonia</_description>
- <languageList><iso639Id>est</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Estonian letters</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ir</name>
- <_shortDescription>Irn</_shortDescription>
- <_description>Iran</_description>
- <languageList><iso639Id>per</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>pes_keypad</name>
- <_description>Persian, with Persian Keypad</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku</name>
- <_description>Kurdish, Latin Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_f</name>
- <_description>Kurdish, (F)</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_alt</name>
- <_description>Kurdish, Latin Alt-Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_ara</name>
- <_description>Kurdish, Arabic-Latin</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>iq</name>
- <_shortDescription>Irq</_shortDescription>
- <_description>Iraq</_description>
- <languageList><iso639Id>ara</iso639Id>
- <iso639Id>kur</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>ku</name>
- <_description>Kurdish, Latin Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_f</name>
- <_description>Kurdish, (F)</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_alt</name>
- <_description>Kurdish, Latin Alt-Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_ara</name>
- <_description>Kurdish, Arabic-Latin</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>fo</name>
- <_shortDescription>Fro</_shortDescription>
- <_description>Faroe Islands</_description>
- <languageList><iso639Id>fao</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>fi</name>
- <_shortDescription>Fin</_shortDescription>
- <_description>Finland</_description>
- <languageList><iso639Id>fin</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>classic</name>
- <_description>Classic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Classic, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>smi</name>
- <_description>Northern Saami</_description>
- <languageList><iso639Id>smi</iso639Id>
- <iso639Id>sme</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>fr</name>
- <_shortDescription>Fra</_shortDescription>
- <_description>France</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss</name>
- <_description>Alternative</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss_latin9</name>
- <_description>Alternative, latin-9 only</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss_nodeadkeys</name>
- <_description>Alternative, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oss_sundeadkeys</name>
- <_description>Alternative, Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latin9</name>
- <_description>(Legacy) Alternative</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latin9_nodeadkeys</name>
- <_description>(Legacy) Alternative, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latin9_sundeadkeys</name>
- <_description>(Legacy) Alternative, Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>bepo</name>
- <_description>Bepo, ergonomic, Dvorak way</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>bepo_latin9</name>
- <_description>Bepo, ergonomic, Dvorak way, latin-9 only</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>bre</name>
- <_description>Breton</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>oci</name>
- <_description>Occitan</_description>
- <languageList><iso639Id>oci</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>geo</name>
- <_description>Georgian AZERTY Tskapo</_description>
- <languageList><iso639Id>geo</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>gh</name>
- <_shortDescription>Gha</_shortDescription>
- <_description>Ghana</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>generic</name>
- <_description>Multilingual</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>akan</name>
- <_description>Akan</_description>
- <languageList><iso639Id>aka</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ewe</name>
- <_description>Ewe</_description>
- <languageList><iso639Id>ewe</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fula</name>
- <_description>Fula</_description>
- <languageList><iso639Id>ful</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ga</name>
- <_description>Ga</_description>
- <languageList><iso639Id>gaa</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>hausa</name>
- <_description>Hausa</_description>
- <languageList><iso639Id>hau</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>avn</name>
- <_description>Avatime</_description>
- <languageList><iso639Id>avn</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>gillbt</name>
- <_description>GILLBT</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>gn</name>
- <_shortDescription>Gin</_shortDescription>
- <_description>Guinea</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>ge</name>
- <_shortDescription>Geo</_shortDescription>
- <_description>Georgia</_description>
- <languageList><iso639Id>geo</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>ergonomic</name>
- <_description>Ergonomic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mess</name>
- <_description>MESS</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ru</name>
- <_description>Russian</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>os</name>
- <_description>Ossetian</_description>
- <languageList><iso639Id>oss</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>de</name>
- <_shortDescription>Deu</_shortDescription>
- <_description>Germany</_description>
- <languageList><iso639Id>ger</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>deadacute</name>
- <_description>Dead acute</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>deadgraveacute</name>
- <_description>Dead grave acute</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ro</name>
- <_description>Romanian keyboard with German letters</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ro_nodeadkeys</name>
- <_description>Romanian keyboard with German letters, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>neo</name>
- <_description>Neo 2</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_nodeadkeys</name>
- <_description>Macintosh, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dsb</name>
- <_description>Lower Sorbian</_description>
- <languageList><iso639Id>dsb</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dsb_qwertz</name>
- <_description>Lower Sorbian (qwertz)</_description>
- <languageList><iso639Id>dsb</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty</name>
- <_description>qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ru</name>
- <_description>Russian phonetic</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>gr</name>
- <_shortDescription>Grc</_shortDescription>
- <_description>Greece</_description>
- <languageList><iso639Id>gre</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>simple</name>
- <_description>Simple</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>extended</name>
- <_description>Extended</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>polytonic</name>
- <_description>Polytonic</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>hu</name>
- <_shortDescription>Hun</_shortDescription>
- <_description>Hungary</_description>
- <languageList><iso639Id>hun</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>standard</name>
- <_description>Standard</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty</name>
- <_description>qwerty</_description>
- </configItem>
- </variant>
-
- <!-- 101 keys -->
- <variant>
- <configItem>
- <name>101_qwertz_comma_dead</name>
- <_description>101/qwertz/comma/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwertz_comma_nodead</name>
- <_description>101/qwertz/comma/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwertz_dot_dead</name>
- <_description>101/qwertz/dot/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwertz_dot_nodead</name>
- <_description>101/qwertz/dot/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwerty_comma_dead</name>
- <_description>101/qwerty/comma/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwerty_comma_nodead</name>
- <_description>101/qwerty/comma/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwerty_dot_dead</name>
- <_description>101/qwerty/dot/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>101_qwerty_dot_nodead</name>
- <_description>101/qwerty/dot/Eliminate dead keys</_description>
- </configItem>
- </variant>
-
-
- <!-- 102 keys -->
- <variant>
- <configItem>
- <name>102_qwertz_comma_dead</name>
- <_description>102/qwertz/comma/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwertz_comma_nodead</name>
- <_description>102/qwertz/comma/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwertz_dot_dead</name>
- <_description>102/qwertz/dot/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwertz_dot_nodead</name>
- <_description>102/qwertz/dot/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwerty_comma_dead</name>
- <_description>102/qwerty/comma/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwerty_comma_nodead</name>
- <_description>102/qwerty/comma/Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwerty_dot_dead</name>
- <_description>102/qwerty/dot/Dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>102_qwerty_dot_nodead</name>
- <_description>102/qwerty/dot/Eliminate dead keys</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>is</name>
- <_shortDescription>Isl</_shortDescription>
- <_description>Iceland</_description>
- <languageList><iso639Id>ice</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>Sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>il</name>
- <_shortDescription>Isr</_shortDescription>
- <_description>Israel</_description>
- <languageList><iso639Id>heb</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>lyx</name>
- <_description>lyx</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>biblical</name>
- <_description>Biblical Hebrew (Tiro)</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>it</name>
- <_shortDescription>Ita</_shortDescription>
- <_description>Italy</_description>
- <languageList><iso639Id>ita</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Italian letters</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>geo</name>
- <_description>Georgian</_description>
- <languageList><iso639Id>geo</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>jp</name>
- <_shortDescription>Jpn</_shortDescription>
- <_description>Japan</_description>
- <languageList><iso639Id>jpn</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>kana</name>
- <_description>Kana</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>kana86</name>
- <_description>Kana 86</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>OADG109A</name>
- <_description>OADG 109A</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>kg</name>
- <_shortDescription>Kgz</_shortDescription>
- <_description>Kyrgyzstan</_description>
- <languageList><iso639Id>kir</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Phonetic</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>kh</name>
- <_shortDescription>Khm</_shortDescription>
- <_description>Cambodia</_description>
- <languageList><iso639Id>khm</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>kz</name>
- <_shortDescription>Kaz</_shortDescription>
- <_description>Kazakhstan</_description>
- <languageList><iso639Id>kaz</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>ruskaz</name>
- <_description>Russian with Kazakh</_description>
- <languageList><iso639Id>kaz</iso639Id>
- <iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>kazrus</name>
- <_description>Kazakh with Russian</_description>
- <languageList><iso639Id>kaz</iso639Id>
- <iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>la</name>
- <_shortDescription>Lao</_shortDescription>
- <_description>Laos</_description>
- <languageList><iso639Id>lao</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>latam</name>
- <_shortDescription>LAm</_shortDescription>
- <_description>Latin American</_description>
- <countryList>
- <iso3166Id>AR</iso3166Id>
- <iso3166Id>BO</iso3166Id>
- <iso3166Id>CL</iso3166Id>
- <iso3166Id>CO</iso3166Id>
- <iso3166Id>CR</iso3166Id>
- <iso3166Id>CU</iso3166Id>
- <iso3166Id>DO</iso3166Id>
- <iso3166Id>EC</iso3166Id>
- <iso3166Id>GT</iso3166Id>
- <iso3166Id>HN</iso3166Id>
- <iso3166Id>HT</iso3166Id>
- <iso3166Id>MX</iso3166Id>
- <iso3166Id>NI</iso3166Id>
- <iso3166Id>PA</iso3166Id>
- <iso3166Id>PE</iso3166Id>
- <iso3166Id>PR</iso3166Id>
- <iso3166Id>PY</iso3166Id>
- <iso3166Id>SV</iso3166Id>
- <iso3166Id>US</iso3166Id>
- <iso3166Id>UY</iso3166Id>
- <iso3166Id>VE</iso3166Id>
- </countryList>
- <languageList><iso639Id>spa</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>deadtilde</name>
- <_description>Include dead tilde</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>lt</name>
- <_shortDescription>Ltu</_shortDescription>
- <_description>Lithuania</_description>
- <languageList><iso639Id>lit</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>std</name>
- <_description>Standard</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Lithuanian letters</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ibm</name>
- <_description>IBM (LST 1205-92)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>lekp</name>
- <_description>LEKP</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>lekpa</name>
- <_description>LEKPa</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>lv</name>
- <_shortDescription>Lva</_shortDescription>
- <_description>Latvia</_description>
- <languageList><iso639Id>lav</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>apostrophe</name>
- <_description>Apostrophe (') variant</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tilde</name>
- <_description>Tilde (~) variant</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fkey</name>
- <_description>F-letter (F) variant</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mao</name>
- <_shortDescription>Mao</_shortDescription>
- <_description>Maori</_description>
- <languageList><iso639Id>mao</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>me</name>
- <_shortDescription>MNE</_shortDescription>
- <_description>Montenegro</_description>
- <languageList><iso639Id>srp</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>cyrillic</name>
- <_description>Cyrillic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>cyrillicyz</name>
- <_description>Cyrillic, Z and ZHE swapped</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinunicode</name>
- <_description>Latin unicode</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinyz</name>
- <_description>Latin qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinunicodeyz</name>
- <_description>Latin unicode qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>cyrillicalternatequotes</name>
- <_description>Cyrillic with guillemets</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinalternatequotes</name>
- <_description>Latin with guillemets</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mk</name>
- <_shortDescription>Mkd</_shortDescription>
- <_description>Macedonia</_description>
- <languageList><iso639Id>mkd</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mt</name>
- <_shortDescription>Mlt</_shortDescription>
- <_description>Malta</_description>
- <languageList><iso639Id>mlt</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>us</name>
- <_description>Maltese keyboard with US layout</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mn</name>
- <_shortDescription>Mng</_shortDescription>
- <_description>Mongolia</_description>
- <languageList><iso639Id>mng</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>no</name>
- <_shortDescription>Nor</_shortDescription>
- <_description>Norway</_description>
- <languageList><iso639Id>nor</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>smi</name>
- <_description>Northern Saami</_description>
- <languageList><iso639Id>sme</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>smi_nodeadkeys</name>
- <_description>Northern Saami, eliminate dead keys</_description>
- <languageList><iso639Id>sme</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_nodeadkeys</name>
- <_description>Macintosh, eliminate dead keys</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>pl</name>
- <_shortDescription>Pol</_shortDescription>
- <_description>Poland</_description>
- <languageList><iso639Id>pol</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>qwertz</name>
- <_description>qwertz</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak_quotes</name>
- <_description>Dvorak, Polish quotes on quotemark key</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak_altquotes</name>
- <_description>Dvorak, Polish quotes on key 1</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>csb</name>
- <_description>Kashubian</_description>
- <languageList><iso639Id>csb</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ru_phonetic_dvorak</name>
- <_description>Russian phonetic Dvorak</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvp</name>
- <_description>Programmer Dvorak</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>pt</name>
- <_shortDescription>Prt</_shortDescription>
- <_description>Portugal</_description>
- <languageList><iso639Id>por</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_nodeadkeys</name>
- <_description>Macintosh, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_sundeadkeys</name>
- <_description>Macintosh, Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo</name>
- <_description>Nativo</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo-us</name>
- <_description>Nativo for USA keyboards</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>nativo-epo</name>
- <_description>Nativo for Esperanto</_description>
- <languageList><iso639Id>epo</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ro</name>
- <_shortDescription>Rou</_shortDescription>
- <_description>Romania</_description>
- <languageList><iso639Id>rum</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>cedilla</name>
- <_description>Cedilla</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>std</name>
- <_description>Standard</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>std_cedilla</name>
- <_description>Standard (Cedilla)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>winkeys</name>
- <_description>Winkeys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_f</name>
- <_description>Crimean Tatar (Turkish F)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_alt</name>
- <_description>Crimean Tatar (Turkish Alt-Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_dobruca1</name>
- <_description>Crimean Tatar (Dobruca-1 Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_dobruca2</name>
- <_description>Crimean Tatar (Dobruca-2 Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ru</name>
- <_shortDescription>Rus</_shortDescription>
- <_description>Russia</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>phonetic_winkeys</name>
- <_description>Phonetic Winkeys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>typewriter</name>
- <_description>Typewriter</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>typewriter-legacy</name>
- <_description>Typewriter, legacy</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tt</name>
- <_description>Tatar</_description>
- <languageList><iso639Id>tat</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>os_legacy</name>
- <_description>Ossetian, legacy</_description>
- <languageList><iso639Id>oss</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>os_winkeys</name>
- <_description>Ossetian, Winkeys</_description>
- <languageList><iso639Id>oss</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>cv</name>
- <_description>Chuvash</_description>
- <languageList><iso639Id>chv</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>cv_latin</name>
- <_description>Chuvash Latin</_description>
- <languageList><iso639Id>chv</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>udm</name>
- <_description>Udmurt</_description>
- <languageList><iso639Id>udm</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>kom</name>
- <_description>Komi</_description>
- <languageList><iso639Id>kom</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sah</name>
- <_description>Yakut</_description>
- <languageList><iso639Id>sah</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>xal</name>
- <_description>Kalmyk</_description>
- <languageList><iso639Id>xal</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dos</name>
- <_description>DOS</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>srp</name>
- <_description>Serbian</_description>
- <languageList><iso639Id>rus</iso639Id>
- <iso639Id>srp</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>bak</name>
- <_description>Bashkirian</_description>
- <languageList><iso639Id>bak</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>rs</name>
- <_shortDescription>SRB</_shortDescription>
- <_description>Serbia</_description>
- <languageList><iso639Id>srp</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>yz</name>
- <_description>Z and ZHE swapped</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latin</name>
- <_description>Latin</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinunicode</name>
- <_description>Latin Unicode</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinyz</name>
- <_description>Latin qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinunicodeyz</name>
- <_description>Latin Unicode qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>alternatequotes</name>
- <_description>With guillemets</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>latinalternatequotes</name>
- <_description>Latin with guillemets</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rue</name>
- <_description>Pannonian Rusyn Homophonic</_description>
- <languageList><iso639Id>rue</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>si</name>
- <_shortDescription>Svn</_shortDescription>
- <_description>Slovenia</_description>
- <languageList><iso639Id>slv</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>alternatequotes</name>
- <_description>Use guillemets for quotes</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us</name>
- <_description>US keyboard with Slovenian letters</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>sk</name>
- <_shortDescription>Svk</_shortDescription>
- <_description>Slovakia</_description>
- <languageList><iso639Id>slo</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>bksl</name>
- <_description>Extended Backslash</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty</name>
- <_description>qwerty</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>qwerty_bksl</name>
- <_description>qwerty, extended Backslash</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>es</name>
- <_shortDescription>Esp</_shortDescription>
- <_description>Spain</_description>
- <languageList><iso639Id>spa</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>deadtilde</name>
- <_description>Include dead tilde</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ast</name>
- <_description>Asturian variant with bottom-dot H and bottom-dot L</_description>
- <languageList><iso639Id>ast</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>cat</name>
- <_description>Catalan variant with middle-dot L</_description>
- <languageList><iso639Id>cat</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>se</name>
- <_shortDescription>Swe</_shortDescription>
- <_description>Sweden</_description>
- <languageList><iso639Id>swe</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>nodeadkeys</name>
- <_description>Eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rus</name>
- <_description>Russian phonetic</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rus_nodeadkeys</name>
- <_description>Russian phonetic, eliminate dead keys</_description>
- <languageList><iso639Id>rus</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>smi</name>
- <_description>Northern Saami</_description>
- <languageList><iso639Id>sme</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>svdvorak</name>
- <_description>Svdvorak</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ch</name>
- <_shortDescription>Che</_shortDescription>
- <_description>Switzerland</_description>
- <languageList><iso639Id>ger</iso639Id>
- <iso639Id>gsw</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>de_nodeadkeys</name>
- <_description>German, eliminate dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>de_sundeadkeys</name>
- <_description>German, Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fr</name>
- <_description>French</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fr_nodeadkeys</name>
- <_description>French, eliminate dead keys</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fr_sundeadkeys</name>
- <_description>French, Sun dead keys</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>fr_mac</name>
- <_description>French (Macintosh)</_description>
- <languageList><iso639Id>fra</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>de_mac</name>
- <_description>German (Macintosh)</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>sy</name>
- <_shortDescription>Syr</_shortDescription>
- <_description>Syria</_description>
- <languageList><iso639Id>syr</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>syc</name>
- <_description>Syriac</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>syc_phonetic</name>
- <_description>Syriac phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku</name>
- <_description>Kurdish, Latin Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_f</name>
- <_description>Kurdish, (F)</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_alt</name>
- <_description>Kurdish, Latin Alt-Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>tj</name>
- <_shortDescription>Tjk</_shortDescription>
- <_description>Tajikistan</_description>
- <languageList><iso639Id>tgk</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>lk</name>
- <_shortDescription>Lka</_shortDescription>
- <_description>Sri Lanka</_description>
- <languageList><iso639Id>sin</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>tam_unicode</name>
- <_description>Tamil Unicode</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>tam_TAB</name>
- <_description>Tamil TAB Typewriter</_description>
- <languageList><iso639Id>tam</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>th</name>
- <_shortDescription>Tha</_shortDescription>
- <_description>Thailand</_description>
- <languageList><iso639Id>tha</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>tis</name>
- <_description>TIS-820.2538</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>pat</name>
- <_description>Pattachote</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>tr</name>
- <_shortDescription>Tur</_shortDescription>
- <_description>Turkey</_description>
- <languageList><iso639Id>tur</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>f</name>
- <_description>(F)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>alt</name>
- <_description>Alt-Q</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>sundeadkeys</name>
- <_description>Sun dead keys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku</name>
- <_description>Kurdish, Latin Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_f</name>
- <_description>Kurdish, (F)</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ku_alt</name>
- <_description>Kurdish, Latin Alt-Q</_description>
- <languageList><iso639Id>kur</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>intl</name>
- <_description>International (with dead keys)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh</name>
- <_description>Crimean Tatar (Turkish Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_f</name>
- <_description>Crimean Tatar (Turkish F)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_alt</name>
- <_description>Crimean Tatar (Turkish Alt-Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ua</name>
- <_shortDescription>Ukr</_shortDescription>
- <_description>Ukraine</_description>
- <languageList><iso639Id>ukr</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>phonetic</name>
- <_description>Phonetic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>typewriter</name>
- <_description>Typewriter</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>winkeys</name>
- <_description>Winkeys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rstu</name>
-<!-- RSTU 2019-91 -->
- <_description>Standard RSTU</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>rstu_ru</name>
-<!-- RSTU 2019-91 -->
- <_description>Standard RSTU on Russian layout</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>homophonic</name>
- <_description>Homophonic</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh</name>
- <_description>Crimean Tatar (Turkish Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_f</name>
- <_description>Crimean Tatar (Turkish F)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_alt</name>
- <_description>Crimean Tatar (Turkish Alt-Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>gb</name>
- <_shortDescription>GBr</_shortDescription>
- <_description>United Kingdom</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>extd</name>
- <_description>Extended - Winkeys</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>intl</name>
- <_description>International (with dead keys)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorakukp</name>
- <_description>Dvorak (UK Punctuation)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac</name>
- <_description>Macintosh</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>mac_intl</name>
- <_description>Macintosh (International)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>colemak</name>
- <_description>Colemak</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>uz</name>
- <_shortDescription>Uzb</_shortDescription>
- <_description>Uzbekistan</_description>
- <languageList><iso639Id>uzb</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>latin</name>
- <_description>Latin</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh</name>
- <_description>Crimean Tatar (Turkish Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_f</name>
- <_description>Crimean Tatar (Turkish F)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>crh_alt</name>
- <_description>Crimean Tatar (Turkish Alt-Q)</_description>
- <languageList><iso639Id>crh</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>vn</name>
- <_shortDescription>Vnm</_shortDescription>
- <_description>Vietnam</_description>
- <languageList><iso639Id>vie</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>kr</name>
- <_shortDescription>Kor</_shortDescription>
- <_description>Korea, Republic of</_description>
- <languageList><iso639Id>kor</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>kr104</name>
- <_description>101/104 key Compatible</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>nec_vndr/jp</name>
- <_shortDescription>Jpn</_shortDescription>
- <_description>Japan (PC-98xx Series)</_description>
- <countryList><iso3166Id>JP</iso3166Id></countryList>
- <languageList><iso639Id>jpn</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>ie</name>
- <_shortDescription>Irl</_shortDescription>
- <_description>Ireland</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>CloGaelach</name>
- <_description>CloGaelach</_description>
- <languageList><iso639Id>gla</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>UnicodeExpert</name>
- <_description>UnicodeExpert</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ogam</name>
- <_description>Ogham</_description>
- <!-- No ISO code in ISO639 -->
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ogam_is434</name>
- <_description>Ogham IS434</_description>
- <!-- No ISO code in ISO639 -->
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>pk</name>
- <_shortDescription>Pak</_shortDescription>
- <_description>Pakistan</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>urd-crulp</name>
- <_description>CRULP</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>urd-nla</name>
- <_description>NLA</_description>
- <languageList><iso639Id>urd</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>ara</name>
- <_description>Arabic</_description>
- <languageList><iso639Id>ara</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>snd</name>
- <_description>Sindhi</_description>
- <languageList><iso639Id>sd</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>mv</name>
- <_shortDescription>Mdv</_shortDescription>
- <_description>Maldives</_description>
- <languageList><iso639Id>div</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>za</name>
- <_shortDescription>Zaf</_shortDescription>
- <_description>South Africa</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- </layout>
- <layout>
- <configItem>
- <name>epo</name>
- <_shortDescription>Epo</_shortDescription>
- <_description>Esperanto</_description>
- <languageList><iso639Id>epo</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>legacy</name>
- <_description>displaced semicolon and quote (obsolete)</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>np</name>
- <_shortDescription>Npl</_shortDescription>
- <_description>Nepal</_description>
- <languageList><iso639Id>nep</iso639Id></languageList>
- </configItem>
- </layout>
- <layout>
- <configItem>
- <name>ng</name>
- <_shortDescription>Nga</_shortDescription>
- <_description>Nigeria</_description>
- <languageList><iso639Id>eng</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>igbo</name>
- <_description>Igbo</_description>
- <languageList><iso639Id>ibo</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>yoruba</name>
- <_description>Yoruba</_description>
- <languageList><iso639Id>yor</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>hausa</name>
- <_description>Hausa</_description>
- <languageList><iso639Id>hau</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>et</name>
- <_shortDescription>Eth</_shortDescription>
- <_description>Ethiopia</_description>
- <languageList><iso639Id>amh</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>sn</name>
- <_shortDescription>Sen</_shortDescription>
- <_description>Senegal</_description>
- <languageList><iso639Id>wol</iso639Id></languageList>
- </configItem>
- <variantList/>
- </layout>
- <layout>
- <configItem>
- <name>brai</name>
- <_shortDescription>Brl</_shortDescription>
- <_description>Braille</_description>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>left_hand</name>
- <_description>Left hand</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>right_hand</name>
- <_description>Right hand</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>tm</name>
- <_shortDescription>Tkm</_shortDescription>
- <_description>Turkmenistan</_description>
- <languageList><iso639Id>tuk</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>alt</name>
- <_description>Alt-Q</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>ml</name>
- <_shortDescription>Mli</_shortDescription>
- <_description>Mali</_description>
- <languageList><iso639Id>bam</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>fr-oss</name>
- <_description>Français (France Alternative)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us-mac</name>
- <_description>English (USA Macintosh)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>us-intl</name>
- <_description>English (USA International)</_description>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>tz</name>
- <_shortDescription>Tza</_shortDescription>
- <_description>Tanzania</_description>
- <languageList><iso639Id>swa</iso639Id></languageList>
- </configItem>
- </layout>
- <layout>
- <configItem>
- <name>ke</name>
- <_shortDescription>Ken</_shortDescription>
- <_description>Kenya</_description>
- <languageList><iso639Id>swa</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>kik</name>
- <_description>Kikuyu</_description>
- <languageList><iso639Id>kik</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- <layout>
- <configItem>
- <name>bw</name>
- <_shortDescription>Bwa</_shortDescription>
- <_description>Botswana</_description>
- <languageList><iso639Id>tsn</iso639Id></languageList>
- </configItem>
- </layout>
- <layout>
- <configItem>
- <name>ph</name>
- <_shortDescription>Phi</_shortDescription>
- <_description>Philippines</_description>
- <languageList><iso639Id>eng</iso639Id>
- <iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- <variantList>
- <variant>
- <configItem>
- <name>qwerty-bay</name>
- <_description>QWERTY (Baybayin)</_description>
- <languageList><iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>capewell-dvorak</name>
- <_description>Capewell-Dvorak (Latin)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>capewell-dvorak-bay</name>
- <_description>Capewell-Dvorak (Baybayin)</_description>
- <languageList><iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>capewell-qwerf2k6</name>
- <_description>Capewell-QWERF 2006 (Latin)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>capewell-qwerf2k6-bay</name>
- <_description>Capewell-QWERF 2006 (Baybayin)</_description>
- <languageList><iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>colemak</name>
- <_description>Colemak (Latin)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>colemak-bay</name>
- <_description>Colemak (Baybayin)</_description>
- <languageList><iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak</name>
- <_description>Dvorak (Latin)</_description>
- </configItem>
- </variant>
- <variant>
- <configItem>
- <name>dvorak-bay</name>
- <_description>Dvorak (Baybayin)</_description>
- <languageList><iso639Id>bik</iso639Id>
- <iso639Id>ceb</iso639Id>
- <iso639Id>fil</iso639Id>
- <iso639Id>hil</iso639Id>
- <iso639Id>ilo</iso639Id>
- <iso639Id>pam</iso639Id>
- <iso639Id>pag</iso639Id>
- <iso639Id>phi</iso639Id>
- <iso639Id>tgl</iso639Id>
- <iso639Id>war</iso639Id></languageList>
- </configItem>
- </variant>
- </variantList>
- </layout>
- </layoutList>
- <optionList>
- <group allowMultipleSelection="true">
- <!-- The key combination used to switch between groups -->
- <configItem>
- <name>grp</name>
- <_description>Key(s) to change layout</_description>
- </configItem>
- <option>
- <configItem>
- <name>grp:switch</name>
- <_description>Right Alt (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lswitch</name>
- <_description>Left Alt (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lwin_switch</name>
- <_description>Left Win (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rwin_switch</name>
- <_description>Right Win (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:win_switch</name>
- <_description>Any Win key (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:caps_switch</name>
- <_description>Caps Lock (while pressed), Alt+Caps Lock does the original capslock action</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rctrl_switch</name>
- <_description>Right Ctrl (while pressed)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:toggle</name>
- <_description>Right Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lalt_toggle</name>
- <_description>Left Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:caps_toggle</name>
- <_description>Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:shift_caps_toggle</name>
- <_description>Shift+Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:shift_caps_switch</name>
- <_description>Caps Lock (to first layout), Shift+Caps Lock (to last layout)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:win_menu_switch</name>
- <_description>Left Win (to first layout), Right Win/Menu (to last layout)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lctrl_rctrl_switch</name>
- <_description>Left Ctrl (to first layout), Right Ctrl (to last layout)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:alt_caps_toggle</name>
- <_description>Alt+Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:shifts_toggle</name>
- <_description>Both Shift keys together</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:alts_toggle</name>
- <_description>Both Alt keys together</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:ctrls_toggle</name>
- <_description>Both Ctrl keys together</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:ctrl_shift_toggle</name>
- <_description>Ctrl+Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lctrl_lshift_toggle</name>
- <_description>Left Ctrl+Left Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rctrl_rshift_toggle</name>
- <_description>Right Ctrl+Right Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:ctrl_alt_toggle</name>
- <_description>Alt+Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:alt_shift_toggle</name>
- <_description>Alt+Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:alt_space_toggle</name>
- <_description>Alt+Space</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:menu_toggle</name>
- <_description>Menu</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lwin_toggle</name>
- <_description>Left Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rwin_toggle</name>
- <_description>Right Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lshift_toggle</name>
- <_description>Left Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rshift_toggle</name>
- <_description>Right Shift</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:lctrl_toggle</name>
- <_description>Left Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:rctrl_toggle</name>
- <_description>Right Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp:sclk_toggle</name>
- <_description>Scroll Lock</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <!-- The key combination used to choose the 3rd (and 4th, together with Shift)
- level of symbols -->
- <configItem>
- <name>lv3</name>
- <_description>Key to choose 3rd level</_description>
- </configItem>
- <option>
- <configItem>
- <name>lv3:switch</name>
- <_description>Right Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:menu_switch</name>
- <_description>Menu</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:win_switch</name>
- <_description>Any Win key</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:lwin_switch</name>
- <_description>Left Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:rwin_switch</name>
- <_description>Right Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:alt_switch</name>
- <_description>Any Alt key</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:lalt_switch</name>
- <_description>Left Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:ralt_switch</name>
- <_description>Right Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:ralt_switch_multikey</name>
- <_description>Right Alt, Shift+Right Alt key is Multi_Key</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:ralt_alt</name>
- <_description>Right Alt key never chooses 3rd level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:enter_switch</name>
- <_description>Enter on keypad</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:caps_switch</name>
- <_description>Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:bksl_switch</name>
- <_description>Backslash</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:lsgt_switch</name>
- <description><Less/Greater></description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:caps_switch_latch</name>
- <description>Caps Lock (chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:bksl_switch_latch</name>
- <description>Backslash chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv3:lsgt_switch_latch</name>
- <description><Less/Greater> (chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <!-- Tweaking the position of the "Ctrl" key -->
- <configItem>
- <name>ctrl</name>
- <_description>Ctrl key position</_description>
- </configItem>
- <option>
- <configItem>
- <name>ctrl:nocaps</name>
- <_description>Make Caps Lock an additional Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:lctrl_meta</name>
- <_description>Meta on Left Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:swapcaps</name>
- <_description>Swap Ctrl and Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:ctrl_ac</name>
- <_description>At left of 'A'</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:ctrl_aa</name>
- <_description>At bottom left</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:ctrl_ra</name>
- <_description>Right Ctrl as Right Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>ctrl:ctrl_menu</name>
- <description>Right Ctrl is mapped to Menu</description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <!-- Using startard LEDs to indicate the alternative (not first) group(s) -->
- <configItem>
- <name>grp_led</name>
- <_description>Use keyboard LED to show alternative layout</_description>
- </configItem>
- <option>
- <configItem>
- <name>grp_led:num</name>
- <_description>Num Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp_led:caps</name>
- <_description>Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>grp_led:scroll</name>
- <_description>Scroll Lock</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="false">
- <!-- Select a keypad type -->
- <configItem>
- <name>keypad</name>
- <_description>Numeric keypad layout selection</_description>
- </configItem>
- <option>
- <configItem>
- <name>keypad:legacy</name>
- <_description>Legacy</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:oss</name>
- <_description>Unicode additions (arrows and math operators)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:future</name>
- <_description>Unicode additions (arrows and math operators). Math operators on default level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:legacy_wang</name>
- <_description>Legacy Wang 724</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:oss_wang</name>
- <_description>Wang 724 keypad with unicode additions (arrows and math operators)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:future_wang</name>
- <_description>Wang 724 keypad with unicode additions (arrows and math operators). Math operators on default level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:hex</name>
- <_description>Hexadecimal</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:atm</name>
- <_description>ATM/phone-style</_description>
- </configItem>
- </option>
- </group>
- <!-- This option should override the KPDL key defined in keypad; I hope it's declared in the right place -->
- <group allowMultipleSelection="false">
- <!-- Select a keypad KPDL variant -->
- <configItem>
- <name>kpdl</name>
- <_description>Numeric keypad delete key behaviour</_description>
- </configItem>
- <option>
- <configItem>
- <!-- Actually, with KP_DECIMAL, as the old keypad(dot) -->
- <name>kpdl:dot</name>
- <_description>Legacy key with dot</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:comma</name>
- <!-- Actually, with KP_SEPARATOR, as the old keypad(comma) -->
- <_description>Legacy key with comma</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:dotoss</name>
- <_description>Four-level key with dot</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:dotoss_latin9</name>
- <_description>Four-level key with dot, latin-9 restriction</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:commaoss</name>
- <_description>Four-level key with comma</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:momayyezoss</name>
- <_description>Four-level key with momayyez</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:kposs</name>
- <!-- This assumes the KP_ abstract symbols are actually useful for some apps
- The description needs to be rewritten -->
- <_description>Four-level key with abstract separators</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>kpdl:semi</name>
- <_description>Semi-colon on third level</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="false">
- <!-- Caps Lock tweaks.
- "Internal" capitalization means capitalization using some internal tables.
- Otherwise "as Shift" - means using next group. -->
- <configItem>
- <name>caps</name>
- <_description>Caps Lock key behavior</_description>
- </configItem>
- <option>
- <configItem>
- <name>caps:internal</name>
- <_description>Caps Lock uses internal capitalization. Shift "pauses" Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:internal_nocancel</name>
- <_description>Caps Lock uses internal capitalization. Shift doesn't affect Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:shift</name>
- <_description>Caps Lock acts as Shift with locking. Shift "pauses" Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:shift_nocancel</name>
- <_description>Caps Lock acts as Shift with locking. Shift doesn't affect Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:capslock</name>
- <_description>Caps Lock toggles normal capitalization of alphabetic characters</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:numlock</name>
- <_description>Make Caps Lock an additional Num Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:swapescape</name>
- <_description>Swap ESC and Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:escape</name>
- <_description>Make Caps Lock an additional ESC</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:backspace</name>
- <_description>Make Caps Lock an additional Backspace</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:super</name>
- <_description>Make Caps Lock an additional Super</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:hyper</name>
- <_description>Make Caps Lock an additional Hyper</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:shiftlock</name>
- <_description>Caps Lock toggles Shift so all keys are affected</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>caps:none</name>
- <_description>Caps Lock is disabled</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="false">
- <!-- Using special PC keys (Win, Menu) to work as standard X keys (Super, Hyper, etc.) -->
- <configItem>
- <name>altwin</name>
- <_description>Alt/Win key behavior</_description>
- </configItem>
- <option>
- <configItem>
- <name>altwin:menu</name>
- <_description>Add the standard behavior to Menu key</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:meta_alt</name>
- <_description>Alt and Meta are on Alt keys</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:ctrl_win</name>
- <_description>Control is mapped to Win keys (and the usual Ctrl keys)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:ctrl_alt_win</name>
- <_description>Control is mapped to Alt keys, Alt is mapped to Win keys</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:meta_win</name>
- <_description>Meta is mapped to Win keys</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:left_meta_win</name>
- <_description>Meta is mapped to Left Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:hyper_win</name>
- <_description>Hyper is mapped to Win-keys</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:alt_super_win</name>
- <_description>Alt is mapped to Right Win, Super to Menu</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>altwin:swap_lalt_lwin</name>
- <_description>Left Alt is swapped with Left Win</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <!-- Tweaking the position of the "Compose" key: mapping to existing PC keys -->
- <configItem>
- <name>Compose key</name>
- <_description>Compose key position</_description>
- </configItem>
- <option>
- <configItem>
- <name>compose:ralt</name>
- <_description>Right Alt</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:lwin</name>
- <_description>Left Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:rwin</name>
- <_description>Right Win</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:menu</name>
- <_description>Menu</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:lctrl</name>
- <_description>Left Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:rctrl</name>
- <_description>Right Ctrl</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:caps</name>
- <_description>Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:102</name>
- <_description><Less/Greater></_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:paus</name>
- <_description>Pause</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:prsc</name>
- <_description>PrtSc</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>compose:sclk</name>
- <_description>Scroll Lock</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <configItem>
- <name>compat</name>
- <_description>Miscellaneous compatibility options</_description>
- </configItem>
- <option>
- <configItem>
- <name>numpad:pc</name>
- <_description>Default numeric keypad keys</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>numpad:mac</name>
- <_description>Numeric keypad keys work as with Mac</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>numpad:microsoft</name>
- <_description>Shift with numeric keypad keys works as in MS Windows</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>numpad:shift3</name>
- <_description>Shift does not cancel Num Lock, chooses 3rd level instead</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>srvrkeys:none</name>
- <_description>Special keys (Ctrl+Alt+<key>) handled in a server</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>apple:alupckeys</name>
- <_description>Apple Aluminium Keyboard: emulate PC keys (Print, Scroll Lock, Pause, Num Lock)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>shift:breaks_caps</name>
- <_description>Shift cancels Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>misc:typo</name>
- <_description>Enable extra typographic characters</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>shift:both_capslock</name>
- <_description>Both Shift-Keys together toggle Caps Lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>shift:both_capslock_cancel</name>
- <description>Both Shift-Keys together activate Caps Lock, one Shift-Key deactivates</description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>shift:both_shiftlock</name>
- <description>Both Shift-Keys together toggle ShiftLock</description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>keypad:pointerkeys</name>
- <_description>Toggle PointerKeys with Shift + NumLock.</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <!-- Special shortcuts for the Euro character -->
- <configItem>
- <name>eurosign</name>
- <_description>Adding currency signs to certain keys</_description>
- </configItem>
- <option>
- <configItem>
- <name>eurosign:e</name>
- <_description>Euro on E</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>eurosign:2</name>
- <_description>Euro on 2</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>eurosign:4</name>
- <_description>Euro on 4</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>eurosign:5</name>
- <_description>Euro on 5</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>rupeesign:4</name>
- <_description>Rupee on 4</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <configItem>
- <name>lv5</name>
- <_description>Key to choose 5th level</_description>
- </configItem>
- <option>
- <configItem>
- <name>lv5:lsgt_switch_lock</name>
- <_description><Less/Greater> chooses 5th level, locks when pressed together with another 5th-level-chooser</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:ralt_switch_lock</name>
- <_description>Right Alt chooses 5th level, locks when pressed together with another 5th-level-chooser</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:lwin_switch_lock</name>
- <_description>Left Win chooses 5th level, locks when pressed together with another 5th-level-chooser</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:rwin_switch_lock</name>
- <_description>Right Win chooses 5th level, locks when pressed together with another 5th-level-chooser</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:lsgt_switch_lock_cancel</name>
- <_description><Less/Greater> chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:ralt_switch_lock_cancel</name>
- <_description>Right Alt chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:lwin_switch_lock_cancel</name>
- <_description>Left Win chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:rwin_switch_lock_cancel</name>
- <_description>Right Win chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:lsgt_switch_lock_cancel</name>
- <description><Less/Greater> chooses 5th level and activates level5-Lock when pressed together with another 5th-level-chooser, one press releases the lock</description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>lv5:ralt_switch_lock_cancel</name>
- <description>Right Alt chooses 5th level and activates level5-Lock when pressed together with another 5th-level-chooser, one press releases the lock</description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="false">
- <!-- Let space output NBSP, NNBSP, ZWNJ, and ZWJ for the desired level -->
- <configItem>
- <name>nbsp</name>
- <_description>Using space key to input non-breakable space character</_description>
- </configItem>
- <option>
- <configItem>
- <name>nbsp:none</name>
- <_description>Usual space at any level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level2</name>
- <_description>Non-breakable space character at second level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level3</name>
- <_description>Non-breakable space character at third level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level3s</name>
- <_description>Non-breakable space character at third level, nothing at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level3n</name>
- <_description>Non-breakable space character at third level, thin non-breakable space character at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level4</name>
- <_description>Non-breakable space character at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level4n</name>
- <_description>Non-breakable space character at fourth level, thin non-breakable space character at sixth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:level4nl</name>
- <_description>Non-breakable space character at fourth level, thin non-breakable space character at sixth level (via Ctrl+Shift)</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2</name>
- <_description>Zero-width non-joiner character at second level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2zwj3</name>
- <_description>Zero-width non-joiner character at second level, zero-width joiner character at third level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2zwj3nb4</name>
- <_description>Zero-width non-joiner character at second level, zero-width joiner character at third level, non-breakable space character at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2nb3</name>
- <_description>Zero-width non-joiner character at second level, non-breakable space character at third level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2nb3s</name>
- <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, nothing at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2nb3zwj4</name>
- <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, zero-width joiner at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj2nb3nnb4</name>
- <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, thin non-breakable space at fourth level</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>nbsp:zwnj3zwj4</name>
- <_description>Zero-width non-joiner character at third level, zero-width joiner at fourth level</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <configItem>
- <name>japan</name>
- <_description>Japanese keyboard options</_description>
- </configItem>
- <option>
- <configItem>
- <name>japan:kana_lock</name>
- <_description>Kana Lock key is locking</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>japan:nicola_f_bs</name>
- <_description>NICOLA-F style Backspace</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="false">
- <configItem>
- <name>esperanto</name>
- <_description>Adding Esperanto circumflexes (supersigno)</_description>
- </configItem>
- <option>
- <configItem>
- <name>esperanto:qwerty</name>
- <_description>To the corresponding key in a Qwerty keyboard.</_description>
- </configItem>
- </option>
- <option>
- <configItem>
- <name>esperanto:dvorak</name>
- <_description>To the corresponding key in a Dvorak keyboard.</_description>
- </configItem>
- </option>
- </group>
- <group allowMultipleSelection="true">
- <configItem>
- <name>terminate</name>
- <_description>Key sequence to kill the X server</_description>
- </configItem>
- <option>
- <configItem>
- <name>terminate:ctrl_alt_bksp</name>
- <_description>Control + Alt + Backspace</_description>
- </configItem>
- </option>
- </group>
- </optionList>
-</xkbConfigRegistry>
+<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE xkbConfigRegistry SYSTEM "xkb.dtd"> +<xkbConfigRegistry> + <modelList> + <model> + <configItem> + <name>pc101</name> + <_description>Generic 101-key PC</_description> + <vendor>Generic</vendor> + </configItem> + </model> + <model> + <configItem> + <name>pc102</name> + <_description>Generic 102-key (Intl) PC</_description> + <vendor>Generic</vendor> + </configItem> + </model> + <model> + <configItem> + <name>pc104</name> + <_description>Generic 104-key PC</_description> + <vendor>Generic</vendor> + </configItem> + </model> + <model> + <configItem> + <name>pc105</name> + <_description>Generic 105-key (Intl) PC</_description> + <vendor>Generic</vendor> + </configItem> + </model> + <model> + <configItem> + <name>dell101</name> + <_description>Dell 101-key PC</_description> + <vendor>Dell</vendor> + </configItem> + </model> + <model> + <configItem> + <name>latitude</name> + <_description>Dell Latitude series laptop</_description> + <vendor>Dell</vendor> + </configItem> + </model> + <model> + <configItem> + <name>dellm65</name> + <_description>Dell Precision M65</_description> + <vendor>Dell</vendor> + </configItem> + </model> + <model> + <configItem> + <name>everex</name> + <_description>Everex STEPnote</_description> + <vendor>Everex</vendor> + </configItem> + </model> + <model> + <configItem> + <name>flexpro</name> + <_description>Keytronic FlexPro</_description> + <vendor>Keytronic</vendor> + </configItem> + </model> + <model> + <configItem> + <name>microsoft</name> + <_description>Microsoft Natural</_description> + <vendor>Microsoft Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>omnikey101</name> + <_description>Northgate OmniKey 101</_description> + <vendor>Northgate</vendor> + </configItem> + </model> + <model> + <configItem> + <name>winbook</name> + <_description>Winbook Model XP5</_description> + <vendor>Generic</vendor> + </configItem> + </model> + <model> + <configItem> + <name>pc98</name> + <_description>PC-98xx Series</_description> + <vendor>Generic</vendor> + </configItem> + </model> + <model> + <configItem> + <name>a4techKB21</name> + <_description>A4Tech KB-21</_description> + <vendor>A4Tech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>a4techKBS8</name> + <_description>A4Tech KBS-8</_description> + <vendor>A4Tech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>a4_rfkb23</name> + <_description>A4Tech Wireless Desktop RFKB-23</_description> + <vendor>A4Tech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>airkey</name> + <_description>Acer AirKey V</_description> + <vendor>Acer</vendor> + </configItem> + </model> + <model> + <configItem> + <name>azonaRF2300</name> + <_description>Azona RF2300 wireless Internet Keyboard</_description> + <vendor>Azona</vendor> + </configItem> + </model> + <model> + <configItem> + <name>scorpius</name> + <_description>Advance Scorpius KI</_description> + <vendor>Scorpius</vendor> + </configItem> + </model> + <model> + <configItem> + <name>brother</name> + <_description>Brother Internet Keyboard</_description> + <vendor>Brother</vendor> + </configItem> + </model> + <model> + <configItem> + <name>btc5113rf</name> + <_description>BTC 5113RF Multimedia</_description> + <vendor>BTC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>btc5126t</name> + <_description>BTC 5126T</_description> + <vendor>BTC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>btc6301urf</name> + <_description>BTC 6301URF</_description> + <vendor>BTC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>btc9000</name> + <_description>BTC 9000</_description> + <vendor>BTC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>btc9000a</name> + <_description>BTC 9000A</_description> + <vendor>BTC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>btc9001ah</name> + <_description>BTC 9001AH</_description> + <vendor>BTC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>btc5090</name> + <_description>BTC 5090</_description> + <vendor>BTC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>btc9019u</name> + <_description>BTC 9019U</_description> + <vendor>BTC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>btc9116u</name> + <_description>BTC 9116U Mini Wireless Internet and Gaming</_description> + </configItem> + </model> + <model> + <configItem> + <name>cherryblue</name> + <_description>Cherry Blue Line CyBo@rd</_description> + </configItem> + </model> + <model> + <configItem> + <name>cherryblueb</name> + <_description>Cherry CyMotion Master XPress</_description> + <vendor>Cherry</vendor> + </configItem> + </model> + <model> + <configItem> + <name>cherrybluea</name> + <_description>Cherry Blue Line CyBo@rd (alternate option)</_description> + <vendor>Cherry</vendor> + </configItem> + </model> + <model> + <configItem> + <name>cherrycyboard</name> + <_description>Cherry CyBo@rd USB-Hub</_description> + <vendor>Cherry</vendor> + </configItem> + </model> + <model> + <configItem> + <name>cherrycmexpert</name> + <_description>Cherry CyMotion Expert</_description> + <vendor>Cherry</vendor> + </configItem> + </model> + <model> + <configItem> + <name>cherrybunlim</name> + <_description>Cherry B.UNLIMITED</_description> + <vendor>Cherry</vendor> + </configItem> + </model> + <model> + <configItem> + <name>chicony</name> + <_description>Chicony Internet Keyboard</_description> + <vendor>Chicony</vendor> + </configItem> + </model> + <model> + <configItem> + <name>chicony0108</name> + <_description>Chicony KU-0108</_description> + <vendor>Chicony</vendor> + </configItem> + </model> + <model> + <configItem> + <name>chicony0420</name> + <_description>Chicony KU-0420</_description> + <vendor>Chicony</vendor> + </configItem> + </model> + <model> + <configItem> + <name>chicony9885</name> + <_description>Chicony KB-9885</_description> + <vendor>Chicony</vendor> + </configItem> + </model> + <model> + <configItem> + <name>compaqeak8</name> + <_description>Compaq Easy Access Keyboard</_description> + <vendor>Compaq</vendor> + </configItem> + </model> + <model> + <configItem> + <name>compaqik7</name> + <_description>Compaq Internet Keyboard (7 keys)</_description> + <vendor>Compaq</vendor> + </configItem> + </model> + <model> + <configItem> + <name>compaqik13</name> + <_description>Compaq Internet Keyboard (13 keys)</_description> + <vendor>Compaq</vendor> + </configItem> + </model> + <model> + <configItem> + <name>compaqik18</name> + <_description>Compaq Internet Keyboard (18 keys)</_description> + <vendor>Compaq</vendor> + </configItem> + </model> + <model> + <configItem> + <name>cymotionlinux</name> + <_description>Cherry CyMotion Master Linux</_description> + <vendor>Cherry</vendor> + </configItem> + </model> + <model> + <configItem> + <name>armada</name> + <_description>Laptop/notebook Compaq (eg. Armada) Laptop Keyboard</_description> + <vendor>Compaq</vendor> + </configItem> + </model> + <model> + <configItem> + <name>presario</name> + <_description>Laptop/notebook Compaq (eg. Presario) Internet Keyboard</_description> + <vendor>Compaq</vendor> + </configItem> + </model> + <model> + <configItem> + <name>ipaq</name> + <_description>Compaq iPaq Keyboard</_description> + <vendor>Compaq</vendor> + </configItem> + </model> + <model> + <configItem> + <name>dell</name> + <_description>Dell</_description> + <vendor>Dell</vendor> + </configItem> + </model> + <model> + <configItem> + <name>dellsk8125</name> + <_description>Dell SK-8125</_description> + <vendor>Dell</vendor> + </configItem> + </model> + <model> + <configItem> + <name>dellsk8135</name> + <_description>Dell SK-8135</_description> + <vendor>Dell</vendor> + </configItem> + </model> + <model> + <configItem> + <name>dellusbmm</name> + <_description>Dell USB Multimedia Keyboard</_description> + <vendor>Dell</vendor> + </configItem> + </model> + <model> + <configItem> + <name>inspiron</name> + <_description>Dell Laptop/notebook Inspiron 6xxx/8xxx</_description> + <vendor>Dell</vendor> + </configItem> + </model> + <model> + <configItem> + <name>precision_m</name> + <_description>Dell Laptop/notebook Precision M series</_description> + <vendor>Dell</vendor> + </configItem> + </model> + <model> + <configItem> + <name>dexxa</name> + <_description>Dexxa Wireless Desktop Keyboard</_description> + <vendor>Dexxa</vendor> + </configItem> + </model> + <model> + <configItem> + <name>diamond</name> + <_description>Diamond 9801 / 9802 series</_description> + <vendor>Diamond</vendor> + </configItem> + </model> + <model> + <configItem> + <name>dtk2000</name> + <_description>DTK2000</_description> + </configItem> + </model> + <model> + <configItem> + <name>ennyah_dkb1008</name> + <_description>Ennyah DKB-1008</_description> + <vendor>Ennyah</vendor> + </configItem> + </model> + <model> + <configItem> + <name>fscaa1667g</name> + <_description>Fujitsu-Siemens Computers AMILO laptop</_description> + <vendor>Fujitsu-Siemens</vendor> + </configItem> + </model> + <model> + <configItem> + <name>genius</name> + <_description>Genius Comfy KB-16M / Genius MM Keyboard KWD-910</_description> + <vendor>Genius</vendor> + </configItem> + </model> + <model> + <configItem> + <name>geniuscomfy</name> + <_description>Genius Comfy KB-12e</_description> + <vendor>Genius</vendor> + </configItem> + </model> + <model> + <configItem> + <name>geniuscomfy2</name> + <_description>Genius Comfy KB-21e-Scroll</_description> + <vendor>Genius</vendor> + </configItem> + </model> + <model> + <configItem> + <name>geniuskb19e</name> + <_description>Genius KB-19e NB</_description> + <vendor>Genius</vendor> + </configItem> + </model> + <model> + <configItem> + <name>geniuskkb2050hs</name> + <_description>Genius KKB-2050HS</_description> + <vendor>Genius</vendor> + </configItem> + </model> + <model> + <configItem> + <name>gyration</name> + <_description>Gyration</_description> + <vendor>Gyration</vendor> + </configItem> + </model> + <model> + <configItem> + <name>htcdream</name> + <_description>HTC Dream</_description> + <vendor>HTC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>kinesis</name> + <_description>Kinesis</_description> + <vendor>Kinesis</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logitech_base</name> + <_description>Logitech Generic Keyboard</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logitech_g15</name> + <_description>Logitech G15 extra keys via G15daemon</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hpi6</name> + <_description>Hewlett-Packard Internet Keyboard</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hp250x</name> + <_description>Hewlett-Packard SK-250x Multimedia Keyboard</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hpxe3gc</name> + <_description>Hewlett-Packard Omnibook XE3 GC</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hpxe3gf</name> + <_description>Hewlett-Packard Omnibook XE3 GF</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hpxt1000</name> + <_description>Hewlett-Packard Omnibook XT1000</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hpdv5</name> + <_description>Hewlett-Packard Pavilion dv5</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hpzt11xx</name> + <_description>Hewlett-Packard Pavilion ZT11xx</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hp500fa</name> + <_description>Hewlett-Packard Omnibook 500 FA</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hp5xx</name> + <_description>Hewlett-Packard Omnibook 5xx</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hpnx9020</name> + <_description>Hewlett-Packard nx9020</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hp6000</name> + <_description>Hewlett-Packard Omnibook 6000/6100</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>honeywell_euroboard</name> + <_description>Honeywell Euroboard</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hpmini110</name> + <_description>Hewlett-Packard Mini 110 Notebook</_description> + <vendor>Hewlett-Packard</vendor> + </configItem> + </model> + <model> + <configItem> + <name>rapidaccess</name> + <_description>IBM Rapid Access</_description> + <vendor>Lenovo (previously IBM)</vendor> + </configItem> + </model> + <model> + <configItem> + <name>rapidaccess2</name> + <_description>IBM Rapid Access II</_description> + <vendor>Lenovo (previously IBM)</vendor> + </configItem> + </model> + <model> + <configItem> + <name>thinkpad</name> + <_description>IBM ThinkPad 560Z/600/600E/A22E</_description> + <vendor>Lenovo (previously IBM)</vendor> + </configItem> + </model> + <model> + <configItem> + <name>thinkpad60</name> + <_description>IBM ThinkPad R60/T60/R61/T61</_description> + <vendor>Lenovo (previously IBM)</vendor> + </configItem> + </model> + <model> + <configItem> + <name>thinkpadz60</name> + <_description>IBM ThinkPad Z60m/Z60t/Z61m/Z61t</_description> + <vendor>Lenovo (previously IBM)</vendor> + </configItem> + </model> + <model> + <configItem> + <name>ibm_spacesaver</name> + <_description>IBM Space Saver</_description> + <vendor>Lenovo (previously IBM)</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logiaccess</name> + <_description>Logitech Access Keyboard</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logiclx300</name> + <_description>Logitech Cordless Desktop LX-300</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logii350</name> + <_description>Logitech Internet 350 Keyboard</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logimel</name> + <_description>Logitech Media Elite Keyboard</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logicd</name> + <_description>Logitech Cordless Desktop</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logicd_it</name> + <_description>Logitech Cordless Desktop iTouch</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logicd_nav</name> + <_description>Logitech Cordless Desktop Navigator</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logicd_opt</name> + <_description>Logitech Cordless Desktop Optical</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logicda</name> + <_description>Logitech Cordless Desktop (alternate option)</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logicdpa2</name> + <_description>Logitech Cordless Desktop Pro (alternate option 2)</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logicfn</name> + <_description>Logitech Cordless Freedom/Desktop Navigator</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logicdn</name> + <_description>Logitech Cordless Desktop Navigator</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logiitc</name> + <_description>Logitech iTouch Cordless Keyboard (model Y-RB6)</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logiik</name> + <_description>Logitech Internet Keyboard</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>itouch</name> + <_description>Logitech iTouch</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logicink</name> + <_description>Logitech Internet Navigator Keyboard</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logiex110</name> + <_description>Logitech Cordless Desktop EX110</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logiinkse</name> + <_description>Logitech iTouch Internet Navigator Keyboard SE</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logiinkseusb</name> + <_description>Logitech iTouch Internet Navigator Keyboard SE (USB)</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logiultrax</name> + <_description>Logitech Ultra-X Keyboard</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logiultraxc</name> + <_description>Logitech Ultra-X Cordless Media Desktop Keyboard</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logidinovo</name> + <_description>Logitech diNovo Keyboard</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>logidinovoedge</name> + <_description>Logitech diNovo Edge Keyboard</_description> + <vendor>Logitech</vendor> + </configItem> + </model> + <model> + <configItem> + <name>mx1998</name> + <_description>Memorex MX1998</_description> + <vendor>Memorex</vendor> + </configItem> + </model> + <model> + <configItem> + <name>mx2500</name> + <_description>Memorex MX2500 EZ-Access Keyboard</_description> + <vendor>Memorex</vendor> + </configItem> + </model> + <model> + <configItem> + <name>mx2750</name> + <_description>Memorex MX2750</_description> + <vendor>Memorex</vendor> + </configItem> + </model> + <model> + <configItem> + <name>microsoft7000</name> + <_description>Microsoft Natural Wireless Ergonomic Keyboard 7000</_description> + <vendor>Microsoft Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>microsoftinet</name> + <_description>Microsoft Internet Keyboard</_description> + <vendor>Microsoft Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>microsoftpro</name> + <_description>Microsoft Natural Keyboard Pro / Microsoft Internet Keyboard Pro</_description> + <vendor>Microsoft Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>microsoftprousb</name> + <_description>Microsoft Natural Keyboard Pro USB / Microsoft Internet Keyboard Pro</_description> + <vendor>Microsoft Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>microsoftprooem</name> + <_description>Microsoft Natural Keyboard Pro OEM</_description> + <vendor>Microsoft Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>vsonku306</name> + <_description>ViewSonic KU-306 Internet Keyboard</_description> + <vendor>ViewSonic</vendor> + </configItem> + </model> + <model> + <configItem> + <name>microsoftprose</name> + <_description>Microsoft Internet Keyboard Pro, Swedish</_description> + <vendor>Microsoft Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>microsoftoffice</name> + <_description>Microsoft Office Keyboard</_description> + <vendor>Microsoft Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>microsoftmult</name> + <_description>Microsoft Wireless Multimedia Keyboard 1.0A</_description> + <vendor>Microsoft Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>microsoftelite</name> + <_description>Microsoft Natural Keyboard Elite</_description> + <vendor>Microsoft Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>microsoftccurve2k</name> + <_description>Microsoft Comfort Curve Keyboard 2000</_description> + <vendor>Microsoft Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>oretec</name> + <_description>Ortek MCK-800 MM/Internet keyboard</_description> + <vendor>Ortek</vendor> + </configItem> + </model> + <model> + <configItem> + <name>propeller</name> + <_description>Propeller Voyager (KTEZ-1000)</_description> + <vendor>KeyTronic</vendor> + </configItem> + </model> + <model> + <configItem> + <name>qtronix</name> + <_description>QTronix Scorpius 98N+</_description> + <vendor>QTronix</vendor> + </configItem> + </model> + <model> + <configItem> + <name>samsung4500</name> + <_description>Samsung SDM 4500P</_description> + <vendor>Samsung</vendor> + </configItem> + </model> + <model> + <configItem> + <name>samsung4510</name> + <_description>Samsung SDM 4510P</_description> + <vendor>Samsung</vendor> + </configItem> + </model> + <model> + <configItem> + <name>sanwaskbkg3</name> + <description>Sanwa Supply SKB-KG3</description> + <vendor>Sanwa Supply Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>sk1300</name> + <_description>SK-1300</_description> + <vendor>NEC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>sk2500</name> + <_description>SK-2500</_description> + <vendor>NEC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>sk6200</name> + <_description>SK-6200</_description> + <vendor>NEC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>sk7100</name> + <_description>SK-7100</_description> + <vendor>NEC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>sp_inet</name> + <_description>Super Power Multimedia Keyboard</_description> + <vendor>Generic</vendor> + </configItem> + </model> + <model> + <configItem> + <name>sven</name> + <_description>SVEN Ergonomic 2500</_description> + <vendor>SVEN</vendor> + </configItem> + </model> + <model> + <configItem> + <name>sven303</name> + <_description>SVEN Slim 303</_description> + <vendor>SVEN</vendor> + </configItem> + </model> + <model> + <configItem> + <name>symplon</name> + <_description>Symplon PaceBook (tablet PC)</_description> + <vendor>Symplon</vendor> + </configItem> + </model> + <model> + <configItem> + <name>toshiba_s3000</name> + <_description>Toshiba Satellite S3000</_description> + <vendor>Toshiba</vendor> + </configItem> + </model> + <model> + <configItem> + <name>trust</name> + <_description>Trust Wireless Keyboard Classic</_description> + <vendor>Trust</vendor> + </configItem> + </model> + <model> + <configItem> + <name>trustda</name> + <_description>Trust Direct Access Keyboard</_description> + <vendor>Trust</vendor> + </configItem> + </model> + <model> + <configItem> + <name>trust_slimline</name> + <_description>Trust Slimline</_description> + <vendor>Trust</vendor> + </configItem> + </model> + <model> + <configItem> + <name>tm2020</name> + <_description>TypeMatrix EZ-Reach 2020</_description> + <vendor>TypeMatrix</vendor> + </configItem> + </model> + <model> + <configItem> + <name>tm2030PS2</name> + <_description>TypeMatrix EZ-Reach 2030 PS2</_description> + <vendor>TypeMatrix</vendor> + </configItem> + </model> + <model> + <configItem> + <name>tm2030USB</name> + <_description>TypeMatrix EZ-Reach 2030 USB</_description> + <vendor>TypeMatrix</vendor> + </configItem> + </model> + <model> + <configItem> + <name>tm2030USB-102</name> + <_description>TypeMatrix EZ-Reach 2030 USB (102/105:EU mode)</_description> + <vendor>TypeMatrix</vendor> + </configItem> + </model> + <model> + <configItem> + <name>tm2030USB-106</name> + <_description>TypeMatrix EZ-Reach 2030 USB (106:JP mode)</_description> + <vendor>TypeMatrix</vendor> + </configItem> + </model> + <model> + <configItem> + <name>yahoo</name> + <_description>Yahoo! Internet Keyboard</_description> + <vendor>Yahoo!</vendor> + </configItem> + </model> + <model> + <configItem> + <name>macbook78</name> + <_description>MacBook/MacBook Pro</_description> + <vendor>Apple</vendor> + </configItem> + </model> + <model> + <configItem> + <name>macbook79</name> + <_description>MacBook/MacBook Pro (Intl)</_description> + <vendor>Apple</vendor> + </configItem> + </model> + <model> + <configItem> + <name>macintosh</name> + <_description>Macintosh</_description> + <vendor>Apple</vendor> + </configItem> + </model> + <model> + <configItem> + <name>macintosh_old</name> + <_description>Macintosh Old</_description> + <vendor>Apple</vendor> + </configItem> + </model> + <model> + <configItem> + <name>macintosh_hhk</name> + <_description>Happy Hacking Keyboard for Mac</_description> + <vendor>Fujitsu</vendor> + </configItem> + </model> + <model> + <configItem> + <name>acer_c300</name> + <_description>Acer C300</_description> + <vendor>Acer</vendor> + </configItem> + </model> + <model> + <configItem> + <name>acer_ferrari4k</name> + <_description>Acer Ferrari 4000</_description> + <vendor>Acer</vendor> + </configItem> + </model> + <model> + <configItem> + <name>acer_laptop</name> + <_description>Acer Laptop</_description> + <vendor>Acer</vendor> + </configItem> + </model> + <model> + <configItem> + <name>asus_laptop</name> + <_description>Asus Laptop</_description> + <vendor>Asus</vendor> + </configItem> + </model> + <model> + <configItem> + <name>apple</name> + <_description>Apple</_description> + <vendor>Apple</vendor> + </configItem> + </model> + <model> + <configItem> + <name>apple_laptop</name> + <_description>Apple Laptop</_description> + <vendor>Apple</vendor> + </configItem> + </model> + <model> + <configItem> + <name>applealu_ansi</name> + <_description>Apple Aluminium Keyboard (ANSI)</_description> + <vendor>Apple</vendor> + </configItem> + </model> + <model> + <configItem> + <name>applealu_iso</name> + <_description>Apple Aluminium Keyboard (ISO)</_description> + <vendor>Apple</vendor> + </configItem> + </model> + <model> + <configItem> + <name>applealu_jis</name> + <_description>Apple Aluminium Keyboard (JIS)</_description> + <vendor>Apple</vendor> + </configItem> + </model> + <model> + <configItem> + <name>silvercrest</name> + <_description>SILVERCREST Multimedia Wireless Keyboard</_description> + <vendor>Silvercrest</vendor> + </configItem> + </model> + <model> + <configItem> + <name>emachines</name> + <_description>Laptop/notebook eMachines m68xx</_description> + <vendor>eMachines</vendor> + </configItem> + </model> + <model> + <configItem> + <name>benqx</name> + <_description>BenQ X-Touch</_description> + <vendor>BenQ</vendor> + </configItem> + </model> + <model> + <configItem> + <name>benqx730</name> + <_description>BenQ X-Touch 730</_description> + <vendor>BenQ</vendor> + </configItem> + </model> + <model> + <configItem> + <name>benqx800</name> + <_description>BenQ X-Touch 800</_description> + <vendor>BenQ</vendor> + </configItem> + </model> + <model> + <configItem> + <name>hhk</name> + <_description>Happy Hacking Keyboard</_description> + <vendor>Fujitsu</vendor> + </configItem> + </model> + <model> + <configItem> + <name>classmate</name> + <_description>Classmate PC</_description> + <vendor>Intel</vendor> + </configItem> + </model> + <model> + <configItem> + <name>olpc</name> + <_description>OLPC</_description> + <vendor>OLPC</vendor> + </configItem> + </model> + <model> + <configItem> + <name>sun6</name> + <_description>Sun Type 5/6</_description> + <vendor>Sun Microsystems</vendor> + </configItem> + </model> + <model> + <configItem> + <name>targa_v811</name> + <_description>Targa Visionary 811</_description> + <vendor>Targa</vendor> + </configItem> + </model> + <model> + <configItem> + <name>unitekkb1925</name> + <_description>Unitek KB-1925</_description> + <vendor>Unitek Group</vendor> + </configItem> + </model> + <model> + <configItem> + <name>compalfl90</name> + <_description>FL90</_description> + <vendor>Compal Electronics Inc.</vendor> + </configItem> + </model> + <model> + <configItem> + <name>creativedw7000</name> + <_description>Creative Desktop Wireless 7000</_description> + <vendor>Creative</vendor> + </configItem> + </model> + <model> + <configItem> + <name>htcdream</name> + <_description>Htc Dream phone</_description> + <vendor>htc</vendor> + </configItem> + </model> + </modelList> + <layoutList> + <layout> + <configItem> + <name>us</name> + <_shortDescription>USA</_shortDescription> + <_description>USA</_description> + <languageList><iso639Id>eng</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>chr</name> + <_description>Cherokee</_description> + <languageList><iso639Id>chr</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>euro</name> + <_description>With EuroSign on 5</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>intl</name> + <_description>International (with dead keys)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>alt-intl</name> + <_description>Alternative international</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>colemak</name> + <_description>Colemak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak-intl</name> + <_description>Dvorak international (with dead keys)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak-alt-intl</name> + <_description>Dvorak alternative international (no dead keys)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak-l</name> + <_description>Left handed Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak-r</name> + <_description>Right handed Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak-classic</name> + <_description>Classic Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvp</name> + <_description>Programmer Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>rus</name> + <_description>Russian phonetic</_description> + <languageList><iso639Id>rus</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>altgr-intl</name> + <_description>International (AltGr dead keys)</_description> + <languageList><iso639Id>eng</iso639Id> + <iso639Id>fra</iso639Id> + <iso639Id>ger</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>olpc2</name> + <_description>Layout toggle on multiply/divide key</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>hbs</name> + <_description>Serbo-Croatian</_description> + <languageList><iso639Id>eng</iso639Id> + <iso639Id>bos</iso639Id> + <iso639Id>hbs</iso639Id> + <iso639Id>hrv</iso639Id> + <iso639Id>srp</iso639Id> </languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>ad</name> + <_shortDescription>And</_shortDescription> + <_description>Andorra</_description> + <languageList><iso639Id>cat</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>af</name> + <_shortDescription>Afg</_shortDescription> + <_description>Afghanistan</_description> + </configItem> + <variantList> + <variant> + <configItem> + <name>ps</name> + <_description>Pashto</_description> + <languageList><iso639Id>pus</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>uz</name> + <_description>Southern Uzbek</_description> + <languageList><iso639Id>uzb</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>olpc-ps</name> + <_description>OLPC Pashto</_description> + <languageList><iso639Id>pus</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>olpc-fa</name> + <_description>OLPC Dari</_description> + <!-- No ISO code in ISO639-2, only draft ISO693-3 --> + </configItem> + </variant> + <variant> + <configItem> + <name>olpc-uz</name> + <_description>OLPC Southern Uzbek</_description> + <languageList><iso639Id>uzb</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>ara</name> + <_shortDescription>Ara</_shortDescription> + <_description>Arabic</_description> + <countryList> + <iso3166Id>AE</iso3166Id> + <iso3166Id>BH</iso3166Id> + <iso3166Id>DZ</iso3166Id> + <iso3166Id>EG</iso3166Id> + <iso3166Id>EH</iso3166Id> + <iso3166Id>JO</iso3166Id> + <iso3166Id>KW</iso3166Id> + <iso3166Id>LB</iso3166Id> + <iso3166Id>LY</iso3166Id> + <iso3166Id>MA</iso3166Id> + <iso3166Id>MR</iso3166Id> + <iso3166Id>OM</iso3166Id> + <iso3166Id>PS</iso3166Id> + <iso3166Id>QA</iso3166Id> + <iso3166Id>SA</iso3166Id> + <iso3166Id>SD</iso3166Id> + <iso3166Id>SY</iso3166Id> + <iso3166Id>TN</iso3166Id> + <iso3166Id>YE</iso3166Id> + </countryList> + <languageList><iso639Id>ara</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>azerty</name> + <_description>azerty</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>azerty_digits</name> + <_description>azerty/digits</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>digits</name> + <_description>digits</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>qwerty</name> + <_description>qwerty</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>qwerty_digits</name> + <_description>qwerty/digits</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>buckwalter</name> + <_description>Buckwalter</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>al</name> + <_shortDescription>Alb</_shortDescription> + <_description>Albania</_description> + <languageList><iso639Id>alb</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>am</name> + <_shortDescription>Arm</_shortDescription> + <_description>Armenia</_description> + <languageList><iso639Id>hye</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>phonetic</name> + <_description>Phonetic</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>phonetic-alt</name> + <_description>Alternative Phonetic</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>eastern</name> + <_description>Eastern</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>western</name> + <_description>Western</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>eastern-alt</name> + <_description>Alternative Eastern</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>at</name> + <_shortDescription>Aut</_shortDescription> + <_description>Austria</_description> + <languageList><iso639Id>ger</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>sundeadkeys</name> + <_description>Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>az</name> + <_shortDescription>Aze</_shortDescription> + <_description>Azerbaijan</_description> + <languageList><iso639Id>aze</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>cyrillic</name> + <_description>Cyrillic</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>by</name> + <_shortDescription>Blr</_shortDescription> + <_description>Belarus</_description> + <languageList><iso639Id>bel</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>legacy</name> + <_description>Legacy</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latin</name> + <_description>Latin</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>be</name> + <_shortDescription>Bel</_shortDescription> + <_description>Belgium</_description> + <languageList><iso639Id>ger</iso639Id> + <iso639Id>nld</iso639Id> + <iso639Id>fra</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>oss</name> + <_description>Alternative</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>oss_latin9</name> + <_description>Alternative, latin-9 only</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>oss_sundeadkeys</name> + <_description>Alternative, Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>iso-alternate</name> + <_description>ISO Alternate</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>sundeadkeys</name> + <_description>Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>wang</name> + <_description>Wang model 724 azerty</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>bd</name> + <_shortDescription>Bgd</_shortDescription> + <_description>Bangladesh</_description> + <languageList><iso639Id>ben</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>probhat</name> + <_description>Probhat</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>in</name> + <_shortDescription>Ind</_shortDescription> + <_description>India</_description> + </configItem> + <variantList> + <variant> + <configItem> + <name>ben</name> + <_description>Bengali</_description> + <languageList><iso639Id>ben</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ben_probhat</name> + <_description>Bengali Probhat</_description> + <languageList><iso639Id>ben</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>guj</name> + <_description>Gujarati</_description> + <languageList><iso639Id>guj</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>guru</name> + <_description>Gurmukhi</_description> + <languageList><iso639Id>pan</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>jhelum</name> + <_description>Gurmukhi Jhelum</_description> + <languageList><iso639Id>pan</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>kan</name> + <_description>Kannada</_description> + <languageList><iso639Id>kan</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>mal</name> + <_description>Malayalam</_description> + <languageList><iso639Id>mal</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>mal_lalitha</name> + <_description>Malayalam Lalitha</_description> + <languageList><iso639Id>mal</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ori</name> + <_description>Oriya</_description> + <languageList><iso639Id>ori</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tam_unicode</name> + <_description>Tamil Unicode</_description> + <languageList><iso639Id>tam</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tam_keyboard_with_numerals</name> + <_description>Tamil Keyboard with Numerals</_description> + <languageList><iso639Id>tam</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tam_TAB</name> + <_description>Tamil TAB Typewriter</_description> + <languageList><iso639Id>tam</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tam_TSCII</name> + <_description>Tamil TSCII Typewriter</_description> + <languageList><iso639Id>tam</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tam</name> + <_description>Tamil</_description> + <languageList><iso639Id>tam</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tel</name> + <_description>Telugu</_description> + <languageList><iso639Id>tel</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>urd-phonetic</name> + <_description>Urdu, Phonetic</_description> + <languageList><iso639Id>urd</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>urd-phonetic3</name> + <_description>Urdu, Alternative phonetic</_description> + <languageList><iso639Id>urd</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>urd-winkeys</name> + <_description>Urdu, Winkeys</_description> + <languageList><iso639Id>urd</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>bolnagri</name> + <_description>Hindi Bolnagri</_description> + <languageList><iso639Id>hin</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>hin-wx</name> + <_description>Hindi Wx</_description> + <languageList><iso639Id>hin</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>eng</name> + <_description>English with RupeeSign</_description> + <languageList><iso639Id>eng</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>ba</name> + <_shortDescription>Bih</_shortDescription> + <_description>Bosnia and Herzegovina</_description> + <languageList><iso639Id>bos</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>alternatequotes</name> + <_description> Use guillemets for quotes</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>unicode</name> + <_description>Use Bosnian digraphs</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>unicodeus</name> + <_description>US keyboard with Bosnian digraphs</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>us</name> + <_description>US keyboard with Bosnian letters</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>br</name> + <_shortDescription>Bra</_shortDescription> + <_description>Brazil</_description> + <languageList><iso639Id>por</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nativo</name> + <_description>Nativo</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nativo-us</name> + <_description>Nativo for USA keyboards</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nativo-epo</name> + <_description>Nativo for Esperanto</_description> + <languageList><iso639Id>epo</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>bg</name> + <_shortDescription>Bgr</_shortDescription> + <_description>Bulgaria</_description> + <languageList><iso639Id>bul</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>phonetic</name> + <_description>Traditional phonetic</_description> + </configItem> + </variant> + </variantList> + <variantList> + <variant> + <configItem> + <name>bas_phonetic</name> + <_description>New phonetic</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>ma</name> + <_description>Morocco</_description> + </configItem> + <variantList> + <variant> + <configItem> + <name>french</name> + <_description>French</_description> + <languageList><iso639Id>fra</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tifinagh</name> + <_description>Tifinagh</_description> + <languageList><iso639Id>ber</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tifinagh-alt</name> + <_description>Tifinagh alternative</_description> + <languageList><iso639Id>ber</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tifinagh-alt-phonetic</name> + <_description>Tifinagh alternative phonetic</_description> + <languageList><iso639Id>ber</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tifinagh-extended</name> + <_description>Tifinagh extended</_description> + <languageList><iso639Id>ber</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tifinagh-phonetic</name> + <_description>Tifinagh phonetic</_description> + <languageList><iso639Id>ber</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tifinagh-extended-phonetic</name> + <_description>Tifinagh extended phonetic</_description> + <languageList><iso639Id>ber</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>mm</name> + <_shortDescription>Mmr</_shortDescription> + <_description>Myanmar</_description> + <languageList><iso639Id>mya</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>ca</name> + <_shortDescription>Can</_shortDescription> + <_description>Canada</_description> + <languageList><iso639Id>fra</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>fr-dvorak</name> + <_description>French Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>fr-legacy</name> + <_description>French (legacy)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>multix</name> + <_description>Multilingual</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>multi</name> + <_description>Multilingual, first part</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>multi-2gr</name> + <_description>Multilingual, second part</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ike</name> + <_description>Inuktitut</_description> + <languageList><iso639Id>iku</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>shs</name> + <_description>Secwepemctsin</_description> + <!-- No ISO code in ISO639-2, only draft ISO693-3 --> + </configItem> + </variant> + <variant> + <configItem> + <name>kut</name> + <_description>Ktunaxa</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>eng</name> + <_description>English</_description> + <languageList><iso639Id>eng</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>cd</name> + <_shortDescription>COD</_shortDescription> + <_description>Congo, Democratic Republic of the</_description> + <languageList><iso639Id>fra</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>cn</name> + <_shortDescription>Chn</_shortDescription> + <_description>China</_description> + <languageList><iso639Id>chi</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>tib</name> + <_description>Tibetan</_description> + <languageList><iso639Id>tib</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tib_asciinum</name> + <_description>Tibetan (with ASCII numerals)</_description> + <languageList><iso639Id>tib</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>hr</name> + <_shortDescription>Hrv</_shortDescription> + <_description>Croatia</_description> + <languageList><iso639Id>scr</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>alternatequotes</name> + <_description>Use guillemets for quotes</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>unicode</name> + <_description>Use Croatian digraphs</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>unicodeus</name> + <_description>US keyboard with Croatian digraphs</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>us</name> + <_description>US keyboard with Croatian letters</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>cz</name> + <_shortDescription>Cze</_shortDescription> + <_description>Czechia</_description> + <languageList><iso639Id>cze</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>bksl</name> + <_description>With <\|> key</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>qwerty</name> + <_description>qwerty</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>qwerty_bksl</name> + <_description>qwerty, extended Backslash</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ucw</name> + <_description>UCW layout (accented letters only)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak-ucw</name> + <_description>US Dvorak with CZ UCW support</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>dk</name> + <_shortDescription>Dnk</_shortDescription> + <_description>Denmark</_description> + <languageList><iso639Id>dan</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac_nodeadkeys</name> + <_description>Macintosh, eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>nl</name> + <_shortDescription>Nld</_shortDescription> + <_description>Netherlands</_description> + <languageList><iso639Id>nld</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>sundeadkeys</name> + <_description>Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>std</name> + <_description>Standard</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>bt</name> + <_shortDescription>Btn</_shortDescription> + <_description>Bhutan</_description> + <languageList><iso639Id>dzo</iso639Id></languageList> + </configItem> + </layout> + <layout> + <configItem> + <name>ee</name> + <_shortDescription>Est</_shortDescription> + <_description>Estonia</_description> + <languageList><iso639Id>est</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>us</name> + <_description>US keyboard with Estonian letters</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>ir</name> + <_shortDescription>Irn</_shortDescription> + <_description>Iran</_description> + <languageList><iso639Id>per</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>pes_keypad</name> + <_description>Persian, with Persian Keypad</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ku</name> + <_description>Kurdish, Latin Q</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ku_f</name> + <_description>Kurdish, (F)</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ku_alt</name> + <_description>Kurdish, Latin Alt-Q</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ku_ara</name> + <_description>Kurdish, Arabic-Latin</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>iq</name> + <_shortDescription>Irq</_shortDescription> + <_description>Iraq</_description> + <languageList><iso639Id>ara</iso639Id> + <iso639Id>kur</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>ku</name> + <_description>Kurdish, Latin Q</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ku_f</name> + <_description>Kurdish, (F)</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ku_alt</name> + <_description>Kurdish, Latin Alt-Q</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ku_ara</name> + <_description>Kurdish, Arabic-Latin</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>fo</name> + <_shortDescription>Fro</_shortDescription> + <_description>Faroe Islands</_description> + <languageList><iso639Id>fao</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>fi</name> + <_shortDescription>Fin</_shortDescription> + <_description>Finland</_description> + <languageList><iso639Id>fin</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>classic</name> + <_description>Classic</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Classic, eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>smi</name> + <_description>Northern Saami</_description> + <languageList><iso639Id>smi</iso639Id> + <iso639Id>sme</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>fr</name> + <_shortDescription>Fra</_shortDescription> + <_description>France</_description> + <languageList><iso639Id>fra</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>sundeadkeys</name> + <_description>Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>oss</name> + <_description>Alternative</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>oss_latin9</name> + <_description>Alternative, latin-9 only</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>oss_nodeadkeys</name> + <_description>Alternative, eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>oss_sundeadkeys</name> + <_description>Alternative, Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latin9</name> + <_description>(Legacy) Alternative</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latin9_nodeadkeys</name> + <_description>(Legacy) Alternative, eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latin9_sundeadkeys</name> + <_description>(Legacy) Alternative, Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>bepo</name> + <_description>Bepo, ergonomic, Dvorak way</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>bepo_latin9</name> + <_description>Bepo, ergonomic, Dvorak way, latin-9 only</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>bre</name> + <_description>Breton</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>oci</name> + <_description>Occitan</_description> + <languageList><iso639Id>oci</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>geo</name> + <_description>Georgian AZERTY Tskapo</_description> + <languageList><iso639Id>geo</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>gh</name> + <_shortDescription>Gha</_shortDescription> + <_description>Ghana</_description> + <languageList><iso639Id>eng</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>generic</name> + <_description>Multilingual</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>akan</name> + <_description>Akan</_description> + <languageList><iso639Id>aka</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ewe</name> + <_description>Ewe</_description> + <languageList><iso639Id>ewe</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>fula</name> + <_description>Fula</_description> + <languageList><iso639Id>ful</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ga</name> + <_description>Ga</_description> + <languageList><iso639Id>gaa</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>hausa</name> + <_description>Hausa</_description> + <languageList><iso639Id>hau</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>avn</name> + <_description>Avatime</_description> + <languageList><iso639Id>avn</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>gillbt</name> + <_description>GILLBT</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>gn</name> + <_shortDescription>Gin</_shortDescription> + <_description>Guinea</_description> + <languageList><iso639Id>fra</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>ge</name> + <_shortDescription>Geo</_shortDescription> + <_description>Georgia</_description> + <languageList><iso639Id>geo</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>ergonomic</name> + <_description>Ergonomic</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mess</name> + <_description>MESS</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ru</name> + <_description>Russian</_description> + <languageList><iso639Id>rus</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>os</name> + <_description>Ossetian</_description> + <languageList><iso639Id>oss</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>de</name> + <_shortDescription>Deu</_shortDescription> + <_description>Germany</_description> + <languageList><iso639Id>ger</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>deadacute</name> + <_description>Dead acute</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>deadgraveacute</name> + <_description>Dead grave acute</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ro</name> + <_description>Romanian keyboard with German letters</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ro_nodeadkeys</name> + <_description>Romanian keyboard with German letters, eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>sundeadkeys</name> + <_description>Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>neo</name> + <_description>Neo 2</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac_nodeadkeys</name> + <_description>Macintosh, eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dsb</name> + <_description>Lower Sorbian</_description> + <languageList><iso639Id>dsb</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>dsb_qwertz</name> + <_description>Lower Sorbian (qwertz)</_description> + <languageList><iso639Id>dsb</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>qwerty</name> + <_description>qwerty</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ru</name> + <_description>Russian phonetic</_description> + <languageList><iso639Id>rus</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>gr</name> + <_shortDescription>Grc</_shortDescription> + <_description>Greece</_description> + <languageList><iso639Id>gre</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>simple</name> + <_description>Simple</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>extended</name> + <_description>Extended</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>polytonic</name> + <_description>Polytonic</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>hu</name> + <_shortDescription>Hun</_shortDescription> + <_description>Hungary</_description> + <languageList><iso639Id>hun</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>standard</name> + <_description>Standard</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>qwerty</name> + <_description>qwerty</_description> + </configItem> + </variant> + + <!-- 101 keys --> + <variant> + <configItem> + <name>101_qwertz_comma_dead</name> + <_description>101/qwertz/comma/Dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>101_qwertz_comma_nodead</name> + <_description>101/qwertz/comma/Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>101_qwertz_dot_dead</name> + <_description>101/qwertz/dot/Dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>101_qwertz_dot_nodead</name> + <_description>101/qwertz/dot/Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>101_qwerty_comma_dead</name> + <_description>101/qwerty/comma/Dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>101_qwerty_comma_nodead</name> + <_description>101/qwerty/comma/Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>101_qwerty_dot_dead</name> + <_description>101/qwerty/dot/Dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>101_qwerty_dot_nodead</name> + <_description>101/qwerty/dot/Eliminate dead keys</_description> + </configItem> + </variant> + + + <!-- 102 keys --> + <variant> + <configItem> + <name>102_qwertz_comma_dead</name> + <_description>102/qwertz/comma/Dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>102_qwertz_comma_nodead</name> + <_description>102/qwertz/comma/Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>102_qwertz_dot_dead</name> + <_description>102/qwertz/dot/Dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>102_qwertz_dot_nodead</name> + <_description>102/qwertz/dot/Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>102_qwerty_comma_dead</name> + <_description>102/qwerty/comma/Dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>102_qwerty_comma_nodead</name> + <_description>102/qwerty/comma/Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>102_qwerty_dot_dead</name> + <_description>102/qwerty/dot/Dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>102_qwerty_dot_nodead</name> + <_description>102/qwerty/dot/Eliminate dead keys</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>is</name> + <_shortDescription>Isl</_shortDescription> + <_description>Iceland</_description> + <languageList><iso639Id>ice</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>Sundeadkeys</name> + <_description>Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>il</name> + <_shortDescription>Isr</_shortDescription> + <_description>Israel</_description> + <languageList><iso639Id>heb</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>lyx</name> + <_description>lyx</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>phonetic</name> + <_description>Phonetic</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>biblical</name> + <_description>Biblical Hebrew (Tiro)</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>it</name> + <_shortDescription>Ita</_shortDescription> + <_description>Italy</_description> + <languageList><iso639Id>ita</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>us</name> + <_description>US keyboard with Italian letters</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>geo</name> + <_description>Georgian</_description> + <languageList><iso639Id>geo</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>jp</name> + <_shortDescription>Jpn</_shortDescription> + <_description>Japan</_description> + <languageList><iso639Id>jpn</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>kana</name> + <_description>Kana</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>kana86</name> + <_description>Kana 86</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>OADG109A</name> + <_description>OADG 109A</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>kg</name> + <_shortDescription>Kgz</_shortDescription> + <_description>Kyrgyzstan</_description> + <languageList><iso639Id>kir</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>phonetic</name> + <_description>Phonetic</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>kh</name> + <_shortDescription>Khm</_shortDescription> + <_description>Cambodia</_description> + <languageList><iso639Id>khm</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>kz</name> + <_shortDescription>Kaz</_shortDescription> + <_description>Kazakhstan</_description> + <languageList><iso639Id>kaz</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>ruskaz</name> + <_description>Russian with Kazakh</_description> + <languageList><iso639Id>kaz</iso639Id> + <iso639Id>rus</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>kazrus</name> + <_description>Kazakh with Russian</_description> + <languageList><iso639Id>kaz</iso639Id> + <iso639Id>rus</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>la</name> + <_shortDescription>Lao</_shortDescription> + <_description>Laos</_description> + <languageList><iso639Id>lao</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>latam</name> + <_shortDescription>LAm</_shortDescription> + <_description>Latin American</_description> + <countryList> + <iso3166Id>AR</iso3166Id> + <iso3166Id>BO</iso3166Id> + <iso3166Id>CL</iso3166Id> + <iso3166Id>CO</iso3166Id> + <iso3166Id>CR</iso3166Id> + <iso3166Id>CU</iso3166Id> + <iso3166Id>DO</iso3166Id> + <iso3166Id>EC</iso3166Id> + <iso3166Id>GT</iso3166Id> + <iso3166Id>HN</iso3166Id> + <iso3166Id>HT</iso3166Id> + <iso3166Id>MX</iso3166Id> + <iso3166Id>NI</iso3166Id> + <iso3166Id>PA</iso3166Id> + <iso3166Id>PE</iso3166Id> + <iso3166Id>PR</iso3166Id> + <iso3166Id>PY</iso3166Id> + <iso3166Id>SV</iso3166Id> + <iso3166Id>US</iso3166Id> + <iso3166Id>UY</iso3166Id> + <iso3166Id>VE</iso3166Id> + </countryList> + <languageList><iso639Id>spa</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>deadtilde</name> + <_description>Include dead tilde</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>sundeadkeys</name> + <_description>Sun dead keys</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>lt</name> + <_shortDescription>Ltu</_shortDescription> + <_description>Lithuania</_description> + <languageList><iso639Id>lit</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>std</name> + <_description>Standard</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>us</name> + <_description>US keyboard with Lithuanian letters</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ibm</name> + <_description>IBM (LST 1205-92)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>lekp</name> + <_description>LEKP</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>lekpa</name> + <_description>LEKPa</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>lv</name> + <_shortDescription>Lva</_shortDescription> + <_description>Latvia</_description> + <languageList><iso639Id>lav</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>apostrophe</name> + <_description>Apostrophe (') variant</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>tilde</name> + <_description>Tilde (~) variant</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>fkey</name> + <_description>F-letter (F) variant</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>mao</name> + <_shortDescription>Mao</_shortDescription> + <_description>Maori</_description> + <languageList><iso639Id>mao</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>me</name> + <_shortDescription>MNE</_shortDescription> + <_description>Montenegro</_description> + <languageList><iso639Id>srp</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>cyrillic</name> + <_description>Cyrillic</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>cyrillicyz</name> + <_description>Cyrillic, Z and ZHE swapped</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latinunicode</name> + <_description>Latin unicode</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latinyz</name> + <_description>Latin qwerty</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latinunicodeyz</name> + <_description>Latin unicode qwerty</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>cyrillicalternatequotes</name> + <_description>Cyrillic with guillemets</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latinalternatequotes</name> + <_description>Latin with guillemets</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>mk</name> + <_shortDescription>Mkd</_shortDescription> + <_description>Macedonia</_description> + <languageList><iso639Id>mkd</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>mt</name> + <_shortDescription>Mlt</_shortDescription> + <_description>Malta</_description> + <languageList><iso639Id>mlt</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>us</name> + <_description>Maltese keyboard with US layout</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>mn</name> + <_shortDescription>Mng</_shortDescription> + <_description>Mongolia</_description> + <languageList><iso639Id>mng</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>no</name> + <_shortDescription>Nor</_shortDescription> + <_description>Norway</_description> + <languageList><iso639Id>nor</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>smi</name> + <_description>Northern Saami</_description> + <languageList><iso639Id>sme</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>smi_nodeadkeys</name> + <_description>Northern Saami, eliminate dead keys</_description> + <languageList><iso639Id>sme</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac_nodeadkeys</name> + <_description>Macintosh, eliminate dead keys</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>pl</name> + <_shortDescription>Pol</_shortDescription> + <_description>Poland</_description> + <languageList><iso639Id>pol</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>qwertz</name> + <_description>qwertz</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak_quotes</name> + <_description>Dvorak, Polish quotes on quotemark key</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak_altquotes</name> + <_description>Dvorak, Polish quotes on key 1</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>csb</name> + <_description>Kashubian</_description> + <languageList><iso639Id>csb</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ru_phonetic_dvorak</name> + <_description>Russian phonetic Dvorak</_description> + <languageList><iso639Id>rus</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>dvp</name> + <_description>Programmer Dvorak</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>pt</name> + <_shortDescription>Prt</_shortDescription> + <_description>Portugal</_description> + <languageList><iso639Id>por</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>sundeadkeys</name> + <_description>Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac_nodeadkeys</name> + <_description>Macintosh, eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac_sundeadkeys</name> + <_description>Macintosh, Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nativo</name> + <_description>Nativo</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nativo-us</name> + <_description>Nativo for USA keyboards</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>nativo-epo</name> + <_description>Nativo for Esperanto</_description> + <languageList><iso639Id>epo</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>ro</name> + <_shortDescription>Rou</_shortDescription> + <_description>Romania</_description> + <languageList><iso639Id>rum</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>cedilla</name> + <_description>Cedilla</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>std</name> + <_description>Standard</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>std_cedilla</name> + <_description>Standard (Cedilla)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>winkeys</name> + <_description>Winkeys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>crh_f</name> + <_description>Crimean Tatar (Turkish F)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>crh_alt</name> + <_description>Crimean Tatar (Turkish Alt-Q)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>crh_dobruca1</name> + <_description>Crimean Tatar (Dobruca-1 Q)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>crh_dobruca2</name> + <_description>Crimean Tatar (Dobruca-2 Q)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>ru</name> + <_shortDescription>Rus</_shortDescription> + <_description>Russia</_description> + <languageList><iso639Id>rus</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>phonetic</name> + <_description>Phonetic</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>phonetic_winkeys</name> + <_description>Phonetic Winkeys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>typewriter</name> + <_description>Typewriter</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>legacy</name> + <_description>Legacy</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>typewriter-legacy</name> + <_description>Typewriter, legacy</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>tt</name> + <_description>Tatar</_description> + <languageList><iso639Id>tat</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>os_legacy</name> + <_description>Ossetian, legacy</_description> + <languageList><iso639Id>oss</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>os_winkeys</name> + <_description>Ossetian, Winkeys</_description> + <languageList><iso639Id>oss</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>cv</name> + <_description>Chuvash</_description> + <languageList><iso639Id>chv</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>cv_latin</name> + <_description>Chuvash Latin</_description> + <languageList><iso639Id>chv</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>udm</name> + <_description>Udmurt</_description> + <languageList><iso639Id>udm</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>kom</name> + <_description>Komi</_description> + <languageList><iso639Id>kom</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>sah</name> + <_description>Yakut</_description> + <languageList><iso639Id>sah</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>xal</name> + <_description>Kalmyk</_description> + <languageList><iso639Id>xal</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>dos</name> + <_description>DOS</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>srp</name> + <_description>Serbian</_description> + <languageList><iso639Id>rus</iso639Id> + <iso639Id>srp</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>bak</name> + <_description>Bashkirian</_description> + <languageList><iso639Id>bak</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>chm</name> + <_description>Mari</_description> + <languageList><iso639Id>chm</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>rs</name> + <_shortDescription>SRB</_shortDescription> + <_description>Serbia</_description> + <languageList><iso639Id>srp</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>yz</name> + <_description>Z and ZHE swapped</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latin</name> + <_description>Latin</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latinunicode</name> + <_description>Latin Unicode</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latinyz</name> + <_description>Latin qwerty</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latinunicodeyz</name> + <_description>Latin Unicode qwerty</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>alternatequotes</name> + <_description>With guillemets</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>latinalternatequotes</name> + <_description>Latin with guillemets</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>rue</name> + <_description>Pannonian Rusyn Homophonic</_description> + <languageList><iso639Id>rue</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>si</name> + <_shortDescription>Svn</_shortDescription> + <_description>Slovenia</_description> + <languageList><iso639Id>slv</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>alternatequotes</name> + <_description>Use guillemets for quotes</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>us</name> + <_description>US keyboard with Slovenian letters</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>sk</name> + <_shortDescription>Svk</_shortDescription> + <_description>Slovakia</_description> + <languageList><iso639Id>slo</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>bksl</name> + <_description>Extended Backslash</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>qwerty</name> + <_description>qwerty</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>qwerty_bksl</name> + <_description>qwerty, extended Backslash</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>es</name> + <_shortDescription>Esp</_shortDescription> + <_description>Spain</_description> + <languageList><iso639Id>spa</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>deadtilde</name> + <_description>Include dead tilde</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>sundeadkeys</name> + <_description>Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ast</name> + <_description>Asturian variant with bottom-dot H and bottom-dot L</_description> + <languageList><iso639Id>ast</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>cat</name> + <_description>Catalan variant with middle-dot L</_description> + <languageList><iso639Id>cat</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>se</name> + <_shortDescription>Swe</_shortDescription> + <_description>Sweden</_description> + <languageList><iso639Id>swe</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>nodeadkeys</name> + <_description>Eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>rus</name> + <_description>Russian phonetic</_description> + <languageList><iso639Id>rus</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>rus_nodeadkeys</name> + <_description>Russian phonetic, eliminate dead keys</_description> + <languageList><iso639Id>rus</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>smi</name> + <_description>Northern Saami</_description> + <languageList><iso639Id>sme</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>svdvorak</name> + <_description>Svdvorak</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>ch</name> + <_shortDescription>Che</_shortDescription> + <_description>Switzerland</_description> + <languageList><iso639Id>ger</iso639Id> + <iso639Id>gsw</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>legacy</name> + <_description>Legacy</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>de_nodeadkeys</name> + <_description>German, eliminate dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>de_sundeadkeys</name> + <_description>German, Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>fr</name> + <_description>French</_description> + <languageList><iso639Id>fra</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>fr_nodeadkeys</name> + <_description>French, eliminate dead keys</_description> + <languageList><iso639Id>fra</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>fr_sundeadkeys</name> + <_description>French, Sun dead keys</_description> + <languageList><iso639Id>fra</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>fr_mac</name> + <_description>French (Macintosh)</_description> + <languageList><iso639Id>fra</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>de_mac</name> + <_description>German (Macintosh)</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>sy</name> + <_shortDescription>Syr</_shortDescription> + <_description>Syria</_description> + <languageList><iso639Id>syr</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>syc</name> + <_description>Syriac</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>syc_phonetic</name> + <_description>Syriac phonetic</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ku</name> + <_description>Kurdish, Latin Q</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ku_f</name> + <_description>Kurdish, (F)</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ku_alt</name> + <_description>Kurdish, Latin Alt-Q</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>tj</name> + <_shortDescription>Tjk</_shortDescription> + <_description>Tajikistan</_description> + <languageList><iso639Id>tgk</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>legacy</name> + <_description>Legacy</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>lk</name> + <_shortDescription>Lka</_shortDescription> + <_description>Sri Lanka</_description> + <languageList><iso639Id>sin</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>tam_unicode</name> + <_description>Tamil Unicode</_description> + <languageList><iso639Id>tam</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>tam_TAB</name> + <_description>Tamil TAB Typewriter</_description> + <languageList><iso639Id>tam</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>th</name> + <_shortDescription>Tha</_shortDescription> + <_description>Thailand</_description> + <languageList><iso639Id>tha</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>tis</name> + <_description>TIS-820.2538</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>pat</name> + <_description>Pattachote</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>tr</name> + <_shortDescription>Tur</_shortDescription> + <_description>Turkey</_description> + <languageList><iso639Id>tur</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>f</name> + <_description>(F)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>alt</name> + <_description>Alt-Q</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>sundeadkeys</name> + <_description>Sun dead keys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ku</name> + <_description>Kurdish, Latin Q</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ku_f</name> + <_description>Kurdish, (F)</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ku_alt</name> + <_description>Kurdish, Latin Alt-Q</_description> + <languageList><iso639Id>kur</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>intl</name> + <_description>International (with dead keys)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>crh</name> + <_description>Crimean Tatar (Turkish Q)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>crh_f</name> + <_description>Crimean Tatar (Turkish F)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>crh_alt</name> + <_description>Crimean Tatar (Turkish Alt-Q)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>ua</name> + <_shortDescription>Ukr</_shortDescription> + <_description>Ukraine</_description> + <languageList><iso639Id>ukr</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>phonetic</name> + <_description>Phonetic</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>typewriter</name> + <_description>Typewriter</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>winkeys</name> + <_description>Winkeys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>legacy</name> + <_description>Legacy</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>rstu</name> +<!-- RSTU 2019-91 --> + <_description>Standard RSTU</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>rstu_ru</name> +<!-- RSTU 2019-91 --> + <_description>Standard RSTU on Russian layout</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>homophonic</name> + <_description>Homophonic</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>crh</name> + <_description>Crimean Tatar (Turkish Q)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>crh_f</name> + <_description>Crimean Tatar (Turkish F)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>crh_alt</name> + <_description>Crimean Tatar (Turkish Alt-Q)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>gb</name> + <_shortDescription>GBr</_shortDescription> + <_description>United Kingdom</_description> + <languageList><iso639Id>eng</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>extd</name> + <_description>Extended - Winkeys</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>intl</name> + <_description>International (with dead keys)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorakukp</name> + <_description>Dvorak (UK Punctuation)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac</name> + <_description>Macintosh</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>mac_intl</name> + <_description>Macintosh (International)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>colemak</name> + <_description>Colemak</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>uz</name> + <_shortDescription>Uzb</_shortDescription> + <_description>Uzbekistan</_description> + <languageList><iso639Id>uzb</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>latin</name> + <_description>Latin</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>crh</name> + <_description>Crimean Tatar (Turkish Q)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>crh_f</name> + <_description>Crimean Tatar (Turkish F)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>crh_alt</name> + <_description>Crimean Tatar (Turkish Alt-Q)</_description> + <languageList><iso639Id>crh</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>vn</name> + <_shortDescription>Vnm</_shortDescription> + <_description>Vietnam</_description> + <languageList><iso639Id>vie</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>kr</name> + <_shortDescription>Kor</_shortDescription> + <_description>Korea, Republic of</_description> + <languageList><iso639Id>kor</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>kr104</name> + <_description>101/104 key Compatible</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>nec_vndr/jp</name> + <_shortDescription>Jpn</_shortDescription> + <_description>Japan (PC-98xx Series)</_description> + <countryList><iso3166Id>JP</iso3166Id></countryList> + <languageList><iso639Id>jpn</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>ie</name> + <_shortDescription>Irl</_shortDescription> + <_description>Ireland</_description> + <languageList><iso639Id>eng</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>CloGaelach</name> + <_description>CloGaelach</_description> + <languageList><iso639Id>gla</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>UnicodeExpert</name> + <_description>UnicodeExpert</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>ogam</name> + <_description>Ogham</_description> + <!-- No ISO code in ISO639 --> + </configItem> + </variant> + <variant> + <configItem> + <name>ogam_is434</name> + <_description>Ogham IS434</_description> + <!-- No ISO code in ISO639 --> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>pk</name> + <_shortDescription>Pak</_shortDescription> + <_description>Pakistan</_description> + <languageList><iso639Id>urd</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>urd-crulp</name> + <_description>CRULP</_description> + <languageList><iso639Id>urd</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>urd-nla</name> + <_description>NLA</_description> + <languageList><iso639Id>urd</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>ara</name> + <_description>Arabic</_description> + <languageList><iso639Id>ara</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>snd</name> + <_description>Sindhi</_description> + <languageList><iso639Id>sd</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>mv</name> + <_shortDescription>Mdv</_shortDescription> + <_description>Maldives</_description> + <languageList><iso639Id>div</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>za</name> + <_shortDescription>Zaf</_shortDescription> + <_description>South Africa</_description> + <languageList><iso639Id>eng</iso639Id></languageList> + </configItem> + </layout> + <layout> + <configItem> + <name>epo</name> + <_shortDescription>Epo</_shortDescription> + <_description>Esperanto</_description> + <languageList><iso639Id>epo</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>legacy</name> + <_description>displaced semicolon and quote (obsolete)</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>np</name> + <_shortDescription>Npl</_shortDescription> + <_description>Nepal</_description> + <languageList><iso639Id>nep</iso639Id></languageList> + </configItem> + </layout> + <layout> + <configItem> + <name>ng</name> + <_shortDescription>Nga</_shortDescription> + <_description>Nigeria</_description> + <languageList><iso639Id>eng</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>igbo</name> + <_description>Igbo</_description> + <languageList><iso639Id>ibo</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>yoruba</name> + <_description>Yoruba</_description> + <languageList><iso639Id>yor</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>hausa</name> + <_description>Hausa</_description> + <languageList><iso639Id>hau</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>et</name> + <_shortDescription>Eth</_shortDescription> + <_description>Ethiopia</_description> + <languageList><iso639Id>amh</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>sn</name> + <_shortDescription>Sen</_shortDescription> + <_description>Senegal</_description> + <languageList><iso639Id>wol</iso639Id></languageList> + </configItem> + <variantList/> + </layout> + <layout> + <configItem> + <name>brai</name> + <_shortDescription>Brl</_shortDescription> + <_description>Braille</_description> + </configItem> + <variantList> + <variant> + <configItem> + <name>left_hand</name> + <_description>Left hand</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>right_hand</name> + <_description>Right hand</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>tm</name> + <_shortDescription>Tkm</_shortDescription> + <_description>Turkmenistan</_description> + <languageList><iso639Id>tuk</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>alt</name> + <_description>Alt-Q</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>ml</name> + <_shortDescription>Mli</_shortDescription> + <_description>Mali</_description> + <languageList><iso639Id>bam</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>fr-oss</name> + <_description>Français (France Alternative)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>us-mac</name> + <_description>English (USA Macintosh)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>us-intl</name> + <_description>English (USA International)</_description> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>tz</name> + <_shortDescription>Tza</_shortDescription> + <_description>Tanzania</_description> + <languageList><iso639Id>swa</iso639Id></languageList> + </configItem> + </layout> + <layout> + <configItem> + <name>ke</name> + <_shortDescription>Ken</_shortDescription> + <_description>Kenya</_description> + <languageList><iso639Id>swa</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>kik</name> + <_description>Kikuyu</_description> + <languageList><iso639Id>kik</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + <layout> + <configItem> + <name>bw</name> + <_shortDescription>Bwa</_shortDescription> + <_description>Botswana</_description> + <languageList><iso639Id>tsn</iso639Id></languageList> + </configItem> + </layout> + <layout> + <configItem> + <name>ph</name> + <_shortDescription>Phi</_shortDescription> + <_description>Philippines</_description> + <languageList><iso639Id>eng</iso639Id> + <iso639Id>bik</iso639Id> + <iso639Id>ceb</iso639Id> + <iso639Id>fil</iso639Id> + <iso639Id>hil</iso639Id> + <iso639Id>ilo</iso639Id> + <iso639Id>pam</iso639Id> + <iso639Id>pag</iso639Id> + <iso639Id>phi</iso639Id> + <iso639Id>tgl</iso639Id> + <iso639Id>war</iso639Id></languageList> + </configItem> + <variantList> + <variant> + <configItem> + <name>qwerty-bay</name> + <_description>QWERTY (Baybayin)</_description> + <languageList><iso639Id>bik</iso639Id> + <iso639Id>ceb</iso639Id> + <iso639Id>fil</iso639Id> + <iso639Id>hil</iso639Id> + <iso639Id>ilo</iso639Id> + <iso639Id>pam</iso639Id> + <iso639Id>pag</iso639Id> + <iso639Id>phi</iso639Id> + <iso639Id>tgl</iso639Id> + <iso639Id>war</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>capewell-dvorak</name> + <_description>Capewell-Dvorak (Latin)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>capewell-dvorak-bay</name> + <_description>Capewell-Dvorak (Baybayin)</_description> + <languageList><iso639Id>bik</iso639Id> + <iso639Id>ceb</iso639Id> + <iso639Id>fil</iso639Id> + <iso639Id>hil</iso639Id> + <iso639Id>ilo</iso639Id> + <iso639Id>pam</iso639Id> + <iso639Id>pag</iso639Id> + <iso639Id>phi</iso639Id> + <iso639Id>tgl</iso639Id> + <iso639Id>war</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>capewell-qwerf2k6</name> + <_description>Capewell-QWERF 2006 (Latin)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>capewell-qwerf2k6-bay</name> + <_description>Capewell-QWERF 2006 (Baybayin)</_description> + <languageList><iso639Id>bik</iso639Id> + <iso639Id>ceb</iso639Id> + <iso639Id>fil</iso639Id> + <iso639Id>hil</iso639Id> + <iso639Id>ilo</iso639Id> + <iso639Id>pam</iso639Id> + <iso639Id>pag</iso639Id> + <iso639Id>phi</iso639Id> + <iso639Id>tgl</iso639Id> + <iso639Id>war</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>colemak</name> + <_description>Colemak (Latin)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>colemak-bay</name> + <_description>Colemak (Baybayin)</_description> + <languageList><iso639Id>bik</iso639Id> + <iso639Id>ceb</iso639Id> + <iso639Id>fil</iso639Id> + <iso639Id>hil</iso639Id> + <iso639Id>ilo</iso639Id> + <iso639Id>pam</iso639Id> + <iso639Id>pag</iso639Id> + <iso639Id>phi</iso639Id> + <iso639Id>tgl</iso639Id> + <iso639Id>war</iso639Id></languageList> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak</name> + <_description>Dvorak (Latin)</_description> + </configItem> + </variant> + <variant> + <configItem> + <name>dvorak-bay</name> + <_description>Dvorak (Baybayin)</_description> + <languageList><iso639Id>bik</iso639Id> + <iso639Id>ceb</iso639Id> + <iso639Id>fil</iso639Id> + <iso639Id>hil</iso639Id> + <iso639Id>ilo</iso639Id> + <iso639Id>pam</iso639Id> + <iso639Id>pag</iso639Id> + <iso639Id>phi</iso639Id> + <iso639Id>tgl</iso639Id> + <iso639Id>war</iso639Id></languageList> + </configItem> + </variant> + </variantList> + </layout> + </layoutList> + <optionList> + <group allowMultipleSelection="true"> + <!-- The key combination used to switch between groups --> + <configItem> + <name>grp</name> + <_description>Key(s) to change layout</_description> + </configItem> + <option> + <configItem> + <name>grp:switch</name> + <_description>Right Alt (while pressed)</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:lswitch</name> + <_description>Left Alt (while pressed)</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:lwin_switch</name> + <_description>Left Win (while pressed)</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:rwin_switch</name> + <_description>Right Win (while pressed)</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:win_switch</name> + <_description>Any Win key (while pressed)</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:caps_switch</name> + <_description>Caps Lock (while pressed), Alt+Caps Lock does the original capslock action</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:rctrl_switch</name> + <_description>Right Ctrl (while pressed)</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:toggle</name> + <_description>Right Alt</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:lalt_toggle</name> + <_description>Left Alt</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:caps_toggle</name> + <_description>Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:shift_caps_toggle</name> + <_description>Shift+Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:shift_caps_switch</name> + <_description>Caps Lock (to first layout), Shift+Caps Lock (to last layout)</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:win_menu_switch</name> + <_description>Left Win (to first layout), Right Win/Menu (to last layout)</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:lctrl_rctrl_switch</name> + <_description>Left Ctrl (to first layout), Right Ctrl (to last layout)</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:alt_caps_toggle</name> + <_description>Alt+Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:shifts_toggle</name> + <_description>Both Shift keys together</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:alts_toggle</name> + <_description>Both Alt keys together</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:ctrls_toggle</name> + <_description>Both Ctrl keys together</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:ctrl_shift_toggle</name> + <_description>Ctrl+Shift</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:lctrl_lshift_toggle</name> + <_description>Left Ctrl+Left Shift</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:rctrl_rshift_toggle</name> + <_description>Right Ctrl+Right Shift</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:ctrl_alt_toggle</name> + <_description>Alt+Ctrl</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:alt_shift_toggle</name> + <_description>Alt+Shift</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:alt_space_toggle</name> + <_description>Alt+Space</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:menu_toggle</name> + <_description>Menu</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:lwin_toggle</name> + <_description>Left Win</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:rwin_toggle</name> + <_description>Right Win</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:lshift_toggle</name> + <_description>Left Shift</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:rshift_toggle</name> + <_description>Right Shift</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:lctrl_toggle</name> + <_description>Left Ctrl</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:rctrl_toggle</name> + <_description>Right Ctrl</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp:sclk_toggle</name> + <_description>Scroll Lock</_description> + </configItem> + </option> + </group> + <group allowMultipleSelection="true"> + <!-- The key combination used to choose the 3rd (and 4th, together with Shift) + level of symbols --> + <configItem> + <name>lv3</name> + <_description>Key to choose 3rd level</_description> + </configItem> + <option> + <configItem> + <name>lv3:switch</name> + <_description>Right Ctrl</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:menu_switch</name> + <_description>Menu</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:win_switch</name> + <_description>Any Win key</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:lwin_switch</name> + <_description>Left Win</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:rwin_switch</name> + <_description>Right Win</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:alt_switch</name> + <_description>Any Alt key</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:lalt_switch</name> + <_description>Left Alt</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:ralt_switch</name> + <_description>Right Alt</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:ralt_switch_multikey</name> + <_description>Right Alt, Shift+Right Alt key is Multi_Key</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:ralt_alt</name> + <_description>Right Alt key never chooses 3rd level</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:enter_switch</name> + <_description>Enter on keypad</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:caps_switch</name> + <_description>Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:bksl_switch</name> + <_description>Backslash</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:lsgt_switch</name> + <description><Less/Greater></description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:caps_switch_latch</name> + <description>Caps Lock (chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:bksl_switch_latch</name> + <description>Backslash chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description> + </configItem> + </option> + <option> + <configItem> + <name>lv3:lsgt_switch_latch</name> + <description><Less/Greater> (chooses 3rd level, latches when pressed together with another 3rd-level-chooser)</description> + </configItem> + </option> + </group> + <group allowMultipleSelection="true"> + <!-- Tweaking the position of the "Ctrl" key --> + <configItem> + <name>ctrl</name> + <_description>Ctrl key position</_description> + </configItem> + <option> + <configItem> + <name>ctrl:nocaps</name> + <_description>Make Caps Lock an additional Ctrl</_description> + </configItem> + </option> + <option> + <configItem> + <name>ctrl:lctrl_meta</name> + <_description>Meta on Left Ctrl</_description> + </configItem> + </option> + <option> + <configItem> + <name>ctrl:swapcaps</name> + <_description>Swap Ctrl and Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>ctrl:ctrl_ac</name> + <_description>At left of 'A'</_description> + </configItem> + </option> + <option> + <configItem> + <name>ctrl:ctrl_aa</name> + <_description>At bottom left</_description> + </configItem> + </option> + <option> + <configItem> + <name>ctrl:ctrl_ra</name> + <_description>Right Ctrl as Right Alt</_description> + </configItem> + </option> + <option> + <configItem> + <name>ctrl:ctrl_menu</name> + <description>Right Ctrl is mapped to Menu</description> + </configItem> + </option> + </group> + <group allowMultipleSelection="true"> + <!-- Using startard LEDs to indicate the alternative (not first) group(s) --> + <configItem> + <name>grp_led</name> + <_description>Use keyboard LED to show alternative layout</_description> + </configItem> + <option> + <configItem> + <name>grp_led:num</name> + <_description>Num Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp_led:caps</name> + <_description>Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>grp_led:scroll</name> + <_description>Scroll Lock</_description> + </configItem> + </option> + </group> + <group allowMultipleSelection="false"> + <!-- Select a keypad type --> + <configItem> + <name>keypad</name> + <_description>Numeric keypad layout selection</_description> + </configItem> + <option> + <configItem> + <name>keypad:legacy</name> + <_description>Legacy</_description> + </configItem> + </option> + <option> + <configItem> + <name>keypad:oss</name> + <_description>Unicode additions (arrows and math operators)</_description> + </configItem> + </option> + <option> + <configItem> + <name>keypad:future</name> + <_description>Unicode additions (arrows and math operators). Math operators on default level</_description> + </configItem> + </option> + <option> + <configItem> + <name>keypad:legacy_wang</name> + <_description>Legacy Wang 724</_description> + </configItem> + </option> + <option> + <configItem> + <name>keypad:oss_wang</name> + <_description>Wang 724 keypad with unicode additions (arrows and math operators)</_description> + </configItem> + </option> + <option> + <configItem> + <name>keypad:future_wang</name> + <_description>Wang 724 keypad with unicode additions (arrows and math operators). Math operators on default level</_description> + </configItem> + </option> + <option> + <configItem> + <name>keypad:hex</name> + <_description>Hexadecimal</_description> + </configItem> + </option> + <option> + <configItem> + <name>keypad:atm</name> + <_description>ATM/phone-style</_description> + </configItem> + </option> + </group> + <!-- This option should override the KPDL key defined in keypad; I hope it's declared in the right place --> + <group allowMultipleSelection="false"> + <!-- Select a keypad KPDL variant --> + <configItem> + <name>kpdl</name> + <_description>Numeric keypad delete key behaviour</_description> + </configItem> + <option> + <configItem> + <!-- Actually, with KP_DECIMAL, as the old keypad(dot) --> + <name>kpdl:dot</name> + <_description>Legacy key with dot</_description> + </configItem> + </option> + <option> + <configItem> + <name>kpdl:comma</name> + <!-- Actually, with KP_SEPARATOR, as the old keypad(comma) --> + <_description>Legacy key with comma</_description> + </configItem> + </option> + <option> + <configItem> + <name>kpdl:dotoss</name> + <_description>Four-level key with dot</_description> + </configItem> + </option> + <option> + <configItem> + <name>kpdl:dotoss_latin9</name> + <_description>Four-level key with dot, latin-9 restriction</_description> + </configItem> + </option> + <option> + <configItem> + <name>kpdl:commaoss</name> + <_description>Four-level key with comma</_description> + </configItem> + </option> + <option> + <configItem> + <name>kpdl:momayyezoss</name> + <_description>Four-level key with momayyez</_description> + </configItem> + </option> + <option> + <configItem> + <name>kpdl:kposs</name> + <!-- This assumes the KP_ abstract symbols are actually useful for some apps + The description needs to be rewritten --> + <_description>Four-level key with abstract separators</_description> + </configItem> + </option> + <option> + <configItem> + <name>kpdl:semi</name> + <_description>Semi-colon on third level</_description> + </configItem> + </option> + </group> + <group allowMultipleSelection="false"> + <!-- Caps Lock tweaks. + "Internal" capitalization means capitalization using some internal tables. + Otherwise "as Shift" - means using next group. --> + <configItem> + <name>caps</name> + <_description>Caps Lock key behavior</_description> + </configItem> + <option> + <configItem> + <name>caps:internal</name> + <_description>Caps Lock uses internal capitalization. Shift "pauses" Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:internal_nocancel</name> + <_description>Caps Lock uses internal capitalization. Shift doesn't affect Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:shift</name> + <_description>Caps Lock acts as Shift with locking. Shift "pauses" Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:shift_nocancel</name> + <_description>Caps Lock acts as Shift with locking. Shift doesn't affect Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:capslock</name> + <_description>Caps Lock toggles normal capitalization of alphabetic characters</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:numlock</name> + <_description>Make Caps Lock an additional Num Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:swapescape</name> + <_description>Swap ESC and Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:escape</name> + <_description>Make Caps Lock an additional ESC</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:backspace</name> + <_description>Make Caps Lock an additional Backspace</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:super</name> + <_description>Make Caps Lock an additional Super</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:hyper</name> + <_description>Make Caps Lock an additional Hyper</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:shiftlock</name> + <_description>Caps Lock toggles Shift so all keys are affected</_description> + </configItem> + </option> + <option> + <configItem> + <name>caps:none</name> + <_description>Caps Lock is disabled</_description> + </configItem> + </option> + </group> + <group allowMultipleSelection="false"> + <!-- Using special PC keys (Win, Menu) to work as standard X keys (Super, Hyper, etc.) --> + <configItem> + <name>altwin</name> + <_description>Alt/Win key behavior</_description> + </configItem> + <option> + <configItem> + <name>altwin:menu</name> + <_description>Add the standard behavior to Menu key</_description> + </configItem> + </option> + <option> + <configItem> + <name>altwin:meta_alt</name> + <_description>Alt and Meta are on Alt keys</_description> + </configItem> + </option> + <option> + <configItem> + <name>altwin:ctrl_win</name> + <_description>Control is mapped to Win keys (and the usual Ctrl keys)</_description> + </configItem> + </option> + <option> + <configItem> + <name>altwin:ctrl_alt_win</name> + <_description>Control is mapped to Alt keys, Alt is mapped to Win keys</_description> + </configItem> + </option> + <option> + <configItem> + <name>altwin:meta_win</name> + <_description>Meta is mapped to Win keys</_description> + </configItem> + </option> + <option> + <configItem> + <name>altwin:left_meta_win</name> + <_description>Meta is mapped to Left Win</_description> + </configItem> + </option> + <option> + <configItem> + <name>altwin:hyper_win</name> + <_description>Hyper is mapped to Win-keys</_description> + </configItem> + </option> + <option> + <configItem> + <name>altwin:alt_super_win</name> + <_description>Alt is mapped to Right Win, Super to Menu</_description> + </configItem> + </option> + <option> + <configItem> + <name>altwin:swap_lalt_lwin</name> + <_description>Left Alt is swapped with Left Win</_description> + </configItem> + </option> + </group> + <group allowMultipleSelection="true"> + <!-- Tweaking the position of the "Compose" key: mapping to existing PC keys --> + <configItem> + <name>Compose key</name> + <_description>Compose key position</_description> + </configItem> + <option> + <configItem> + <name>compose:ralt</name> + <_description>Right Alt</_description> + </configItem> + </option> + <option> + <configItem> + <name>compose:lwin</name> + <_description>Left Win</_description> + </configItem> + </option> + <option> + <configItem> + <name>compose:rwin</name> + <_description>Right Win</_description> + </configItem> + </option> + <option> + <configItem> + <name>compose:menu</name> + <_description>Menu</_description> + </configItem> + </option> + <option> + <configItem> + <name>compose:lctrl</name> + <_description>Left Ctrl</_description> + </configItem> + </option> + <option> + <configItem> + <name>compose:rctrl</name> + <_description>Right Ctrl</_description> + </configItem> + </option> + <option> + <configItem> + <name>compose:caps</name> + <_description>Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>compose:102</name> + <_description><Less/Greater></_description> + </configItem> + </option> + <option> + <configItem> + <name>compose:paus</name> + <_description>Pause</_description> + </configItem> + </option> + <option> + <configItem> + <name>compose:prsc</name> + <_description>PrtSc</_description> + </configItem> + </option> + <option> + <configItem> + <name>compose:sclk</name> + <_description>Scroll Lock</_description> + </configItem> + </option> + </group> + <group allowMultipleSelection="true"> + <configItem> + <name>compat</name> + <_description>Miscellaneous compatibility options</_description> + </configItem> + <option> + <configItem> + <name>numpad:pc</name> + <_description>Default numeric keypad keys</_description> + </configItem> + </option> + <option> + <configItem> + <name>numpad:mac</name> + <_description>Numeric keypad keys work as with Mac</_description> + </configItem> + </option> + <option> + <configItem> + <name>numpad:microsoft</name> + <_description>Shift with numeric keypad keys works as in MS Windows</_description> + </configItem> + </option> + <option> + <configItem> + <name>numpad:shift3</name> + <_description>Shift does not cancel Num Lock, chooses 3rd level instead</_description> + </configItem> + </option> + <option> + <configItem> + <name>srvrkeys:none</name> + <_description>Special keys (Ctrl+Alt+<key>) handled in a server</_description> + </configItem> + </option> + <option> + <configItem> + <name>apple:alupckeys</name> + <_description>Apple Aluminium Keyboard: emulate PC keys (Print, Scroll Lock, Pause, Num Lock)</_description> + </configItem> + </option> + <option> + <configItem> + <name>shift:breaks_caps</name> + <_description>Shift cancels Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>misc:typo</name> + <_description>Enable extra typographic characters</_description> + </configItem> + </option> + <option> + <configItem> + <name>shift:both_capslock</name> + <_description>Both Shift-Keys together toggle Caps Lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>shift:both_capslock_cancel</name> + <description>Both Shift-Keys together activate Caps Lock, one Shift-Key deactivates</description> + </configItem> + </option> + <option> + <configItem> + <name>shift:both_shiftlock</name> + <description>Both Shift-Keys together toggle ShiftLock</description> + </configItem> + </option> + <option> + <configItem> + <name>keypad:pointerkeys</name> + <_description>Toggle PointerKeys with Shift + NumLock.</_description> + </configItem> + </option> + </group> + <group allowMultipleSelection="true"> + <!-- Special shortcuts for the Euro character --> + <configItem> + <name>eurosign</name> + <_description>Adding currency signs to certain keys</_description> + </configItem> + <option> + <configItem> + <name>eurosign:e</name> + <_description>Euro on E</_description> + </configItem> + </option> + <option> + <configItem> + <name>eurosign:2</name> + <_description>Euro on 2</_description> + </configItem> + </option> + <option> + <configItem> + <name>eurosign:4</name> + <_description>Euro on 4</_description> + </configItem> + </option> + <option> + <configItem> + <name>eurosign:5</name> + <_description>Euro on 5</_description> + </configItem> + </option> + <option> + <configItem> + <name>rupeesign:4</name> + <_description>Rupee on 4</_description> + </configItem> + </option> + </group> + <group allowMultipleSelection="true"> + <configItem> + <name>lv5</name> + <_description>Key to choose 5th level</_description> + </configItem> + <option> + <configItem> + <name>lv5:lsgt_switch_lock</name> + <_description><Less/Greater> chooses 5th level, locks when pressed together with another 5th-level-chooser</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv5:ralt_switch_lock</name> + <_description>Right Alt chooses 5th level, locks when pressed together with another 5th-level-chooser</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv5:lwin_switch_lock</name> + <_description>Left Win chooses 5th level, locks when pressed together with another 5th-level-chooser</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv5:rwin_switch_lock</name> + <_description>Right Win chooses 5th level, locks when pressed together with another 5th-level-chooser</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv5:lsgt_switch_lock_cancel</name> + <_description><Less/Greater> chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv5:ralt_switch_lock_cancel</name> + <_description>Right Alt chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv5:lwin_switch_lock_cancel</name> + <_description>Left Win chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv5:rwin_switch_lock_cancel</name> + <_description>Right Win chooses 5th level, locks when pressed together with another 5th-level-chooser, one press releases the lock</_description> + </configItem> + </option> + <option> + <configItem> + <name>lv5:lsgt_switch_lock_cancel</name> + <description><Less/Greater> chooses 5th level and activates level5-Lock when pressed together with another 5th-level-chooser, one press releases the lock</description> + </configItem> + </option> + <option> + <configItem> + <name>lv5:ralt_switch_lock_cancel</name> + <description>Right Alt chooses 5th level and activates level5-Lock when pressed together with another 5th-level-chooser, one press releases the lock</description> + </configItem> + </option> + </group> + <group allowMultipleSelection="false"> + <!-- Let space output NBSP, NNBSP, ZWNJ, and ZWJ for the desired level --> + <configItem> + <name>nbsp</name> + <_description>Using space key to input non-breakable space character</_description> + </configItem> + <option> + <configItem> + <name>nbsp:none</name> + <_description>Usual space at any level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:level2</name> + <_description>Non-breakable space character at second level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:level3</name> + <_description>Non-breakable space character at third level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:level3s</name> + <_description>Non-breakable space character at third level, nothing at fourth level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:level3n</name> + <_description>Non-breakable space character at third level, thin non-breakable space character at fourth level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:level4</name> + <_description>Non-breakable space character at fourth level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:level4n</name> + <_description>Non-breakable space character at fourth level, thin non-breakable space character at sixth level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:level4nl</name> + <_description>Non-breakable space character at fourth level, thin non-breakable space character at sixth level (via Ctrl+Shift)</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:zwnj2</name> + <_description>Zero-width non-joiner character at second level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:zwnj2zwj3</name> + <_description>Zero-width non-joiner character at second level, zero-width joiner character at third level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:zwnj2zwj3nb4</name> + <_description>Zero-width non-joiner character at second level, zero-width joiner character at third level, non-breakable space character at fourth level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:zwnj2nb3</name> + <_description>Zero-width non-joiner character at second level, non-breakable space character at third level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:zwnj2nb3s</name> + <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, nothing at fourth level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:zwnj2nb3zwj4</name> + <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, zero-width joiner at fourth level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:zwnj2nb3nnb4</name> + <_description>Zero-width non-joiner character at second level, non-breakable space character at third level, thin non-breakable space at fourth level</_description> + </configItem> + </option> + <option> + <configItem> + <name>nbsp:zwnj3zwj4</name> + <_description>Zero-width non-joiner character at third level, zero-width joiner at fourth level</_description> + </configItem> + </option> + </group> + <group allowMultipleSelection="true"> + <configItem> + <name>japan</name> + <_description>Japanese keyboard options</_description> + </configItem> + <option> + <configItem> + <name>japan:kana_lock</name> + <_description>Kana Lock key is locking</_description> + </configItem> + </option> + <option> + <configItem> + <name>japan:nicola_f_bs</name> + <_description>NICOLA-F style Backspace</_description> + </configItem> + </option> + </group> + <group allowMultipleSelection="false"> + <configItem> + <name>esperanto</name> + <_description>Adding Esperanto circumflexes (supersigno)</_description> + </configItem> + <option> + <configItem> + <name>esperanto:qwerty</name> + <_description>To the corresponding key in a Qwerty keyboard.</_description> + </configItem> + </option> + <option> + <configItem> + <name>esperanto:dvorak</name> + <_description>To the corresponding key in a Dvorak keyboard.</_description> + </configItem> + </option> + </group> + <group allowMultipleSelection="true"> + <configItem> + <name>terminate</name> + <_description>Key sequence to kill the X server</_description> + </configItem> + <option> + <configItem> + <name>terminate:ctrl_alt_bksp</name> + <_description>Control + Alt + Backspace</_description> + </configItem> + </option> + </group> + </optionList> +</xkbConfigRegistry> diff --git a/xorg-server/xkeyboard-config/symbols/fi b/xorg-server/xkeyboard-config/symbols/fi index 78dd91934..9d0f6247e 100644 --- a/xorg-server/xkeyboard-config/symbols/fi +++ b/xorg-server/xkeyboard-config/symbols/fi @@ -1,207 +1,208 @@ -//
-// $XKeyboardConfig$
-//
-// X keyboard maps for Finland
-//
-// SFS 5966 / Kotoistus keymap created by Troy Korjuslommi
-// Classic keymap based on traditional by Marko Myllynen
-// Eliminate deadkeys alternative sent by Linus Torvalds
-//
-
-//
-// Missing from X11/keysymdef.h as of 2010-05-13
-//
-// U2030 # PER MILLE SIGN
-// U0292 # LATIN SMALL LETTER EZH
-// U01B7 # LATIN CAPITAL LETTER EZH
-//
-
-partial alphanumeric_keys default
-xkb_symbols "kotoistus" {
-
- // Official keymap for Finland based on SFS 5966 standard
- //
- // This keymap implements all the functionality of Annex 1
- // of the standard and additionally defines the following to
- // allow entering these characters with keyboars without LSGT.
- //
- // AE08+4, U+003C : LESS-THAN SIGN (less)
- // AE09+4, U+003E : GREATER-THAN SIGN (greater)
- // AD08+4, U+007C : VERTICAL LINE (bar)
- //
- // Annex 3 of the standard is implemented in fi_FI.UTF-8/Compose
-
- name[Group1]="Finland";
-
- key <TLDE> { [ section, onehalf, dead_stroke, NoSymbol ] };
- key <AE01> { [ 1, exclam, NoSymbol, exclamdown ] };
- key <AE02> { [ 2, quotedbl, at, rightdoublequotemark ] };
- key <AE03> { [ 3, numbersign, sterling, guillemotright ] };
- key <AE04> { [ 4, currency, dollar, guillemotleft ] };
- key <AE05> { [ 5, percent, U2030, leftdoublequotemark ] };
- key <AE06> { [ 6, ampersand, singlelowquotemark, doublelowquotemark ] };
- key <AE07> { [ 7, slash, braceleft, NoSymbol ] };
- key <AE08> { [ 8, parenleft, bracketleft, less ] };
- key <AE09> { [ 9, parenright, bracketright, greater ] };
- key <AE10> { [ 0, equal, braceright, degree ] };
- key <AE11> { [ plus, question, backslash, questiondown ] };
- key <AE12> { [ dead_acute, dead_grave, dead_cedilla, dead_ogonek ] };
-
- key <AD01> { [ q, Q, q, Q ] };
- key <AD02> { [ w, W, w, W ] };
- key <AD03> { [ e, E, EuroSign, NoSymbol ] };
- key <AD04> { [ r, R, r, R ] };
- key <AD05> { [ t, T, thorn, THORN ] };
- key <AD06> { [ y, Y, y, Y ] };
- key <AD07> { [ u, U, u, U ] };
- key <AD08> { [ i, I, idotless, bar ] };
- key <AD09> { [ o, O, oe, OE ] };
- key <AD10> { [ p, P, dead_horn, dead_hook ] };
- key <AD11> { [ aring, Aring, dead_doubleacute, dead_abovering ] };
- key <AD12> { [ dead_diaeresis, dead_circumflex, dead_tilde, dead_macron ] };
-
- key <AC01> { [ a, A, schwa, SCHWA ] };
- key <AC02> { [ s, S, ssharp, NoSymbol ] };
- key <AC03> { [ d, D, eth, ETH ] };
- key <AC04> { [ f, F, f, F ] };
- key <AC05> { [ g, G, g, G ] };
- key <AC06> { [ h, H, h, H ] };
- key <AC07> { [ j, J, j, J ] };
- key <AC08> { [ k, K, kra, NoSymbol ] };
- key <AC09> { [ l, L, dead_stroke, NoSymbol ] };
- key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] };
- key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] };
- key <BKSL> { [ apostrophe, asterisk, dead_caron, dead_breve ] };
-
- key <LSGT> { [ less, greater, bar, NoSymbol ] };
- key <AB01> { [ z, Z, U0292, U01B7 ] };
- key <AB02> { [ x, X, multiply, periodcentered ] };
- key <AB03> { [ c, C, c, C ] };
- key <AB04> { [ v, V, v, V ] };
- key <AB05> { [ b, B, b, B ] };
- key <AB06> { [ n, N, eng, ENG ] };
- key <AB07> { [ m, M, mu, emdash ] };
- key <AB08> { [ comma, semicolon, rightsinglequotemark, leftsinglequotemark ] };
- key <AB09> { [ period, colon, dead_belowdot, dead_abovedot ] };
- key <AB10> { [ minus, underscore, endash, dead_belowcomma ] };
-
- include "nbsp(level3)"
- include "kpdl(comma)"
- include "level3(ralt_switch)"
- include "compose(rwin)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "classic" {
-
- include "fi(fi)"
-
- name[Group1]="Finland - Classic";
-};
-
-partial alphanumeric_keys hidden
-xkb_symbols "fi" {
-
- // Classic Finnish keyboard layout with dead keys support
- // and all ISO-8859-1 and ISO-8859-15 characters available
-
- key <TLDE> { [ section, onehalf, onequarter, threequarters ] };
- key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
- key <AE02> { [ 2, quotedbl, at, twosuperior ] };
- key <AE03> { [ 3, numbersign, sterling, threesuperior ] };
- key <AE04> { [ 4, currency, dollar, cent ] };
- key <AE05> { [ 5, percent, EuroSign, masculine ] };
- key <AE06> { [ 6, ampersand, yen, ordfeminine ] };
- key <AE07> { [ 7, slash, braceleft, plusminus ] };
- key <AE08> { [ 8, parenleft, bracketleft, guillemotleft ] };
- key <AE09> { [ 9, parenright, bracketright, guillemotright ] };
- key <AE10> { [ 0, equal, braceright, degree ] };
- key <AE11> { [ plus, question, backslash, questiondown ] };
- key <AE12> { [ dead_acute, dead_grave, dead_cedilla, dead_ogonek ] };
-
- key <AD01> { [ q, Q, q, Q ] };
- key <AD02> { [ w, W, w, W ] };
- key <AD03> { [ e, E, EuroSign, cent ] };
- key <AD04> { [ r, R, registered, NoSymbol ] };
- key <AD05> { [ t, T, thorn, THORN ] };
- key <AD06> { [ y, Y, y, Y ] };
- key <AD07> { [ u, U, u, U ] };
- key <AD08> { [ i, I, idotless, bar ] };
- key <AD09> { [ o, O, o, O ] };
- key <AD10> { [ p, P, paragraph, NoSymbol ] };
- key <AD11> { [ aring, Aring, oe, OE ] };
- key <AD12> { [ dead_diaeresis, dead_circumflex, dead_tilde, dead_caron ] };
-
- key <AC01> { [ a, A, schwa, SCHWA ] };
- key <AC02> { [ s, S, scaron, Scaron ] };
- key <AC03> { [ d, D, eth, ETH ] };
- key <AC04> { [ f, F, f, F ] };
- key <AC05> { [ g, G, eng, ENG ] };
- key <AC06> { [ h, H, h, H ] };
- key <AC07> { [ j, J, j, J ] };
- key <AC08> { [ k, K, kra, NoSymbol ] };
- key <AC09> { [ l, L, dead_stroke, NoSymbol ] };
- key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] };
- key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] };
- key <BKSL> { [ apostrophe, asterisk, dead_caron, dead_breve ] };
-
- key <LSGT> { [ less, greater, bar, brokenbar ] };
- key <AB01> { [ z, Z, zcaron, Zcaron ] };
- key <AB02> { [ x, X, multiply, division ] };
- key <AB03> { [ c, C, copyright, cent ] };
- key <AB04> { [ v, V, v, V ] };
- key <AB05> { [ b, B, ssharp, NoSymbol ] };
- key <AB06> { [ n, N, ntilde, Ntilde ] };
- key <AB07> { [ m, M, mu, NoSymbol ] };
- key <AB08> { [ comma, semicolon, dead_cedilla, dead_ogonek ] };
- key <AB09> { [ period, colon, periodcentered, notsign ] };
- key <AB10> { [ minus, underscore, hyphen, dead_macron ] };
-
- include "nbsp(level4)"
- include "kpdl(comma)"
- include "level3(ralt_switch)"
- include "compose(rwin)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "nodeadkeys" {
-
- // Classic Finnish keyboard layout without dead keys
-
- include "fi(fi)"
-
- name[Group1]="Finland - Classic, eliminate dead keys";
-
- key <AE12> { [ acute, grave, cedilla, ogonek ] };
- key <AD12> { [ diaeresis, asciicircum, asciitilde, caron ] };
- key <AC09> { [ l, L, l, L ] };
- key <BKSL> { [ apostrophe, asterisk, caron, breve ] };
- key <AB08> { [ comma, semicolon, cedilla, ogonek ] };
- key <AB10> { [ minus, underscore, hyphen, macron ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "smi" {
-
- // Describes the differences between a Norwegian Northern Sami
- // (keyboard with dead key support) and a Swedish/Finnish Sami
- // keyboard according to the specs at:
- // http://www.hum.uit.no/a/trond/se-lat9-sefi-keys.html
-
- include "no(smi)"
-
- name[Group1]="Finland - Northern Saami";
-
- key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] };
- key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "mac" {
-
- // Macintosh keyboard for Finland based on Swedish(Macintosh) keyboard
-
- include "se(mac)"
-
- name[Group1]="Finland - Macintosh";
-};
+// +// $XKeyboardConfig$ +// +// X keyboard maps for Finland +// +// SFS 5966 / Kotoistus keymap created by Troy Korjuslommi +// Classic keymap based on traditional by Marko Myllynen +// Eliminate deadkeys alternative sent by Linus Torvalds +// + +// +// Missing from X11/keysymdef.h as of 2010-05-13 +// +// U2030 # PER MILLE SIGN +// U0292 # LATIN SMALL LETTER EZH +// U01B7 # LATIN CAPITAL LETTER EZH +// + +partial alphanumeric_keys default +xkb_symbols "kotoistus" { + + // Official keymap for Finland based on SFS 5966 standard + // + // This keymap implements all the functionality of Annex 1 + // of the standard and additionally defines the following to + // allow entering these characters with keyboars without LSGT. + // + // AE08+4, U+003C : LESS-THAN SIGN (less) + // AE09+4, U+003E : GREATER-THAN SIGN (greater) + // AD08+4, U+007C : VERTICAL LINE (bar) + // + // Annex 3 of the standard is implemented in fi_FI.UTF-8/Compose + + name[Group1]="Finland"; + + key <TLDE> { [ section, onehalf, dead_stroke, NoSymbol ] }; + key <AE01> { [ 1, exclam, NoSymbol, exclamdown ] }; + key <AE02> { [ 2, quotedbl, at, rightdoublequotemark ] }; + key <AE03> { [ 3, numbersign, sterling, guillemotright ] }; + key <AE04> { [ 4, currency, dollar, guillemotleft ] }; + key <AE05> { [ 5, percent, U2030, leftdoublequotemark ] }; + key <AE06> { [ 6, ampersand, singlelowquotemark, doublelowquotemark ] }; + key <AE07> { [ 7, slash, braceleft, NoSymbol ] }; + key <AE08> { [ 8, parenleft, bracketleft, less ] }; + key <AE09> { [ 9, parenright, bracketright, greater ] }; + key <AE10> { [ 0, equal, braceright, degree ] }; + key <AE11> { [ plus, question, backslash, questiondown ] }; + key <AE12> { [ dead_acute, dead_grave, dead_cedilla, dead_ogonek ] }; + + key <AD01> { [ q, Q, q, Q ] }; + key <AD02> { [ w, W, w, W ] }; + key <AD03> { [ e, E, EuroSign, NoSymbol ] }; + key <AD04> { [ r, R, r, R ] }; + key <AD05> { [ t, T, thorn, THORN ] }; + key <AD06> { [ y, Y, y, Y ] }; + key <AD07> { [ u, U, u, U ] }; + key <AD08> { [ i, I, idotless, bar ] }; + key <AD09> { [ o, O, oe, OE ] }; + key <AD10> { [ p, P, dead_horn, dead_hook ] }; + key <AD11> { [ aring, Aring, dead_doubleacute, dead_abovering ] }; + key <AD12> { [ dead_diaeresis, dead_circumflex, dead_tilde, dead_macron ] }; + + key <AC01> { [ a, A, schwa, SCHWA ] }; + key <AC02> { [ s, S, ssharp, NoSymbol ] }; + key <AC03> { [ d, D, eth, ETH ] }; + key <AC04> { [ f, F, f, F ] }; + key <AC05> { [ g, G, g, G ] }; + key <AC06> { [ h, H, h, H ] }; + key <AC07> { [ j, J, j, J ] }; + key <AC08> { [ k, K, kra, NoSymbol ] }; + key <AC09> { [ l, L, dead_stroke, NoSymbol ] }; + key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] }; + key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] }; + key <BKSL> { [ apostrophe, asterisk, dead_caron, dead_breve ] }; + + key <LSGT> { [ less, greater, bar, NoSymbol ] }; + key <AB01> { [ z, Z, U0292, U01B7 ] }; + key <AB02> { [ x, X, multiply, periodcentered ] }; + key <AB03> { [ c, C, c, C ] }; + key <AB04> { [ v, V, v, V ] }; + key <AB05> { [ b, B, b, B ] }; + key <AB06> { [ n, N, eng, ENG ] }; + key <AB07> { [ m, M, mu, emdash ] }; + key <AB08> { [ comma, semicolon, rightsinglequotemark, leftsinglequotemark ] }; + key <AB09> { [ period, colon, dead_belowdot, dead_abovedot ] }; + key <AB10> { [ minus, underscore, endash, dead_belowcomma ] }; + + include "nbsp(level4)" + include "nbsp(level3)" + include "kpdl(comma)" + include "level3(ralt_switch)" + include "compose(rwin)" +}; + +partial alphanumeric_keys +xkb_symbols "classic" { + + include "fi(fi)" + + name[Group1]="Finland - Classic"; +}; + +partial alphanumeric_keys hidden +xkb_symbols "fi" { + + // Classic Finnish keyboard layout with dead keys support + // and all ISO-8859-1 and ISO-8859-15 characters available + + key <TLDE> { [ section, onehalf, onequarter, threequarters ] }; + key <AE01> { [ 1, exclam, exclamdown, onesuperior ] }; + key <AE02> { [ 2, quotedbl, at, twosuperior ] }; + key <AE03> { [ 3, numbersign, sterling, threesuperior ] }; + key <AE04> { [ 4, currency, dollar, cent ] }; + key <AE05> { [ 5, percent, EuroSign, masculine ] }; + key <AE06> { [ 6, ampersand, yen, ordfeminine ] }; + key <AE07> { [ 7, slash, braceleft, plusminus ] }; + key <AE08> { [ 8, parenleft, bracketleft, guillemotleft ] }; + key <AE09> { [ 9, parenright, bracketright, guillemotright ] }; + key <AE10> { [ 0, equal, braceright, degree ] }; + key <AE11> { [ plus, question, backslash, questiondown ] }; + key <AE12> { [ dead_acute, dead_grave, dead_cedilla, dead_ogonek ] }; + + key <AD01> { [ q, Q, q, Q ] }; + key <AD02> { [ w, W, w, W ] }; + key <AD03> { [ e, E, EuroSign, cent ] }; + key <AD04> { [ r, R, registered, NoSymbol ] }; + key <AD05> { [ t, T, thorn, THORN ] }; + key <AD06> { [ y, Y, y, Y ] }; + key <AD07> { [ u, U, u, U ] }; + key <AD08> { [ i, I, idotless, bar ] }; + key <AD09> { [ o, O, o, O ] }; + key <AD10> { [ p, P, paragraph, NoSymbol ] }; + key <AD11> { [ aring, Aring, oe, OE ] }; + key <AD12> { [ dead_diaeresis, dead_circumflex, dead_tilde, dead_caron ] }; + + key <AC01> { [ a, A, schwa, SCHWA ] }; + key <AC02> { [ s, S, scaron, Scaron ] }; + key <AC03> { [ d, D, eth, ETH ] }; + key <AC04> { [ f, F, f, F ] }; + key <AC05> { [ g, G, eng, ENG ] }; + key <AC06> { [ h, H, h, H ] }; + key <AC07> { [ j, J, j, J ] }; + key <AC08> { [ k, K, kra, NoSymbol ] }; + key <AC09> { [ l, L, dead_stroke, NoSymbol ] }; + key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] }; + key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] }; + key <BKSL> { [ apostrophe, asterisk, dead_caron, dead_breve ] }; + + key <LSGT> { [ less, greater, bar, brokenbar ] }; + key <AB01> { [ z, Z, zcaron, Zcaron ] }; + key <AB02> { [ x, X, multiply, division ] }; + key <AB03> { [ c, C, copyright, cent ] }; + key <AB04> { [ v, V, v, V ] }; + key <AB05> { [ b, B, ssharp, NoSymbol ] }; + key <AB06> { [ n, N, ntilde, Ntilde ] }; + key <AB07> { [ m, M, mu, NoSymbol ] }; + key <AB08> { [ comma, semicolon, dead_cedilla, dead_ogonek ] }; + key <AB09> { [ period, colon, periodcentered, notsign ] }; + key <AB10> { [ minus, underscore, hyphen, dead_macron ] }; + + include "nbsp(level4)" + include "kpdl(comma)" + include "level3(ralt_switch)" + include "compose(rwin)" +}; + +partial alphanumeric_keys +xkb_symbols "nodeadkeys" { + + // Classic Finnish keyboard layout without dead keys + + include "fi(fi)" + + name[Group1]="Finland - Classic, eliminate dead keys"; + + key <AE12> { [ acute, grave, cedilla, ogonek ] }; + key <AD12> { [ diaeresis, asciicircum, asciitilde, caron ] }; + key <AC09> { [ l, L, l, L ] }; + key <BKSL> { [ apostrophe, asterisk, caron, breve ] }; + key <AB08> { [ comma, semicolon, cedilla, ogonek ] }; + key <AB10> { [ minus, underscore, hyphen, macron ] }; +}; + +partial alphanumeric_keys +xkb_symbols "smi" { + + // Describes the differences between a Norwegian Northern Sami + // (keyboard with dead key support) and a Swedish/Finnish Sami + // keyboard according to the specs at: + // http://www.hum.uit.no/a/trond/se-lat9-sefi-keys.html + + include "no(smi)" + + name[Group1]="Finland - Northern Saami"; + + key <AC10> { [ odiaeresis, Odiaeresis, oslash, Oslash ] }; + key <AC11> { [ adiaeresis, Adiaeresis, ae, AE ] }; +}; + +partial alphanumeric_keys +xkb_symbols "mac" { + + // Macintosh keyboard for Finland based on Swedish(Macintosh) keyboard + + include "se(mac)" + + name[Group1]="Finland - Macintosh"; +}; diff --git a/xorg-server/xkeyboard-config/symbols/ru b/xorg-server/xkeyboard-config/symbols/ru index 0e059afad..b95d6d57e 100644 --- a/xorg-server/xkeyboard-config/symbols/ru +++ b/xorg-server/xkeyboard-config/symbols/ru @@ -1,510 +1,531 @@ -// $XKeyboardConfig$
-
-// based on
-// russian standard keyboard
-// AEN <aen@logic.ru>
-// 2001/12/23 by Leon Kanter <leon@blackcatlinux.com>
-// 2005/12/09 Valery Inozemtsev <shrek@altlinux.ru>
-//
-// $XFree86: xc/programs/xkbcomp/symbols/ru,v 1.3 2003/02/15 22:27:05 dawes Exp $
-
-// Windows layout
-partial default alphanumeric_keys
-xkb_symbols "winkeys" {
- include "ru(common)"
-
- name[Group1]= "Russia";
-
- key <AE03> { [ 3, numerosign ] };
- key <AE04> { [ 4, semicolon ] };
- key <AE05> { [ 5, percent ] };
- key <AE06> { [ 6, colon ] };
- key <AE07> { [ 7, question ] };
- key <AE08> { [ 8, asterisk ] };
-
- key <AB10> { [ period, comma ] };
- key <BKSL> { [ backslash, slash ] };
-};
-
-partial hidden alphanumeric_keys
-xkb_symbols "common" {
-
- key <AE01> { [ 1, exclam ] };
- key <AE02> { [ 2, quotedbl ] };
- key <AE03> { [ 3, numbersign ] };
- key <AE04> { [ 4, asterisk ] };
- key <AE05> { [ 5, colon ] };
- key <AE06> { [ 6, comma ] };
- key <AE07> { [ 7, period ] };
- key <AE08> { [ 8, semicolon ] };
- key <AE09> { [ 9, parenleft ] };
- key <AE10> { [ 0, parenright ] };
- key <AE11> { [ minus, underscore ] };
- key <AE12> { [ equal, plus ] };
- key <BKSL> { [ backslash, bar ] };
- key <AB10> { [ slash, question ] };
- key <LSGT> { [ slash, bar ] };
-
- key <TLDE> { [ Cyrillic_io, Cyrillic_IO ] };
- key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI ] };
- key <AD02> { [ Cyrillic_tse, Cyrillic_TSE ] };
- key <AD03> { [ Cyrillic_u, Cyrillic_U ] };
- key <AD04> { [ Cyrillic_ka, Cyrillic_KA ] };
- key <AD05> { [ Cyrillic_ie, Cyrillic_IE ] };
- key <AD06> { [ Cyrillic_en, Cyrillic_EN ] };
- key <AD07> { [ Cyrillic_ghe, Cyrillic_GHE ] };
- key <AD08> { [ Cyrillic_sha, Cyrillic_SHA ] };
- key <AD09> { [ Cyrillic_shcha, Cyrillic_SHCHA ] };
- key <AD10> { [ Cyrillic_ze, Cyrillic_ZE ] };
- key <AD11> { [ Cyrillic_ha, Cyrillic_HA ] };
- key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
- key <AC01> { [ Cyrillic_ef, Cyrillic_EF ] };
- key <AC02> { [ Cyrillic_yeru, Cyrillic_YERU ] };
- key <AC03> { [ Cyrillic_ve, Cyrillic_VE ] };
- key <AC04> { [ Cyrillic_a, Cyrillic_A ] };
- key <AC05> { [ Cyrillic_pe, Cyrillic_PE ] };
- key <AC06> { [ Cyrillic_er, Cyrillic_ER ] };
- key <AC07> { [ Cyrillic_o, Cyrillic_O ] };
- key <AC08> { [ Cyrillic_el, Cyrillic_EL ] };
- key <AC09> { [ Cyrillic_de, Cyrillic_DE ] };
- key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE ] };
- key <AC11> { [ Cyrillic_e, Cyrillic_E ] };
- key <AB01> { [ Cyrillic_ya, Cyrillic_YA ] };
- key <AB02> { [ Cyrillic_che, Cyrillic_CHE ] };
- key <AB03> { [ Cyrillic_es, Cyrillic_ES ] };
- key <AB04> { [ Cyrillic_em, Cyrillic_EM ] };
- key <AB05> { [ Cyrillic_i, Cyrillic_I ] };
- key <AB06> { [ Cyrillic_te, Cyrillic_TE ] };
- key <AB07> { [Cyrillic_softsign,Cyrillic_SOFTSIGN ] };
- key <AB08> { [ Cyrillic_be, Cyrillic_BE ] };
- key <AB09> { [ Cyrillic_yu, Cyrillic_YU ] };
-
- key.type[group1]="TWO_LEVEL";
-
- include "kpdl(comma)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "legacy" {
- include "ru(common)"
-
- name[Group1]= "Russia - Legacy";
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc" {
-
- include "ru(common)"
-
- key <TLDE> { [ 0x01000451, 0x01000401, grave ] }; // Ñ‘, Ð
- key <AE03> { [ 3, numbersign, 0x01002116 ] }; // â„–
- key <AE04> { [ 4, dollar, semicolon ] };
- key <AE06> { [ 6, asciicircum, colon ] };
- key <AE07> { [ 7, ampersand ] };
- key <AE09> { [ 9, parenleft, acute ] };
- key <AC12> { [ backslash, bar, slash ] };
-
- include "group(olpc)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "typewriter" {
- include "ru(common)"
- name[Group1]= "Russia - Typewriter";
- key <TLDE> { [ bar, plus ] };
- key <AE01> { [ numerosign, 1 ] };
- key <AE02> { [ minus, 2 ] };
- key <AE03> { [ slash, 3 ] };
- key <AE04> { [ quotedbl, 4 ] };
- key <AE05> { [ colon, 5 ] };
- key <AE06> { [ comma, 6 ] };
- key <AE07> { [ period, 7 ] };
- key <AE08> { [ underscore, 8 ] };
- key <AE09> { [ question, 9 ] };
- key <AE10> { [ percent, 0 ] };
- key <AE11> { [ exclam, equal ] };
- key <AE12> { [ semicolon, backslash ] };
-
- key <BKSL> { [ parenright, parenleft ] };
-
- key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
- key <AB10> { [ Cyrillic_io, Cyrillic_IO ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "typewriter-legacy" {
- include "ru(common)"
- name[Group1]= "Russia - Typewriter, legacy";
- key <TLDE> { [ apostrophe, quotedbl ] };
- key <AE01> { [ exclam, 1 ] };
- key <AE02> { [ numerosign, 2 ] };
- key <AE03> { [ slash, 3 ] };
- key <AE04> { [ semicolon, 4 ] };
- key <AE05> { [ colon, 5 ] };
- key <AE06> { [ comma, 6 ] };
- key <AE07> { [ period, 7 ] };
- key <AE08> { [ underscore, 8 ] };
- key <AE09> { [ question, 9 ] };
- key <AE10> { [ percent, 0 ] };
- key <BKSL> { [ parenleft, parenright ] };
-
- key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
- key <AB10> { [ Cyrillic_io, Cyrillic_IO ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "phonetic" {
-
- name[Group1]= "Russia - Phonetic";
-
- key <AE01> { [ 1, exclam ] };
- key <AE02> { [ 2, at ] };
- key <AE03> { [ 3, Cyrillic_io ] };
- key <AE04> { [ 4, Cyrillic_IO ] };
- key <AE05> { [ 5, Cyrillic_hardsign ] };
- key <AE06> { [ 6, Cyrillic_HARDSIGN ] };
- key <AE07> { [ 7, ampersand ] };
- key <AE08> { [ 8, asterisk ] };
- key <AE09> { [ 9, parenleft ] };
- key <AE10> { [ 0, parenright ] };
- key <AE11> { [ minus, underscore ] };
-
- key <AB09> { [ period, greater ] };
- key <AB10> { [ slash, question ] };
- key <AB08> { [ comma, less ] };
- key <AC10> { [ semicolon, colon ] };
- key <AC11> { [ apostrophe, quotedbl ] };
- key <LSGT> { [ bar, brokenbar ] };
-
- key <TLDE> { [ Cyrillic_yu, Cyrillic_YU ] };
- key <LatQ> { [ Cyrillic_ya, Cyrillic_YA ] };
- key <LatZ> { [ Cyrillic_ze, Cyrillic_ZE ] };
- key <LatS> { [ Cyrillic_es, Cyrillic_ES ] };
- key <LatA> { [ Cyrillic_a, Cyrillic_A ] };
- key <LatW> { [ Cyrillic_ve, Cyrillic_VE ] };
- key <LatC> { [ Cyrillic_tse, Cyrillic_TSE ] };
- key <LatX> { [Cyrillic_softsign,Cyrillic_SOFTSIGN ] };
- key <LatD> { [ Cyrillic_de, Cyrillic_DE ] };
- key <LatE> { [ Cyrillic_ie, Cyrillic_IE ] };
- key <LatV> { [ Cyrillic_zhe, Cyrillic_ZHE ] };
- key <LatF> { [ Cyrillic_ef, Cyrillic_EF ] };
- key <LatT> { [ Cyrillic_te, Cyrillic_TE ] };
- key <LatR> { [ Cyrillic_er, Cyrillic_ER ] };
- key <LatN> { [ Cyrillic_en, Cyrillic_EN ] };
- key <LatB> { [ Cyrillic_be, Cyrillic_BE ] };
- key <LatH> { [ Cyrillic_ha, Cyrillic_HA ] };
- key <LatG> { [ Cyrillic_ghe, Cyrillic_GHE ] };
- key <LatY> { [ Cyrillic_yeru, Cyrillic_YERU ] };
- key <LatM> { [ Cyrillic_em, Cyrillic_EM ] };
- key <LatJ> { [ Cyrillic_shorti, Cyrillic_SHORTI ] };
- key <LatU> { [ Cyrillic_u, Cyrillic_U ] };
- key <LatK> { [ Cyrillic_ka, Cyrillic_KA ] };
- key <LatI> { [ Cyrillic_i, Cyrillic_I ] };
- key <LatO> { [ Cyrillic_o, Cyrillic_O ] };
- key <LatL> { [ Cyrillic_el, Cyrillic_EL ] };
- key <LatP> { [ Cyrillic_pe, Cyrillic_PE ] };
-
- key <AD11> { [ Cyrillic_sha, Cyrillic_SHA ] };
- key <AE12> { [ Cyrillic_che, Cyrillic_CHE ] };
- key <AD12> { [ Cyrillic_shcha, Cyrillic_SHCHA ] };
- key <BKSL> { [ Cyrillic_e, Cyrillic_E ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "phonetic_winkeys" {
-
- include "ru(phonetic)"
- name[Group1]= "Russia - Phonetic Winkeys";
-
- key <LatX> { [ Cyrillic_ha, Cyrillic_HA ] };
- key <LatH> { [ Cyrillic_che, Cyrillic_CHE ] };
- key <AE12> { [ Cyrillic_softsign, Cyrillic_softsign ] };
-
-};
-
-partial alphanumeric_keys
-xkb_symbols "tt" {
- include "ru(winkeys)"
- name[Group1]= "Russia - Tatar";
-
- key.type[group1]="FOUR_LEVEL";
-
- key <TLDE> { [ 0x010004bb, 0x010004ba,
- Cyrillic_io, Cyrillic_IO ] };
- key <AD02> { [ 0x010004e9, 0x010004e8,
- Cyrillic_tse, Cyrillic_TSE ] };
- key <AD09> { [ 0x010004d9, 0x010004d8,
- Cyrillic_shcha, Cyrillic_SHCHA ] };
- key <AD12> { [ 0x010004af, 0x010004ae,
- Cyrillic_hardsign,Cyrillic_HARDSIGN ] };
- key <AC10> { [ 0x010004a3, 0x010004a2,
- Cyrillic_zhe, Cyrillic_ZHE ] };
- key <AB07> { [ 0x01000497, 0x01000496,
- Cyrillic_softsign,Cyrillic_SOFTSIGN ] };
-
- include "level3(ralt_switch)"
-
-};
-
-partial alphanumeric_keys
-xkb_symbols "os_legacy" {
- include "ru(common)"
-
- name[Group1]= "Russia - Ossetian, legacy";
-
- key <TLDE> { [ Cyrillic_e, Cyrillic_E ] };
- key <AC07> { [ Cyrillic_o, Cyrillic_O, Cyrillic_io, Cyrillic_IO ] };
- key <AC11> { [ 0x010004D5, 0x010004D4 ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "os_winkeys" {
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Ossetian, Winkeys";
-
- key <TLDE> { [ Cyrillic_e, Cyrillic_E ] };
- key <AC07> { [ Cyrillic_o, Cyrillic_O, Cyrillic_io, Cyrillic_IO ] };
- key <AC11> { [ 0x010004D5, 0x010004D4 ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "cv" {
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Chuvash";
-
- key.type[group1]="FOUR_LEVEL";
-
- key <AD03> { [ Cyrillic_u, Cyrillic_U,
- 0x010004f3, 0x010004f2 ] };
- key <AD05> { [ Cyrillic_ie, Cyrillic_IE,
- 0x01000115, 0x01000114 ] };
- key <AC04> { [ Cyrillic_a, Cyrillic_A,
- abreve, Abreve ] };
- key <AB03> { [ Cyrillic_es, Cyrillic_ES,
- ccedilla, Ccedilla ] };
-
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "udm" {
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Udmurt";
-
- key.type[group1]="FOUR_LEVEL";
-
- key <AE01> { [ question, exclam, 1, 1 ] };
- key <AE02> { [ parenleft, quotedbl, 2, 2 ] };
- key <AE03> { [ parenright, numerosign, 3, 3 ] };
- key <AE04> { [ colon, semicolon, 4, 4 ] };
- key <AE05> { [ asterisk, percent, 5, 5 ] };
- key <AE06> { [ 0x010004dd, 0x010004dc, 6, 6 ] };
- key <AE07> { [ 0x010004e7, 0x010004e6, 7, 7 ] };
- key <AE08> { [ 0x010004f5, 0x010004f4, 8, 8 ] };
- key <AE09> { [ 0x010004e5, 0x010004e4, 9, 9 ] };
- key <AE10> { [ 0x010004df, 0x010004de, 0, 0 ] };
-
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "cv_latin" {
- include "us(alt-intl)"
-
- name[Group1]= "Russia - Chuvash Latin";
-
- key.type[group1]="FOUR_LEVEL";
-
- key <AD01> { [ q, Q, 0x01000161, 0x01000160 ] };
- key <AD02> { [ w, W, udiaeresis, Udiaeresis ] };
- key <AD03> { [ e, E, 0x01000115, 0x01000114 ] };
- key <AD07> { [ u, U, udiaeresis, Udiaeresis ] };
- key <AD08> { [ i, I, 0x0100012d, 0x0100012c ] };
- key <AD09> { [ o, O, odiaeresis, Odiaeresis ] };
- key <AC01> { [ a, A, abreve, Abreve ] };
- key <AC02> { [ s, S, scedilla, Scedilla ] };
- key <AC05> { [ g, G, gbreve, Gbreve ] };
- key <AC07> { [ j, J, 0x01000131, 0x01000130 ] };
- key <AB03> { [ c, C, ccedilla, Ccedilla ] };
-
- include "level3(ralt_switch)"
-
-};
-
-// Komi language layout
-// based on
-// russian standard keyboard
-// Vlad Shakhov <lumpen.intellectual@gmail.com>
-// Last Changes 2007/10/23 by Vlad Shakhov <lumpen.intellectual@gmail.com>
-
-partial alphanumeric_keys
-xkb_symbols "kom" {
-
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Komi";
-
- key.type[group1]="FOUR_LEVEL_ALPHABETIC";
-
-// cyrilllic o with diaeresis
- key <AC07> { [ Cyrillic_o, Cyrillic_O,
- U04E7, U04E6 ] };
-
-// hard I as additional key for soft Cyrillic_I
- key <AB05> { [ Cyrillic_i, Cyrillic_I,
- Ukrainian_i, Ukrainian_I ] };
-
- include "level3(ralt_switch)"
-};
-
-// Yakut language layout
-// 2008/04/23 Yakov Aleksandrov <bertjickty@yandex.ru>
-// 2008/04/23 Anatoliy Zhozhikov <jav@sitc.ru>
-// 2008/04/23 Aleksandr Varlamov
-partial alphanumeric_keys
-xkb_symbols "sah" {
-
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Yakut";
-
- key.type[group1]="FOUR_LEVEL_ALPHABETIC";
-
- key <TLDE> { [ Cyrillic_io, Cyrillic_IO,
- U04EB, U04EA ] };
- key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI,
- U048B, U048A ] };
- key <AD03> { [ Cyrillic_u, Cyrillic_U,
- Cyrillic_u_straight, Cyrillic_U_straight ] };
- key <AD04> { [ Cyrillic_ka, Cyrillic_KA,
- U04C4, U04C3 ] };
- key <AD06> { [ Cyrillic_en, Cyrillic_EN,
- U04A5, U04A4 ] };
- key <AD07> { [ Cyrillic_ghe, Cyrillic_GHE,
- U0495, U0494 ] };
- key <AD10> { [ Cyrillic_ze, Cyrillic_ZE,
- U04E1, U04E0 ] };
- key <AD11> { [ Cyrillic_ha, Cyrillic_HA,
- Cyrillic_shha, Cyrillic_SHHA ] };
- key <AC07> { [ Cyrillic_o, Cyrillic_O,
- Cyrillic_o_bar, Cyrillic_O_bar ] };
- key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE,
- U0461, U0460 ] };
- key <AB02> { [ Cyrillic_che, Cyrillic_CHE,
- Cyrillic_u_macron, Cyrillic_U_macron ] };
- key <AB04> { [ Cyrillic_em, Cyrillic_EM,
- U04C8, U04C7 ] };
- key <AB05> { [ Cyrillic_i, Cyrillic_I,
- Cyrillic_i_macron, Cyrillic_I_macron ] };
-
- include "level3(ralt_switch)"
-};
-
-
-//Kalmyk language layout
-//based on the Kalmyk language layout: http://soft.oyrat.org/
-//Nikolay Korneev <halmg@oyrat.org>
-//Toli Miron <mirontoli@gmail.com>
-
-partial alphanumeric_keys
-xkb_symbols "xal" {
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Kalmyk";
-
- key.type[group1]="FOUR_LEVEL";
-
- key <AE01> { [ question, exclam, 1 ] };
- key <AE02> { [ numerosign, quotedbl, 2 ] };
- key <AE03> { [ Cyrillic_u_straight, Cyrillic_U_straight, 3 ] };
- key <AE04> { [ Cyrillic_schwa, Cyrillic_SCHWA, 4 ] };
- key <AE05> { [ asterisk, percent, 5 ] };
- key <AE06> { [ Cyrillic_en_descender, Cyrillic_EN_descender, 6 ] };
- key <AE07> { [ Cyrillic_o_bar, Cyrillic_O_bar, 7 ] };
- key <AE08> { [ Cyrillic_shha, Cyrillic_SHHA, 8 ] };
- key <AE09> { [ Cyrillic_zhe_descender, Cyrillic_ZHE_descender, 9 ] };
- key <AE10> { [ semicolon, colon, 0 ] };
-
- key <TLDE> { [ parenleft, parenright, Cyrillic_io, Cyrillic_IO ] };
-
- key <AD02> { [ Cyrillic_tse, Cyrillic_TSE, dollar ] };
- key <AD03> { [ Cyrillic_u, Cyrillic_U, EuroSign ] };
- key <AD04> { [ Cyrillic_ka, Cyrillic_KA, registered ] };
- key <AD05> { [ Cyrillic_ie, Cyrillic_IE, trademark ] };
- key <AD11> { [ Cyrillic_ha, Cyrillic_HA, bracketleft ] };
- key <AD12> { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, bracketright ] };
- key <AC11> { [ Cyrillic_e, Cyrillic_E, apostrophe ] };
- key <AB03> { [ Cyrillic_es, Cyrillic_ES, copyright ] };
- key <AB08> { [ Cyrillic_be, Cyrillic_BE, less ] };
- key <AB09> { [ Cyrillic_yu, Cyrillic_YU, greater ] };
-
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "dos" {
-
- include "ru(common)"
-
- name[Group1]= "Russia - DOS";
-
- key <TLDE> { [ parenright, parenleft ] };
- key <AE04> { [ 4, currency ] };
- key <AE09> { [ 9, question ] };
- key <AE10> { [ 0, percent ] };
-
- key <AB10> { [ Cyrillic_io, Cyrillic_IO ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "bak" {
- include "ru(winkeys)"
-
- name[Group1]= "Russia - Bashkirian";
- key.type[group1]="FOUR_LEVEL";
-
- key <TLDE> { [ 0x010004d9, 0x010004d8, Cyrillic_io, Cyrillic_IO ] };
- key <AE01> { [ exclam, quotedbl, 1, 1 ] };
- key <AE02> { [ 0x010004e9, 0x010004e8, 2, 2 ] };
- key <AE03> { [ 0x010004a1, 0x010004a0, 3, 3 ] };
- key <AE04> { [ 0x01000493, 0x01000492, 4, 4 ] };
- key <AE05> { [ 0x010004ab, 0x010004aa, 5, 5 ] };
- key <AE06> { [ colon, semicolon, 6, 6 ] };
- key <AE07> { [ 0x01000499, 0x01000498, 7, 7 ] };
- key <AE08> { [ 0x010004bb, 0x010004ba, 8, 8 ] };
- key <AE09> { [ question, parenleft, 9, 9 ] };
- key <AE10> { [ numerosign, parenright, 0, 0 ] };
- key <AE11> { [ minus, percent, minus, underscore ]};
- key <AE12> { [ 0x010004af, 0x010004ae, equal, plus ]};
- key <BKSL> { [ 0x010004a3, 0x010004a2, backslash, slash ]};
-
- include "level3(ralt_switch)"
-};
-
-// Serbian charecters added as third level symbols to Russian keyboard layout.
-
-partial alphanumeric_keys
-xkb_symbols "srp" {
- include "ru(common)"
- include "level3(ralt_switch)"
-
- name[Group1]= "Russia - Serbian";
-
- key <AE03> { [ 3, numerosign ] };
- key <AE04> { [ 4, semicolon ] };
- key <AE05> { [ 5, percent ] };
- key <AE06> { [ 6, colon ] };
- key <AE07> { [ 7, question ] };
- key <AE08> { [ 8, asterisk ] };
- key <AB10> { [ period, comma ] };
- key <BKSL> { [ backslash, slash ] };
- key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI, U458, U408 ] };
- key <AD06> { [ Cyrillic_en, Cyrillic_EN, U45A, U40A ] };
- key <AC08> { [ Cyrillic_el, Cyrillic_EL, U459, U409 ] };
- key <AC09> { [ Cyrillic_de, Cyrillic_DE, U45F, U40F ] };
- key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE, U452, U402 ] };
- key <AB02> { [ Cyrillic_che, Cyrillic_CHE, U45B, U40B ] };
-};
+// $XKeyboardConfig$ + +// based on +// russian standard keyboard +// AEN <aen@logic.ru> +// 2001/12/23 by Leon Kanter <leon@blackcatlinux.com> +// 2005/12/09 Valery Inozemtsev <shrek@altlinux.ru> +// +// $XFree86: xc/programs/xkbcomp/symbols/ru,v 1.3 2003/02/15 22:27:05 dawes Exp $ + +// Windows layout +partial default alphanumeric_keys +xkb_symbols "winkeys" { + include "ru(common)" + + name[Group1]= "Russia"; + + key <AE03> { [ 3, numerosign ] }; + key <AE04> { [ 4, semicolon ] }; + key <AE05> { [ 5, percent ] }; + key <AE06> { [ 6, colon ] }; + key <AE07> { [ 7, question ] }; + key <AE08> { [ 8, asterisk ] }; + + key <AB10> { [ period, comma ] }; + key <BKSL> { [ backslash, slash ] }; +}; + +partial hidden alphanumeric_keys +xkb_symbols "common" { + + key <AE01> { [ 1, exclam ] }; + key <AE02> { [ 2, quotedbl ] }; + key <AE03> { [ 3, numbersign ] }; + key <AE04> { [ 4, asterisk ] }; + key <AE05> { [ 5, colon ] }; + key <AE06> { [ 6, comma ] }; + key <AE07> { [ 7, period ] }; + key <AE08> { [ 8, semicolon ] }; + key <AE09> { [ 9, parenleft ] }; + key <AE10> { [ 0, parenright ] }; + key <AE11> { [ minus, underscore ] }; + key <AE12> { [ equal, plus ] }; + key <BKSL> { [ backslash, bar ] }; + key <AB10> { [ slash, question ] }; + key <LSGT> { [ slash, bar ] }; + + key <TLDE> { [ Cyrillic_io, Cyrillic_IO ] }; + key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI ] }; + key <AD02> { [ Cyrillic_tse, Cyrillic_TSE ] }; + key <AD03> { [ Cyrillic_u, Cyrillic_U ] }; + key <AD04> { [ Cyrillic_ka, Cyrillic_KA ] }; + key <AD05> { [ Cyrillic_ie, Cyrillic_IE ] }; + key <AD06> { [ Cyrillic_en, Cyrillic_EN ] }; + key <AD07> { [ Cyrillic_ghe, Cyrillic_GHE ] }; + key <AD08> { [ Cyrillic_sha, Cyrillic_SHA ] }; + key <AD09> { [ Cyrillic_shcha, Cyrillic_SHCHA ] }; + key <AD10> { [ Cyrillic_ze, Cyrillic_ZE ] }; + key <AD11> { [ Cyrillic_ha, Cyrillic_HA ] }; + key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] }; + key <AC01> { [ Cyrillic_ef, Cyrillic_EF ] }; + key <AC02> { [ Cyrillic_yeru, Cyrillic_YERU ] }; + key <AC03> { [ Cyrillic_ve, Cyrillic_VE ] }; + key <AC04> { [ Cyrillic_a, Cyrillic_A ] }; + key <AC05> { [ Cyrillic_pe, Cyrillic_PE ] }; + key <AC06> { [ Cyrillic_er, Cyrillic_ER ] }; + key <AC07> { [ Cyrillic_o, Cyrillic_O ] }; + key <AC08> { [ Cyrillic_el, Cyrillic_EL ] }; + key <AC09> { [ Cyrillic_de, Cyrillic_DE ] }; + key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE ] }; + key <AC11> { [ Cyrillic_e, Cyrillic_E ] }; + key <AB01> { [ Cyrillic_ya, Cyrillic_YA ] }; + key <AB02> { [ Cyrillic_che, Cyrillic_CHE ] }; + key <AB03> { [ Cyrillic_es, Cyrillic_ES ] }; + key <AB04> { [ Cyrillic_em, Cyrillic_EM ] }; + key <AB05> { [ Cyrillic_i, Cyrillic_I ] }; + key <AB06> { [ Cyrillic_te, Cyrillic_TE ] }; + key <AB07> { [Cyrillic_softsign,Cyrillic_SOFTSIGN ] }; + key <AB08> { [ Cyrillic_be, Cyrillic_BE ] }; + key <AB09> { [ Cyrillic_yu, Cyrillic_YU ] }; + + key.type[group1]="TWO_LEVEL"; + + include "kpdl(comma)" +}; + +partial alphanumeric_keys +xkb_symbols "legacy" { + include "ru(common)" + + name[Group1]= "Russia - Legacy"; +}; + +partial alphanumeric_keys +xkb_symbols "olpc" { + + include "ru(common)" + + key <TLDE> { [ 0x01000451, 0x01000401, grave ] }; // Ñ‘, Ð + key <AE03> { [ 3, numbersign, 0x01002116 ] }; // â„– + key <AE04> { [ 4, dollar, semicolon ] }; + key <AE06> { [ 6, asciicircum, colon ] }; + key <AE07> { [ 7, ampersand ] }; + key <AE09> { [ 9, parenleft, acute ] }; + key <AC12> { [ backslash, bar, slash ] }; + + include "group(olpc)" +}; + +partial alphanumeric_keys +xkb_symbols "typewriter" { + include "ru(common)" + name[Group1]= "Russia - Typewriter"; + key <TLDE> { [ bar, plus ] }; + key <AE01> { [ numerosign, 1 ] }; + key <AE02> { [ minus, 2 ] }; + key <AE03> { [ slash, 3 ] }; + key <AE04> { [ quotedbl, 4 ] }; + key <AE05> { [ colon, 5 ] }; + key <AE06> { [ comma, 6 ] }; + key <AE07> { [ period, 7 ] }; + key <AE08> { [ underscore, 8 ] }; + key <AE09> { [ question, 9 ] }; + key <AE10> { [ percent, 0 ] }; + key <AE11> { [ exclam, equal ] }; + key <AE12> { [ semicolon, backslash ] }; + + key <BKSL> { [ parenright, parenleft ] }; + + key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] }; + key <AB10> { [ Cyrillic_io, Cyrillic_IO ] }; +}; + +partial alphanumeric_keys +xkb_symbols "typewriter-legacy" { + include "ru(common)" + name[Group1]= "Russia - Typewriter, legacy"; + key <TLDE> { [ apostrophe, quotedbl ] }; + key <AE01> { [ exclam, 1 ] }; + key <AE02> { [ numerosign, 2 ] }; + key <AE03> { [ slash, 3 ] }; + key <AE04> { [ semicolon, 4 ] }; + key <AE05> { [ colon, 5 ] }; + key <AE06> { [ comma, 6 ] }; + key <AE07> { [ period, 7 ] }; + key <AE08> { [ underscore, 8 ] }; + key <AE09> { [ question, 9 ] }; + key <AE10> { [ percent, 0 ] }; + key <BKSL> { [ parenleft, parenright ] }; + + key <AD12> { [Cyrillic_hardsign,Cyrillic_HARDSIGN ] }; + key <AB10> { [ Cyrillic_io, Cyrillic_IO ] }; +}; + +partial alphanumeric_keys +xkb_symbols "phonetic" { + + name[Group1]= "Russia - Phonetic"; + + key <AE01> { [ 1, exclam ] }; + key <AE02> { [ 2, at ] }; + key <AE03> { [ 3, Cyrillic_io ] }; + key <AE04> { [ 4, Cyrillic_IO ] }; + key <AE05> { [ 5, Cyrillic_hardsign ] }; + key <AE06> { [ 6, Cyrillic_HARDSIGN ] }; + key <AE07> { [ 7, ampersand ] }; + key <AE08> { [ 8, asterisk ] }; + key <AE09> { [ 9, parenleft ] }; + key <AE10> { [ 0, parenright ] }; + key <AE11> { [ minus, underscore ] }; + + key <AB09> { [ period, greater ] }; + key <AB10> { [ slash, question ] }; + key <AB08> { [ comma, less ] }; + key <AC10> { [ semicolon, colon ] }; + key <AC11> { [ apostrophe, quotedbl ] }; + key <LSGT> { [ bar, brokenbar ] }; + + key <TLDE> { [ Cyrillic_yu, Cyrillic_YU ] }; + key <LatQ> { [ Cyrillic_ya, Cyrillic_YA ] }; + key <LatZ> { [ Cyrillic_ze, Cyrillic_ZE ] }; + key <LatS> { [ Cyrillic_es, Cyrillic_ES ] }; + key <LatA> { [ Cyrillic_a, Cyrillic_A ] }; + key <LatW> { [ Cyrillic_ve, Cyrillic_VE ] }; + key <LatC> { [ Cyrillic_tse, Cyrillic_TSE ] }; + key <LatX> { [Cyrillic_softsign,Cyrillic_SOFTSIGN ] }; + key <LatD> { [ Cyrillic_de, Cyrillic_DE ] }; + key <LatE> { [ Cyrillic_ie, Cyrillic_IE ] }; + key <LatV> { [ Cyrillic_zhe, Cyrillic_ZHE ] }; + key <LatF> { [ Cyrillic_ef, Cyrillic_EF ] }; + key <LatT> { [ Cyrillic_te, Cyrillic_TE ] }; + key <LatR> { [ Cyrillic_er, Cyrillic_ER ] }; + key <LatN> { [ Cyrillic_en, Cyrillic_EN ] }; + key <LatB> { [ Cyrillic_be, Cyrillic_BE ] }; + key <LatH> { [ Cyrillic_ha, Cyrillic_HA ] }; + key <LatG> { [ Cyrillic_ghe, Cyrillic_GHE ] }; + key <LatY> { [ Cyrillic_yeru, Cyrillic_YERU ] }; + key <LatM> { [ Cyrillic_em, Cyrillic_EM ] }; + key <LatJ> { [ Cyrillic_shorti, Cyrillic_SHORTI ] }; + key <LatU> { [ Cyrillic_u, Cyrillic_U ] }; + key <LatK> { [ Cyrillic_ka, Cyrillic_KA ] }; + key <LatI> { [ Cyrillic_i, Cyrillic_I ] }; + key <LatO> { [ Cyrillic_o, Cyrillic_O ] }; + key <LatL> { [ Cyrillic_el, Cyrillic_EL ] }; + key <LatP> { [ Cyrillic_pe, Cyrillic_PE ] }; + + key <AD11> { [ Cyrillic_sha, Cyrillic_SHA ] }; + key <AE12> { [ Cyrillic_che, Cyrillic_CHE ] }; + key <AD12> { [ Cyrillic_shcha, Cyrillic_SHCHA ] }; + key <BKSL> { [ Cyrillic_e, Cyrillic_E ] }; +}; + +partial alphanumeric_keys +xkb_symbols "phonetic_winkeys" { + + include "ru(phonetic)" + name[Group1]= "Russia - Phonetic Winkeys"; + + key <LatX> { [ Cyrillic_ha, Cyrillic_HA ] }; + key <LatH> { [ Cyrillic_che, Cyrillic_CHE ] }; + key <AE12> { [ Cyrillic_softsign, Cyrillic_softsign ] }; + +}; + +partial alphanumeric_keys +xkb_symbols "tt" { + include "ru(winkeys)" + name[Group1]= "Russia - Tatar"; + + key.type[group1]="FOUR_LEVEL"; + + key <TLDE> { [ 0x010004bb, 0x010004ba, + Cyrillic_io, Cyrillic_IO ] }; + key <AD02> { [ 0x010004e9, 0x010004e8, + Cyrillic_tse, Cyrillic_TSE ] }; + key <AD09> { [ 0x010004d9, 0x010004d8, + Cyrillic_shcha, Cyrillic_SHCHA ] }; + key <AD12> { [ 0x010004af, 0x010004ae, + Cyrillic_hardsign,Cyrillic_HARDSIGN ] }; + key <AC10> { [ 0x010004a3, 0x010004a2, + Cyrillic_zhe, Cyrillic_ZHE ] }; + key <AB07> { [ 0x01000497, 0x01000496, + Cyrillic_softsign,Cyrillic_SOFTSIGN ] }; + + include "level3(ralt_switch)" + +}; + +partial alphanumeric_keys +xkb_symbols "os_legacy" { + include "ru(common)" + + name[Group1]= "Russia - Ossetian, legacy"; + + key <TLDE> { [ Cyrillic_e, Cyrillic_E ] }; + key <AC07> { [ Cyrillic_o, Cyrillic_O, Cyrillic_io, Cyrillic_IO ] }; + key <AC11> { [ 0x010004D5, 0x010004D4 ] }; +}; + +partial alphanumeric_keys +xkb_symbols "os_winkeys" { + include "ru(winkeys)" + + name[Group1]= "Russia - Ossetian, Winkeys"; + + key <TLDE> { [ Cyrillic_e, Cyrillic_E ] }; + key <AC07> { [ Cyrillic_o, Cyrillic_O, Cyrillic_io, Cyrillic_IO ] }; + key <AC11> { [ 0x010004D5, 0x010004D4 ] }; +}; + +partial alphanumeric_keys +xkb_symbols "cv" { + include "ru(winkeys)" + + name[Group1]= "Russia - Chuvash"; + + key.type[group1]="FOUR_LEVEL"; + + key <AD03> { [ Cyrillic_u, Cyrillic_U, + 0x010004f3, 0x010004f2 ] }; + key <AD05> { [ Cyrillic_ie, Cyrillic_IE, + 0x01000115, 0x01000114 ] }; + key <AC04> { [ Cyrillic_a, Cyrillic_A, + abreve, Abreve ] }; + key <AB03> { [ Cyrillic_es, Cyrillic_ES, + ccedilla, Ccedilla ] }; + + include "level3(ralt_switch)" +}; + +partial alphanumeric_keys +xkb_symbols "udm" { + include "ru(winkeys)" + + name[Group1]= "Russia - Udmurt"; + + key.type[group1]="FOUR_LEVEL"; + + key <AE01> { [ question, exclam, 1, 1 ] }; + key <AE02> { [ parenleft, quotedbl, 2, 2 ] }; + key <AE03> { [ parenright, numerosign, 3, 3 ] }; + key <AE04> { [ colon, semicolon, 4, 4 ] }; + key <AE05> { [ asterisk, percent, 5, 5 ] }; + key <AE06> { [ 0x010004dd, 0x010004dc, 6, 6 ] }; + key <AE07> { [ 0x010004e7, 0x010004e6, 7, 7 ] }; + key <AE08> { [ 0x010004f5, 0x010004f4, 8, 8 ] }; + key <AE09> { [ 0x010004e5, 0x010004e4, 9, 9 ] }; + key <AE10> { [ 0x010004df, 0x010004de, 0, 0 ] }; + + include "level3(ralt_switch)" +}; + +partial alphanumeric_keys +xkb_symbols "cv_latin" { + include "us(alt-intl)" + + name[Group1]= "Russia - Chuvash Latin"; + + key.type[group1]="FOUR_LEVEL"; + + key <AD01> { [ q, Q, 0x01000161, 0x01000160 ] }; + key <AD02> { [ w, W, udiaeresis, Udiaeresis ] }; + key <AD03> { [ e, E, 0x01000115, 0x01000114 ] }; + key <AD07> { [ u, U, udiaeresis, Udiaeresis ] }; + key <AD08> { [ i, I, 0x0100012d, 0x0100012c ] }; + key <AD09> { [ o, O, odiaeresis, Odiaeresis ] }; + key <AC01> { [ a, A, abreve, Abreve ] }; + key <AC02> { [ s, S, scedilla, Scedilla ] }; + key <AC05> { [ g, G, gbreve, Gbreve ] }; + key <AC07> { [ j, J, 0x01000131, 0x01000130 ] }; + key <AB03> { [ c, C, ccedilla, Ccedilla ] }; + + include "level3(ralt_switch)" + +}; + +// Komi language layout +// based on +// russian standard keyboard +// Vlad Shakhov <lumpen.intellectual@gmail.com> +// Last Changes 2007/10/23 by Vlad Shakhov <lumpen.intellectual@gmail.com> + +partial alphanumeric_keys +xkb_symbols "kom" { + + include "ru(winkeys)" + + name[Group1]= "Russia - Komi"; + + key.type[group1]="FOUR_LEVEL_ALPHABETIC"; + +// cyrilllic o with diaeresis + key <AC07> { [ Cyrillic_o, Cyrillic_O, + U04E7, U04E6 ] }; + +// hard I as additional key for soft Cyrillic_I + key <AB05> { [ Cyrillic_i, Cyrillic_I, + Ukrainian_i, Ukrainian_I ] }; + + include "level3(ralt_switch)" +}; + +// Yakut language layout +// 2008/04/23 Yakov Aleksandrov <bertjickty@yandex.ru> +// 2008/04/23 Anatoliy Zhozhikov <jav@sitc.ru> +// 2008/04/23 Aleksandr Varlamov +partial alphanumeric_keys +xkb_symbols "sah" { + + include "ru(winkeys)" + + name[Group1]= "Russia - Yakut"; + + key.type[group1]="FOUR_LEVEL_ALPHABETIC"; + + key <TLDE> { [ Cyrillic_io, Cyrillic_IO, + U04EB, U04EA ] }; + key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI, + U048B, U048A ] }; + key <AD03> { [ Cyrillic_u, Cyrillic_U, + Cyrillic_u_straight, Cyrillic_U_straight ] }; + key <AD04> { [ Cyrillic_ka, Cyrillic_KA, + U04C4, U04C3 ] }; + key <AD06> { [ Cyrillic_en, Cyrillic_EN, + U04A5, U04A4 ] }; + key <AD07> { [ Cyrillic_ghe, Cyrillic_GHE, + U0495, U0494 ] }; + key <AD10> { [ Cyrillic_ze, Cyrillic_ZE, + U04E1, U04E0 ] }; + key <AD11> { [ Cyrillic_ha, Cyrillic_HA, + Cyrillic_shha, Cyrillic_SHHA ] }; + key <AC07> { [ Cyrillic_o, Cyrillic_O, + Cyrillic_o_bar, Cyrillic_O_bar ] }; + key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE, + U0461, U0460 ] }; + key <AB02> { [ Cyrillic_che, Cyrillic_CHE, + Cyrillic_u_macron, Cyrillic_U_macron ] }; + key <AB04> { [ Cyrillic_em, Cyrillic_EM, + U04C8, U04C7 ] }; + key <AB05> { [ Cyrillic_i, Cyrillic_I, + Cyrillic_i_macron, Cyrillic_I_macron ] }; + + include "level3(ralt_switch)" +}; + + +//Kalmyk language layout +//based on the Kalmyk language layout: http://soft.oyrat.org/ +//Nikolay Korneev <halmg@oyrat.org> +//Toli Miron <mirontoli@gmail.com> + +partial alphanumeric_keys +xkb_symbols "xal" { + include "ru(winkeys)" + + name[Group1]= "Russia - Kalmyk"; + + key.type[group1]="FOUR_LEVEL"; + + key <AE01> { [ question, exclam, 1 ] }; + key <AE02> { [ numerosign, quotedbl, 2 ] }; + key <AE03> { [ Cyrillic_u_straight, Cyrillic_U_straight, 3 ] }; + key <AE04> { [ Cyrillic_schwa, Cyrillic_SCHWA, 4 ] }; + key <AE05> { [ asterisk, percent, 5 ] }; + key <AE06> { [ Cyrillic_en_descender, Cyrillic_EN_descender, 6 ] }; + key <AE07> { [ Cyrillic_o_bar, Cyrillic_O_bar, 7 ] }; + key <AE08> { [ Cyrillic_shha, Cyrillic_SHHA, 8 ] }; + key <AE09> { [ Cyrillic_zhe_descender, Cyrillic_ZHE_descender, 9 ] }; + key <AE10> { [ semicolon, colon, 0 ] }; + + key <TLDE> { [ parenleft, parenright, Cyrillic_io, Cyrillic_IO ] }; + + key <AD02> { [ Cyrillic_tse, Cyrillic_TSE, dollar ] }; + key <AD03> { [ Cyrillic_u, Cyrillic_U, EuroSign ] }; + key <AD04> { [ Cyrillic_ka, Cyrillic_KA, registered ] }; + key <AD05> { [ Cyrillic_ie, Cyrillic_IE, trademark ] }; + key <AD11> { [ Cyrillic_ha, Cyrillic_HA, bracketleft ] }; + key <AD12> { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, bracketright ] }; + key <AC11> { [ Cyrillic_e, Cyrillic_E, apostrophe ] }; + key <AB03> { [ Cyrillic_es, Cyrillic_ES, copyright ] }; + key <AB08> { [ Cyrillic_be, Cyrillic_BE, less ] }; + key <AB09> { [ Cyrillic_yu, Cyrillic_YU, greater ] }; + + include "level3(ralt_switch)" +}; + +partial alphanumeric_keys +xkb_symbols "dos" { + + include "ru(common)" + + name[Group1]= "Russia - DOS"; + + key <TLDE> { [ parenright, parenleft ] }; + key <AE04> { [ 4, currency ] }; + key <AE09> { [ 9, question ] }; + key <AE10> { [ 0, percent ] }; + + key <AB10> { [ Cyrillic_io, Cyrillic_IO ] }; +}; + +partial alphanumeric_keys +xkb_symbols "bak" { + include "ru(winkeys)" + + name[Group1]= "Russia - Bashkirian"; + key.type[group1]="FOUR_LEVEL"; + + key <TLDE> { [ 0x010004d9, 0x010004d8, Cyrillic_io, Cyrillic_IO ] }; + key <AE01> { [ exclam, quotedbl, 1, 1 ] }; + key <AE02> { [ 0x010004e9, 0x010004e8, 2, 2 ] }; + key <AE03> { [ 0x010004a1, 0x010004a0, 3, 3 ] }; + key <AE04> { [ 0x01000493, 0x01000492, 4, 4 ] }; + key <AE05> { [ 0x010004ab, 0x010004aa, 5, 5 ] }; + key <AE06> { [ colon, semicolon, 6, 6 ] }; + key <AE07> { [ 0x01000499, 0x01000498, 7, 7 ] }; + key <AE08> { [ 0x010004bb, 0x010004ba, 8, 8 ] }; + key <AE09> { [ question, parenleft, 9, 9 ] }; + key <AE10> { [ numerosign, parenright, 0, 0 ] }; + key <AE11> { [ minus, percent, minus, underscore ]}; + key <AE12> { [ 0x010004af, 0x010004ae, equal, plus ]}; + key <BKSL> { [ 0x010004a3, 0x010004a2, backslash, slash ]}; + + include "level3(ralt_switch)" +}; + +// Serbian charecters added as third level symbols to Russian keyboard layout. + +partial alphanumeric_keys +xkb_symbols "srp" { + include "ru(common)" + include "level3(ralt_switch)" + + name[Group1]= "Russia - Serbian"; + + key <AE03> { [ 3, numerosign ] }; + key <AE04> { [ 4, semicolon ] }; + key <AE05> { [ 5, percent ] }; + key <AE06> { [ 6, colon ] }; + key <AE07> { [ 7, question ] }; + key <AE08> { [ 8, asterisk ] }; + key <AB10> { [ period, comma ] }; + key <BKSL> { [ backslash, slash ] }; + key <AD01> { [ Cyrillic_shorti, Cyrillic_SHORTI, U458, U408 ] }; + key <AD06> { [ Cyrillic_en, Cyrillic_EN, U45A, U40A ] }; + key <AC08> { [ Cyrillic_el, Cyrillic_EL, U459, U409 ] }; + key <AC09> { [ Cyrillic_de, Cyrillic_DE, U45F, U40F ] }; + key <AC10> { [ Cyrillic_zhe, Cyrillic_ZHE, U452, U402 ] }; + key <AB02> { [ Cyrillic_che, Cyrillic_CHE, U45B, U40B ] }; +}; + +// Mari language layout +// based on Russian standard keyboard +// http://www.marlamuter.ru/ +partial alphanumeric_keys +xkb_symbols "chm" { + include "ru(common)" + + name[Group1]= "Russia - Mari"; + + key.type[group1]="FOUR_LEVEL_ALPHABETIC"; + key <AC04> { [ Cyrillic_a, Cyrillic_A, U04D3, U04D2 ] }; + key <AD03> { [ Cyrillic_u, Cyrillic_U, U04F1, U04F0 ] }; + key <AC02> { [ Cyrillic_ui, Cyrillic_UI, U04F9, U04F8 ] }; + key <AD06> { [ Cyrillic_n, Cyrillic_N, U04A5, U04A4 ] }; + key <AC11> { [ Cyrillic_e, Cyrillic_E, U04E9, U04E8 ] }; + key <AC10> { [ Cyrillic_zh, Cyrillic_ZH, U04EB, U04EA ] }; + key <AC01> { [ Cyrillic_f, Cyrillic_F, UF537, UF536 ] }; + + include "level3(ralt_switch)" +}; diff --git a/xorg-server/xkeyboard-config/symbols/us b/xorg-server/xkeyboard-config/symbols/us index 2d9523922..092fb747d 100644 --- a/xorg-server/xkeyboard-config/symbols/us +++ b/xorg-server/xkeyboard-config/symbols/us @@ -1,1194 +1,1196 @@ -// $XKeyboardConfig$
-
-//
-// $XdotOrg: xc/programs/xkbcomp/symbols/us,v 1.1.4.3 2004/03/05 13:41:33 eich Exp $
-// $XFree86: xc/programs/xkbcomp/symbols/us,v 1.6 2003/10/31 14:32:05 pascal Exp $
-
-default
-partial alphanumeric_keys modifier_keys
-xkb_symbols "basic" {
-
- name[Group1]= "USA";
-
- // 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, question ] };
-
- key <BKSL> { [ backslash, bar ] };
- // End alphanumeric section
-};
-
-partial alphanumeric_keys
-xkb_symbols "euro" {
-
- name[Group1]= "USA - With EuroSign on 5";
-
- include "us(basic)"
-
- include "eurosign(5)"
-
- include "level3(ralt_switch)"
-};
-
-
-partial alphanumeric_keys
-xkb_symbols "intl" {
-
- name[Group1]= "USA - International (with dead keys)";
-
- include "us(basic)"
-
- // Alphanumeric section
- key <TLDE> { [dead_grave, dead_tilde, grave, asciitilde ] };
- key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
- key <AE02> { [ 2, at, twosuperior, dead_doubleacute ] };
- key <AE03> { [ 3, numbersign, threesuperior, dead_macron ] };
- key <AE04> { [ 4, dollar, currency, sterling ] };
- key <AE05> { [ 5, percent, EuroSign, dead_cedilla ] };
- key <AE06> { [ 6, dead_circumflex, onequarter, asciicircum ] };
- key <AE07> { [ 7, ampersand, onehalf, dead_horn ] };
- key <AE08> { [ 8, asterisk, threequarters, dead_ogonek ] };
- key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] };
- key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] };
- key <AE11> { [ minus, underscore, yen, dead_belowdot ] };
- key <AE12> { [ equal, plus, multiply, division ] };
-
- key <AD01> { [ q, Q, adiaeresis, Adiaeresis ] };
- key <AD02> { [ w, W, aring, Aring ] };
- key <AD03> { [ e, E, eacute, Eacute ] };
- key <AD04> { [ r, R, registered, registered ] };
- key <AD05> { [ t, T, thorn, THORN ] };
- key <AD06> { [ y, Y, udiaeresis, Udiaeresis ] };
- key <AD07> { [ u, U, uacute, Uacute ] };
- key <AD08> { [ i, I, iacute, Iacute ] };
- key <AD09> { [ o, O, oacute, Oacute ] };
- key <AD10> { [ p, P, odiaeresis, Odiaeresis ] };
- key <AD11> { [ bracketleft, braceleft, guillemotleft, leftdoublequotemark ] };
- key <AD12> { [bracketright, braceright, guillemotright, rightdoublequotemark ] };
-
- key <AC01> { [ a, A, aacute, Aacute ] };
- key <AC02> { [ s, S, ssharp, section ] };
- key <AC03> { [ d, D, eth, ETH ] };
- key <AC04> { [ f, F, f, F ] };
- key <AC05> { [ g, G, g, G ] };
- key <AC06> { [ h, H, h, H ] };
- key <AC07> { [ j, J, j, J ] };
- key <AC08> { [ k, K, oe, OE ] };
-
- key <AC09> { [ l, L, oslash, Ooblique ] };
- key <AC10> { [ semicolon, colon, paragraph, degree ] };
- key <AC11> { [dead_acute, dead_diaeresis, apostrophe, quotedbl ] };
-
- key <AB01> { [ z, Z, ae, AE ] };
- key <AB02> { [ x, X, x, X ] };
- key <AB03> { [ c, C, copyright, cent ] };
- key <AB04> { [ v, V, v, V ] };
- key <AB05> { [ b, B, b, B ] };
- key <AB06> { [ n, N, ntilde, Ntilde ] };
- key <AB07> { [ m, M, mu, mu ] };
- key <AB08> { [ comma, less, ccedilla, Ccedilla ] };
- key <AB09> { [ period, greater, dead_abovedot, dead_caron ] };
- key <AB10> { [ slash, question, questiondown, dead_hook ] };
- key <BKSL> { [ backslash, bar, notsign, brokenbar ] };
-
- include "level3(ralt_switch)"
-};
-
-// Based on symbols/us_intl keyboard map:
-// Dead-keys definition for a very simple US/ASCII layout.
-// by Conectiva (http://www.conectiva.com.br)
-// modified by Ricardo Y. Igarashi (iga@that.com.br)
-
-// Added the following deadkeys, to make it truly international:
-//
-// dead_macron: on AltGr-minus
-// dead_breve: on AltGr-parenleft
-// dead_abovedot: on AltGr-period
-// dead_abovering: on AltGr-0
-// dead_doubleacute: on AltGr-equal (as quotedbl is already used)
-// dead_caron: on AltGr-less (AltGr-shift-comma)
-// dead_cedilla: on AltGr-comma
-// dead_ogonek: on AltGr-semicolon
-// dead_belowdot: on AltGr-underscore (AltGr-shift-minus)
-// dead_hook: on AltGr-question
-// dead_horn: on AltGr-plus (AltGr-shift-equal)
-// dead_diaeresis: on AltGr-colon (Alt-shift-semicolon)
-//
-// those were already there:
-// dead_grave
-// dead_acute
-// dead_circumflex
-// dead_tilde
-// dead_diaeresis
-
-partial alphanumeric_keys
-xkb_symbols "alt-intl" {
-
- name[Group1]= "USA - Alternative international";
-
- include "us"
-
- key <TLDE> { [ dead_grave, dead_tilde, grave, asciitilde ] };
- key <AE05> { [ 5, percent, EuroSign ] };
- key <AE06> { [ 6, dead_circumflex, asciicircum, asciicircum ] };
- key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] };
- key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] };
- key <AE11> { [ minus, underscore, dead_macron, dead_belowdot ] };
- key <AE12> { [ equal, plus, dead_doubleacute, dead_horn ] };
-
- key <AD03> { [ e, E, EuroSign, cent ] };
-
- key <AC10> { [ semicolon, colon, dead_ogonek, dead_diaeresis ] };
- key <AC11> { [ dead_acute, dead_diaeresis, apostrophe, quotedbl ] };
-
- key <AB08> { [ comma, less, dead_cedilla, dead_caron ] };
- key <AB09> { [ period, greater, dead_abovedot, dead_circumflex ] };
- key <AB10> { [ slash, question, dead_hook, dead_hook ] };
-
- include "level3(ralt_switch)"
-};
-
-// based on a keyboard map from an 'xkb/symbols/dk' file
-//
-// $XFree86: xc/programs/xkbcomp/symbols/dvorak,v 1.5 2004/01/03 16:35:07 herrb Exp $
-
-partial alphanumeric_keys
-xkb_symbols "dvorak" {
-
- name[Group1]= "USA - Dvorak";
-
- // Alphanumeric section
-
- key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
-
- key <AE01> { [ 1, exclam ] };
- key <AE02> { [ 2, at ] };
- key <AE03> { [ 3, numbersign ] };
- key <AE04> { [ 4, dollar ] };
- key <AE05> { [ 5, percent ] };
- key <AE06> { [ 6, asciicircum, dead_circumflex, dead_circumflex ] };
- key <AE07> { [ 7, ampersand ] };
- key <AE08> { [ 8, asterisk ] };
- key <AE09> { [ 9, parenleft, dead_grave] };
- key <AE10> { [ 0, parenright ] };
- key <AE11> { [ bracketleft, braceleft ] };
- key <AE12> { [ bracketright, braceright, dead_tilde] };
-
- key <AD01> { [ apostrophe, quotedbl, dead_acute, dead_diaeresis ] };
- key <AD02> { [ comma, less, dead_cedilla, dead_caron ] };
- key <AD03> { [ period, greater, dead_abovedot, periodcentered ] };
- key <AD04> { [ p, P ] };
- key <AD05> { [ y, Y ] };
- key <AD06> { [ f, F ] };
- key <AD07> { [ g, G ] };
- key <AD08> { [ c, C ] };
- key <AD09> { [ r, R ] };
- key <AD10> { [ l, L ] };
- key <AD11> { [ slash, question ] };
- key <AD12> { [ equal, plus ] };
-
- key <AC01> { [ a, A ] };
- key <AC02> { [ o, O ] };
- key <AC03> { [ e, E ] };
- key <AC04> { [ u, U ] };
- key <AC05> { [ i, I ] };
- key <AC06> { [ d, D ] };
- key <AC07> { [ h, H ] };
- key <AC08> { [ t, T ] };
- key <AC09> { [ n, N ] };
- key <AC10> { [ s, S ] };
- key <AC11> { [ minus, underscore ] };
-
- key <AB01> { [ semicolon, colon, dead_ogonek, dead_doubleacute ] };
- key <AB02> { [ q, Q ] };
- key <AB03> { [ j, J ] };
- key <AB04> { [ k, K ] };
- key <AB05> { [ x, X ] };
- key <AB06> { [ b, B ] };
- key <AB07> { [ m, M ] };
- key <AB08> { [ w, W ] };
- key <AB09> { [ v, V ] };
- key <AB10> { [ z, Z ] };
-
- key <BKSL> { [ backslash, bar ] };
-};
-
-// Dvorak international with dead keys
-// Olivier Mehani (shtrom-xorg@ssji.net)
-// Reproduce the per-key mapping of us(intl) for the dvorak layout
-// aka "I just swapped my keys over"
-partial alphanumeric_keys
-xkb_symbols "dvorak-intl" {
-
- name[Group1]= "USA - Dvorak international (with dead keys)";
-
- include "us(dvorak)"
-
- key <TLDE> { [dead_grave, dead_tilde, grave, asciitilde ] };
-
- key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
- key <AE02> { [ 2, at, twosuperior, dead_doubleacute ] };
- key <AE03> { [ 3, numbersign, threesuperior, dead_macron ] };
- key <AE04> { [ 4, dollar, currency, sterling ] };
- key <AE05> { [ 5, percent, EuroSign, dead_cedilla ] };
- key <AE06> { [ 6, dead_circumflex, onequarter, asciicircum ] };
- key <AE07> { [ 7, ampersand, onehalf, dead_horn ] };
- key <AE08> { [ 8, asterisk, threequarters, dead_ogonek ] };
- key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] };
- key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] };
- key <AE11> { [ bracketleft, braceleft, guillemotleft, leftdoublequotemark ] };
- key <AE12> { [bracketright, braceright, guillemotright, rightdoublequotemark ] };
-
- key <AD01> { [dead_acute, dead_diaeresis, apostrophe, quotedbl ] };
- key <AD02> { [ comma, less, ccedilla, Ccedilla ] };
- key <AD03> { [ period, greater, dead_abovedot, dead_caron ] };
- key <AD04> { [ p, P, odiaeresis, Odiaeresis ] };
- key <AD05> { [ y, Y, udiaeresis, Udiaeresis ] };
- // key <AD06> { [ f, F ] };
- // key <AD07> { [ g, G ] };
- key <AD08> { [ c, C, copyright, cent ] };
- key <AD09> { [ r, R, registered, registered ] };
- key <AD10> { [ l, L, oslash, Ooblique ] };
- key <AD11> { [ slash, question, questiondown, dead_hook ] };
- // key <AD12> { [ equal, plus, multiply, division ] };
-
- key <AC01> { [ a, A, aacute, Aacute ] };
- key <AC02> { [ o, O, oacute, Oacute ] };
- key <AC03> { [ e, E, eacute, Eacute ] };
- key <AC04> { [ u, U, uacute, Uacute ] };
- key <AC05> { [ i, I, iacute, Iacute ] };
- key <AC06> { [ d, D, eth, ETH ] };
- // key <AC07> { [ h, H ] };
- key <AC08> { [ t, T, thorn, THORN ] };
- key <AC09> { [ n, N, ntilde, Ntilde ] };
- key <AC10> { [ s, S, ssharp, section ] };
- // key <AC11> { [ minus, underscore, yen, dead_belowdot ] };
-
- key <AB01> { [ semicolon, colon, paragraph, degree ] };
- key <AB02> { [ q, Q, adiaeresis, Adiaeresis ] };
- // key <AB03> { [ j, J ] };
- key <AB04> { [ k, K, oe, OE ] };
- // key <AB05> { [ x, X ] };
- // key <AB06> { [ b, B ] };
- key <AB07> { [ m, M, mu, mu ] };
- key <AB08> { [ w, W, aring, Aring ] };
- // key <AB09> { [ v, V ] };
- key <AB10> { [ z, Z, ae, AE ] };
-
- key <BKSL> { [ backslash, bar, notsign, brokenbar ] };
-
- include "level3(ralt_switch)"
-};
-
-// Dvorak international without dead keys
-// Stephane Magnenat (stephane at magnenat dot net, http://stephane.magnenat.net)
-// Based on information from http://www.poupinou.org/dvorak/index.html
-//
-// ` 1 2 3 4 5 6 7 8 9 0 [ ] \
-// €
-//
-// ' , . p y f g c r l / =
-// ä ê ë ü ç
-//
-// a o e u i d h t n s -
-// à ô é û î ß
-//
-// ; q j k x b m w v z
-// â ö è ù ï
-
-partial alphanumeric_keys
-xkb_symbols "dvorak-alt-intl" {
-
- name[Group1]= "USA - Dvorak alternative international (no dead keys)";
-
- include "us(dvorak)"
-
- key <AE04> { [ 4, dollar, EuroSign ] };
-
- key <AD02> { [ comma, less, adiaeresis, dead_caron ] };
- key <AD03> { [ period, greater, ecircumflex, periodcentered ] };
- key <AD04> { [ p, P, ediaeresis, dead_cedilla ] };
- key <AD05> { [ y, Y, udiaeresis ] };
- key <AD08> { [ c, C, ccedilla, dead_abovedot ] };
-
- key <AC01> { [ a, A, agrave ] };
- key <AC02> { [ o, O, ocircumflex ] };
- key <AC03> { [ e, E, eacute ] };
- key <AC04> { [ u, U, ucircumflex ] };
- key <AC05> { [ i, I, icircumflex ] };
- key <AC10> { [ s, S, ssharp ] };
-
- key <AB01> { [ semicolon, colon, acircumflex ] };
- key <AB02> { [ q, Q, odiaeresis, dead_ogonek ] };
- key <AB03> { [ j, J, egrave, dead_doubleacute ] };
- key <AB04> { [ k, K, ugrave ] };
- key <AB05> { [ x, X, idiaeresis ] };
-
- include "level3(ralt_switch)"
-};
-
-// Left and right handed dvorak layouts
-// by sqweek <sqweek@gmail.com> 2006-01-30
-// Based on the corresponding layouts in the console-tools package.
-partial alphanumeric_keys
-xkb_symbols "dvorak-l" {
-
- include "us(dvorak)"
- name[Group1]= "USA - Left handed Dvorak";
-
- key <AE01> { [ bracketleft, braceleft ] };
- key <AE02> { [ bracketright, braceright ] };
- key <AE03> { [ slash, question ] };
- key <AE04> { [ p, P ] };
- key <AE05> { [ f, F ] };
- key <AE06> { [ m, M ] };
- key <AE07> { [ l, L ] };
- key <AE08> { [ j, J ] };
- key <AE09> { [ 4, dollar ] };
- key <AE10> { [ 3, numbersign ] };
- key <AE11> { [ 2, at ] };
- key <AE12> { [ 1, exclam ] };
-
- key <AD01> { [ semicolon, colon ] };
- key <AD02> { [ q, Q ] };
- key <AD03> { [ b, B ] };
- key <AD04> { [ y, Y ] };
- key <AD05> { [ u, U ] };
- key <AD06> { [ r, R ] };
- key <AD07> { [ s, S ] };
- key <AD08> { [ o, O ] };
- key <AD09> { [ period, greater ] };
- key <AD10> { [ 6, asciicircum ] };
- key <AD11> { [ 5, percent ] };
- key <AD12> { [ equal, plus ] };
-
- key <AC01> { [ minus, underscore ] };
- key <AC02> { [ k, K ] };
- key <AC03> { [ c, C ] };
- key <AC04> { [ d, D ] };
- key <AC05> { [ t, T ] };
- key <AC06> { [ h, H ] };
- key <AC07> { [ e, E ] };
- key <AC08> { [ a, A ] };
- key <AC09> { [ z, Z ] };
- key <AC10> { [ 8, asterisk ] };
- key <AC11> { [ 7, ampersand ] };
-
- key <AB01> { [ apostrophe, quotedbl ] };
- key <AB02> { [ x, X ] };
- key <AB03> { [ g, G ] };
- key <AB04> { [ v, V ] };
- key <AB05> { [ w, W ] };
- key <AB06> { [ n, N ] };
- key <AB07> { [ i, I ] };
- key <AB08> { [ comma, less ] };
- key <AB09> { [ 0, parenright ] };
- key <AB10> { [ 9, parenleft ] };
-};
-
-partial alphanumeric_keys
-xkb_symbols "dvorak-r" {
-
- include "us(dvorak)"
- name[Group1]= "USA - Right handed Dvorak";
-
- key <AE01> { [ 1, exclam ] };
- key <AE02> { [ 2, at ] };
- key <AE03> { [ 3, numbersign ] };
- key <AE04> { [ 4, dollar ] };
- key <AE05> { [ j, J ] };
- key <AE06> { [ l, L ] };
- key <AE07> { [ m, M ] };
- key <AE08> { [ f, F ] };
- key <AE09> { [ p, P ] };
- key <AE10> { [ slash, question ] };
- key <AE11> { [ bracketleft, braceleft ] };
- key <AE12> { [ bracketright, braceright ] };
-
- key <AD01> { [ 5, percent ] };
- key <AD02> { [ 6, asciicircum ] };
- key <AD03> { [ q, Q ] };
- key <AD04> { [ period, greater ] };
- key <AD05> { [ o, O ] };
- key <AD06> { [ r, R ] };
- key <AD07> { [ s, S ] };
- key <AD08> { [ u, U ] };
- key <AD09> { [ y, Y ] };
- key <AD10> { [ b, B ] };
- key <AD11> { [ semicolon, colon ] };
- key <AD12> { [ equal, plus ] };
-
- key <AC01> { [ 7, ampersand ] };
- key <AC02> { [ 8, asterisk ] };
- key <AC03> { [ z, Z ] };
- key <AC04> { [ a, A ] };
- key <AC05> { [ e, E ] };
- key <AC06> { [ h, H ] };
- key <AC07> { [ t, T ] };
- key <AC08> { [ d, D ] };
- key <AC09> { [ c, C ] };
- key <AC10> { [ k, K ] };
- key <AC11> { [ minus, underscore ] };
-
- key <AB01> { [ 9, parenleft ] };
- key <AB02> { [ 0, parenright ] };
- key <AB03> { [ x, X ] };
- key <AB04> { [ comma, less ] };
- key <AB05> { [ i, I ] };
- key <AB06> { [ n, N ] };
- key <AB07> { [ w, W ] };
- key <AB08> { [ v, V ] };
- key <AB09> { [ g, G ] };
- key <AB10> { [ apostrophe, quotedbl ] };
-};
-
-// Classic dvorak layout
-// by Piter Punk <piterpk@terra.com.br> - 2006-07-06
-// Based on dvorak layout and e-mail from Russel L. Harris rlharris@oplink.net
-// on xorg list.
-partial alphanumeric_keys
-xkb_symbols "dvorak-classic" {
-
- name[Group1]= "USA - Classic Dvorak";
-
- // Alphanumeric section
-
- key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
-
- key <AE01> { [ bracketleft, braceleft ] };
- key <AE02> { [ 7, ampersand ] };
- key <AE03> { [ 5, percent ] };
- key <AE04> { [ 3, numbersign ] };
- key <AE05> { [ 1, exclam ] };
- key <AE06> { [ 9, parenleft, dead_grave] };
- key <AE07> { [ 0, parenright ] };
- key <AE08> { [ 2, at ] };
- key <AE09> { [ 4, dollar ] };
- key <AE10> { [ 6, asciicircum, dead_circumflex, dead_circumflex ] };
- key <AE11> { [ 8, asterisk ] };
- key <AE12> { [ bracketright, braceright, dead_tilde] };
-
- key <AD01> { [ slash, question ] };
- key <AD02> { [ comma, less, dead_cedilla, dead_caron ] };
- key <AD03> { [ period, greater, dead_abovedot, periodcentered ] };
- key <AD04> { [ p, P ] };
- key <AD05> { [ y, Y ] };
- key <AD06> { [ f, F ] };
- key <AD07> { [ g, G ] };
- key <AD08> { [ c, C ] };
- key <AD09> { [ r, R ] };
- key <AD10> { [ l, L ] };
- key <AD11> { [ apostrophe, quotedbl, dead_acute, dead_diaeresis ] };
- key <AD12> { [ equal, plus ] };
-
- key <AC01> { [ a, A ] };
- key <AC02> { [ o, O ] };
- key <AC03> { [ e, E ] };
- key <AC04> { [ u, U ] };
- key <AC05> { [ i, I ] };
- key <AC06> { [ d, D ] };
- key <AC07> { [ h, H ] };
- key <AC08> { [ t, T ] };
- key <AC09> { [ n, N ] };
- key <AC10> { [ s, S ] };
- key <AC11> { [ minus, underscore ] };
-
- key <AB01> { [ semicolon, colon, dead_ogonek, dead_doubleacute ] };
- key <AB02> { [ q, Q ] };
- key <AB03> { [ j, J ] };
- key <AB04> { [ k, K ] };
- key <AB05> { [ x, X ] };
- key <AB06> { [ b, B ] };
- key <AB07> { [ m, M ] };
- key <AB08> { [ w, W ] };
- key <AB09> { [ v, V ] };
- key <AB10> { [ z, Z ] };
- key <BKSL> { [ backslash, bar ] };
-};
-
-// Programmer Dvorak, by Roland Kaufmann <rlndkfmn at gmail dot com>
-// License: BSD, available at <http://www.kaufmann.no/roland/dvorak/license.html>
-// Main features: Numbers are in shift position (like French), symbols have been
-// placed in locations that give good hand-alternation and finger rolling with
-// symbols that usually follows, accented characters are possible for I18N.
-partial alphanumeric_keys
-xkb_symbols "dvp" {
- include "us(dvorak)"
-
- name[Group1] = "USA - Programmer Dvorak";
-
- // Unmodified Shift AltGr Shift+AltGr
- // symbols row, left side
- key <TLDE> { [ dollar, asciitilde, dead_tilde ] };
- key <AE01> { [ ampersand, percent ] };
- key <AE02> { [ bracketleft, 7, currency ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE03> { [ braceleft, 5, cent ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE04> { [ braceright, 3, yen ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE05> { [ parenleft, 1, EuroSign ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE06> { [ equal, 9, sterling ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
-
- // symbols row, right side
- key <AE07> { [ asterisk, 0 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE08> { [ parenright, 2, onehalf ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE09> { [ plus, 4 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE10> { [ bracketright, 6 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE11> { [ exclam, 8, exclamdown ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <AE12> { [ numbersign, grave, dead_grave ] };
- key <BKSP> { [ BackSpace ] };
-
- // upper row, left side
- key <AD01> { [ semicolon, colon, dead_diaeresis ] };
- key <AD02> { [ comma, less, guillemotleft ] };
- key <AD03> { [ period, greater, guillemotright ] };
- key <AD04> { [ p, P, paragraph, section ] };
- key <AD05> { [ y, Y, udiaeresis, Udiaeresis ] };
-
- // upper row, right side
- key <AD08> { [ c, C, ccedilla, Ccedilla ] };
- key <AD09> { [ r, R, registered, trademark ] };
- key <AD11> { [ slash, question, questiondown ] };
- key <AD12> { [ at, asciicircum, dead_circumflex, dead_caron ] };
-
- // home row, left side
- key <AC01> { [ a, A, aring, Aring ] };
- key <AC02> { [ o, O, oslash, Ooblique ] };
- key <AC03> { [ e, E, ae, AE ] };
- key <AC04> { [ u, U, eacute, Eacute ] };
-
- // home row, right side
- key <AC06> { [ d, D, eth, ETH ] };
- key <AC07> { [ h, H, dead_acute ] };
- key <AC08> { [ t, T, thorn, THORN ] };
- key <AC09> { [ n, N, ntilde, Ntilde ] };
- key <AC10> { [ s, S, ssharp ] };
- key <AC11> { [ minus, underscore, hyphen ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
- key <BKSL> { [ backslash, bar ] };
-
- // lower row, left side
- key <AB01> { [ apostrophe, quotedbl, dead_acute ] };
-};
-
-// phonetic layout for Russian letters on an US keyboard
-// by Ivan Popov <pin@konvalo.org> 2005-07-17
-
-// level3 modifier is a shortcut to the "us" meaning of the keys where
-// we place cyrillic letters, handy for accessing the corresponding
-// punctuation marks.
-// It is important to have access to punctuation marks, and the rest of
-// alphabetical keys are added for being consequent so that the users
-// can expect the level3 modifier to give what the key label shows.
-
-partial alphanumeric_keys
-xkb_symbols "rus" {
-
- name[Group1]= "USA - Russian phonetic";
-
- include "us(basic)"
-
-key.type[group1]="FOUR_LEVEL_ALPHABETIC";
-
- key <LatA> { [ Cyrillic_a, Cyrillic_A ] };
- key <LatB> { [ Cyrillic_be, Cyrillic_BE ] };
- key <LatW> { [ Cyrillic_ve, Cyrillic_VE ] };
- key <LatG> { [ Cyrillic_ghe, Cyrillic_GHE ] };
- key <LatD> { [ Cyrillic_de, Cyrillic_DE ] };
- key <LatE> { [ Cyrillic_ie, Cyrillic_IE ] };
- key <TLDE> { [ Cyrillic_io, Cyrillic_IO, grave, asciitilde ] };
- key <LatV> { [ Cyrillic_zhe, Cyrillic_ZHE ] };
- key <LatZ> { [ Cyrillic_ze, Cyrillic_ZE ] };
- key <LatI> { [ Cyrillic_i, Cyrillic_I ] };
- key <LatJ> { [ Cyrillic_shorti, Cyrillic_SHORTI ] };
- key <LatK> { [ Cyrillic_ka, Cyrillic_KA ] };
- key <LatL> { [ Cyrillic_el, Cyrillic_EL ] };
- key <LatM> { [ Cyrillic_em, Cyrillic_EM ] };
- key <LatN> { [ Cyrillic_en, Cyrillic_EN ] };
- key <LatO> { [ Cyrillic_o, Cyrillic_O ] };
- key <LatP> { [ Cyrillic_pe, Cyrillic_PE ] };
- key <LatR> { [ Cyrillic_er, Cyrillic_ER ] };
- key <LatS> { [ Cyrillic_es, Cyrillic_ES ] };
- key <LatT> { [ Cyrillic_te, Cyrillic_TE ] };
- key <LatU> { [ Cyrillic_u, Cyrillic_U ] };
- key <LatF> { [ Cyrillic_ef, Cyrillic_EF ] };
- key <LatH> { [ Cyrillic_ha, Cyrillic_HA ] };
- key <LatC> { [ Cyrillic_tse, Cyrillic_TSE ] };
- key <AC10> { [ Cyrillic_che, Cyrillic_CHE, semicolon, colon ] };
- key <AD11> { [ Cyrillic_sha, Cyrillic_SHA, bracketleft, braceleft] };
- key <AD12> { [ Cyrillic_shcha, Cyrillic_SHCHA, bracketright, braceright ] };
- key <AE12> { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, equal, plus ] };
- key <LatY> { [ Cyrillic_yeru, Cyrillic_YERU ] };
- key <LatX> { [ Cyrillic_softsign, Cyrillic_SOFTSIGN ] };
- key <BKSL> { [ Cyrillic_e, Cyrillic_E, backslash, bar ] };
- key <AC11> { [ Cyrillic_yu, Cyrillic_YU, apostrophe, quotedbl ] };
- key <LatQ> { [ Cyrillic_ya, Cyrillic_YA ] };
-
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "mac" {
-
- include "us(basic)"
- name[Group1]= "USA - Macintosh";
- key.type[group1]="FOUR_LEVEL";
-
- // Slightly improvised from http://homepage.mac.com/thgewecke/kblayout.jpg
- key <LSGT> { [ section, plusminus, section, plusminus ] };
- key <TLDE> { [ grave, asciitilde, dead_grave, dead_horn ] };
- key <AE01> { [ 1, exclam, exclamdown, U2044 ] };
- key <AE02> { [ 2, at, trademark, EuroSign ] };
- key <AE03> { [ 3, numbersign, sterling, U2039 ] };
- key <AE04> { [ 4, dollar, cent, U203A ] };
- key <AE05> { [ 5, percent, infinity, UFB01 ] };
- key <AE06> { [ 6,asciicircum, section, UFB02 ] };
- key <AE07> { [ 7, ampersand, paragraph, doubledagger ] };
- key <AE08> { [ 8, asterisk, enfilledcircbullet, degree ] };
- key <AE09> { [ 9, parenleft, ordfeminine, periodcentered ] };
- key <AE10> { [ 0, parenright, masculine,singlelowquotemark] };
- key <AE11> { [ minus, underscore, endash, emdash ] };
- key <AE12> { [ equal, plus, notequal, plusminus ] };
-
- key <AD01> { [ q, Q, oe, OE ] };
- key <AD02> { [ w, W, U2211,doublelowquotemark] };
- key <AD03> { [ e, E, dead_acute, acute ] };
- key <AD04> { [ r, R, registered, U2030 ] };
- key <AD05> { [ t, T, dagger, dead_caron ] };
- key <AD06> { [ y, Y, yen, onequarter ] };
- key <AD07> { [ u, U, dead_diaeresis, diaeresis ] };
- key <AD08> { [ i, I, dead_circumflex, U02C6 ] };
- key <AD09> { [ o, O, oslash, Ooblique ] };
- key <AD10> { [ p, P, Greek_pi, U220F ] };
- key <AD11> { [ bracketleft, braceleft, leftdoublequotemark, rightdoublequotemark ] };
- key <AD12> { [bracketright, braceright, leftsinglequotemark, rightsinglequotemark ] };
- key <BKSL> { [ backslash, bar, guillemotleft, guillemotright ] };
-
- key <AC01> { [ a, A, aring, Aring ] };
- key <AC02> { [ s, S, ssharp, dead_stroke ] };
- key <AC03> { [ d, D, partialderivative, eth ] };
- key <AC04> { [ f, F, function, dead_hook ] };
- key <AC05> { [ g, G, copyright, dead_doubleacute ] };
- key <AC06> { [ h, H, dead_abovedot, dead_belowdot ] };
- key <AC07> { [ j, J, U2206, onehalf ] };
- key <AC08> { [ k, K,dead_abovering, UF8FF ] };
-
- key <AC09> { [ l, L, notsign, THORN ] };
- key <AC10> { [ semicolon, colon, U2026, thorn ] };
- key <AC11> { [apostrophe, quotedbl, ae, AE ] };
-
- key <AB01> { [ z, Z, Greek_OMEGA, dead_cedilla ] };
- key <AB02> { [ x, X, U2248, dead_ogonek ] };
- // unclear whether "approxeq" is 2248 or 2245
- key <AB03> { [ c, C, ccedilla, Ccedilla ] };
- key <AB04> { [ v, V, squareroot, U25CA ] };
- key <AB05> { [ b, B, integral, idotless ] };
- key <AB06> { [ n, N, dead_tilde, U02DC ] };
- key <AB07> { [ m, M, mu, threequarters ] };
- key <AB08> { [ comma, less, lessthanequal, dead_macron ] };
- key <AB09> { [ period, greater, greaterthanequal, dead_breve ] };
- key <AB10> { [ slash, question, division, questiondown ] };
-
- include "level3(ralt_switch)"
-};
-
-// Colemak symbols for xkb on X.Org Server 7.x
-// 2006-01-01 Shai Coleman, http://colemak.com/ . Public domain.
-
-partial alphanumeric_keys
-xkb_symbols "colemak" {
- include "us"
- name[Group1]= "USA - Colemak";
-
- // Alphanumeric section
- key <TLDE> { [ grave, asciitilde, dead_tilde, asciitilde ] };
- key <AE01> { [ 1, exclam, exclamdown, onesuperior ] };
- key <AE02> { [ 2, at, masculine, twosuperior ] };
- key <AE03> { [ 3, numbersign, ordfeminine, threesuperior ] };
- key <AE04> { [ 4, dollar, cent, sterling ] };
- key <AE05> { [ 5, percent, EuroSign, yen ] };
- key <AE06> { [ 6, asciicircum, hstroke, Hstroke ] };
- key <AE07> { [ 7, ampersand, eth, ETH ] };
- key <AE08> { [ 8, asterisk, thorn, THORN ] };
- key <AE09> { [ 9, parenleft, leftsinglequotemark, leftdoublequotemark ] };
- key <AE10> { [ 0, parenright, rightsinglequotemark, rightdoublequotemark ] };
- key <AE11> { [ minus, underscore, endash, emdash ] };
- key <AE12> { [ equal, plus, multiply, division ] };
-
- key <AD01> { [ q, Q, adiaeresis, Adiaeresis ] };
- key <AD02> { [ w, W, aring, Aring ] };
- key <AD03> { [ f, F, atilde, Atilde ] };
- key <AD04> { [ p, P, oslash, Ooblique ] };
- key <AD05> { [ g, G, dead_ogonek, asciitilde ] };
- key <AD06> { [ j, J, dstroke, Dstroke ] };
- key <AD07> { [ l, L, lstroke, Lstroke ] };
- key <AD08> { [ u, U, uacute, Uacute ] };
- key <AD09> { [ y, Y, udiaeresis, Udiaeresis ] };
- key <AD10> { [ semicolon, colon, odiaeresis, Odiaeresis ] };
- key <AD11> { [ bracketleft, braceleft, guillemotleft, 0x1002039 ] };
- key <AD12> { [ bracketright, braceright, guillemotright, 0x100203a ] };
- key <BKSL> { [ backslash, bar, asciitilde, asciitilde ] };
-
- key <AC01> { [ a, A, aacute, Aacute ] };
- key <AC02> { [ r, R, dead_grave, asciitilde ] };
- key <AC03> { [ s, S, ssharp, asciitilde ] };
- key <AC04> { [ t, T, dead_acute, dead_doubleacute ] };
- key <AC05> { [ d, D, dead_diaeresis, asciitilde ] };
- key <AC06> { [ h, H, dead_caron, asciitilde ] };
- key <AC07> { [ n, N, ntilde, Ntilde ] };
- key <AC08> { [ e, E, eacute, Eacute ] };
- key <AC09> { [ i, I, iacute, Iacute ] };
- key <AC10> { [ o, O, oacute, Oacute ] };
- key <AC11> { [ apostrophe, quotedbl, otilde, Otilde ] };
-
- key <AB01> { [ z, Z, ae, AE ] };
- key <AB02> { [ x, X, dead_circumflex, asciitilde ] };
- key <AB03> { [ c, C, ccedilla, Ccedilla ] };
- key <AB04> { [ v, V, oe, OE ] };
- key <AB05> { [ b, B, dead_breve, asciitilde ] };
- key <AB06> { [ k, K, dead_abovering, asciitilde ] };
- key <AB07> { [ m, M, dead_macron, asciitilde ] };
- key <AB08> { [ comma, less, dead_cedilla, asciitilde ] };
- key <AB09> { [ period, greater, dead_abovedot, asciitilde ] };
- key <AB10> { [ slash, question, questiondown, asciitilde ] };
-
- key <CAPS> { [ BackSpace, BackSpace, BackSpace, BackSpace ] };
- key <LSGT> { [ minus, underscore, endash, emdash ] };
- key <SPCE> { [ space, space, space, nobreakspace ] };
-
- include "level3(ralt_switch)"
-};
-
-// I do NOT like dead-keys - the International keyboard as defined by Microsoft
-// doesn't fit my needs. Why use two keystrokes for all simple characters (eg '
-// and <space> generates a single ') just to have an é (eacute) in two strokes
-// as well? I type ' more often than é (eacute).
-//
-// This file works just like a regular keyboard, BUT has all dead-keys
-// accessible at level3 (through AltGr). An ë (ediaeresis) is now: AltGr+"
-// followed by an e. In other words, this keyboard is not international as long
-// as you leave the right Alt key alone.
-//
-// The original MS International keyboard was intended for Latin1 (iso8859-1).
-// With the introduction of iso8859-15, the (important) ligature oe (and OE)
-// became available. I added them next to ae. Because I write ediaeresis more
-// often than registered, I moved registered to be next to copyright and added
-// ediaeresis and idiaeresis. - Adriaan
-
-partial alphanumeric_keys
-xkb_symbols "altgr-intl" {
-
- name[Group1]= "USA - International (AltGr dead keys)";
-
- include "us(intl)"
-
-// five dead keys moved into level3:
-
- key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
- key <AC11> { [apostrophe,quotedbl, dead_acute, dead_diaeresis ] };
-
-// diversions from the MS Intl keyboard:
-
- key <AE01> { [ 1, exclam, onesuperior, exclamdown ] };
- key <AD04> { [ r, R, ediaeresis, Ediaeresis ] };
- key <AC07> { [ j, J, idiaeresis, Idiaeresis ] };
- key <AB02> { [ x, X, oe, OE ] };
- key <AB04> { [ v, V, registered, registered ] };
-
-// onequarter etc (not in iso8859-15) moved to get three unshifted deadkeys:
-
- key <AE06> { [ 6, asciicircum, dead_circumflex, onequarter ] };
- key <AE07> { [ 7, ampersand, dead_horn, onehalf ] };
- key <AE08> { [ 8, asterisk, dead_ogonek, threequarters ] };
-
- include "level3(ralt_switch)"
-};
-
-// Intel ClassmatePC Keyboard Layout
-// by Piter PUNK <piterpk@terra.com.br>
-//
-// The keyboard layouts below maps the us(basic), us(intl) and us(alt-intl)
-// to ClassmatePC keyboard. All layouts uses RCTL as level3(switch) since
-// the keyboard doesn't have AltGr key. The EuroSign is engraved at 5 key.
-
-// classmate - us(basic)
-partial alphanumeric_keys
-xkb_symbols "classmate" {
- include "us(basic)"
- name[Group1]= "USA - ClassmatePC";
-
- key <LSGT> { [ backslash, bar, backslash, bar ] };
-
- include "eurosign(5)"
- include "level3(switch)"
-};
-
-// classmate-intl - us(intl)
-// RCTL is generated by Fn+Alt, because that, when trying to access
-// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got
-// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key>
-// generate the same symbol as the original key.
-partial alphanumeric_keys
-xkb_symbols "classmate-intl" {
- include "us(intl)"
- name[Group1]= "USA - ClassmatePC (International)";
- key.type[Group1]="FOUR_LEVEL";
-
- key <LSGT> { [ backslash, bar, backslash, bar ] };
-
- key <KP7> { [ KP_Home, KP_7,
- onehalf, dead_horn ] };
- key <KP8> { [ KP_Up, KP_8,
- threequarters, dead_ogonek ] };
- key <KP9> { [ KP_Prior, KP_9,
- leftsinglequotemark, dead_breve ] };
- key <KPMU> { [ KP_Multiply, KP_Multiply,
- rightsinglequotemark, dead_abovering ] };
-
- key <KP4> { [ KP_Left, KP_4,
- uacute, Uacute ] };
- key <KP5> { [ KP_Begin, KP_5,
- iacute, Iacute ] };
- key <KP6> { [ KP_Right, KP_6,
- oacute, Oacute ] };
- key <KPSU> { [ KP_Subtract, KP_Subtract,
- odiaeresis, Odiaeresis ] };
-
- key <KP2> { [ KP_Down, KP_2,
- oe, OE ] };
- key <KP3> { [ KP_Next, KP_3,
- oslash, Ooblique ] };
- key <KPAD> { [ KP_Add, KP_Add,
- paragraph, degree ] };
-
- key <KP0> { [ KP_Insert, KP_0,
- mu, mu ] };
- key <KPDL> { [ KP_Delete, KP_Decimal,
- dead_abovedot, dead_caron ] };
- key <KPDV> { [ KP_Divide, KP_Divide,
- questiondown, dead_hook ] };
-
- include "level3(switch)"
-};
-
-// classmate-alt-intl - us(alt-intl)
-// RCTL is generated by Fn+Alt, because that, when trying to access
-// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got
-// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key>
-// generate the same symbol as the original key.
-partial alphanumeric_keys
-xkb_symbols "classmate-alt-intl" {
- include "us(alt-intl)"
- name[Group1]= "USA - ClassmatePC (Alternative international)";
- key.type[Group1]="FOUR_LEVEL";
-
- key <LSGT> { [ backslash, bar, backslash, bar ] };
-
- key <KPSU> { [ KP_Subtract, KP_Subtract ] };
-
- key <KP9> { [ KP_Prior, KP_9,
- leftsinglequotemark, dead_breve ] };
- key <KPMU> { [ KP_Multiply, KP_Multiply,
- rightsinglequotemark, dead_abovering ] };
-
- key <KPAD> { [ KP_Add, KP_Add,
- dead_ogonek, dead_diaeresis ] };
-
- key <KPDL> { [ KP_Delete, KP_Decimal,
- dead_abovedot, dead_circumflex ] };
- key <KPDV> { [ KP_Divide, KP_Divide,
- dead_hook, dead_hook ] };
-
- include "level3(switch)"
-};
-
-// classmate-altgr-intl - us(altgr-intl)
-// RCTL is generated by Fn+Alt, because that, when trying to access
-// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got
-// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key>
-// generate the same symbol as the original key.
-partial alphanumeric_keys
-xkb_symbols "classmate-altgr-intl" {
- include "us(altgr-intl)"
- name[Group1]= "USA - ClassmatePC (International Fn+Alt dead-keys)";
- key.type[Group1]="FOUR_LEVEL";
-
- key <LSGT> { [ backslash, bar, backslash, bar ] };
-
- key <KP7> { [ KP_Home, KP_7,
- dead_horn, dead_horn ] };
- key <KP8> { [ KP_Up, KP_8,
- dead_ogonek, dead_ogonek ] };
- key <KP9> { [ KP_Prior, KP_9,
- leftsinglequotemark, dead_breve ] };
- key <KPMU> { [ KP_Multiply, KP_Multiply,
- rightsinglequotemark, dead_abovering ] };
-
- key <KP4> { [ KP_Left, KP_4,
- uacute, Uacute ] };
- key <KP5> { [ KP_Begin, KP_5,
- iacute, Iacute ] };
- key <KP6> { [ KP_Right, KP_6,
- oacute, Oacute ] };
- key <KPSU> { [ KP_Subtract, KP_Subtract,
- odiaeresis, Odiaeresis ] };
-
- key <KP1> { [ KP_End, KP_1,
- idiaeresis, Idiaeresis ] };
- key <KP2> { [ KP_Down, KP_2,
- oe, OE ] };
- key <KP3> { [ KP_Next, KP_3,
- oslash, Ooblique ] };
- key <KPAD> { [ KP_Add, KP_Add,
- paragraph, degree ] };
-
- key <KP0> { [ KP_Insert, KP_0,
- mu, mu ] };
- key <KPDL> { [ KP_Delete, KP_Decimal,
- dead_abovedot, dead_caron ] };
- key <KPDV> { [ KP_Divide, KP_Divide,
- questiondown, dead_hook ] };
-
- include "level3(switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc" {
-
- include "us(basic)"
- name[Group1]= "USA";
-
- // OLPC international US English keyboard layout.
- // It's a little different from the usual international layout.
- // See: http://wiki.laptop.org/go/Image:Keyboard_english.png
-
- key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] };
- key <AE01> { [ 1, exclam, exclamdown, exclamdown ] };
- key <AE02> { [ 2, at, notsign, notsign ] };
- key <AE03> { [ 3, numbersign, 0x1000300, 0x1000300 ] }; // combining grave
- key <AE04> { [ 4, dollar, 0x1000301, 0x1000301 ] }; // combining acute
- key <AE05> { [ 5, percent, 0x1000306, 0x1000306 ] }; // combining breve above
- key <AE06> { [ 6,asciicircum, 0x100030A, 0x100030A ] }; // combining ring above
- key <AE07> { [ 7, ampersand, 0x1000302, 0x1000302 ] }; // combining circumflex above
- key <AE08> { [ 8, asterisk, 0x100030C, 0x100030C ] }; // combining caron above
- key <AE09> { [ 9, parenleft, 0x1000307, 0x1000307 ] }; // combining dot above
- key <AE10> { [ 0, parenright, 0x1000308, 0x1000308 ] }; // combining diaeresis above
- key <AE11> { [ minus, underscore, 0x1000304, 0x1000304 ] }; // combining macron above
- key <AE12> { [ equal, plus, 0x1000303, 0x1000303 ] }; // combining tilde above
-
- key <AD01> { [ q, Q, Greek_omega, Greek_OMEGA ] };
- key <AD02> { [ w, W, oslash, Oslash ] };
- key <AD03> { [ e, E, oe, OE ] };
- key <AD04> { [ r, R, 0x1000327, 0x1000327 ] }; // combining cedilla
- key <AD05> { [ t, T, 0x100032E, 0x100032E ] }; // combining breve below
- key <AD06> { [ y, Y, 0x1000325, 0x1000325 ] }; // combining ring below
- key <AD07> { [ u, U, 0x100032D, 0x100032D ] }; // combining circumflex below
- key <AD08> { [ i, I, 0x100032C, 0x100032C ] }; // combining caron below
- key <AD09> { [ o, O, 0x1000323, 0x1000323 ] }; // combining dot below
- key <AD10> { [ p, P, 0x1000324, 0x1000324 ] }; // combining diaeresis below
- key <AD11> { [ bracketleft, braceleft, 0x1000331, 0x1000331 ] }; // combining macron below
- key <AD12> { [bracketright, braceright, 0x1000330, 0x1000330 ] }; // combining tilde below
-
- key <AC01> { [ a, A, ae, AE ] };
- key <AC02> { [ s, S, ssharp, 0x1001E9C ] }; // uppercase S sharp
- key <AC03> { [ d, D, eth, ETH ] };
- key <AC04> { [ f, F, thorn, THORN ] };
- key <AC06> { [ h, H, sterling, sterling ] };
- key <AC07> { [ j, J, EuroSign, EuroSign ] };
- key <AC10> { [ semicolon, colon, masculine, ordfeminine ] };
- key <AC11> { [ apostrophe, quotedbl, currency, currency ] };
- key <BKSL> { [ backslash, bar, section, section ] };
-
- key <AB03> { [ c, C, ccedilla, Ccedilla ] };
- key <AB06> { [ n, N, ntilde, Ntilde ] };
- key <AB07> { [ m, M, mu, mu ] };
- key <AB08> { [ comma, less, guillemotleft, guillemotleft ] };
- key <AB09> { [ period, greater, guillemotright, guillemotright ] };
- key <AB10> { [ slash, question, questiondown, questiondown ] };
-
- key <I219> { [ multiply, division, ISO_Next_Group, ISO_Prev_Group ] };
-
- include "level3(ralt_switch)"
-};
-
-partial alphanumeric_keys
-xkb_symbols "olpc2" {
- include "us(olpc)"
- name[Group1]= "USA - Layout toggle on multiply/divide key";
- include "group(olpc)"
-};
-
-// Based on Cherokee Nation Official Layout
-// http://www.cherokee.org/extras/downloads/font/Keyboard.htm
-
-partial alphanumeric_keys modifier_keys
-xkb_symbols "chr" {
-
- name[Group1]= "USA - Cherokee";
- key.type[group1]="ALPHABETIC";
-
- // Alphanumeric section
- key <TLDE> { [ grave, U13CA ] };
- key <AE01> { [ 1, U13B1 ] };
- key <AE02> { [ 2, U13C7 ] };
- key <AE03> { [ 3, U13E7 ] };
- key <AE04> { [ U13D9, U13B0 ] };
- key <AE05> { [ U13E6, U13B9 ] };
- key <AE06> { [ U13DC, U13DD ] };
- key <AE07> { [ U13CB, U13E1 ] };
- key <AE08> { [ U13D6, U13BA ] };
- key <AE09> { [ U13D2, parenleft ] };
- key <AE10> { [ U13C4, parenright ] };
- key <AE11> { [ U13BF, U13BC ] };
- key <AE12> { [ U13F3, U13BD ] };
-
- key <AD01> { [ U13AA, U13C6 ] };
- key <AD02> { [ U13B3, U13EB ] };
- key <AD03> { [ U13A1, U13E3 ] };
- key <AD04> { [ U13DB, U13CF ] };
- key <AD05> { [ U13D4, U13D8 ] };
- key <AD06> { [ U13EF, U13F2 ] };
- key <AD07> { [ U13A4, U13AD ] };
- key <AD08> { [ U13A2, U13F1 ] };
- key <AD09> { [ U13A3, U13EC ] };
- key <AD10> { [ U13C1, U13EA ] };
- key <AD11> { [ U13D5, U13D1 ] };
- key <AD12> { [ U13B6, U13E4 ] };
- key <BKSL> { [ U13E9, U13EE ] };
-
- key <AC01> { [ U13A0, U13CC ] };
- key <AC02> { [ U13CD, U13CE ] };
- key <AC03> { [ U13D7, U13D0 ] };
- key <AC04> { [ U13A9, U13C8 ] };
- key <AC05> { [ U13A6, U13E5 ] };
- key <AC06> { [ U13AF, U13B2 ] };
- key <AC07> { [ U13DA, U13AB ] };
- key <AC08> { [ U13B8, U13A7 ] };
- key <AC09> { [ U13B5, U13AE ] };
- key <AC10> { [ U13E8, U13E0 ] };
- key <AC11> { [ apostrophe, quotedbl ] };
-
- key <AB01> { [ U13AC, U13C3 ] };
- key <AB02> { [ U13F4, U13ED ] };
- key <AB03> { [ U13D3, U13DF ] };
- key <AB04> { [ U13A5, U13DE ] };
- key <AB05> { [ U13A8, U13F0 ] };
- key <AB06> { [ U13BE, U13BB ] };
- key <AB07> { [ U13C5, U13B7 ] };
- key <AB08> { [ comma, U13E2 ] };
- key <AB09> { [ period, U13B4 ] };
- key <AB10> { [ U13C2, U13C9 ] };
-
- // End alphanumeric section
-};
-
-// Serbian charecters added as third level symbols to US keyboard layout.
-
-partial alphanumeric_keys
-xkb_symbols "srp" {
-
- name[Group1]= "USA - Serbian";
-
- include "us"
-
- key <TLDE> { [ grave, asciitilde ] };
- key <AE06> { [ 6, dead_caron, asciicircum, asciicircum ] };
- key <AC09> { [ l, L, U1C9, U1C8 ] };
- key <AB06> { [ n, N, U1CC, U1CB ] };
- key <AB01> { [ z, Z, U1C6, U1C5 ] };
- key <AD03> { [ e, E, EuroSign, cent ] };
- key <AC03> { [ d, D, dstroke, Dstroke ] };
- key <AC11> { [ dead_acute, quotedbl, apostrophe, U315 ] };
- key <SPCE> { [ space, space, nobreakspace, nobreakspace ] };
-
- include "level3(ralt_switch)"
-};
-
-//based on http://upload.wikimedia.org/wikipedia/commons/1/18/T-Mobile_G1_launch_event_2.jpg
-partial alphanumeric_keys
-xkb_symbols "htcdream" {
- include "inet(htcdream)"
- name[Group1]= "USA - htcdream";
-
- //second row
- key <AD01> { [ q, Q, Tab, Tab ] };
- key <AD02> { [ w, W, grave, grave ] };
- key <AD03> { [ e, E, underscore, underscore ] };
- key <AD04> { [ r, R, sterling, sterling ] };
- key <AD05> { [ t, T, EuroSign, EuroSign ] };
- key <AD06> { [ y, Y, division, division ] };
- key <AD07> { [ u, U, multiply, multiply ] };
- key <AD08> { [ i, I, minus, minus ] };
- key <AD09> { [ o, O, plus, plus ] };
- key <AD10> { [ p, P, equal, equal ] };
-
- //third row
- key <AC01> { [ a, A, NoSymbol, NoSymbol ] };
- key <AC02> { [ s, S, bar, bar ] };
- key <AC03> { [ d ,D, backslash, backslash ] };
- key <AC04> { [ f, F, braceleft, braceleft ] };
- key <AC05> { [ g, G, braceright, braceright ] };
- key <AC06> { [ h, H, colon, colon ] };
- key <AC07> { [ j, J, semicolon, semicolon ] };
- key <AC08> { [ k, K, quotedbl, quotedbl ] };
- key <AC09> { [ l, L, apostrophe, apostrophe ] };
-
- //forth row
- key <AB01> { [ z, Z, NoSymbol, NoSymbol ] };
- key <AB02> { [ x, X, NoSymbol, NoSymbol ] };
- key <AB03> { [ c, C, NoSymbol, NoSymbol ] };
- key <AB04> { [ v, V, bracketleft, bracketleft ] };
- key <AB05> { [ b, B, bracketright, bracketright ] };
- key <AB06> { [ n, N, less, less ] };
- key <AB07> { [ m, M, greater, greater ] };
- key <AB08> { [ comma, comma, question, question ] };
-
- //fifth row
- key <FK15> { [ at, at, asciitilde, asciitilde ] };
-
- include "level3(alt_switch)"
-};
\ No newline at end of file +// $XKeyboardConfig$ + +// +// $XdotOrg: xc/programs/xkbcomp/symbols/us,v 1.1.4.3 2004/03/05 13:41:33 eich Exp $ +// $XFree86: xc/programs/xkbcomp/symbols/us,v 1.6 2003/10/31 14:32:05 pascal Exp $ + +default +partial alphanumeric_keys modifier_keys +xkb_symbols "basic" { + + name[Group1]= "USA"; + + // 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, question ] }; + + key <BKSL> { [ backslash, bar ] }; + // End alphanumeric section +}; + +partial alphanumeric_keys +xkb_symbols "euro" { + + name[Group1]= "USA - With EuroSign on 5"; + + include "us(basic)" + + include "eurosign(5)" + + include "level3(ralt_switch)" +}; + + +partial alphanumeric_keys +xkb_symbols "intl" { + + name[Group1]= "USA - International (with dead keys)"; + + include "us(basic)" + + // Alphanumeric section + key <TLDE> { [dead_grave, dead_tilde, grave, asciitilde ] }; + key <AE01> { [ 1, exclam, exclamdown, onesuperior ] }; + key <AE02> { [ 2, at, twosuperior, dead_doubleacute ] }; + key <AE03> { [ 3, numbersign, threesuperior, dead_macron ] }; + key <AE04> { [ 4, dollar, currency, sterling ] }; + key <AE05> { [ 5, percent, EuroSign, dead_cedilla ] }; + key <AE06> { [ 6, dead_circumflex, onequarter, asciicircum ] }; + key <AE07> { [ 7, ampersand, onehalf, dead_horn ] }; + key <AE08> { [ 8, asterisk, threequarters, dead_ogonek ] }; + key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] }; + key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] }; + key <AE11> { [ minus, underscore, yen, dead_belowdot ] }; + key <AE12> { [ equal, plus, multiply, division ] }; + + key <AD01> { [ q, Q, adiaeresis, Adiaeresis ] }; + key <AD02> { [ w, W, aring, Aring ] }; + key <AD03> { [ e, E, eacute, Eacute ] }; + key <AD04> { [ r, R, registered, registered ] }; + key <AD05> { [ t, T, thorn, THORN ] }; + key <AD06> { [ y, Y, udiaeresis, Udiaeresis ] }; + key <AD07> { [ u, U, uacute, Uacute ] }; + key <AD08> { [ i, I, iacute, Iacute ] }; + key <AD09> { [ o, O, oacute, Oacute ] }; + key <AD10> { [ p, P, odiaeresis, Odiaeresis ] }; + key <AD11> { [ bracketleft, braceleft, guillemotleft, leftdoublequotemark ] }; + key <AD12> { [bracketright, braceright, guillemotright, rightdoublequotemark ] }; + + key <AC01> { [ a, A, aacute, Aacute ] }; + key <AC02> { [ s, S, ssharp, section ] }; + key <AC03> { [ d, D, eth, ETH ] }; + key <AC04> { [ f, F, f, F ] }; + key <AC05> { [ g, G, g, G ] }; + key <AC06> { [ h, H, h, H ] }; + key <AC07> { [ j, J, j, J ] }; + key <AC08> { [ k, K, oe, OE ] }; + + key <AC09> { [ l, L, oslash, Ooblique ] }; + key <AC10> { [ semicolon, colon, paragraph, degree ] }; + key <AC11> { [dead_acute, dead_diaeresis, apostrophe, quotedbl ] }; + + key <AB01> { [ z, Z, ae, AE ] }; + key <AB02> { [ x, X, x, X ] }; + key <AB03> { [ c, C, copyright, cent ] }; + key <AB04> { [ v, V, v, V ] }; + key <AB05> { [ b, B, b, B ] }; + key <AB06> { [ n, N, ntilde, Ntilde ] }; + key <AB07> { [ m, M, mu, mu ] }; + key <AB08> { [ comma, less, ccedilla, Ccedilla ] }; + key <AB09> { [ period, greater, dead_abovedot, dead_caron ] }; + key <AB10> { [ slash, question, questiondown, dead_hook ] }; + key <BKSL> { [ backslash, bar, notsign, brokenbar ] }; + + include "level3(ralt_switch)" +}; + +// Based on symbols/us_intl keyboard map: +// Dead-keys definition for a very simple US/ASCII layout. +// by Conectiva (http://www.conectiva.com.br) +// modified by Ricardo Y. Igarashi (iga@that.com.br) + +// Added the following deadkeys, to make it truly international: +// +// dead_macron: on AltGr-minus +// dead_breve: on AltGr-parenleft +// dead_abovedot: on AltGr-period +// dead_abovering: on AltGr-0 +// dead_doubleacute: on AltGr-equal (as quotedbl is already used) +// dead_caron: on AltGr-less (AltGr-shift-comma) +// dead_cedilla: on AltGr-comma +// dead_ogonek: on AltGr-semicolon +// dead_belowdot: on AltGr-underscore (AltGr-shift-minus) +// dead_hook: on AltGr-question +// dead_horn: on AltGr-plus (AltGr-shift-equal) +// dead_diaeresis: on AltGr-colon (Alt-shift-semicolon) +// +// those were already there: +// dead_grave +// dead_acute +// dead_circumflex +// dead_tilde +// dead_diaeresis + +partial alphanumeric_keys +xkb_symbols "alt-intl" { + + name[Group1]= "USA - Alternative international"; + + include "us" + + key <TLDE> { [ dead_grave, dead_tilde, grave, asciitilde ] }; + key <AE05> { [ 5, percent, EuroSign ] }; + key <AE06> { [ 6, dead_circumflex, asciicircum, asciicircum ] }; + key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] }; + key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] }; + key <AE11> { [ minus, underscore, dead_macron, dead_belowdot ] }; + key <AE12> { [ equal, plus, dead_doubleacute, dead_horn ] }; + + key <AD03> { [ e, E, EuroSign, cent ] }; + + key <AC10> { [ semicolon, colon, dead_ogonek, dead_diaeresis ] }; + key <AC11> { [ dead_acute, dead_diaeresis, apostrophe, quotedbl ] }; + + key <AB08> { [ comma, less, dead_cedilla, dead_caron ] }; + key <AB09> { [ period, greater, dead_abovedot, dead_circumflex ] }; + key <AB10> { [ slash, question, dead_hook, dead_hook ] }; + + include "level3(ralt_switch)" +}; + +// based on a keyboard map from an 'xkb/symbols/dk' file +// +// $XFree86: xc/programs/xkbcomp/symbols/dvorak,v 1.5 2004/01/03 16:35:07 herrb Exp $ + +partial alphanumeric_keys +xkb_symbols "dvorak" { + + name[Group1]= "USA - Dvorak"; + + // Alphanumeric section + + key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] }; + + key <AE01> { [ 1, exclam ] }; + key <AE02> { [ 2, at ] }; + key <AE03> { [ 3, numbersign ] }; + key <AE04> { [ 4, dollar ] }; + key <AE05> { [ 5, percent ] }; + key <AE06> { [ 6, asciicircum, dead_circumflex, dead_circumflex ] }; + key <AE07> { [ 7, ampersand ] }; + key <AE08> { [ 8, asterisk ] }; + key <AE09> { [ 9, parenleft, dead_grave] }; + key <AE10> { [ 0, parenright ] }; + key <AE11> { [ bracketleft, braceleft ] }; + key <AE12> { [ bracketright, braceright, dead_tilde] }; + + key <AD01> { [ apostrophe, quotedbl, dead_acute, dead_diaeresis ] }; + key <AD02> { [ comma, less, dead_cedilla, dead_caron ] }; + key <AD03> { [ period, greater, dead_abovedot, periodcentered ] }; + key <AD04> { [ p, P ] }; + key <AD05> { [ y, Y ] }; + key <AD06> { [ f, F ] }; + key <AD07> { [ g, G ] }; + key <AD08> { [ c, C ] }; + key <AD09> { [ r, R ] }; + key <AD10> { [ l, L ] }; + key <AD11> { [ slash, question ] }; + key <AD12> { [ equal, plus ] }; + + key <AC01> { [ a, A ] }; + key <AC02> { [ o, O ] }; + key <AC03> { [ e, E ] }; + key <AC04> { [ u, U ] }; + key <AC05> { [ i, I ] }; + key <AC06> { [ d, D ] }; + key <AC07> { [ h, H ] }; + key <AC08> { [ t, T ] }; + key <AC09> { [ n, N ] }; + key <AC10> { [ s, S ] }; + key <AC11> { [ minus, underscore ] }; + + key <AB01> { [ semicolon, colon, dead_ogonek, dead_doubleacute ] }; + key <AB02> { [ q, Q ] }; + key <AB03> { [ j, J ] }; + key <AB04> { [ k, K ] }; + key <AB05> { [ x, X ] }; + key <AB06> { [ b, B ] }; + key <AB07> { [ m, M ] }; + key <AB08> { [ w, W ] }; + key <AB09> { [ v, V ] }; + key <AB10> { [ z, Z ] }; + + key <BKSL> { [ backslash, bar ] }; +}; + +// Dvorak international with dead keys +// Olivier Mehani (shtrom-xorg@ssji.net) +// Reproduce the per-key mapping of us(intl) for the dvorak layout +// aka "I just swapped my keys over" +partial alphanumeric_keys +xkb_symbols "dvorak-intl" { + + name[Group1]= "USA - Dvorak international (with dead keys)"; + + include "us(dvorak)" + + key <TLDE> { [dead_grave, dead_tilde, grave, asciitilde ] }; + + key <AE01> { [ 1, exclam, exclamdown, onesuperior ] }; + key <AE02> { [ 2, at, twosuperior, dead_doubleacute ] }; + key <AE03> { [ 3, numbersign, threesuperior, dead_macron ] }; + key <AE04> { [ 4, dollar, currency, sterling ] }; + key <AE05> { [ 5, percent, EuroSign, dead_cedilla ] }; + key <AE06> { [ 6, dead_circumflex, onequarter, asciicircum ] }; + key <AE07> { [ 7, ampersand, onehalf, dead_horn ] }; + key <AE08> { [ 8, asterisk, threequarters, dead_ogonek ] }; + key <AE09> { [ 9, parenleft, leftsinglequotemark, dead_breve ] }; + key <AE10> { [ 0, parenright, rightsinglequotemark, dead_abovering ] }; + key <AE11> { [ bracketleft, braceleft, guillemotleft, leftdoublequotemark ] }; + key <AE12> { [bracketright, braceright, guillemotright, rightdoublequotemark ] }; + + key <AD01> { [dead_acute, dead_diaeresis, apostrophe, quotedbl ] }; + key <AD02> { [ comma, less, ccedilla, Ccedilla ] }; + key <AD03> { [ period, greater, dead_abovedot, dead_caron ] }; + key <AD04> { [ p, P, odiaeresis, Odiaeresis ] }; + key <AD05> { [ y, Y, udiaeresis, Udiaeresis ] }; + // key <AD06> { [ f, F ] }; + // key <AD07> { [ g, G ] }; + key <AD08> { [ c, C, copyright, cent ] }; + key <AD09> { [ r, R, registered, registered ] }; + key <AD10> { [ l, L, oslash, Ooblique ] }; + key <AD11> { [ slash, question, questiondown, dead_hook ] }; + // key <AD12> { [ equal, plus, multiply, division ] }; + + key <AC01> { [ a, A, aacute, Aacute ] }; + key <AC02> { [ o, O, oacute, Oacute ] }; + key <AC03> { [ e, E, eacute, Eacute ] }; + key <AC04> { [ u, U, uacute, Uacute ] }; + key <AC05> { [ i, I, iacute, Iacute ] }; + key <AC06> { [ d, D, eth, ETH ] }; + // key <AC07> { [ h, H ] }; + key <AC08> { [ t, T, thorn, THORN ] }; + key <AC09> { [ n, N, ntilde, Ntilde ] }; + key <AC10> { [ s, S, ssharp, section ] }; + // key <AC11> { [ minus, underscore, yen, dead_belowdot ] }; + + key <AB01> { [ semicolon, colon, paragraph, degree ] }; + key <AB02> { [ q, Q, adiaeresis, Adiaeresis ] }; + // key <AB03> { [ j, J ] }; + key <AB04> { [ k, K, oe, OE ] }; + // key <AB05> { [ x, X ] }; + // key <AB06> { [ b, B ] }; + key <AB07> { [ m, M, mu, mu ] }; + key <AB08> { [ w, W, aring, Aring ] }; + // key <AB09> { [ v, V ] }; + key <AB10> { [ z, Z, ae, AE ] }; + + key <BKSL> { [ backslash, bar, notsign, brokenbar ] }; + + include "level3(ralt_switch)" +}; + +// Dvorak international without dead keys +// Stephane Magnenat (stephane at magnenat dot net, http://stephane.magnenat.net) +// Based on information from http://www.poupinou.org/dvorak/index.html +// +// ` 1 2 3 4 5 6 7 8 9 0 [ ] \ +// € +// +// ' , . p y f g c r l / = +// ä ê ë ü ç +// +// a o e u i d h t n s - +// à ô é û î ß +// +// ; q j k x b m w v z +// â ö è ù ï + +partial alphanumeric_keys +xkb_symbols "dvorak-alt-intl" { + + name[Group1]= "USA - Dvorak alternative international (no dead keys)"; + + include "us(dvorak)" + + key <AE04> { [ 4, dollar, EuroSign ] }; + + key <AD02> { [ comma, less, adiaeresis, dead_caron ] }; + key <AD03> { [ period, greater, ecircumflex, periodcentered ] }; + key <AD04> { [ p, P, ediaeresis, dead_cedilla ] }; + key <AD05> { [ y, Y, udiaeresis ] }; + key <AD08> { [ c, C, ccedilla, dead_abovedot ] }; + + key <AC01> { [ a, A, agrave ] }; + key <AC02> { [ o, O, ocircumflex ] }; + key <AC03> { [ e, E, eacute ] }; + key <AC04> { [ u, U, ucircumflex ] }; + key <AC05> { [ i, I, icircumflex ] }; + key <AC10> { [ s, S, ssharp ] }; + + key <AB01> { [ semicolon, colon, acircumflex ] }; + key <AB02> { [ q, Q, odiaeresis, dead_ogonek ] }; + key <AB03> { [ j, J, egrave, dead_doubleacute ] }; + key <AB04> { [ k, K, ugrave ] }; + key <AB05> { [ x, X, idiaeresis ] }; + + include "level3(ralt_switch)" +}; + +// Left and right handed dvorak layouts +// by sqweek <sqweek@gmail.com> 2006-01-30 +// Based on the corresponding layouts in the console-tools package. +partial alphanumeric_keys +xkb_symbols "dvorak-l" { + + include "us(dvorak)" + name[Group1]= "USA - Left handed Dvorak"; + + key <AE01> { [ bracketleft, braceleft ] }; + key <AE02> { [ bracketright, braceright ] }; + key <AE03> { [ slash, question ] }; + key <AE04> { [ p, P ] }; + key <AE05> { [ f, F ] }; + key <AE06> { [ m, M ] }; + key <AE07> { [ l, L ] }; + key <AE08> { [ j, J ] }; + key <AE09> { [ 4, dollar ] }; + key <AE10> { [ 3, numbersign ] }; + key <AE11> { [ 2, at ] }; + key <AE12> { [ 1, exclam ] }; + + key <AD01> { [ semicolon, colon ] }; + key <AD02> { [ q, Q ] }; + key <AD03> { [ b, B ] }; + key <AD04> { [ y, Y ] }; + key <AD05> { [ u, U ] }; + key <AD06> { [ r, R ] }; + key <AD07> { [ s, S ] }; + key <AD08> { [ o, O ] }; + key <AD09> { [ period, greater ] }; + key <AD10> { [ 6, asciicircum ] }; + key <AD11> { [ 5, percent ] }; + key <AD12> { [ equal, plus ] }; + + key <AC01> { [ minus, underscore ] }; + key <AC02> { [ k, K ] }; + key <AC03> { [ c, C ] }; + key <AC04> { [ d, D ] }; + key <AC05> { [ t, T ] }; + key <AC06> { [ h, H ] }; + key <AC07> { [ e, E ] }; + key <AC08> { [ a, A ] }; + key <AC09> { [ z, Z ] }; + key <AC10> { [ 8, asterisk ] }; + key <AC11> { [ 7, ampersand ] }; + + key <AB01> { [ apostrophe, quotedbl ] }; + key <AB02> { [ x, X ] }; + key <AB03> { [ g, G ] }; + key <AB04> { [ v, V ] }; + key <AB05> { [ w, W ] }; + key <AB06> { [ n, N ] }; + key <AB07> { [ i, I ] }; + key <AB08> { [ comma, less ] }; + key <AB09> { [ 0, parenright ] }; + key <AB10> { [ 9, parenleft ] }; +}; + +partial alphanumeric_keys +xkb_symbols "dvorak-r" { + + include "us(dvorak)" + name[Group1]= "USA - Right handed Dvorak"; + + key <AE01> { [ 1, exclam ] }; + key <AE02> { [ 2, at ] }; + key <AE03> { [ 3, numbersign ] }; + key <AE04> { [ 4, dollar ] }; + key <AE05> { [ j, J ] }; + key <AE06> { [ l, L ] }; + key <AE07> { [ m, M ] }; + key <AE08> { [ f, F ] }; + key <AE09> { [ p, P ] }; + key <AE10> { [ slash, question ] }; + key <AE11> { [ bracketleft, braceleft ] }; + key <AE12> { [ bracketright, braceright ] }; + + key <AD01> { [ 5, percent ] }; + key <AD02> { [ 6, asciicircum ] }; + key <AD03> { [ q, Q ] }; + key <AD04> { [ period, greater ] }; + key <AD05> { [ o, O ] }; + key <AD06> { [ r, R ] }; + key <AD07> { [ s, S ] }; + key <AD08> { [ u, U ] }; + key <AD09> { [ y, Y ] }; + key <AD10> { [ b, B ] }; + key <AD11> { [ semicolon, colon ] }; + key <AD12> { [ equal, plus ] }; + + key <AC01> { [ 7, ampersand ] }; + key <AC02> { [ 8, asterisk ] }; + key <AC03> { [ z, Z ] }; + key <AC04> { [ a, A ] }; + key <AC05> { [ e, E ] }; + key <AC06> { [ h, H ] }; + key <AC07> { [ t, T ] }; + key <AC08> { [ d, D ] }; + key <AC09> { [ c, C ] }; + key <AC10> { [ k, K ] }; + key <AC11> { [ minus, underscore ] }; + + key <AB01> { [ 9, parenleft ] }; + key <AB02> { [ 0, parenright ] }; + key <AB03> { [ x, X ] }; + key <AB04> { [ comma, less ] }; + key <AB05> { [ i, I ] }; + key <AB06> { [ n, N ] }; + key <AB07> { [ w, W ] }; + key <AB08> { [ v, V ] }; + key <AB09> { [ g, G ] }; + key <AB10> { [ apostrophe, quotedbl ] }; +}; + +// Classic dvorak layout +// by Piter Punk <piterpk@terra.com.br> - 2006-07-06 +// Based on dvorak layout and e-mail from Russel L. Harris rlharris@oplink.net +// on xorg list. +partial alphanumeric_keys +xkb_symbols "dvorak-classic" { + + name[Group1]= "USA - Classic Dvorak"; + + // Alphanumeric section + + key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] }; + + key <AE01> { [ bracketleft, braceleft ] }; + key <AE02> { [ 7, ampersand ] }; + key <AE03> { [ 5, percent ] }; + key <AE04> { [ 3, numbersign ] }; + key <AE05> { [ 1, exclam ] }; + key <AE06> { [ 9, parenleft, dead_grave] }; + key <AE07> { [ 0, parenright ] }; + key <AE08> { [ 2, at ] }; + key <AE09> { [ 4, dollar ] }; + key <AE10> { [ 6, asciicircum, dead_circumflex, dead_circumflex ] }; + key <AE11> { [ 8, asterisk ] }; + key <AE12> { [ bracketright, braceright, dead_tilde] }; + + key <AD01> { [ slash, question ] }; + key <AD02> { [ comma, less, dead_cedilla, dead_caron ] }; + key <AD03> { [ period, greater, dead_abovedot, periodcentered ] }; + key <AD04> { [ p, P ] }; + key <AD05> { [ y, Y ] }; + key <AD06> { [ f, F ] }; + key <AD07> { [ g, G ] }; + key <AD08> { [ c, C ] }; + key <AD09> { [ r, R ] }; + key <AD10> { [ l, L ] }; + key <AD11> { [ apostrophe, quotedbl, dead_acute, dead_diaeresis ] }; + key <AD12> { [ equal, plus ] }; + + key <AC01> { [ a, A ] }; + key <AC02> { [ o, O ] }; + key <AC03> { [ e, E ] }; + key <AC04> { [ u, U ] }; + key <AC05> { [ i, I ] }; + key <AC06> { [ d, D ] }; + key <AC07> { [ h, H ] }; + key <AC08> { [ t, T ] }; + key <AC09> { [ n, N ] }; + key <AC10> { [ s, S ] }; + key <AC11> { [ minus, underscore ] }; + + key <AB01> { [ semicolon, colon, dead_ogonek, dead_doubleacute ] }; + key <AB02> { [ q, Q ] }; + key <AB03> { [ j, J ] }; + key <AB04> { [ k, K ] }; + key <AB05> { [ x, X ] }; + key <AB06> { [ b, B ] }; + key <AB07> { [ m, M ] }; + key <AB08> { [ w, W ] }; + key <AB09> { [ v, V ] }; + key <AB10> { [ z, Z ] }; + key <BKSL> { [ backslash, bar ] }; +}; + +// Programmer Dvorak, by Roland Kaufmann <rlndkfmn at gmail dot com> +// License: BSD, available at <http://www.kaufmann.no/roland/dvorak/license.html> +// Main features: Numbers are in shift position (like French), symbols have been +// placed in locations that give good hand-alternation and finger rolling with +// symbols that usually follows, accented characters are possible for I18N. +partial alphanumeric_keys +xkb_symbols "dvp" { + include "us(dvorak)" + + name[Group1] = "USA - Programmer Dvorak"; + + // Unmodified Shift AltGr Shift+AltGr + // symbols row, left side + key <TLDE> { [ dollar, asciitilde, dead_tilde ] }; + key <AE01> { [ ampersand, percent ] }; + key <AE02> { [ bracketleft, 7, currency ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" }; + key <AE03> { [ braceleft, 5, cent ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" }; + key <AE04> { [ braceright, 3, yen ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" }; + key <AE05> { [ parenleft, 1, EuroSign ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" }; + key <AE06> { [ equal, 9, sterling ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" }; + + // symbols row, right side + key <AE07> { [ asterisk, 0 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" }; + key <AE08> { [ parenright, 2, onehalf ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" }; + key <AE09> { [ plus, 4 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" }; + key <AE10> { [ bracketright, 6 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" }; + key <AE11> { [ exclam, 8, exclamdown ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" }; + key <AE12> { [ numbersign, grave, dead_grave ] }; + key <BKSP> { [ BackSpace ] }; + + // upper row, left side + key <AD01> { [ semicolon, colon, dead_diaeresis ] }; + key <AD02> { [ comma, less, guillemotleft ] }; + key <AD03> { [ period, greater, guillemotright ] }; + key <AD04> { [ p, P, paragraph, section ] }; + key <AD05> { [ y, Y, udiaeresis, Udiaeresis ] }; + + // upper row, right side + key <AD08> { [ c, C, ccedilla, Ccedilla ] }; + key <AD09> { [ r, R, registered, trademark ] }; + key <AD11> { [ slash, question, questiondown ] }; + key <AD12> { [ at, asciicircum, dead_circumflex, dead_caron ] }; + + // home row, left side + key <AC01> { [ a, A, aring, Aring ] }; + key <AC02> { [ o, O, oslash, Ooblique ] }; + key <AC03> { [ e, E, ae, AE ] }; + key <AC04> { [ u, U, eacute, Eacute ] }; + + // home row, right side + key <AC06> { [ d, D, eth, ETH ] }; + key <AC07> { [ h, H, dead_acute ] }; + key <AC08> { [ t, T, thorn, THORN ] }; + key <AC09> { [ n, N, ntilde, Ntilde ] }; + key <AC10> { [ s, S, ssharp ] }; + key <AC11> { [ minus, underscore, hyphen ], type[Group1] = "FOUR_LEVEL_ALPHABETIC" }; + key <BKSL> { [ backslash, bar ] }; + + // lower row, left side + key <AB01> { [ apostrophe, quotedbl, dead_acute ] }; +}; + +// phonetic layout for Russian letters on an US keyboard +// by Ivan Popov <pin@konvalo.org> 2005-07-17 + +// level3 modifier is a shortcut to the "us" meaning of the keys where +// we place cyrillic letters, handy for accessing the corresponding +// punctuation marks. +// It is important to have access to punctuation marks, and the rest of +// alphabetical keys are added for being consequent so that the users +// can expect the level3 modifier to give what the key label shows. + +partial alphanumeric_keys +xkb_symbols "rus" { + + name[Group1]= "USA - Russian phonetic"; + + include "us(basic)" + +key.type[group1]="FOUR_LEVEL_ALPHABETIC"; + + key <LatA> { [ Cyrillic_a, Cyrillic_A ] }; + key <LatB> { [ Cyrillic_be, Cyrillic_BE ] }; + key <LatW> { [ Cyrillic_ve, Cyrillic_VE ] }; + key <LatG> { [ Cyrillic_ghe, Cyrillic_GHE ] }; + key <LatD> { [ Cyrillic_de, Cyrillic_DE ] }; + key <LatE> { [ Cyrillic_ie, Cyrillic_IE ] }; + key <TLDE> { [ Cyrillic_io, Cyrillic_IO, grave, asciitilde ] }; + key <LatV> { [ Cyrillic_zhe, Cyrillic_ZHE ] }; + key <LatZ> { [ Cyrillic_ze, Cyrillic_ZE ] }; + key <LatI> { [ Cyrillic_i, Cyrillic_I ] }; + key <LatJ> { [ Cyrillic_shorti, Cyrillic_SHORTI ] }; + key <LatK> { [ Cyrillic_ka, Cyrillic_KA ] }; + key <LatL> { [ Cyrillic_el, Cyrillic_EL ] }; + key <LatM> { [ Cyrillic_em, Cyrillic_EM ] }; + key <LatN> { [ Cyrillic_en, Cyrillic_EN ] }; + key <LatO> { [ Cyrillic_o, Cyrillic_O ] }; + key <LatP> { [ Cyrillic_pe, Cyrillic_PE ] }; + key <LatR> { [ Cyrillic_er, Cyrillic_ER ] }; + key <LatS> { [ Cyrillic_es, Cyrillic_ES ] }; + key <LatT> { [ Cyrillic_te, Cyrillic_TE ] }; + key <LatU> { [ Cyrillic_u, Cyrillic_U ] }; + key <LatF> { [ Cyrillic_ef, Cyrillic_EF ] }; + key <LatH> { [ Cyrillic_ha, Cyrillic_HA ] }; + key <LatC> { [ Cyrillic_tse, Cyrillic_TSE ] }; + key <AC10> { [ Cyrillic_che, Cyrillic_CHE, semicolon, colon ] }; + key <AD11> { [ Cyrillic_sha, Cyrillic_SHA, bracketleft, braceleft] }; + key <AD12> { [ Cyrillic_shcha, Cyrillic_SHCHA, bracketright, braceright ] }; + key <AE12> { [ Cyrillic_hardsign, Cyrillic_HARDSIGN, equal, plus ] }; + key <LatY> { [ Cyrillic_yeru, Cyrillic_YERU ] }; + key <LatX> { [ Cyrillic_softsign, Cyrillic_SOFTSIGN ] }; + key <BKSL> { [ Cyrillic_e, Cyrillic_E, backslash, bar ] }; + key <AC11> { [ Cyrillic_yu, Cyrillic_YU, apostrophe, quotedbl ] }; + key <LatQ> { [ Cyrillic_ya, Cyrillic_YA ] }; + + include "level3(ralt_switch)" +}; + +partial alphanumeric_keys +xkb_symbols "mac" { + + include "us(basic)" + name[Group1]= "USA - Macintosh"; + key.type[group1]="FOUR_LEVEL"; + + // Slightly improvised from http://homepage.mac.com/thgewecke/kblayout.jpg + key <LSGT> { [ section, plusminus, section, plusminus ] }; + key <TLDE> { [ grave, asciitilde, dead_grave, dead_horn ] }; + key <AE01> { [ 1, exclam, exclamdown, U2044 ] }; + key <AE02> { [ 2, at, trademark, EuroSign ] }; + key <AE03> { [ 3, numbersign, sterling, U2039 ] }; + key <AE04> { [ 4, dollar, cent, U203A ] }; + key <AE05> { [ 5, percent, infinity, UFB01 ] }; + key <AE06> { [ 6,asciicircum, section, UFB02 ] }; + key <AE07> { [ 7, ampersand, paragraph, doubledagger ] }; + key <AE08> { [ 8, asterisk, enfilledcircbullet, degree ] }; + key <AE09> { [ 9, parenleft, ordfeminine, periodcentered ] }; + key <AE10> { [ 0, parenright, masculine,singlelowquotemark] }; + key <AE11> { [ minus, underscore, endash, emdash ] }; + key <AE12> { [ equal, plus, notequal, plusminus ] }; + + key <AD01> { [ q, Q, oe, OE ] }; + key <AD02> { [ w, W, U2211,doublelowquotemark] }; + key <AD03> { [ e, E, dead_acute, acute ] }; + key <AD04> { [ r, R, registered, U2030 ] }; + key <AD05> { [ t, T, dagger, dead_caron ] }; + key <AD06> { [ y, Y, yen, onequarter ] }; + key <AD07> { [ u, U, dead_diaeresis, diaeresis ] }; + key <AD08> { [ i, I, dead_circumflex, U02C6 ] }; + key <AD09> { [ o, O, oslash, Ooblique ] }; + key <AD10> { [ p, P, Greek_pi, U220F ] }; + key <AD11> { [ bracketleft, braceleft, leftdoublequotemark, rightdoublequotemark ] }; + key <AD12> { [bracketright, braceright, leftsinglequotemark, rightsinglequotemark ] }; + key <BKSL> { [ backslash, bar, guillemotleft, guillemotright ] }; + + key <AC01> { [ a, A, aring, Aring ] }; + key <AC02> { [ s, S, ssharp, dead_stroke ] }; + key <AC03> { [ d, D, partialderivative, eth ] }; + key <AC04> { [ f, F, function, dead_hook ] }; + key <AC05> { [ g, G, copyright, dead_doubleacute ] }; + key <AC06> { [ h, H, dead_abovedot, dead_belowdot ] }; + key <AC07> { [ j, J, U2206, onehalf ] }; + key <AC08> { [ k, K,dead_abovering, UF8FF ] }; + + key <AC09> { [ l, L, notsign, THORN ] }; + key <AC10> { [ semicolon, colon, U2026, thorn ] }; + key <AC11> { [apostrophe, quotedbl, ae, AE ] }; + + key <AB01> { [ z, Z, Greek_OMEGA, dead_cedilla ] }; + key <AB02> { [ x, X, U2248, dead_ogonek ] }; + // unclear whether "approxeq" is 2248 or 2245 + key <AB03> { [ c, C, ccedilla, Ccedilla ] }; + key <AB04> { [ v, V, squareroot, U25CA ] }; + key <AB05> { [ b, B, integral, idotless ] }; + key <AB06> { [ n, N, dead_tilde, U02DC ] }; + key <AB07> { [ m, M, mu, threequarters ] }; + key <AB08> { [ comma, less, lessthanequal, dead_macron ] }; + key <AB09> { [ period, greater, greaterthanequal, dead_breve ] }; + key <AB10> { [ slash, question, division, questiondown ] }; + + include "level3(ralt_switch)" +}; + +// Colemak symbols for xkb on X.Org Server 7.x +// 2006-01-01 Shai Coleman, http://colemak.com/ . Public domain. + +partial alphanumeric_keys +xkb_symbols "colemak" { + include "us" + name[Group1]= "USA - Colemak"; + + // Alphanumeric section + key <TLDE> { [ grave, asciitilde, dead_tilde, asciitilde ] }; + key <AE01> { [ 1, exclam, exclamdown, onesuperior ] }; + key <AE02> { [ 2, at, masculine, twosuperior ] }; + key <AE03> { [ 3, numbersign, ordfeminine, threesuperior ] }; + key <AE04> { [ 4, dollar, cent, sterling ] }; + key <AE05> { [ 5, percent, EuroSign, yen ] }; + key <AE06> { [ 6, asciicircum, hstroke, Hstroke ] }; + key <AE07> { [ 7, ampersand, eth, ETH ] }; + key <AE08> { [ 8, asterisk, thorn, THORN ] }; + key <AE09> { [ 9, parenleft, leftsinglequotemark, leftdoublequotemark ] }; + key <AE10> { [ 0, parenright, rightsinglequotemark, rightdoublequotemark ] }; + key <AE11> { [ minus, underscore, endash, emdash ] }; + key <AE12> { [ equal, plus, multiply, division ] }; + + key <AD01> { [ q, Q, adiaeresis, Adiaeresis ] }; + key <AD02> { [ w, W, aring, Aring ] }; + key <AD03> { [ f, F, atilde, Atilde ] }; + key <AD04> { [ p, P, oslash, Ooblique ] }; + key <AD05> { [ g, G, dead_ogonek, asciitilde ] }; + key <AD06> { [ j, J, dstroke, Dstroke ] }; + key <AD07> { [ l, L, lstroke, Lstroke ] }; + key <AD08> { [ u, U, uacute, Uacute ] }; + key <AD09> { [ y, Y, udiaeresis, Udiaeresis ] }; + key <AD10> { [ semicolon, colon, odiaeresis, Odiaeresis ] }; + key <AD11> { [ bracketleft, braceleft, guillemotleft, 0x1002039 ] }; + key <AD12> { [ bracketright, braceright, guillemotright, 0x100203a ] }; + key <BKSL> { [ backslash, bar, asciitilde, asciitilde ] }; + + key <AC01> { [ a, A, aacute, Aacute ] }; + key <AC02> { [ r, R, dead_grave, asciitilde ] }; + key <AC03> { [ s, S, ssharp, asciitilde ] }; + key <AC04> { [ t, T, dead_acute, dead_doubleacute ] }; + key <AC05> { [ d, D, dead_diaeresis, asciitilde ] }; + key <AC06> { [ h, H, dead_caron, asciitilde ] }; + key <AC07> { [ n, N, ntilde, Ntilde ] }; + key <AC08> { [ e, E, eacute, Eacute ] }; + key <AC09> { [ i, I, iacute, Iacute ] }; + key <AC10> { [ o, O, oacute, Oacute ] }; + key <AC11> { [ apostrophe, quotedbl, otilde, Otilde ] }; + + key <AB01> { [ z, Z, ae, AE ] }; + key <AB02> { [ x, X, dead_circumflex, asciitilde ] }; + key <AB03> { [ c, C, ccedilla, Ccedilla ] }; + key <AB04> { [ v, V, oe, OE ] }; + key <AB05> { [ b, B, dead_breve, asciitilde ] }; + key <AB06> { [ k, K, dead_abovering, asciitilde ] }; + key <AB07> { [ m, M, dead_macron, asciitilde ] }; + key <AB08> { [ comma, less, dead_cedilla, asciitilde ] }; + key <AB09> { [ period, greater, dead_abovedot, asciitilde ] }; + key <AB10> { [ slash, question, questiondown, asciitilde ] }; + + key <CAPS> { [ BackSpace, BackSpace, BackSpace, BackSpace ] }; + key <LSGT> { [ minus, underscore, endash, emdash ] }; + key <SPCE> { [ space, space, space, nobreakspace ] }; + + include "level3(ralt_switch)" +}; + +// I do NOT like dead-keys - the International keyboard as defined by Microsoft +// doesn't fit my needs. Why use two keystrokes for all simple characters (eg ' +// and <space> generates a single ') just to have an é (eacute) in two strokes +// as well? I type ' more often than é (eacute). +// +// This file works just like a regular keyboard, BUT has all dead-keys +// accessible at level3 (through AltGr). An ë (ediaeresis) is now: AltGr+" +// followed by an e. In other words, this keyboard is not international as long +// as you leave the right Alt key alone. +// +// The original MS International keyboard was intended for Latin1 (iso8859-1). +// With the introduction of iso8859-15, the (important) ligature oe (and OE) +// became available. I added them next to ae. Because I write ediaeresis more +// often than registered, I moved registered to be next to copyright and added +// ediaeresis and idiaeresis. - Adriaan + +partial alphanumeric_keys +xkb_symbols "altgr-intl" { + + name[Group1]= "USA - International (AltGr dead keys)"; + + include "us(intl)" + +// five dead keys moved into level3: + + key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] }; + key <AC11> { [apostrophe,quotedbl, dead_acute, dead_diaeresis ] }; + +// diversions from the MS Intl keyboard: + + key <AE01> { [ 1, exclam, onesuperior, exclamdown ] }; + key <AD04> { [ r, R, ediaeresis, Ediaeresis ] }; + key <AC07> { [ j, J, idiaeresis, Idiaeresis ] }; + key <AB02> { [ x, X, oe, OE ] }; + key <AB04> { [ v, V, registered, registered ] }; + +// onequarter etc (not in iso8859-15) moved to get three unshifted deadkeys: + + key <AE06> { [ 6, asciicircum, dead_circumflex, onequarter ] }; + key <AE07> { [ 7, ampersand, dead_horn, onehalf ] }; + key <AE08> { [ 8, asterisk, dead_ogonek, threequarters ] }; + + include "level3(ralt_switch)" +}; + +// Intel ClassmatePC Keyboard Layout +// by Piter PUNK <piterpk@terra.com.br> +// +// The keyboard layouts below maps the us(basic), us(intl) and us(alt-intl) +// to ClassmatePC keyboard. All layouts uses RCTL as level3(switch) since +// the keyboard doesn't have AltGr key. The EuroSign is engraved at 5 key. + +// classmate - us(basic) +partial alphanumeric_keys +xkb_symbols "classmate" { + include "us(basic)" + name[Group1]= "USA - ClassmatePC"; + + key <LSGT> { [ backslash, bar, backslash, bar ] }; + + include "eurosign(5)" + include "level3(switch)" +}; + +// classmate-intl - us(intl) +// RCTL is generated by Fn+Alt, because that, when trying to access +// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got +// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key> +// generate the same symbol as the original key. +partial alphanumeric_keys +xkb_symbols "classmate-intl" { + include "us(intl)" + name[Group1]= "USA - ClassmatePC (International)"; + key.type[Group1]="FOUR_LEVEL"; + + key <LSGT> { [ backslash, bar, backslash, bar ] }; + + key <KP7> { [ KP_Home, KP_7, + onehalf, dead_horn ] }; + key <KP8> { [ KP_Up, KP_8, + threequarters, dead_ogonek ] }; + key <KP9> { [ KP_Prior, KP_9, + leftsinglequotemark, dead_breve ] }; + key <KPMU> { [ KP_Multiply, KP_Multiply, + rightsinglequotemark, dead_abovering ] }; + + key <KP4> { [ KP_Left, KP_4, + uacute, Uacute ] }; + key <KP5> { [ KP_Begin, KP_5, + iacute, Iacute ] }; + key <KP6> { [ KP_Right, KP_6, + oacute, Oacute ] }; + key <KPSU> { [ KP_Subtract, KP_Subtract, + odiaeresis, Odiaeresis ] }; + + key <KP2> { [ KP_Down, KP_2, + oe, OE ] }; + key <KP3> { [ KP_Next, KP_3, + oslash, Ooblique ] }; + key <KPAD> { [ KP_Add, KP_Add, + paragraph, degree ] }; + + key <KP0> { [ KP_Insert, KP_0, + mu, mu ] }; + key <KPDL> { [ KP_Delete, KP_Decimal, + dead_abovedot, dead_caron ] }; + key <KPDV> { [ KP_Divide, KP_Divide, + questiondown, dead_hook ] }; + + include "level3(switch)" +}; + +// classmate-alt-intl - us(alt-intl) +// RCTL is generated by Fn+Alt, because that, when trying to access +// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got +// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key> +// generate the same symbol as the original key. +partial alphanumeric_keys +xkb_symbols "classmate-alt-intl" { + include "us(alt-intl)" + name[Group1]= "USA - ClassmatePC (Alternative international)"; + key.type[Group1]="FOUR_LEVEL"; + + key <LSGT> { [ backslash, bar, backslash, bar ] }; + + key <KPSU> { [ KP_Subtract, KP_Subtract ] }; + + key <KP9> { [ KP_Prior, KP_9, + leftsinglequotemark, dead_breve ] }; + key <KPMU> { [ KP_Multiply, KP_Multiply, + rightsinglequotemark, dead_abovering ] }; + + key <KPAD> { [ KP_Add, KP_Add, + dead_ogonek, dead_diaeresis ] }; + + key <KPDL> { [ KP_Delete, KP_Decimal, + dead_abovedot, dead_circumflex ] }; + key <KPDV> { [ KP_Divide, KP_Divide, + dead_hook, dead_hook ] }; + + include "level3(switch)" +}; + +// classmate-altgr-intl - us(altgr-intl) +// RCTL is generated by Fn+Alt, because that, when trying to access +// the level3 symbols at 7,8,9,0,u,i,o,p,j,k,l,;,m,. and / we got +// the keypad keycodes. The keypad is changed to make Fn+Alt+<KP_key> +// generate the same symbol as the original key. +partial alphanumeric_keys +xkb_symbols "classmate-altgr-intl" { + include "us(altgr-intl)" + name[Group1]= "USA - ClassmatePC (International Fn+Alt dead-keys)"; + key.type[Group1]="FOUR_LEVEL"; + + key <LSGT> { [ backslash, bar, backslash, bar ] }; + + key <KP7> { [ KP_Home, KP_7, + dead_horn, dead_horn ] }; + key <KP8> { [ KP_Up, KP_8, + dead_ogonek, dead_ogonek ] }; + key <KP9> { [ KP_Prior, KP_9, + leftsinglequotemark, dead_breve ] }; + key <KPMU> { [ KP_Multiply, KP_Multiply, + rightsinglequotemark, dead_abovering ] }; + + key <KP4> { [ KP_Left, KP_4, + uacute, Uacute ] }; + key <KP5> { [ KP_Begin, KP_5, + iacute, Iacute ] }; + key <KP6> { [ KP_Right, KP_6, + oacute, Oacute ] }; + key <KPSU> { [ KP_Subtract, KP_Subtract, + odiaeresis, Odiaeresis ] }; + + key <KP1> { [ KP_End, KP_1, + idiaeresis, Idiaeresis ] }; + key <KP2> { [ KP_Down, KP_2, + oe, OE ] }; + key <KP3> { [ KP_Next, KP_3, + oslash, Ooblique ] }; + key <KPAD> { [ KP_Add, KP_Add, + paragraph, degree ] }; + + key <KP0> { [ KP_Insert, KP_0, + mu, mu ] }; + key <KPDL> { [ KP_Delete, KP_Decimal, + dead_abovedot, dead_caron ] }; + key <KPDV> { [ KP_Divide, KP_Divide, + questiondown, dead_hook ] }; + + include "level3(switch)" +}; + +partial alphanumeric_keys +xkb_symbols "olpc" { + + include "us(basic)" + name[Group1]= "USA"; + + // OLPC international US English keyboard layout. + // It's a little different from the usual international layout. + // See: http://wiki.laptop.org/go/Image:Keyboard_english.png + + key <TLDE> { [ grave, asciitilde, dead_grave, dead_tilde ] }; + key <AE01> { [ 1, exclam, exclamdown, exclamdown ] }; + key <AE02> { [ 2, at, notsign, notsign ] }; + key <AE03> { [ 3, numbersign, 0x1000300, 0x1000300 ] }; // combining grave + key <AE04> { [ 4, dollar, 0x1000301, 0x1000301 ] }; // combining acute + key <AE05> { [ 5, percent, 0x1000306, 0x1000306 ] }; // combining breve above + key <AE06> { [ 6,asciicircum, 0x100030A, 0x100030A ] }; // combining ring above + key <AE07> { [ 7, ampersand, 0x1000302, 0x1000302 ] }; // combining circumflex above + key <AE08> { [ 8, asterisk, 0x100030C, 0x100030C ] }; // combining caron above + key <AE09> { [ 9, parenleft, 0x1000307, 0x1000307 ] }; // combining dot above + key <AE10> { [ 0, parenright, 0x1000308, 0x1000308 ] }; // combining diaeresis above + key <AE11> { [ minus, underscore, 0x1000304, 0x1000304 ] }; // combining macron above + key <AE12> { [ equal, plus, 0x1000303, 0x1000303 ] }; // combining tilde above + + key <AD01> { [ q, Q, Greek_omega, Greek_OMEGA ] }; + key <AD02> { [ w, W, oslash, Oslash ] }; + key <AD03> { [ e, E, oe, OE ] }; + key <AD04> { [ r, R, 0x1000327, 0x1000327 ] }; // combining cedilla + key <AD05> { [ t, T, 0x100032E, 0x100032E ] }; // combining breve below + key <AD06> { [ y, Y, 0x1000325, 0x1000325 ] }; // combining ring below + key <AD07> { [ u, U, 0x100032D, 0x100032D ] }; // combining circumflex below + key <AD08> { [ i, I, 0x100032C, 0x100032C ] }; // combining caron below + key <AD09> { [ o, O, 0x1000323, 0x1000323 ] }; // combining dot below + key <AD10> { [ p, P, 0x1000324, 0x1000324 ] }; // combining diaeresis below + key <AD11> { [ bracketleft, braceleft, 0x1000331, 0x1000331 ] }; // combining macron below + key <AD12> { [bracketright, braceright, 0x1000330, 0x1000330 ] }; // combining tilde below + + key <AC01> { [ a, A, ae, AE ] }; + key <AC02> { [ s, S, ssharp, 0x1001E9C ] }; // uppercase S sharp + key <AC03> { [ d, D, eth, ETH ] }; + key <AC04> { [ f, F, thorn, THORN ] }; + key <AC06> { [ h, H, sterling, sterling ] }; + key <AC07> { [ j, J, EuroSign, EuroSign ] }; + key <AC10> { [ semicolon, colon, masculine, ordfeminine ] }; + key <AC11> { [ apostrophe, quotedbl, currency, currency ] }; + key <BKSL> { [ backslash, bar, section, section ] }; + + key <AB03> { [ c, C, ccedilla, Ccedilla ] }; + key <AB06> { [ n, N, ntilde, Ntilde ] }; + key <AB07> { [ m, M, mu, mu ] }; + key <AB08> { [ comma, less, guillemotleft, guillemotleft ] }; + key <AB09> { [ period, greater, guillemotright, guillemotright ] }; + key <AB10> { [ slash, question, questiondown, questiondown ] }; + + key <I219> { [ multiply, division, ISO_Next_Group, ISO_Prev_Group ] }; + + include "level3(ralt_switch)" +}; + +partial alphanumeric_keys +xkb_symbols "olpc2" { + include "us(olpc)" + name[Group1]= "USA - Layout toggle on multiply/divide key"; + include "group(olpc)" +}; + +// Based on Cherokee Nation Official Layout +// http://www.cherokee.org/extras/downloads/font/Keyboard.htm + +partial alphanumeric_keys modifier_keys +xkb_symbols "chr" { + + name[Group1]= "USA - Cherokee"; + key.type[group1]="ALPHABETIC"; + + // Alphanumeric section + key <TLDE> { [ grave, U13CA ] }; + key <AE01> { [ 1, U13B1 ] }; + key <AE02> { [ 2, U13C7 ] }; + key <AE03> { [ 3, U13E7 ] }; + key <AE04> { [ U13D9, U13B0 ] }; + key <AE05> { [ U13E6, U13B9 ] }; + key <AE06> { [ U13DC, U13DD ] }; + key <AE07> { [ U13CB, U13E1 ] }; + key <AE08> { [ U13D6, U13BA ] }; + key <AE09> { [ U13D2, parenleft ] }; + key <AE10> { [ U13C4, parenright ] }; + key <AE11> { [ U13BF, U13BC ] }; + key <AE12> { [ U13F3, U13BD ] }; + + key <AD01> { [ U13AA, U13C6 ] }; + key <AD02> { [ U13B3, U13EB ] }; + key <AD03> { [ U13A1, U13E3 ] }; + key <AD04> { [ U13DB, U13CF ] }; + key <AD05> { [ U13D4, U13D8 ] }; + key <AD06> { [ U13EF, U13F2 ] }; + key <AD07> { [ U13A4, U13AD ] }; + key <AD08> { [ U13A2, U13F1 ] }; + key <AD09> { [ U13A3, U13EC ] }; + key <AD10> { [ U13C1, U13EA ] }; + key <AD11> { [ U13D5, U13D1 ] }; + key <AD12> { [ U13B6, U13E4 ] }; + key <BKSL> { [ U13E9, U13EE ] }; + + key <AC01> { [ U13A0, U13CC ] }; + key <AC02> { [ U13CD, U13CE ] }; + key <AC03> { [ U13D7, U13D0 ] }; + key <AC04> { [ U13A9, U13C8 ] }; + key <AC05> { [ U13A6, U13E5 ] }; + key <AC06> { [ U13AF, U13B2 ] }; + key <AC07> { [ U13DA, U13AB ] }; + key <AC08> { [ U13B8, U13A7 ] }; + key <AC09> { [ U13B5, U13AE ] }; + key <AC10> { [ U13E8, U13E0 ] }; + key <AC11> { [ apostrophe, quotedbl ] }; + + key <AB01> { [ U13AC, U13C3 ] }; + key <AB02> { [ U13F4, U13ED ] }; + key <AB03> { [ U13D3, U13DF ] }; + key <AB04> { [ U13A5, U13DE ] }; + key <AB05> { [ U13A8, U13F0 ] }; + key <AB06> { [ U13BE, U13BB ] }; + key <AB07> { [ U13C5, U13B7 ] }; + key <AB08> { [ comma, U13E2 ] }; + key <AB09> { [ period, U13B4 ] }; + key <AB10> { [ U13C2, U13C9 ] }; + + // End alphanumeric section +}; + +// Serbian charecters added as third level symbols to US keyboard layout. + +partial alphanumeric_keys +xkb_symbols "hbs" { + + name[Group1]= "USA - Serbo-Croatian"; + + include "us" + + key <TLDE> { [ grave, asciitilde ] }; + key <AE06> { [ 6, dead_caron, asciicircum, asciicircum ] }; + key <AC09> { [ l, L, U1C9, U1C8 ] }; + key <AB06> { [ n, N, U1CC, U1CB ] }; + key <AB01> { [ z, Z, U1C6, U1C5 ] }; + key <AD03> { [ e, E, EuroSign, cent ] }; + key <AC03> { [ d, D, dstroke, Dstroke ] }; + key <AC11> { [ dead_acute, quotedbl, apostrophe, apostrophe ] }; + key <SPCE> { [ space, space, nobreakspace, nobreakspace ] }; + key <AB08> { [ comma, less, NoSymbol, guillemotright ] }; + key <AB09> { [ period, greater, NoSymbol, guillemotleft ] }; + + include "level3(ralt_switch)" +}; + +//based on http://upload.wikimedia.org/wikipedia/commons/1/18/T-Mobile_G1_launch_event_2.jpg +partial alphanumeric_keys +xkb_symbols "htcdream" { + include "inet(htcdream)" + name[Group1]= "USA - htcdream"; + + //second row + key <AD01> { [ q, Q, Tab, Tab ] }; + key <AD02> { [ w, W, grave, grave ] }; + key <AD03> { [ e, E, underscore, underscore ] }; + key <AD04> { [ r, R, sterling, sterling ] }; + key <AD05> { [ t, T, EuroSign, EuroSign ] }; + key <AD06> { [ y, Y, division, division ] }; + key <AD07> { [ u, U, multiply, multiply ] }; + key <AD08> { [ i, I, minus, minus ] }; + key <AD09> { [ o, O, plus, plus ] }; + key <AD10> { [ p, P, equal, equal ] }; + + //third row + key <AC01> { [ a, A, NoSymbol, NoSymbol ] }; + key <AC02> { [ s, S, bar, bar ] }; + key <AC03> { [ d ,D, backslash, backslash ] }; + key <AC04> { [ f, F, braceleft, braceleft ] }; + key <AC05> { [ g, G, braceright, braceright ] }; + key <AC06> { [ h, H, colon, colon ] }; + key <AC07> { [ j, J, semicolon, semicolon ] }; + key <AC08> { [ k, K, quotedbl, quotedbl ] }; + key <AC09> { [ l, L, apostrophe, apostrophe ] }; + + //forth row + key <AB01> { [ z, Z, NoSymbol, NoSymbol ] }; + key <AB02> { [ x, X, NoSymbol, NoSymbol ] }; + key <AB03> { [ c, C, NoSymbol, NoSymbol ] }; + key <AB04> { [ v, V, bracketleft, bracketleft ] }; + key <AB05> { [ b, B, bracketright, bracketright ] }; + key <AB06> { [ n, N, less, less ] }; + key <AB07> { [ m, M, greater, greater ] }; + key <AB08> { [ comma, comma, question, question ] }; + + //fifth row + key <FK15> { [ at, at, asciitilde, asciitilde ] }; + + include "level3(alt_switch)" +}; |