wm_abi.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. /* Canvas-window flags (struct win_create.flags). A popover is chromeless,
  38. * always on top and anchored by the WM under the top-bar network icon; its
  39. * canvas fills the whole window rectangle. */
  40. #define WIN_F_POPOVER 0x1u
  41. struct wm_screen_info {
  42. unsigned int width;
  43. unsigned int height;
  44. unsigned int pitch;
  45. unsigned int bpp;
  46. unsigned int bytes;
  47. void *fb;
  48. };
  49. struct wm_mouse_info {
  50. unsigned int x;
  51. unsigned int y;
  52. unsigned int buttons; /* bit0 left, bit1 right, bit2 middle */
  53. };
  54. struct wm_status {
  55. struct wm_mouse_info mouse;
  56. unsigned int full_redraw;
  57. unsigned int boot_ready; /* storage is mounted; spawn the first terminal */
  58. unsigned int kexec_busy;
  59. unsigned int kexec_progress;
  60. unsigned int kexec_total;
  61. /* Panel backlight, for the WM's brightness OSD. seq changes on every
  62. * key/command adjustment; level is 0 when no PWM was found. */
  63. unsigned int backlight_present;
  64. unsigned int backlight_level;
  65. unsigned int backlight_seq;
  66. /* Bumped when a client installs a new wallpaper (SYS_WM_WALLPAPER);
  67. * the WM reloads its copy when this changes. */
  68. unsigned int wallpaper_seq;
  69. };
  70. /* Wallpaper file: one header followed by tightly packed RGB565 pixels,
  71. * width * height * 2 bytes. The viewer pre-scales to at most 1440x810 and
  72. * the WM stretches the stored image to the framebuffer, so no image decoder
  73. * is linked into the WM. The installed data volume wins over the RAM copy. */
  74. #define WM_WALLPAPER_MAGIC "NBWAL1\0"
  75. #define WM_WALLPAPER_DATA "/data/WALLPAPR.BIN"
  76. #define WM_WALLPAPER_SHARE "/share/wallpaper"
  77. #define WM_WALLPAPER_MAX_W 1440
  78. #define WM_WALLPAPER_MAX_H 810
  79. struct wm_wallpaper_hdr {
  80. char magic[8];
  81. unsigned int width;
  82. unsigned int height;
  83. unsigned int reserved;
  84. };
  85. struct wm_window_info {
  86. unsigned int used;
  87. unsigned int focused;
  88. unsigned int pid;
  89. unsigned int popover; /* WIN_F_POPOVER: no title bar, drawn on top */
  90. int x, y;
  91. unsigned int w, h; /* outer window rectangle */
  92. unsigned int content_w, content_h;
  93. unsigned int dirty;
  94. unsigned int dirty_seq;
  95. unsigned int dmg_x, dmg_y, dmg_w, dmg_h; /* content-relative pixels */
  96. unsigned int content_gen;
  97. char title[16];
  98. };
  99. /* SYS_WIN_PRESENT argument: the content-relative part of the canvas that
  100. * changed since the last present. w == 0 or h == 0 means the whole canvas,
  101. * so a caller that does not track damage keeps the old behaviour. */
  102. struct wm_win_present {
  103. unsigned int x, y, w, h;
  104. };
  105. struct wm_map_info {
  106. void *va;
  107. unsigned int kind;
  108. unsigned int w, h;
  109. unsigned int stride; /* bytes per row for gfx, cells*2 for text */
  110. unsigned int generation;
  111. };
  112. struct wm_rect {
  113. int x, y;
  114. unsigned int w, h;
  115. };
  116. struct wm_present_info {
  117. unsigned int count; /* 0..4 */
  118. unsigned int immediate; /* 1: flush now (drag); 0: budgeted */
  119. struct wm_rect rect[4];
  120. };
  121. struct wm_geom {
  122. int x, y;
  123. };
  124. struct wm_size {
  125. unsigned int w, h;
  126. /* New window origin minus the old one, in screen pixels. The kernel
  127. * carries the previous front canvas over anchored by this delta, so a
  128. * left/top edge drag keeps the content in place instead of sliding it
  129. * or blanking it until the client repaints. */
  130. int dx, dy;
  131. };
  132. /* Generic canvas-window client API (gfx commands own their own window). */
  133. struct win_create {
  134. unsigned int w, h;
  135. unsigned int flags; /* WIN_F_* */
  136. char title[16];
  137. };
  138. struct win_info {
  139. void *fb; /* mapped RGB565 back buffer */
  140. unsigned int width, height;
  141. unsigned int id;
  142. };
  143. /* Pointer input for generic canvas windows. The ring-3 WM queues press and
  144. * release edges; the command polls the current position for hover and drags. */
  145. struct win_pointer {
  146. int x, y; /* relative to the canvas, may be outside */
  147. unsigned int buttons; /* bit0 left, bit1 right, bit2 middle */
  148. unsigned int inside; /* pointer is over this window's content */
  149. unsigned int focused;
  150. };
  151. /* Scroll accumulated for this window since the previous call, in pixels.
  152. * Positive dy means later content (wheel down under natural scrolling). */
  153. struct win_scroll {
  154. int dx, dy;
  155. };
  156. #define WIN_EV_POINTER_DOWN 1
  157. #define WIN_EV_POINTER_UP 2
  158. struct win_event {
  159. unsigned int type; /* WIN_EV_POINTER_* */
  160. int x, y; /* content-relative */
  161. unsigned int buttons; /* buttons after the event */
  162. unsigned int button; /* button that changed: bit0 left, bit1 right */
  163. };
  164. #endif