| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 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 | |
| 32 | typedef int XcursorBool; |
| 33 | typedef uint32_t XcursorUInt; |
| 34 | |
| 35 | typedef XcursorUInt XcursorDim; |
| 36 | typedef XcursorUInt XcursorPixel; |
| 37 | |
| 38 | #define XcursorTrue 1 |
| 39 | #define XcursorFalse 0 |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | #define XCURSOR_MAGIC 0x72756358 |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 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 | |
| 88 | |
| 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 | |
| 96 | typedef struct _XcursorFileToc { |
| 97 | XcursorUInt type; |
| 98 | XcursorUInt subtype; |
| 99 | XcursorUInt position; |
| 100 | } XcursorFileToc; |
| 101 | |
| 102 | typedef struct _XcursorFileHeader { |
| 103 | XcursorUInt magic; |
| 104 | XcursorUInt header; |
| 105 | XcursorUInt version; |
| 106 | XcursorUInt ntoc; |
| 107 | XcursorFileToc *tocs; |
| 108 | } XcursorFileHeader; |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | |
| 114 | |
| 115 | |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | #define XCURSOR_CHUNK_HEADER_LEN (4 * 4) |
| 127 | |
| 128 | typedef struct _XcursorChunkHeader { |
| 129 | XcursorUInt header; |
| 130 | XcursorUInt type; |
| 131 | XcursorUInt subtype; |
| 132 | XcursorUInt version; |
| 133 | } XcursorChunkHeader; |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 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 | |
| 157 | typedef struct _XcursorComment { |
| 158 | XcursorUInt version; |
| 159 | XcursorUInt comment_type; |
| 160 | char *comment; |
| 161 | } XcursorComment; |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 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 |
| 183 | |
| 184 | typedef struct _XcursorImage { |
| 185 | XcursorUInt version; |
| 186 | XcursorDim size; |
| 187 | XcursorDim width; |
| 188 | XcursorDim height; |
| 189 | XcursorDim xhot; |
| 190 | XcursorDim yhot; |
| 191 | XcursorUInt delay; |
| 192 | XcursorPixel *pixels; |
| 193 | } XcursorImage; |
| 194 | |
| 195 | |
| 196 | |
| 197 | |
| 198 | typedef struct _XcursorImages { |
| 199 | int nimage; |
| 200 | XcursorImage **images; |
| 201 | char *name; |
| 202 | } XcursorImages; |
| 203 | |
| 204 | typedef struct _XcursorCursors { |
| 205 | Display *dpy; |
| 206 | int ref; |
| 207 | int ncursor; |
| 208 | Cursor *cursors; |
| 209 | } XcursorCursors; |
| 210 | |
| 211 | typedef struct _XcursorAnimate { |
| 212 | XcursorCursors *cursors; |
| 213 | int sequence; |
| 214 | } XcursorAnimate; |
| 215 | |
| 216 | typedef struct _XcursorFile XcursorFile; |
| 217 | |
| 218 | struct _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 | |
| 225 | typedef struct _XcursorComments { |
| 226 | int ncomment; |
| 227 | XcursorComment **comments; |
| 228 | } XcursorComments; |
| 229 | |
| 230 | #define XCURSOR_CORE_THEME "core" |
| 231 | |
| 232 | _XFUNCPROTOBEGIN |
| 233 | |
| 234 | |
| 235 | |
| 236 | |
| 237 | XcursorImage * |
| 238 | XcursorImageCreate (int width, int height); |
| 239 | |
| 240 | void |
| 241 | XcursorImageDestroy (XcursorImage *image); |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | XcursorImages * |
| 247 | XcursorImagesCreate (int size); |
| 248 | |
| 249 | void |
| 250 | XcursorImagesDestroy (XcursorImages *images); |
| 251 | |
| 252 | void |
| 253 | XcursorImagesSetName (XcursorImages *images, const char *name); |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | XcursorCursors * |
| 259 | XcursorCursorsCreate (Display *dpy, int size); |
| 260 | |
| 261 | void |
| 262 | XcursorCursorsDestroy (XcursorCursors *cursors); |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | XcursorAnimate * |
| 268 | XcursorAnimateCreate (XcursorCursors *cursors); |
| 269 | |
| 270 | void |
| 271 | XcursorAnimateDestroy (XcursorAnimate *animate); |
| 272 | |
| 273 | Cursor |
| 274 | XcursorAnimateNext (XcursorAnimate *animate); |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | XcursorComment * |
| 280 | XcursorCommentCreate (XcursorUInt comment_type, int length); |
| 281 | |
| 282 | void |
| 283 | XcursorCommentDestroy (XcursorComment *comment); |
| 284 | |
| 285 | XcursorComments * |
| 286 | XcursorCommentsCreate (int size); |
| 287 | |
| 288 | void |
| 289 | XcursorCommentsDestroy (XcursorComments *comments); |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | XcursorImage * |
| 295 | XcursorXcFileLoadImage (XcursorFile *file, int size); |
| 296 | |
| 297 | XcursorImages * |
| 298 | XcursorXcFileLoadImages (XcursorFile *file, int size); |
| 299 | |
| 300 | XcursorImages * |
| 301 | XcursorXcFileLoadAllImages (XcursorFile *file); |
| 302 | |
| 303 | XcursorBool |
| 304 | XcursorXcFileLoad (XcursorFile *file, |
| 305 | XcursorComments **commentsp, |
| 306 | XcursorImages **imagesp); |
| 307 | |
| 308 | XcursorBool |
| 309 | XcursorXcFileSave (XcursorFile *file, |
| 310 | const XcursorComments *comments, |
| 311 | const XcursorImages *images); |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | XcursorImage * |
| 317 | XcursorFileLoadImage (FILE *file, int size); |
| 318 | |
| 319 | XcursorImages * |
| 320 | XcursorFileLoadImages (FILE *file, int size); |
| 321 | |
| 322 | XcursorImages * |
| 323 | XcursorFileLoadAllImages (FILE *file); |
| 324 | |
| 325 | XcursorBool |
| 326 | XcursorFileLoad (FILE *file, |
| 327 | XcursorComments **commentsp, |
| 328 | XcursorImages **imagesp); |
| 329 | |
| 330 | XcursorBool |
| 331 | XcursorFileSaveImages (FILE *file, const XcursorImages *images); |
| 332 | |
| 333 | XcursorBool |
| 334 | XcursorFileSave (FILE * file, |
| 335 | const XcursorComments *comments, |
| 336 | const XcursorImages *images); |
| 337 | |
| 338 | |
| 339 | |
| 340 | |
| 341 | XcursorImage * |
| 342 | XcursorFilenameLoadImage (const char *filename, int size); |
| 343 | |
| 344 | XcursorImages * |
| 345 | XcursorFilenameLoadImages (const char *filename, int size); |
| 346 | |
| 347 | XcursorImages * |
| 348 | XcursorFilenameLoadAllImages (const char *filename); |
| 349 | |
| 350 | XcursorBool |
| 351 | XcursorFilenameLoad (const char *file, |
| 352 | XcursorComments **commentsp, |
| 353 | XcursorImages **imagesp); |
| 354 | |
| 355 | XcursorBool |
| 356 | XcursorFilenameSaveImages (const char *filename, const XcursorImages *images); |
| 357 | |
| 358 | XcursorBool |
| 359 | XcursorFilenameSave (const char *file, |
| 360 | const XcursorComments *comments, |
| 361 | const XcursorImages *images); |
| 362 | |
| 363 | |
| 364 | |
| 365 | |
| 366 | XcursorImage * |
| 367 | XcursorLibraryLoadImage (const char *library, const char *theme, int size); |
| 368 | |
| 369 | XcursorImages * |
| 370 | XcursorLibraryLoadImages (const char *library, const char *theme, int size); |
| 371 | |
| 372 | |
| 373 | |
| 374 | |
| 375 | |
| 376 | const char * |
| 377 | XcursorLibraryPath (void); |
| 378 | |
| 379 | int |
| 380 | XcursorLibraryShape (const char *library); |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | Cursor |
| 387 | XcursorImageLoadCursor (Display *dpy, const XcursorImage *image); |
| 388 | |
| 389 | XcursorCursors * |
| 390 | XcursorImagesLoadCursors (Display *dpy, const XcursorImages *images); |
| 391 | |
| 392 | Cursor |
| 393 | XcursorImagesLoadCursor (Display *dpy, const XcursorImages *images); |
| 394 | |
| 395 | |
| 396 | |
| 397 | |
| 398 | Cursor |
| 399 | XcursorFilenameLoadCursor (Display *dpy, const char *file); |
| 400 | |
| 401 | XcursorCursors * |
| 402 | XcursorFilenameLoadCursors (Display *dpy, const char *file); |
| 403 | |
| 404 | |
| 405 | |
| 406 | |
| 407 | Cursor |
| 408 | XcursorLibraryLoadCursor (Display *dpy, const char *file); |
| 409 | |
| 410 | XcursorCursors * |
| 411 | XcursorLibraryLoadCursors (Display *dpy, const char *file); |
| 412 | |
| 413 | |
| 414 | |
| 415 | |
| 416 | |
| 417 | XcursorImage * |
| 418 | XcursorShapeLoadImage (unsigned int shape, const char *theme, int size); |
| 419 | |
| 420 | XcursorImages * |
| 421 | XcursorShapeLoadImages (unsigned int shape, const char *theme, int size); |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | Cursor |
| 427 | XcursorShapeLoadCursor (Display *dpy, unsigned int shape); |
| 428 | |
| 429 | XcursorCursors * |
| 430 | XcursorShapeLoadCursors (Display *dpy, unsigned int shape); |
| 431 | |
| 432 | |
| 433 | |
| 434 | |
| 435 | |
| 436 | |
| 437 | |
| 438 | Cursor |
| 439 | XcursorTryShapeCursor (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 | |
| 447 | void |
| 448 | XcursorNoticeCreateBitmap (Display *dpy, |
| 449 | Pixmap pid, |
| 450 | unsigned int width, |
| 451 | unsigned int height); |
| 452 | |
| 453 | void |
| 454 | XcursorNoticePutBitmap (Display *dpy, |
| 455 | Drawable draw, |
| 456 | XImage *image); |
| 457 | |
| 458 | Cursor |
| 459 | XcursorTryShapeBitmapCursor (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 | |
| 469 | void |
| 470 | XcursorImageHash (XImage *image, |
| 471 | unsigned char hash[XCURSOR_BITMAP_HASH_SIZE]); |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | XcursorBool |
| 477 | XcursorSupportsARGB (Display *dpy); |
| 478 | |
| 479 | XcursorBool |
| 480 | XcursorSupportsAnim (Display *dpy); |
| 481 | |
| 482 | XcursorBool |
| 483 | XcursorSetDefaultSize (Display *dpy, int size); |
| 484 | |
| 485 | int |
| 486 | XcursorGetDefaultSize (Display *dpy); |
| 487 | |
| 488 | XcursorBool |
| 489 | XcursorSetResizable (Display *dpy, XcursorBool flag); |
| 490 | |
| 491 | XcursorBool |
| 492 | XcursorGetResizable (Display *dpy); |
| 493 | |
| 494 | XcursorBool |
| 495 | XcursorSetTheme (Display *dpy, const char *theme); |
| 496 | |
| 497 | char * |
| 498 | XcursorGetTheme (Display *dpy); |
| 499 | |
| 500 | XcursorBool |
| 501 | XcursorGetThemeCore (Display *dpy); |
| 502 | |
| 503 | XcursorBool |
| 504 | XcursorSetThemeCore (Display *dpy, XcursorBool theme_core); |
| 505 | |
| 506 | _XFUNCPROTOEND |
| 507 | |
| 508 | #endif |