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