wm_abi.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 shadow; /* 1 = soft window shadows */
  54. unsigned int snap; /* 1 = snap to screen edges on drop */
  55. unsigned int resist; /* 1 = edge resistance while dragging */
  56. unsigned int bg_rgb; /* desktop colour without a wallpaper */
  57. unsigned int reserved[4];
  58. };
  59. #define WM_PREFS_MAGIC "NBSET1\0\0"
  60. #define WM_PREFS_VERSION 1u
  61. #define WM_PREFS_DATA "/data/SETTINGS.CFG"
  62. #define WM_PREFS_SHARE "/share/settings.cfg"
  63. /* The WM writes the requested section here before focusing an already
  64. * running Settings window; the app polls it and switches panes. */
  65. #define WM_SETTINGS_REQUEST "/share/settings.req"
  66. struct wm_prefs_file {
  67. char magic[8];
  68. unsigned int version;
  69. struct wm_prefs prefs;
  70. };
  71. /* Canvas-window flags (struct win_create.flags). A popover is chromeless,
  72. * always on top and anchored by the WM under the top-bar network icon; its
  73. * canvas fills the whole window rectangle. */
  74. #define WIN_F_POPOVER 0x1u
  75. struct wm_screen_info {
  76. unsigned int width;
  77. unsigned int height;
  78. unsigned int pitch;
  79. unsigned int bpp;
  80. unsigned int bytes;
  81. void *fb;
  82. };
  83. struct wm_mouse_info {
  84. unsigned int x;
  85. unsigned int y;
  86. unsigned int buttons; /* bit0 left, bit1 right, bit2 middle */
  87. };
  88. struct wm_status {
  89. struct wm_mouse_info mouse;
  90. unsigned int full_redraw;
  91. unsigned int boot_ready; /* storage is mounted; spawn the first terminal */
  92. unsigned int kexec_busy;
  93. unsigned int kexec_progress;
  94. unsigned int kexec_total;
  95. /* Panel backlight, for the WM's brightness OSD. seq changes on every
  96. * key/command adjustment; level is 0 when no PWM was found. */
  97. unsigned int backlight_present;
  98. unsigned int backlight_level;
  99. unsigned int backlight_seq;
  100. /* Bumped when a client installs a new wallpaper (SYS_WM_WALLPAPER);
  101. * the WM reloads its copy when this changes. */
  102. unsigned int wallpaper_seq;
  103. /* Current preferences and a change counter (SYS_WM_PREFS). */
  104. unsigned int prefs_seq;
  105. struct wm_prefs prefs;
  106. /* A client asked the WM to open Settings at a section
  107. * (SYS_WM_OPEN_SETTINGS); the sequence makes every request visible. */
  108. unsigned int settings_req_seq;
  109. unsigned int settings_req_section;
  110. };
  111. /* Wallpaper file: one header followed by tightly packed RGB565 pixels,
  112. * width * height * 2 bytes. The viewer pre-scales to at most 1440x810 and
  113. * the WM stretches the stored image to the framebuffer, so no image decoder
  114. * is linked into the WM. The installed data volume wins over the RAM copy. */
  115. #define WM_WALLPAPER_MAGIC "NBWAL1\0"
  116. #define WM_WALLPAPER_DATA "/data/WALLPAPR.BIN"
  117. #define WM_WALLPAPER_SHARE "/share/wallpaper"
  118. #define WM_WALLPAPER_MAX_W 1440
  119. #define WM_WALLPAPER_MAX_H 810
  120. struct wm_wallpaper_hdr {
  121. char magic[8];
  122. unsigned int width;
  123. unsigned int height;
  124. unsigned int reserved;
  125. };
  126. struct wm_window_info {
  127. unsigned int used;
  128. unsigned int focused;
  129. unsigned int pid;
  130. unsigned int popover; /* WIN_F_POPOVER: no title bar, drawn on top */
  131. int x, y;
  132. unsigned int w, h; /* outer window rectangle */
  133. unsigned int content_w, content_h;
  134. unsigned int dirty;
  135. unsigned int dirty_seq;
  136. unsigned int dmg_x, dmg_y, dmg_w, dmg_h; /* content-relative pixels */
  137. unsigned int content_gen;
  138. char title[16];
  139. };
  140. /* SYS_WIN_PRESENT argument: the content-relative part of the canvas that
  141. * changed since the last present. w == 0 or h == 0 means the whole canvas,
  142. * so a caller that does not track damage keeps the old behaviour. */
  143. struct wm_win_present {
  144. unsigned int x, y, w, h;
  145. };
  146. struct wm_map_info {
  147. void *va;
  148. unsigned int kind;
  149. unsigned int w, h;
  150. unsigned int stride; /* bytes per row for gfx, cells*2 for text */
  151. unsigned int generation;
  152. };
  153. struct wm_rect {
  154. int x, y;
  155. unsigned int w, h;
  156. };
  157. struct wm_present_info {
  158. unsigned int count; /* 0..4 */
  159. unsigned int immediate; /* 1: flush now (drag); 0: budgeted */
  160. struct wm_rect rect[4];
  161. };
  162. struct wm_geom {
  163. int x, y;
  164. };
  165. struct wm_size {
  166. unsigned int w, h;
  167. /* New window origin minus the old one, in screen pixels. The kernel
  168. * carries the previous front canvas over anchored by this delta, so a
  169. * left/top edge drag keeps the content in place instead of sliding it
  170. * or blanking it until the client repaints. */
  171. int dx, dy;
  172. };
  173. /* Generic canvas-window client API (gfx commands own their own window). */
  174. struct win_create {
  175. unsigned int w, h;
  176. unsigned int flags; /* WIN_F_* */
  177. char title[16];
  178. };
  179. struct win_info {
  180. void *fb; /* mapped RGB565 back buffer */
  181. unsigned int width, height;
  182. unsigned int id;
  183. };
  184. /* Pointer input for generic canvas windows. The ring-3 WM queues press and
  185. * release edges; the command polls the current position for hover and drags. */
  186. struct win_pointer {
  187. int x, y; /* relative to the canvas, may be outside */
  188. unsigned int buttons; /* bit0 left, bit1 right, bit2 middle */
  189. unsigned int inside; /* pointer is over this window's content */
  190. unsigned int focused;
  191. };
  192. /* Scroll accumulated for this window since the previous call, in pixels.
  193. * Positive dy means later content (wheel down under natural scrolling). */
  194. struct win_scroll {
  195. int dx, dy;
  196. };
  197. #define WIN_EV_POINTER_DOWN 1
  198. #define WIN_EV_POINTER_UP 2
  199. struct win_event {
  200. unsigned int type; /* WIN_EV_POINTER_* */
  201. int x, y; /* content-relative */
  202. unsigned int buttons; /* buttons after the event */
  203. unsigned int button; /* button that changed: bit0 left, bit1 right */
  204. };
  205. #endif