inaban.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // Copyright 2019-2020 Inaban Authors <https://hacktivis.me/git/inaban>
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. // Based on wlroots's TinyWL which is distributed under CC0
  4. #ifndef INABAN_H
  5. #define INABAN_H
  6. #include <stdbool.h>
  7. #include <wayland-server.h>
  8. #include <wlr/backend.h>
  9. #include <wlr/render/wlr_renderer.h>
  10. #include <wlr/types/wlr_compositor.h>
  11. #include <wlr/types/wlr_cursor.h>
  12. #include <wlr/types/wlr_data_device.h>
  13. #include <wlr/types/wlr_input_device.h>
  14. #include <wlr/types/wlr_keyboard.h>
  15. #include <wlr/types/wlr_matrix.h>
  16. #include <wlr/types/wlr_output.h>
  17. #include <wlr/types/wlr_output_layout.h>
  18. #include <wlr/types/wlr_pointer.h>
  19. #include <wlr/types/wlr_seat.h>
  20. #include <wlr/types/wlr_xcursor_manager.h>
  21. #include <wlr/types/wlr_xdg_shell.h>
  22. #include <wlr/util/log.h>
  23. #include <xkbcommon/xkbcommon.h>
  24. struct inaban_server
  25. {
  26. struct wl_display *wl_display;
  27. struct wlr_backend *backend;
  28. struct wlr_renderer *renderer;
  29. struct wlr_xdg_shell *xdg_shell;
  30. struct wl_listener new_xdg_surface;
  31. struct wl_list views;
  32. struct wlr_cursor *cursor;
  33. struct wlr_xcursor_manager *cursor_mgr;
  34. struct wl_listener cursor_motion;
  35. struct wl_listener cursor_motion_absolute;
  36. struct wl_listener cursor_button;
  37. struct wl_listener cursor_axis;
  38. struct wl_listener cursor_frame;
  39. struct wlr_seat *seat;
  40. struct wl_listener new_input;
  41. struct wl_listener request_cursor;
  42. struct wl_list keyboards;
  43. struct wlr_output_layout *output_layout;
  44. struct wl_list outputs;
  45. struct wl_listener new_output;
  46. };
  47. struct inaban_output
  48. {
  49. struct wl_list link;
  50. struct inaban_server *server;
  51. struct wlr_output *wlr_output;
  52. struct wl_listener frame;
  53. };
  54. struct inaban_view
  55. {
  56. struct wl_list link;
  57. struct inaban_server *server;
  58. struct wlr_xdg_surface *xdg_surface;
  59. struct wl_listener map;
  60. struct wl_listener unmap;
  61. struct wl_listener destroy;
  62. struct wl_listener request_move;
  63. struct wl_listener request_resize;
  64. bool mapped;
  65. int x, y;
  66. };
  67. struct inaban_keyboard
  68. {
  69. struct wl_list link;
  70. struct inaban_server *server;
  71. struct wlr_input_device *device;
  72. struct wl_listener modifiers;
  73. struct wl_listener key;
  74. };
  75. /* Used to move all of the data necessary to render a surface from the top-level
  76. * frame handler to the per-surface render function. */
  77. struct render_data
  78. {
  79. struct wlr_output *output;
  80. struct wlr_renderer *renderer;
  81. struct inaban_view *view;
  82. struct timespec *when;
  83. };
  84. typedef union {
  85. int i;
  86. unsigned int ui;
  87. float f;
  88. const void *v;
  89. } Arg;
  90. typedef struct
  91. {
  92. uint32_t mod;
  93. xkb_keysym_t keysym;
  94. void (*func)(const Arg *);
  95. const Arg arg;
  96. } Shortcut;
  97. void spawn(const Arg *arg);
  98. void quit(const Arg *arg);
  99. void server_new_output(struct wl_listener *listener, void *data);
  100. #endif /* INABAN_H */