cursor_abi.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* Mouse-cursor shapes and the NBCUR1 cursor bundle.
  2. *
  3. * Shared by the kernel (kernel/cursor.c loads the bundle and mouse.c draws
  4. * it), ring 3 (SYS_WIN_SET_CURSOR / SYS_WM_SET_CURSOR take a shape id, the
  5. * browser maps CSS `cursor` keywords) and the host tool tools/mkcursors.c,
  6. * which builds /ramfs/cursors/adwaita24.cur from assets/cursors/adwaita/.
  7. *
  8. * The shape names are the CSS / freedesktop cursor names. CURSOR_LIST is an
  9. * X-macro: X(ENUM_SUFFIX, "css-name", "theme-file"); the order is the shape
  10. * id and the order of the shapes in the bundle, so append only. */
  11. #ifndef CURSOR_ABI_H
  12. #define CURSOR_ABI_H
  13. #define CURSOR_LIST(X) \
  14. X(DEFAULT, "default", "default") \
  15. X(POINTER, "pointer", "pointer") \
  16. X(TEXT, "text", "text") \
  17. X(VERTICAL_TEXT, "vertical-text", "vertical-text") \
  18. X(WAIT, "wait", "wait") \
  19. X(PROGRESS, "progress", "progress") \
  20. X(HELP, "help", "help") \
  21. X(CONTEXT_MENU, "context-menu", "context-menu") \
  22. X(CELL, "cell", "cell") \
  23. X(CROSSHAIR, "crosshair", "crosshair") \
  24. X(MOVE, "move", "all-resize") \
  25. X(ALL_SCROLL, "all-scroll", "all-scroll") \
  26. X(GRAB, "grab", "grab") \
  27. X(GRABBING, "grabbing", "grabbing") \
  28. X(NOT_ALLOWED, "not-allowed", "not-allowed") \
  29. X(NO_DROP, "no-drop", "no-drop") \
  30. X(COPY, "copy", "copy") \
  31. X(ALIAS, "alias", "alias") \
  32. X(ZOOM_IN, "zoom-in", "zoom-in") \
  33. X(ZOOM_OUT, "zoom-out", "zoom-out") \
  34. X(COL_RESIZE, "col-resize", "col-resize") \
  35. X(ROW_RESIZE, "row-resize", "row-resize") \
  36. X(N_RESIZE, "n-resize", "n-resize") \
  37. X(E_RESIZE, "e-resize", "e-resize") \
  38. X(S_RESIZE, "s-resize", "s-resize") \
  39. X(W_RESIZE, "w-resize", "w-resize") \
  40. X(NE_RESIZE, "ne-resize", "ne-resize") \
  41. X(NW_RESIZE, "nw-resize", "nw-resize") \
  42. X(SE_RESIZE, "se-resize", "se-resize") \
  43. X(SW_RESIZE, "sw-resize", "sw-resize") \
  44. X(EW_RESIZE, "ew-resize", "ew-resize") \
  45. X(NS_RESIZE, "ns-resize", "ns-resize") \
  46. X(NESW_RESIZE, "nesw-resize", "nesw-resize") \
  47. X(NWSE_RESIZE, "nwse-resize", "nwse-resize") \
  48. X(ALL_RESIZE, "all-resize", "all-resize")
  49. #define CURSOR_ENUM_(e, css, file) CURSOR_##e,
  50. enum cursor_shape {
  51. CURSOR_LIST(CURSOR_ENUM_)
  52. CURSOR_COUNT
  53. };
  54. #undef CURSOR_ENUM_
  55. /* SYS_WM_SET_CURSOR: no WM override, use the window's own cursor. */
  56. #define CURSOR_NO_OVERRIDE (-1)
  57. /* Largest cursor image the kernel accepts (the software cursor's save
  58. * buffer and the hardware planes are sized for it). */
  59. #define CURSOR_MAX_DIM 32
  60. /* ---- NBCUR1 bundle ------------------------------------------------------
  61. * [struct cursor_file_hdr][count x struct cursor_file_shape][pixels]
  62. * Pixels are premultiplied ARGB8888 (0xAARRGGBB little-endian dwords, as in
  63. * Xcursor), w*h per frame, frames stored back to back starting at
  64. * `offset` (bytes from the start of the file). Every field is
  65. * little-endian. */
  66. #define CURSOR_FILE_MAGIC "NBCUR1\0\0"
  67. struct cursor_file_hdr {
  68. char magic[8];
  69. unsigned int count; /* number of shapes (CURSOR_COUNT when built) */
  70. unsigned int nominal; /* theme size in px, e.g. 24 */
  71. };
  72. struct cursor_file_shape {
  73. unsigned short w, h;
  74. unsigned short hot_x, hot_y;
  75. unsigned short frames; /* >= 1; > 1 animates */
  76. unsigned short delay_ms; /* per frame when animated */
  77. unsigned int offset; /* first frame's pixels */
  78. };
  79. #endif