Xcursor.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. /* include/X11/Xcursor/Xcursor.h. Generated from Xcursor.h.in by configure. */
  2. /*
  3. * Copyright © 2002 Keith Packard
  4. *
  5. * Permission to use, copy, modify, distribute, and sell this software and its
  6. * documentation for any purpose is hereby granted without fee, provided that
  7. * the above copyright notice appear in all copies and that both that
  8. * copyright notice and this permission notice appear in supporting
  9. * documentation, and that the name of Keith Packard not be used in
  10. * advertising or publicity pertaining to distribution of the software without
  11. * specific, written prior permission. Keith Packard makes no
  12. * representations about the suitability of this software for any purpose. It
  13. * is provided "as is" without express or implied warranty.
  14. *
  15. * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  16. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  17. * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  18. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  19. * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  20. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  21. * PERFORMANCE OF THIS SOFTWARE.
  22. */
  23. #ifndef _XCURSOR_H_
  24. #define _XCURSOR_H_
  25. #include <stdio.h>
  26. #include <X11/Xfuncproto.h>
  27. #include <X11/Xlib.h>
  28. typedef int XcursorBool;
  29. typedef unsigned int XcursorUInt;
  30. typedef XcursorUInt XcursorDim;
  31. typedef XcursorUInt XcursorPixel;
  32. #define XcursorTrue 1
  33. #define XcursorFalse 0
  34. /*
  35. * Cursor files start with a header. The header
  36. * contains a magic number, a version number and a
  37. * table of contents which has type and offset information
  38. * for the remaining tables in the file.
  39. *
  40. * File minor versions increment for compatible changes
  41. * File major versions increment for incompatible changes (never, we hope)
  42. *
  43. * Chunks of the same type are always upward compatible. Incompatible
  44. * changes are made with new chunk types; the old data can remain under
  45. * the old type. Upward compatible changes can add header data as the
  46. * header lengths are specified in the file.
  47. *
  48. * File:
  49. * FileHeader
  50. * LISTofChunk
  51. *
  52. * FileHeader:
  53. * CARD32 magic magic number
  54. * CARD32 header bytes in file header
  55. * CARD32 version file version
  56. * CARD32 ntoc number of toc entries
  57. * LISTofFileToc toc table of contents
  58. *
  59. * FileToc:
  60. * CARD32 type entry type
  61. * CARD32 subtype entry subtype (size for images)
  62. * CARD32 position absolute file position
  63. */
  64. #define XCURSOR_MAGIC 0x72756358 /* "Xcur" LSBFirst */
  65. /*
  66. * Current Xcursor version number. Will be substituted by configure
  67. * from the version in the libXcursor configure.ac file.
  68. */
  69. #define XCURSOR_LIB_MAJOR 1
  70. #define XCURSOR_LIB_MINOR 2
  71. #define XCURSOR_LIB_REVISION 0
  72. #define XCURSOR_LIB_VERSION ((XCURSOR_LIB_MAJOR * 10000) + \
  73. (XCURSOR_LIB_MINOR * 100) + \
  74. (XCURSOR_LIB_REVISION))
  75. /*
  76. * This version number is stored in cursor files; changes to the
  77. * file format require updating this version number
  78. */
  79. #define XCURSOR_FILE_MAJOR 1
  80. #define XCURSOR_FILE_MINOR 0
  81. #define XCURSOR_FILE_VERSION ((XCURSOR_FILE_MAJOR << 16) | (XCURSOR_FILE_MINOR))
  82. #define XCURSOR_FILE_HEADER_LEN (4 * 4)
  83. #define XCURSOR_FILE_TOC_LEN (3 * 4)
  84. typedef struct _XcursorFileToc {
  85. XcursorUInt type; /* chunk type */
  86. XcursorUInt subtype; /* subtype (size for images) */
  87. XcursorUInt position; /* absolute position in file */
  88. } XcursorFileToc;
  89. typedef struct _XcursorFileHeader {
  90. XcursorUInt magic; /* magic number */
  91. XcursorUInt header; /* byte length of header */
  92. XcursorUInt version; /* file version number */
  93. XcursorUInt ntoc; /* number of toc entries */
  94. XcursorFileToc *tocs; /* table of contents */
  95. } XcursorFileHeader;
  96. /*
  97. * The rest of the file is a list of chunks, each tagged by type
  98. * and version.
  99. *
  100. * Chunk:
  101. * ChunkHeader
  102. * <extra type-specific header fields>
  103. * <type-specific data>
  104. *
  105. * ChunkHeader:
  106. * CARD32 header bytes in chunk header + type header
  107. * CARD32 type chunk type
  108. * CARD32 subtype chunk subtype
  109. * CARD32 version chunk type version
  110. */
  111. #define XCURSOR_CHUNK_HEADER_LEN (4 * 4)
  112. typedef struct _XcursorChunkHeader {
  113. XcursorUInt header; /* bytes in chunk header */
  114. XcursorUInt type; /* chunk type */
  115. XcursorUInt subtype; /* chunk subtype (size for images) */
  116. XcursorUInt version; /* version of this type */
  117. } XcursorChunkHeader;
  118. /*
  119. * Here's a list of the known chunk types
  120. */
  121. /*
  122. * Comments consist of a 4-byte length field followed by
  123. * UTF-8 encoded text
  124. *
  125. * Comment:
  126. * ChunkHeader header chunk header
  127. * CARD32 length bytes in text
  128. * LISTofCARD8 text UTF-8 encoded text
  129. */
  130. #define XCURSOR_COMMENT_TYPE 0xfffe0001
  131. #define XCURSOR_COMMENT_VERSION 1
  132. #define XCURSOR_COMMENT_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (1 *4))
  133. #define XCURSOR_COMMENT_COPYRIGHT 1
  134. #define XCURSOR_COMMENT_LICENSE 2
  135. #define XCURSOR_COMMENT_OTHER 3
  136. #define XCURSOR_COMMENT_MAX_LEN 0x100000
  137. typedef struct _XcursorComment {
  138. XcursorUInt version;
  139. XcursorUInt comment_type;
  140. char *comment;
  141. } XcursorComment;
  142. /*
  143. * Each cursor image occupies a separate image chunk.
  144. * The length of the image header follows the chunk header
  145. * so that future versions can extend the header without
  146. * breaking older applications
  147. *
  148. * Image:
  149. * ChunkHeader header chunk header
  150. * CARD32 width actual width
  151. * CARD32 height actual height
  152. * CARD32 xhot hot spot x
  153. * CARD32 yhot hot spot y
  154. * CARD32 delay animation delay
  155. * LISTofCARD32 pixels ARGB pixels
  156. */
  157. #define XCURSOR_IMAGE_TYPE 0xfffd0002
  158. #define XCURSOR_IMAGE_VERSION 1
  159. #define XCURSOR_IMAGE_HEADER_LEN (XCURSOR_CHUNK_HEADER_LEN + (5*4))
  160. #define XCURSOR_IMAGE_MAX_SIZE 0x7fff /* 32767x32767 max cursor size */
  161. typedef struct _XcursorImage {
  162. XcursorUInt version; /* version of the image data */
  163. XcursorDim size; /* nominal size for matching */
  164. XcursorDim width; /* actual width */
  165. XcursorDim height; /* actual height */
  166. XcursorDim xhot; /* hot spot x (must be inside image) */
  167. XcursorDim yhot; /* hot spot y (must be inside image) */
  168. XcursorUInt delay; /* animation delay to next frame (ms) */
  169. XcursorPixel *pixels; /* pointer to pixels */
  170. } XcursorImage;
  171. /*
  172. * Other data structures exposed by the library API
  173. */
  174. typedef struct _XcursorImages {
  175. int nimage; /* number of images */
  176. XcursorImage **images; /* array of XcursorImage pointers */
  177. char *name; /* name used to load images */
  178. } XcursorImages;
  179. typedef struct _XcursorCursors {
  180. Display *dpy; /* Display holding cursors */
  181. int ref; /* reference count */
  182. int ncursor; /* number of cursors */
  183. Cursor *cursors; /* array of cursors */
  184. } XcursorCursors;
  185. typedef struct _XcursorAnimate {
  186. XcursorCursors *cursors; /* list of cursors to use */
  187. int sequence; /* which cursor is next */
  188. } XcursorAnimate;
  189. typedef struct _XcursorFile XcursorFile;
  190. struct _XcursorFile {
  191. void *closure;
  192. int (*read) (XcursorFile *file, unsigned char *buf, int len);
  193. int (*write) (XcursorFile *file, unsigned char *buf, int len);
  194. int (*seek) (XcursorFile *file, long offset, int whence);
  195. };
  196. typedef struct _XcursorComments {
  197. int ncomment; /* number of comments */
  198. XcursorComment **comments; /* array of XcursorComment pointers */
  199. } XcursorComments;
  200. #define XCURSOR_CORE_THEME "core"
  201. _XFUNCPROTOBEGIN
  202. /*
  203. * Manage Image objects
  204. */
  205. XcursorImage *
  206. XcursorImageCreate (int width, int height);
  207. void
  208. XcursorImageDestroy (XcursorImage *image);
  209. /*
  210. * Manage Images objects
  211. */
  212. XcursorImages *
  213. XcursorImagesCreate (int size);
  214. void
  215. XcursorImagesDestroy (XcursorImages *images);
  216. void
  217. XcursorImagesSetName (XcursorImages *images, const char *name);
  218. /*
  219. * Manage Cursor objects
  220. */
  221. XcursorCursors *
  222. XcursorCursorsCreate (Display *dpy, int size);
  223. void
  224. XcursorCursorsDestroy (XcursorCursors *cursors);
  225. /*
  226. * Manage Animate objects
  227. */
  228. XcursorAnimate *
  229. XcursorAnimateCreate (XcursorCursors *cursors);
  230. void
  231. XcursorAnimateDestroy (XcursorAnimate *animate);
  232. Cursor
  233. XcursorAnimateNext (XcursorAnimate *animate);
  234. /*
  235. * Manage Comment objects
  236. */
  237. XcursorComment *
  238. XcursorCommentCreate (XcursorUInt comment_type, int length);
  239. void
  240. XcursorCommentDestroy (XcursorComment *comment);
  241. XcursorComments *
  242. XcursorCommentsCreate (int size);
  243. void
  244. XcursorCommentsDestroy (XcursorComments *comments);
  245. /*
  246. * XcursorFile/Image APIs
  247. */
  248. XcursorImage *
  249. XcursorXcFileLoadImage (XcursorFile *file, int size);
  250. XcursorImages *
  251. XcursorXcFileLoadImages (XcursorFile *file, int size);
  252. XcursorImages *
  253. XcursorXcFileLoadAllImages (XcursorFile *file);
  254. XcursorBool
  255. XcursorXcFileLoad (XcursorFile *file,
  256. XcursorComments **commentsp,
  257. XcursorImages **imagesp);
  258. XcursorBool
  259. XcursorXcFileSave (XcursorFile *file,
  260. const XcursorComments *comments,
  261. const XcursorImages *images);
  262. /*
  263. * FILE/Image APIs
  264. */
  265. XcursorImage *
  266. XcursorFileLoadImage (FILE *file, int size);
  267. XcursorImages *
  268. XcursorFileLoadImages (FILE *file, int size);
  269. XcursorImages *
  270. XcursorFileLoadAllImages (FILE *file);
  271. XcursorBool
  272. XcursorFileLoad (FILE *file,
  273. XcursorComments **commentsp,
  274. XcursorImages **imagesp);
  275. XcursorBool
  276. XcursorFileSaveImages (FILE *file, const XcursorImages *images);
  277. XcursorBool
  278. XcursorFileSave (FILE * file,
  279. const XcursorComments *comments,
  280. const XcursorImages *images);
  281. /*
  282. * Filename/Image APIs
  283. */
  284. XcursorImage *
  285. XcursorFilenameLoadImage (const char *filename, int size);
  286. XcursorImages *
  287. XcursorFilenameLoadImages (const char *filename, int size);
  288. XcursorImages *
  289. XcursorFilenameLoadAllImages (const char *filename);
  290. XcursorBool
  291. XcursorFilenameLoad (const char *file,
  292. XcursorComments **commentsp,
  293. XcursorImages **imagesp);
  294. XcursorBool
  295. XcursorFilenameSaveImages (const char *filename, const XcursorImages *images);
  296. XcursorBool
  297. XcursorFilenameSave (const char *file,
  298. const XcursorComments *comments,
  299. const XcursorImages *images);
  300. /*
  301. * Library/Image APIs
  302. */
  303. XcursorImage *
  304. XcursorLibraryLoadImage (const char *library, const char *theme, int size);
  305. XcursorImages *
  306. XcursorLibraryLoadImages (const char *library, const char *theme, int size);
  307. /*
  308. * Library/shape API
  309. */
  310. const char *
  311. XcursorLibraryPath (void);
  312. int
  313. XcursorLibraryShape (const char *library);
  314. /*
  315. * Image/Cursor APIs
  316. */
  317. Cursor
  318. XcursorImageLoadCursor (Display *dpy, const XcursorImage *image);
  319. XcursorCursors *
  320. XcursorImagesLoadCursors (Display *dpy, const XcursorImages *images);
  321. Cursor
  322. XcursorImagesLoadCursor (Display *dpy, const XcursorImages *images);
  323. /*
  324. * Filename/Cursor APIs
  325. */
  326. Cursor
  327. XcursorFilenameLoadCursor (Display *dpy, const char *file);
  328. XcursorCursors *
  329. XcursorFilenameLoadCursors (Display *dpy, const char *file);
  330. /*
  331. * Library/Cursor APIs
  332. */
  333. Cursor
  334. XcursorLibraryLoadCursor (Display *dpy, const char *file);
  335. XcursorCursors *
  336. XcursorLibraryLoadCursors (Display *dpy, const char *file);
  337. /*
  338. * Shape/Image APIs
  339. */
  340. XcursorImage *
  341. XcursorShapeLoadImage (unsigned int shape, const char *theme, int size);
  342. XcursorImages *
  343. XcursorShapeLoadImages (unsigned int shape, const char *theme, int size);
  344. /*
  345. * Shape/Cursor APIs
  346. */
  347. Cursor
  348. XcursorShapeLoadCursor (Display *dpy, unsigned int shape);
  349. XcursorCursors *
  350. XcursorShapeLoadCursors (Display *dpy, unsigned int shape);
  351. /*
  352. * This is the function called by Xlib when attempting to
  353. * load cursors from XCreateGlyphCursor. The interface must
  354. * not change as Xlib loads 'libXcursor.so' instead of
  355. * a specific major version
  356. */
  357. Cursor
  358. XcursorTryShapeCursor (Display *dpy,
  359. Font source_font,
  360. Font mask_font,
  361. unsigned int source_char,
  362. unsigned int mask_char,
  363. XColor _Xconst *foreground,
  364. XColor _Xconst *background);
  365. void
  366. XcursorNoticeCreateBitmap (Display *dpy,
  367. Pixmap pid,
  368. unsigned int width,
  369. unsigned int height);
  370. void
  371. XcursorNoticePutBitmap (Display *dpy,
  372. Drawable draw,
  373. XImage *image);
  374. Cursor
  375. XcursorTryShapeBitmapCursor (Display *dpy,
  376. Pixmap source,
  377. Pixmap mask,
  378. XColor *foreground,
  379. XColor *background,
  380. unsigned int x,
  381. unsigned int y);
  382. #define XCURSOR_BITMAP_HASH_SIZE 16
  383. void
  384. XcursorImageHash (XImage *image,
  385. unsigned char hash[XCURSOR_BITMAP_HASH_SIZE]);
  386. /*
  387. * Display information APIs
  388. */
  389. XcursorBool
  390. XcursorSupportsARGB (Display *dpy);
  391. XcursorBool
  392. XcursorSupportsAnim (Display *dpy);
  393. XcursorBool
  394. XcursorSetDefaultSize (Display *dpy, int size);
  395. int
  396. XcursorGetDefaultSize (Display *dpy);
  397. XcursorBool
  398. XcursorSetTheme (Display *dpy, const char *theme);
  399. char *
  400. XcursorGetTheme (Display *dpy);
  401. XcursorBool
  402. XcursorGetThemeCore (Display *dpy);
  403. XcursorBool
  404. XcursorSetThemeCore (Display *dpy, XcursorBool theme_core);
  405. _XFUNCPROTOEND
  406. #endif