wm_abi.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. /* WM input events queued in struct wm_status. Alt+Tab/Shift+Alt+Tab are
  88. * small event codes; a runner key is WM_CHORD_KEY | <key code>. */
  89. #define WM_CHORD_QUEUE 16
  90. #define WM_CHORD_NEXT 1 /* Alt+Tab: next window in MRU order */
  91. #define WM_CHORD_PREV 2 /* Shift+Alt+Tab: previous window */
  92. #define WM_CHORD_KEY 0x80000000u
  93. /* Raw key codes forwarded to the app runner. The values match the kernel's
  94. * IO_KEY_* codes (static assertions in kernel/wm.c keep them in sync). */
  95. #define WM_RUNNER_KEY_LEFT 0x100
  96. #define WM_RUNNER_KEY_RIGHT 0x101
  97. #define WM_RUNNER_KEY_UP 0x102
  98. #define WM_RUNNER_KEY_DOWN 0x103
  99. #define WM_RUNNER_KEY_PAGE_UP 0x104
  100. #define WM_RUNNER_KEY_PAGE_DOWN 0x105
  101. #define WM_RUNNER_KEY_HOME 0x106
  102. #define WM_RUNNER_KEY_END 0x107
  103. #define WM_RUNNER_KEY_DELETE 0x108
  104. struct wm_status {
  105. struct wm_mouse_info mouse;
  106. unsigned int full_redraw;
  107. unsigned int boot_ready; /* storage is mounted; spawn the first terminal */
  108. unsigned int kexec_busy;
  109. unsigned int kexec_progress;
  110. unsigned int kexec_total;
  111. /* Panel backlight, for the WM's brightness OSD. seq changes on every
  112. * key/command adjustment; level is 0 when no PWM was found. */
  113. unsigned int backlight_present;
  114. unsigned int backlight_level;
  115. unsigned int backlight_seq;
  116. /* Bumped when a client installs a new wallpaper (SYS_WM_WALLPAPER);
  117. * the WM reloads its copy when this changes. */
  118. unsigned int wallpaper_seq;
  119. /* Current preferences and a change counter (SYS_WM_PREFS). */
  120. unsigned int prefs_seq;
  121. struct wm_prefs prefs;
  122. /* A client asked the WM to open Settings at a section
  123. * (SYS_WM_OPEN_SETTINGS); the sequence makes every request visible. */
  124. unsigned int settings_req_seq;
  125. unsigned int settings_req_section;
  126. /* WM input events (Alt+Tab chords and app-runner keys). The WM has no
  127. * window key queue of its own, so the kernel consumes them and
  128. * publishes the events here. chord_head is a monotonic write
  129. * counter: the event at position n lives in
  130. * chord_keys[n % WM_CHORD_QUEUE]. alt_down lets the WM commit the
  131. * Alt+Tab selection when Alt is released. */
  132. unsigned int alt_down;
  133. unsigned int chord_head;
  134. unsigned int chord_keys[WM_CHORD_QUEUE];
  135. /* 1 while the kernel is grabbing keys for the WM's app runner. The
  136. * Win/Super key toggles it; the WM mirrors this flag and draws the
  137. * centered input panel. Enter/Esc also release the grab. */
  138. unsigned int runner_active;
  139. };
  140. /* Wallpaper file: one header followed by tightly packed RGB565 pixels,
  141. * width * height * 2 bytes. The viewer pre-scales to at most 1440x810 and
  142. * the WM stretches the stored image to the framebuffer, so no image decoder
  143. * is linked into the WM. The installed data volume wins over the RAM copy. */
  144. #define WM_WALLPAPER_MAGIC "NBWAL1\0"
  145. #define WM_WALLPAPER_DATA "/data/WALLPAPR.BIN"
  146. #define WM_WALLPAPER_SHARE "/share/wallpaper"
  147. #define WM_WALLPAPER_MAX_W 1440
  148. #define WM_WALLPAPER_MAX_H 810
  149. struct wm_wallpaper_hdr {
  150. char magic[8];
  151. unsigned int width;
  152. unsigned int height;
  153. unsigned int reserved;
  154. };
  155. struct wm_window_info {
  156. unsigned int used;
  157. unsigned int focused;
  158. unsigned int pid;
  159. unsigned int popover; /* WIN_F_POPOVER: no title bar, drawn on top */
  160. int x, y;
  161. unsigned int w, h; /* outer window rectangle */
  162. unsigned int content_w, content_h;
  163. unsigned int dirty;
  164. unsigned int dirty_seq;
  165. unsigned int dmg_x, dmg_y, dmg_w, dmg_h; /* content-relative pixels */
  166. unsigned int content_gen;
  167. char title[16];
  168. };
  169. /* SYS_WIN_PRESENT argument: the content-relative part of the canvas that
  170. * changed since the last present. w == 0 or h == 0 means the whole canvas,
  171. * so a caller that does not track damage keeps the old behaviour. */
  172. struct wm_win_present {
  173. unsigned int x, y, w, h;
  174. };
  175. struct wm_map_info {
  176. void *va;
  177. unsigned int kind;
  178. unsigned int w, h;
  179. unsigned int stride; /* bytes per row for gfx, cells*2 for text */
  180. unsigned int generation;
  181. };
  182. struct wm_rect {
  183. int x, y;
  184. unsigned int w, h;
  185. };
  186. struct wm_present_info {
  187. unsigned int count; /* 0..4 */
  188. unsigned int immediate; /* 1: flush now (drag); 0: budgeted */
  189. struct wm_rect rect[4];
  190. };
  191. struct wm_geom {
  192. int x, y;
  193. };
  194. struct wm_size {
  195. unsigned int w, h;
  196. /* New window origin minus the old one, in screen pixels. The kernel
  197. * carries the previous front canvas over anchored by this delta, so a
  198. * left/top edge drag keeps the content in place instead of sliding it
  199. * or blanking it until the client repaints. */
  200. int dx, dy;
  201. };
  202. /* Generic canvas-window client API (gfx commands own their own window). */
  203. struct win_create {
  204. unsigned int w, h;
  205. unsigned int flags; /* WIN_F_* */
  206. char title[16];
  207. };
  208. struct win_info {
  209. void *fb; /* mapped RGB565 back buffer */
  210. unsigned int width, height;
  211. unsigned int id;
  212. };
  213. /* Pointer input for generic canvas windows. The ring-3 WM queues press and
  214. * release edges; the command polls the current position for hover and drags. */
  215. struct win_pointer {
  216. int x, y; /* relative to the canvas, may be outside */
  217. unsigned int buttons; /* bit0 left, bit1 right, bit2 middle */
  218. unsigned int inside; /* pointer is over this window's content */
  219. unsigned int focused;
  220. };
  221. /* Scroll accumulated for this window since the previous call, in pixels.
  222. * Positive dy means later content (wheel down under natural scrolling). */
  223. struct win_scroll {
  224. int dx, dy;
  225. };
  226. #define WIN_EV_POINTER_DOWN 1
  227. #define WIN_EV_POINTER_UP 2
  228. struct win_event {
  229. unsigned int type; /* WIN_EV_POINTER_* */
  230. int x, y; /* content-relative */
  231. unsigned int buttons; /* buttons after the event */
  232. unsigned int button; /* button that changed: bit0 left, bit1 right */
  233. };
  234. #endif