wm.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* Window manager: fixed-size draggable terminal windows + a system bar. */
  2. #ifndef WM_H
  3. #define WM_H
  4. #include "terminal.h"
  5. #include "gfx.h"
  6. #include "wm_abi.h"
  7. #define MAX_WINDOWS WM_MAX_WINDOWS
  8. struct window {
  9. int used;
  10. unsigned int x, y; /* pixel origin (title bar top-left) */
  11. unsigned int pw, ph; /* pixel size */
  12. char title[16];
  13. int focused;
  14. unsigned int pid; /* owning terminal process pid (0 = none) */
  15. struct term *term;
  16. /* Generic canvas window (gfx commands): no terminal, own front/back. */
  17. int canvas_window;
  18. struct gfx_canvas canvas;
  19. unsigned short *back;
  20. unsigned int back_pages;
  21. unsigned short *pending_back; /* new canvas waiting for the app ACK */
  22. unsigned int pending_pages;
  23. int resize_pending;
  24. unsigned int owner_cr3;
  25. int keys[16];
  26. unsigned int key_head, key_tail;
  27. struct wait_queue key_wq;
  28. /* Pointer press/release edges for a generic canvas window. */
  29. struct win_event ptr_events[8];
  30. unsigned int ptr_head, ptr_tail;
  31. /* Ring-3 WM content mapping/bookkeeping. */
  32. unsigned int content_gen; /* bumped when the content kind/session changes */
  33. unsigned int mapped_kind;
  34. unsigned int mapped_gen;
  35. unsigned int mapped_pages;
  36. const void *mapped_src;
  37. };
  38. void wm_run(void);
  39. /* Idle-loop services: these stay in the kernel even while the WM process is
  40. * stopped, so keyboard routing, cursor blink and kexec recovery keep working. */
  41. void wm_pump_keyboard(void);
  42. void wm_blink_cursor(void);
  43. void wm_handle_kexec(void);
  44. int wm_spawn_terminal(void);
  45. /* Kernel window server / ring-3 WM ABI (see wm_abi.h). */
  46. void wm_server_init(void);
  47. void wm_server_start(void);
  48. void wm_server_supervise(void);
  49. int wm_server_is_wm(void);
  50. int wm_server_frame_active(void);
  51. int wm_server_can_reap(void);
  52. int wm_server_attach(struct wm_screen_info *out);
  53. int wm_server_info(unsigned int index, struct wm_window_info *out);
  54. int wm_server_map(unsigned int index, struct wm_map_info *out);
  55. int wm_server_ack(unsigned int index, unsigned int seq);
  56. int wm_server_focus(unsigned int index);
  57. int wm_server_set_geom(unsigned int index, int x, int y);
  58. int wm_server_create_term(void);
  59. int wm_server_close(unsigned int index);
  60. int wm_server_poll(struct wm_status *out);
  61. int wm_server_begin(void);
  62. int wm_server_present(const struct wm_present_info *in);
  63. int wm_server_sync(void);
  64. int wm_server_win_create(const struct win_create *in, struct win_info *out);
  65. int wm_server_win_present(void);
  66. int wm_server_win_close(void);
  67. int wm_server_win_info(struct win_info *out);
  68. int wm_server_win_ack_resize(void);
  69. int wm_server_resize(unsigned int index, unsigned int cw, unsigned int ch);
  70. int wm_server_key_poll(void);
  71. int wm_server_key_wait(unsigned int timeout_ms);
  72. int wm_server_win_pointer(struct win_pointer *out);
  73. int wm_server_win_event(struct win_event *out);
  74. void wm_content_changed(struct text_screen *screen);
  75. void wm_server_unmap_screen(struct text_screen *screen);
  76. void wm_server_unmap_canvas(struct text_screen *screen, const void *canvas);
  77. struct window *wm_focused_window(void);
  78. int wm_is_focused(const struct window *w);
  79. void wm_request_redraw(void);
  80. /* The terminal whose screen is `screen`, or NULL (the sys_gfx service uses the
  81. * inherited screen pointer to find a command's window). */
  82. struct term *wm_term_for_screen(struct text_screen *screen);
  83. /* Pixel size of a window's content area (its canvas size). Returns 0/-1. */
  84. int wm_content_size(struct term *t, unsigned int *w, unsigned int *h);
  85. #endif