Path: blob/master/thirdparty/linuxbsd_headers/X11/Xcursor/Xcursor.h
9917 views
/* include/X11/Xcursor/Xcursor.h. Generated from Xcursor.h.in by configure. */1/*2* Copyright © 2002 Keith Packard3*4* Permission to use, copy, modify, distribute, and sell this software and its5* documentation for any purpose is hereby granted without fee, provided that6* the above copyright notice appear in all copies and that both that7* copyright notice and this permission notice appear in supporting8* documentation, and that the name of Keith Packard not be used in9* advertising or publicity pertaining to distribution of the software without10* specific, written prior permission. Keith Packard makes no11* representations about the suitability of this software for any purpose. It12* is provided "as is" without express or implied warranty.13*14* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,15* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO16* EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR17* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,18* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER19* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR20* PERFORMANCE OF THIS SOFTWARE.21*/2223#ifndef _XCURSOR_H_24#define _XCURSOR_H_25#include <stdio.h>26#include <X11/Xfuncproto.h>27#include <X11/Xlib.h>2829typedef int XcursorBool;30typedef unsigned int XcursorUInt;3132typedef XcursorUInt XcursorDim;33typedef XcursorUInt XcursorPixel;3435#define XcursorTrue 136#define XcursorFalse 03738/*39* Cursor files start with a header. The header40* contains a magic number, a version number and a41* table of contents which has type and offset information42* for the remaining tables in the file.43*44* File minor versions increment for compatible changes45* File major versions increment for incompatible changes (never, we hope)46*47* Chunks of the same type are always upward compatible. Incompatible48* changes are made with new chunk types; the old data can remain under49* the old type. Upward compatible changes can add header data as the50* header lengths are specified in the file.51*52* File:53* FileHeader54* LISTofChunk55*56* FileHeader:57* CARD32 magic magic number58* CARD32 header bytes in file header59* CARD32 version file version60* CARD32 ntoc number of toc entries61* LISTofFileToc toc table of contents62*63* FileToc:64* CARD32 type entry type65* CARD32 subtype entry subtype (size for images)66* CARD32 position absolute file position67*/6869#define XCURSOR_MAGIC 0x72756358 /* "Xcur" LSBFirst */7071/*72* Current Xcursor version number. Will be substituted by configure73* from the version in the libXcursor configure.ac file.74*/7576#define XCURSOR_LIB_MAJOR 177#define XCURSOR_LIB_MINOR 278#define XCURSOR_LIB_REVISION 079#define XCURSOR_LIB_VERSION ((XCURSOR_LIB_MAJOR * 10000) + \80(XCURSOR_LIB_MINOR * 100) + \81(XCURSOR_LIB_REVISION))8283/*84* This version number is stored in cursor files; changes to the85* file format require updating this version number86*/87#define XCURSOR_FILE_MAJOR 188#define XCURSOR_FILE_MINOR 089#define XCURSOR_FILE_VERSION ((XCURSOR_FILE_MAJOR << 16) | (XCURSOR_FILE_MINOR))90#define XCURSOR_FILE_HEADER_LEN (4 * 4)91#define XCURSOR_FILE_TOC_LEN (3 * 4)9293typedef struct _XcursorFileToc {94XcursorUInt type; /* chunk type */95XcursorUInt subtype; /* subtype (size for images) */96XcursorUInt position; /* absolute position in file */97} XcursorFileToc;9899typedef struct _XcursorFileHeader {100XcursorUInt magic; /* magic number */101XcursorUInt header; /* byte length of header */102XcursorUInt version; /* file version number */103XcursorUInt ntoc; /* number of toc entries */104XcursorFileToc *tocs; /* table of contents */105} XcursorFileHeader;106107/*108* The rest of the file is a list of chunks, each tagged by type109* and version.110*111* Chunk:112* ChunkHeader113* <extra type-specific header fields>114* <type-specific data>115*116* ChunkHeader:117* CARD32 header bytes in chunk header + type header118* CARD32 type chunk type119* CARD32 subtype chunk subtype120* CARD32 version chunk type version121*/122123#define XCURSOR_CHUNK_HEADER_LEN (4 * 4)124125typedef struct _XcursorChunkHeader {126XcursorUInt header; /* bytes in chunk header */127XcursorUInt type; /* chunk type */128XcursorUInt subtype; /* chunk subtype (size for images) */129XcursorUInt version; /* version of this type */130} XcursorChunkHeader;131132/*133* Here's a list of the known chunk types134*/135136/*137* Comments consist of a 4-byte length field followed by138* UTF-8 encoded text139*140* Comment:141* ChunkHeader header chunk header142* CARD32 length bytes in text143* LISTofCARD8 text UTF-8 encoded text144*/145146#define XCURSOR_COMMENT_TYPE 0xfffe0001147#define XCURSOR_COMMENT_VERSION 1148#define XCURSOR_COMMENT_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (1 *4))149#define XCURSOR_COMMENT_COPYRIGHT 1150#define XCURSOR_COMMENT_LICENSE 2151#define XCURSOR_COMMENT_OTHER 3152#define XCURSOR_COMMENT_MAX_LEN 0x100000153154typedef struct _XcursorComment {155XcursorUInt version;156XcursorUInt comment_type;157char *comment;158} XcursorComment;159160/*161* Each cursor image occupies a separate image chunk.162* The length of the image header follows the chunk header163* so that future versions can extend the header without164* breaking older applications165*166* Image:167* ChunkHeader header chunk header168* CARD32 width actual width169* CARD32 height actual height170* CARD32 xhot hot spot x171* CARD32 yhot hot spot y172* CARD32 delay animation delay173* LISTofCARD32 pixels ARGB pixels174*/175176#define XCURSOR_IMAGE_TYPE 0xfffd0002177#define XCURSOR_IMAGE_VERSION 1178#define XCURSOR_IMAGE_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (5*4))179#define XCURSOR_IMAGE_MAX_SIZE 0x7fff /* 32767x32767 max cursor size */180181typedef struct _XcursorImage {182XcursorUInt version; /* version of the image data */183XcursorDim size; /* nominal size for matching */184XcursorDim width; /* actual width */185XcursorDim height; /* actual height */186XcursorDim xhot; /* hot spot x (must be inside image) */187XcursorDim yhot; /* hot spot y (must be inside image) */188XcursorUInt delay; /* animation delay to next frame (ms) */189XcursorPixel *pixels; /* pointer to pixels */190} XcursorImage;191192/*193* Other data structures exposed by the library API194*/195typedef struct _XcursorImages {196int nimage; /* number of images */197XcursorImage **images; /* array of XcursorImage pointers */198char *name; /* name used to load images */199} XcursorImages;200201typedef struct _XcursorCursors {202Display *dpy; /* Display holding cursors */203int ref; /* reference count */204int ncursor; /* number of cursors */205Cursor *cursors; /* array of cursors */206} XcursorCursors;207208typedef struct _XcursorAnimate {209XcursorCursors *cursors; /* list of cursors to use */210int sequence; /* which cursor is next */211} XcursorAnimate;212213typedef struct _XcursorFile XcursorFile;214215struct _XcursorFile {216void *closure;217int (*read) (XcursorFile *file, unsigned char *buf, int len);218int (*write) (XcursorFile *file, unsigned char *buf, int len);219int (*seek) (XcursorFile *file, long offset, int whence);220};221222typedef struct _XcursorComments {223int ncomment; /* number of comments */224XcursorComment **comments; /* array of XcursorComment pointers */225} XcursorComments;226227#define XCURSOR_CORE_THEME "core"228229_XFUNCPROTOBEGIN230231/*232* Manage Image objects233*/234XcursorImage *235XcursorImageCreate (int width, int height);236237void238XcursorImageDestroy (XcursorImage *image);239240/*241* Manage Images objects242*/243XcursorImages *244XcursorImagesCreate (int size);245246void247XcursorImagesDestroy (XcursorImages *images);248249void250XcursorImagesSetName (XcursorImages *images, const char *name);251252/*253* Manage Cursor objects254*/255XcursorCursors *256XcursorCursorsCreate (Display *dpy, int size);257258void259XcursorCursorsDestroy (XcursorCursors *cursors);260261/*262* Manage Animate objects263*/264XcursorAnimate *265XcursorAnimateCreate (XcursorCursors *cursors);266267void268XcursorAnimateDestroy (XcursorAnimate *animate);269270Cursor271XcursorAnimateNext (XcursorAnimate *animate);272273/*274* Manage Comment objects275*/276XcursorComment *277XcursorCommentCreate (XcursorUInt comment_type, int length);278279void280XcursorCommentDestroy (XcursorComment *comment);281282XcursorComments *283XcursorCommentsCreate (int size);284285void286XcursorCommentsDestroy (XcursorComments *comments);287288/*289* XcursorFile/Image APIs290*/291XcursorImage *292XcursorXcFileLoadImage (XcursorFile *file, int size);293294XcursorImages *295XcursorXcFileLoadImages (XcursorFile *file, int size);296297XcursorImages *298XcursorXcFileLoadAllImages (XcursorFile *file);299300XcursorBool301XcursorXcFileLoad (XcursorFile *file,302XcursorComments **commentsp,303XcursorImages **imagesp);304305XcursorBool306XcursorXcFileSave (XcursorFile *file,307const XcursorComments *comments,308const XcursorImages *images);309310/*311* FILE/Image APIs312*/313XcursorImage *314XcursorFileLoadImage (FILE *file, int size);315316XcursorImages *317XcursorFileLoadImages (FILE *file, int size);318319XcursorImages *320XcursorFileLoadAllImages (FILE *file);321322XcursorBool323XcursorFileLoad (FILE *file,324XcursorComments **commentsp,325XcursorImages **imagesp);326327XcursorBool328XcursorFileSaveImages (FILE *file, const XcursorImages *images);329330XcursorBool331XcursorFileSave (FILE * file,332const XcursorComments *comments,333const XcursorImages *images);334335/*336* Filename/Image APIs337*/338XcursorImage *339XcursorFilenameLoadImage (const char *filename, int size);340341XcursorImages *342XcursorFilenameLoadImages (const char *filename, int size);343344XcursorImages *345XcursorFilenameLoadAllImages (const char *filename);346347XcursorBool348XcursorFilenameLoad (const char *file,349XcursorComments **commentsp,350XcursorImages **imagesp);351352XcursorBool353XcursorFilenameSaveImages (const char *filename, const XcursorImages *images);354355XcursorBool356XcursorFilenameSave (const char *file,357const XcursorComments *comments,358const XcursorImages *images);359360/*361* Library/Image APIs362*/363XcursorImage *364XcursorLibraryLoadImage (const char *library, const char *theme, int size);365366XcursorImages *367XcursorLibraryLoadImages (const char *library, const char *theme, int size);368369/*370* Library/shape API371*/372373const char *374XcursorLibraryPath (void);375376int377XcursorLibraryShape (const char *library);378379/*380* Image/Cursor APIs381*/382383Cursor384XcursorImageLoadCursor (Display *dpy, const XcursorImage *image);385386XcursorCursors *387XcursorImagesLoadCursors (Display *dpy, const XcursorImages *images);388389Cursor390XcursorImagesLoadCursor (Display *dpy, const XcursorImages *images);391392/*393* Filename/Cursor APIs394*/395Cursor396XcursorFilenameLoadCursor (Display *dpy, const char *file);397398XcursorCursors *399XcursorFilenameLoadCursors (Display *dpy, const char *file);400401/*402* Library/Cursor APIs403*/404Cursor405XcursorLibraryLoadCursor (Display *dpy, const char *file);406407XcursorCursors *408XcursorLibraryLoadCursors (Display *dpy, const char *file);409410/*411* Shape/Image APIs412*/413414XcursorImage *415XcursorShapeLoadImage (unsigned int shape, const char *theme, int size);416417XcursorImages *418XcursorShapeLoadImages (unsigned int shape, const char *theme, int size);419420/*421* Shape/Cursor APIs422*/423Cursor424XcursorShapeLoadCursor (Display *dpy, unsigned int shape);425426XcursorCursors *427XcursorShapeLoadCursors (Display *dpy, unsigned int shape);428429/*430* This is the function called by Xlib when attempting to431* load cursors from XCreateGlyphCursor. The interface must432* not change as Xlib loads 'libXcursor.so' instead of433* a specific major version434*/435Cursor436XcursorTryShapeCursor (Display *dpy,437Font source_font,438Font mask_font,439unsigned int source_char,440unsigned int mask_char,441XColor _Xconst *foreground,442XColor _Xconst *background);443444void445XcursorNoticeCreateBitmap (Display *dpy,446Pixmap pid,447unsigned int width,448unsigned int height);449450void451XcursorNoticePutBitmap (Display *dpy,452Drawable draw,453XImage *image);454455Cursor456XcursorTryShapeBitmapCursor (Display *dpy,457Pixmap source,458Pixmap mask,459XColor *foreground,460XColor *background,461unsigned int x,462unsigned int y);463464#define XCURSOR_BITMAP_HASH_SIZE 16465466void467XcursorImageHash (XImage *image,468unsigned char hash[XCURSOR_BITMAP_HASH_SIZE]);469470/*471* Display information APIs472*/473XcursorBool474XcursorSupportsARGB (Display *dpy);475476XcursorBool477XcursorSupportsAnim (Display *dpy);478479XcursorBool480XcursorSetDefaultSize (Display *dpy, int size);481482int483XcursorGetDefaultSize (Display *dpy);484485XcursorBool486XcursorSetTheme (Display *dpy, const char *theme);487488char *489XcursorGetTheme (Display *dpy);490491XcursorBool492XcursorGetThemeCore (Display *dpy);493494XcursorBool495XcursorSetThemeCore (Display *dpy, XcursorBool theme_core);496497_XFUNCPROTOEND498499#endif500501502