logo

xcursorgen-nox

xcursorgen(1) without libX11/libXcursor dependency

Xcursor.h (13209B)


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