wm_abi.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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 4
  22. /* Corner grab squares reach this far inside the window along both edges, so
  23. * the diagonal resize is easier to hit than the thin edge band. */
  24. #define WM_CORNER_IN 12
  25. /* Keep at least this much of the title bar on-screen when a window is dragged
  26. * past an edge, so it can always be grabbed and brought back. */
  27. #define WM_DRAG_VISIBLE 48
  28. /* Fixed user virtual addresses for the WM's mappings. The shadow is one
  29. * mapping; each window gets a private content slot large enough for a
  30. * full-screen RGB565 canvas (1280x1024 minus the chrome is ~2.5 MB). */
  31. #define WM_SHADOW_VA 0x58000000u
  32. #define WM_CONTENT_VA_BASE 0x59000000u
  33. #define WM_CONTENT_SLOT 0x00400000u /* 4 MB per window */
  34. /* Window content kind. */
  35. #define WM_KIND_NONE 0
  36. #define WM_KIND_GFX 1
  37. /* Settings sections. The control-center popover's pills ask the WM to open
  38. * one of these in the Settings app, and the app's sidebar uses the same
  39. * order. */
  40. #define WM_SETTINGS_NETWORK 0
  41. #define WM_SETTINGS_POWER 1
  42. #define WM_SETTINGS_DATETIME 2
  43. #define WM_SETTINGS_APPEARANCE 3
  44. #define WM_SETTINGS_WINDOWS 4
  45. #define WM_SETTINGS_ABOUT 5
  46. #define WM_SETTINGS_COUNT 6
  47. /* Persistent window-manager preferences. The Settings app writes this
  48. * structure to a small file on /data (or /share before the data volume is
  49. * mounted) and pushes it through SYS_WM_PREFS, so a running WM applies the
  50. * change immediately and a restarted WM can restore it. */
  51. #define WM_DEFAULT_BG_RGB 0x202030u
  52. struct wm_prefs {
  53. unsigned int snap; /* 1 = snap to screen edges on drop */
  54. unsigned int resist; /* 1 = edge resistance while dragging */
  55. unsigned int bg_rgb; /* desktop colour without a wallpaper */
  56. unsigned int reserved[4];
  57. };
  58. #define WM_PREFS_MAGIC "NBSET1\0\0"
  59. #define WM_PREFS_VERSION 2u
  60. #define WM_PREFS_DATA "/data/SETTINGS.CFG"
  61. #define WM_PREFS_SHARE "/share/settings.cfg"
  62. /* The WM writes the requested section here before focusing an already
  63. * running Settings window; the app polls it and switches panes. */
  64. #define WM_SETTINGS_REQUEST "/share/settings.req"
  65. struct wm_prefs_file {
  66. char magic[8];
  67. unsigned int version;
  68. struct wm_prefs prefs;
  69. };
  70. /* Canvas-window flags (struct win_create.flags). A popover is chromeless,
  71. * always on top and anchored by the WM under the top-bar network icon; its
  72. * canvas fills the whole window rectangle. */
  73. #define WIN_F_POPOVER 0x1u
  74. struct wm_screen_info {
  75. unsigned int width;
  76. unsigned int height;
  77. unsigned int pitch;
  78. unsigned int bpp;
  79. unsigned int bytes;
  80. void *fb;
  81. };
  82. struct wm_mouse_info {
  83. unsigned int x;
  84. unsigned int y;
  85. unsigned int buttons; /* bit0 left, bit1 right, bit2 middle */
  86. };
  87. /* Alt+Tab chord events queued in struct wm_status. */
  88. #define WM_CHORD_QUEUE 8
  89. #define WM_CHORD_NEXT 1 /* Alt+Tab: next window in MRU order */
  90. #define WM_CHORD_PREV 2 /* Shift+Alt+Tab: previous window */
  91. struct wm_status {
  92. struct wm_mouse_info mouse;
  93. unsigned int full_redraw;
  94. unsigned int boot_ready; /* storage is mounted; spawn the first terminal */
  95. unsigned int kexec_busy;
  96. unsigned int kexec_progress;
  97. unsigned int kexec_total;
  98. /* Panel backlight, for the WM's brightness OSD. seq changes on every
  99. * key/command adjustment; level is 0 when no PWM was found. */
  100. unsigned int backlight_present;
  101. unsigned int backlight_level;
  102. unsigned int backlight_seq;
  103. /* Bumped when a client installs a new wallpaper (SYS_WM_WALLPAPER);
  104. * the WM reloads its copy when this changes. */
  105. unsigned int wallpaper_seq;
  106. /* Current preferences and a change counter (SYS_WM_PREFS). */
  107. unsigned int prefs_seq;
  108. struct wm_prefs prefs;
  109. /* A client asked the WM to open Settings at a section
  110. * (SYS_WM_OPEN_SETTINGS); the sequence makes every request visible. */
  111. unsigned int settings_req_seq;
  112. unsigned int settings_req_section;
  113. /* Alt+Tab chords for the WM. The WM has no window key queue of its
  114. * own, so the kernel consumes the chord and publishes the events
  115. * here. chord_head is a monotonic write counter: the event at
  116. * position n lives in chord_keys[n % WM_CHORD_QUEUE]. alt_down lets
  117. * the WM commit the selection when Alt is released. */
  118. unsigned int alt_down;
  119. unsigned int chord_head;
  120. unsigned int chord_keys[WM_CHORD_QUEUE];
  121. };
  122. /* Wallpaper file: one header followed by tightly packed RGB565 pixels,
  123. * width * height * 2 bytes. The viewer pre-scales to at most 1440x810 and
  124. * the WM stretches the stored image to the framebuffer, so no image decoder
  125. * is linked into the WM. The installed data volume wins over the RAM copy. */
  126. #define WM_WALLPAPER_MAGIC "NBWAL1\0"
  127. #define WM_WALLPAPER_DATA "/data/WALLPAPR.BIN"
  128. #define WM_WALLPAPER_SHARE "/share/wallpaper"
  129. #define WM_WALLPAPER_MAX_W 1440
  130. #define WM_WALLPAPER_MAX_H 810
  131. struct wm_wallpaper_hdr {
  132. char magic[8];
  133. unsigned int width;
  134. unsigned int height;
  135. unsigned int reserved;
  136. };
  137. struct wm_window_info {
  138. unsigned int used;
  139. unsigned int focused;
  140. unsigned int pid;
  141. unsigned int popover; /* WIN_F_POPOVER: no title bar, drawn on top */
  142. int x, y;
  143. unsigned int w, h; /* outer window rectangle */
  144. unsigned int content_w, content_h;
  145. unsigned int dirty;
  146. unsigned int dirty_seq;
  147. unsigned int dmg_x, dmg_y, dmg_w, dmg_h; /* content-relative pixels */
  148. unsigned int content_gen;
  149. char title[16];
  150. };
  151. /* SYS_WIN_PRESENT argument: the content-relative part of the canvas that
  152. * changed since the last present. w == 0 or h == 0 means the whole canvas,
  153. * so a caller that does not track damage keeps the old behaviour. */
  154. struct wm_win_present {
  155. unsigned int x, y, w, h;
  156. };
  157. struct wm_map_info {
  158. void *va;
  159. unsigned int kind;
  160. unsigned int w, h;
  161. unsigned int stride; /* bytes per row for gfx, cells*2 for text */
  162. unsigned int generation;
  163. };
  164. struct wm_rect {
  165. int x, y;
  166. unsigned int w, h;
  167. };
  168. struct wm_present_info {
  169. unsigned int count; /* 0..4 */
  170. unsigned int immediate; /* 1: flush now (drag); 0: budgeted */
  171. struct wm_rect rect[4];
  172. };
  173. struct wm_geom {
  174. int x, y;
  175. };
  176. struct wm_size {
  177. unsigned int w, h;
  178. /* New window origin minus the old one, in screen pixels. The kernel
  179. * carries the previous front canvas over anchored by this delta, so a
  180. * left/top edge drag keeps the content in place instead of sliding it
  181. * or blanking it until the client repaints. */
  182. int dx, dy;
  183. };
  184. /* Generic canvas-window client API (gfx commands own their own window). */
  185. struct win_create {
  186. unsigned int w, h;
  187. unsigned int flags; /* WIN_F_* */
  188. char title[16];
  189. };
  190. struct win_info {
  191. void *fb; /* mapped RGB565 back buffer */
  192. unsigned int width, height;
  193. unsigned int id;
  194. };
  195. /* Pointer input for generic canvas windows. The ring-3 WM queues press and
  196. * release edges; the command polls the current position for hover and drags. */
  197. struct win_pointer {
  198. int x, y; /* relative to the canvas, may be outside */
  199. unsigned int buttons; /* bit0 left, bit1 right, bit2 middle */
  200. unsigned int inside; /* pointer is over this window's content */
  201. unsigned int focused;
  202. };
  203. /* Scroll accumulated for this window since the previous call, in pixels.
  204. * Positive dy means later content (wheel down under natural scrolling). */
  205. struct win_scroll {
  206. int dx, dy;
  207. };
  208. #define WIN_EV_POINTER_DOWN 1
  209. #define WIN_EV_POINTER_UP 2
  210. struct win_event {
  211. unsigned int type; /* WIN_EV_POINTER_* */
  212. int x, y; /* content-relative */
  213. unsigned int buttons; /* buttons after the event */
  214. unsigned int button; /* button that changed: bit0 left, bit1 right */
  215. };
  216. #endif