wm_abi.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. /* Shared window-manager ABI: kernel <-> ring-3 WM.
  2. * Only plain types and syscall numbers live here; the kernel window state and
  3. * all font/pixel decisions stay elsewhere. */
  4. #ifndef WM_ABI_H
  5. #define WM_ABI_H
  6. #define WM_MAX_WINDOWS 8
  7. /* Shared chrome layout (the WM draws it, the kernel only stores geometry). */
  8. #define WM_BAR_H 30
  9. /* The WM's start button is the NebOS banner at the top left; it opens the
  10. * start menu. The bar notice and the right-aligned status area (clock,
  11. * sensors, network, power) never draw left of this edge. */
  12. #define WM_BAR_LEFT_END 160
  13. #define WM_TITLE_H 22
  14. #define WM_CLOSE_W 16
  15. /* No visible frame: the title bar and content start at the window origin. */
  16. #define WM_BORDER_W 0
  17. /* Invisible resize band around a normal window: WM_RESIZE_IN px inside the
  18. * outer edge and WM_RESIZE_OUT px outside it. Presses in the inside part
  19. * are not routed to the window content; the whole band starts a resize. */
  20. #define WM_RESIZE_IN 1
  21. #define WM_RESIZE_OUT 3
  22. /* Keep at least this much of the title bar on-screen when a window is dragged
  23. * past an edge, so it can always be grabbed and brought back. */
  24. #define WM_DRAG_VISIBLE 48
  25. /* Fixed user virtual addresses for the WM's mappings. The shadow is one
  26. * mapping; each window gets a private content slot large enough for a
  27. * full-screen RGB565 canvas (1280x1024 minus the chrome is ~2.5 MB). */
  28. #define WM_SHADOW_VA 0x58000000u
  29. #define WM_CONTENT_VA_BASE 0x59000000u
  30. #define WM_CONTENT_SLOT 0x00400000u /* 4 MB per window */
  31. /* Window content kind. */
  32. #define WM_KIND_NONE 0
  33. #define WM_KIND_GFX 1
  34. /* Canvas-window flags (struct win_create.flags). A popover is chromeless,
  35. * always on top and anchored by the WM under the top-bar network icon; its
  36. * canvas fills the whole window rectangle. */
  37. #define WIN_F_POPOVER 0x1u
  38. struct wm_screen_info {
  39. unsigned int width;
  40. unsigned int height;
  41. unsigned int pitch;
  42. unsigned int bpp;
  43. unsigned int bytes;
  44. void *fb;
  45. };
  46. struct wm_mouse_info {
  47. unsigned int x;
  48. unsigned int y;
  49. unsigned int buttons; /* bit0 left, bit1 right, bit2 middle */
  50. };
  51. struct wm_status {
  52. struct wm_mouse_info mouse;
  53. unsigned int full_redraw;
  54. unsigned int boot_ready; /* storage is mounted; spawn the first terminal */
  55. unsigned int kexec_busy;
  56. unsigned int kexec_progress;
  57. unsigned int kexec_total;
  58. /* Panel backlight, for the WM's brightness OSD. seq changes on every
  59. * key/command adjustment; level is 0 when no PWM was found. */
  60. unsigned int backlight_present;
  61. unsigned int backlight_level;
  62. unsigned int backlight_seq;
  63. /* Bumped when a client installs a new wallpaper (SYS_WM_WALLPAPER);
  64. * the WM reloads its copy when this changes. */
  65. unsigned int wallpaper_seq;
  66. };
  67. /* Wallpaper file: one header followed by tightly packed RGB565 pixels,
  68. * width * height * 2 bytes. The viewer pre-scales to at most 1440x810 and
  69. * the WM stretches the stored image to the framebuffer, so no image decoder
  70. * is linked into the WM. The installed data volume wins over the RAM copy. */
  71. #define WM_WALLPAPER_MAGIC "NBWAL1\0"
  72. #define WM_WALLPAPER_DATA "/data/WALLPAPR.BIN"
  73. #define WM_WALLPAPER_SHARE "/share/wallpaper"
  74. #define WM_WALLPAPER_MAX_W 1440
  75. #define WM_WALLPAPER_MAX_H 810
  76. struct wm_wallpaper_hdr {
  77. char magic[8];
  78. unsigned int width;
  79. unsigned int height;
  80. unsigned int reserved;
  81. };
  82. struct wm_window_info {
  83. unsigned int used;
  84. unsigned int focused;
  85. unsigned int pid;
  86. unsigned int popover; /* WIN_F_POPOVER: no title bar, drawn on top */
  87. int x, y;
  88. unsigned int w, h; /* outer window rectangle */
  89. unsigned int content_w, content_h;
  90. unsigned int dirty;
  91. unsigned int dirty_seq;
  92. unsigned int dmg_x, dmg_y, dmg_w, dmg_h; /* content-relative pixels */
  93. unsigned int content_gen;
  94. char title[16];
  95. };
  96. /* SYS_WIN_PRESENT argument: the content-relative part of the canvas that
  97. * changed since the last present. w == 0 or h == 0 means the whole canvas,
  98. * so a caller that does not track damage keeps the old behaviour. */
  99. struct wm_win_present {
  100. unsigned int x, y, w, h;
  101. };
  102. struct wm_map_info {
  103. void *va;
  104. unsigned int kind;
  105. unsigned int w, h;
  106. unsigned int stride; /* bytes per row for gfx, cells*2 for text */
  107. unsigned int generation;
  108. };
  109. struct wm_rect {
  110. int x, y;
  111. unsigned int w, h;
  112. };
  113. struct wm_present_info {
  114. unsigned int count; /* 0..4 */
  115. unsigned int immediate; /* 1: flush now (drag); 0: budgeted */
  116. struct wm_rect rect[4];
  117. };
  118. struct wm_geom {
  119. int x, y;
  120. };
  121. struct wm_size {
  122. unsigned int w, h;
  123. /* New window origin minus the old one, in screen pixels. The kernel
  124. * carries the previous front canvas over anchored by this delta, so a
  125. * left/top edge drag keeps the content in place instead of sliding it
  126. * or blanking it until the client repaints. */
  127. int dx, dy;
  128. };
  129. /* Generic canvas-window client API (gfx commands own their own window). */
  130. struct win_create {
  131. unsigned int w, h;
  132. unsigned int flags; /* WIN_F_* */
  133. char title[16];
  134. };
  135. struct win_info {
  136. void *fb; /* mapped RGB565 back buffer */
  137. unsigned int width, height;
  138. unsigned int id;
  139. };
  140. /* Pointer input for generic canvas windows. The ring-3 WM queues press and
  141. * release edges; the command polls the current position for hover and drags. */
  142. struct win_pointer {
  143. int x, y; /* relative to the canvas, may be outside */
  144. unsigned int buttons; /* bit0 left, bit1 right, bit2 middle */
  145. unsigned int inside; /* pointer is over this window's content */
  146. unsigned int focused;
  147. };
  148. /* Scroll accumulated for this window since the previous call, in pixels.
  149. * Positive dy means later content (wheel down under natural scrolling). */
  150. struct win_scroll {
  151. int dx, dy;
  152. };
  153. #define WIN_EV_POINTER_DOWN 1
  154. #define WIN_EV_POINTER_UP 2
  155. struct win_event {
  156. unsigned int type; /* WIN_EV_POINTER_* */
  157. int x, y; /* content-relative */
  158. unsigned int buttons; /* buttons after the event */
  159. unsigned int button; /* button that changed: bit0 left, bit1 right */
  160. };
  161. #endif