logo

inaban

Distrustful Wayland Compositor (inspired by XMonad and dwm) git clone https://hacktivis.me/git/inaban.git

inaban.h (3771B)


  1. // SPDX-FileCopyrightText: 2019 tinyWL Authors
  2. // SPDX-License-Identifier: CC0-1.0
  3. //
  4. // SPDX-FileCopyrightText: 2019-2022 inaban Authors <https://hacktivis.me/git/inaban>
  5. // SPDX-License-Identifier: BSD-3-Clause
  6. #ifndef INABAN_H
  7. #define INABAN_H
  8. #include <stdbool.h>
  9. #include <wayland-server.h>
  10. #include <xkbcommon/xkbcommon.h>
  11. // stable wlroots interfaces
  12. #include <wlr/types/wlr_matrix.h>
  13. #include <wlr/util/log.h>
  14. // unstable wlroots interfaces
  15. #define WLR_USE_UNSTABLE
  16. #include <wlr/backend.h>
  17. #include <wlr/render/allocator.h>
  18. #include <wlr/render/wlr_renderer.h>
  19. #include <wlr/types/wlr_compositor.h>
  20. #include <wlr/types/wlr_cursor.h>
  21. #include <wlr/types/wlr_data_control_v1.h>
  22. #include <wlr/types/wlr_data_device.h>
  23. #include <wlr/types/wlr_input_device.h>
  24. #include <wlr/types/wlr_keyboard.h>
  25. #include <wlr/types/wlr_output.h>
  26. #include <wlr/types/wlr_output_layout.h>
  27. #include <wlr/types/wlr_pointer.h>
  28. #include <wlr/types/wlr_primary_selection.h>
  29. #include <wlr/types/wlr_primary_selection_v1.h>
  30. #include <wlr/types/wlr_seat.h>
  31. #include <wlr/types/wlr_server_decoration.h>
  32. #include <wlr/types/wlr_xcursor_manager.h>
  33. #include <wlr/types/wlr_xdg_decoration_v1.h>
  34. #include <wlr/types/wlr_xdg_shell.h>
  35. #undef WLR_USE_UNSTABLE
  36. enum inaban_input_mode
  37. {
  38. INABAN_INPUT_NORMAL,
  39. INABAN_INPUT_MODKEY,
  40. };
  41. enum inaban_cursor_mode
  42. {
  43. INABAN_CURSOR_NORMAL,
  44. INABAN_CURSOR_MOVE,
  45. INABAN_CURSOR_RESIZE,
  46. };
  47. struct inaban_server
  48. {
  49. struct wl_display *wl_display;
  50. struct wlr_backend *backend;
  51. struct wlr_renderer *renderer;
  52. struct wlr_allocator *allocator;
  53. struct wlr_xdg_shell *xdg_shell;
  54. struct wl_listener new_xdg_surface;
  55. struct wl_list views;
  56. struct wl_listener xdg_toplevel_decoration;
  57. struct wlr_cursor *cursor;
  58. struct wlr_xcursor_manager *cursor_mgr;
  59. struct wl_listener cursor_motion;
  60. struct wl_listener cursor_motion_absolute;
  61. struct wl_listener cursor_button;
  62. struct wl_listener cursor_axis;
  63. struct wl_listener cursor_frame;
  64. struct wlr_seat *seat;
  65. struct wl_listener new_input;
  66. struct wl_listener request_cursor;
  67. struct wl_list keyboards;
  68. struct wlr_output_layout *output_layout;
  69. struct wl_list outputs;
  70. struct wl_listener new_output;
  71. enum inaban_input_mode input_mode;
  72. enum inaban_cursor_mode cursor_mode;
  73. struct inaban_view *grabbed_view;
  74. /* cursor position */
  75. double grab_x, grab_y;
  76. /* window size */
  77. int grab_width, grab_height;
  78. /* clipboard */
  79. struct wl_listener request_set_primary_selection;
  80. struct wl_listener request_set_selection;
  81. bool locked;
  82. };
  83. struct inaban_output
  84. {
  85. struct wl_list link;
  86. struct inaban_server *server;
  87. struct wlr_output *wlr_output;
  88. struct wl_listener frame;
  89. struct wl_listener mode;
  90. };
  91. struct inaban_view
  92. {
  93. struct wl_list link;
  94. struct inaban_server *server;
  95. struct wlr_xdg_surface *xdg_surface;
  96. struct wl_listener map;
  97. struct wl_listener unmap;
  98. struct wl_listener destroy;
  99. struct wl_listener request_move;
  100. struct wl_listener request_resize;
  101. bool mapped;
  102. int x, y;
  103. };
  104. struct inaban_keyboard
  105. {
  106. struct wl_list link;
  107. struct inaban_server *server;
  108. struct wlr_input_device *device;
  109. struct wl_listener modifiers;
  110. struct wl_listener key;
  111. };
  112. /* Used to move all of the data necessary to render a surface from the top-level
  113. * frame handler to the per-surface render function. */
  114. struct render_data
  115. {
  116. struct wlr_output *output;
  117. struct wlr_renderer *renderer;
  118. struct inaban_view *view;
  119. struct timespec *when;
  120. };
  121. typedef union
  122. {
  123. int i;
  124. unsigned int ui;
  125. float f;
  126. const void *v;
  127. } Arg;
  128. typedef struct
  129. {
  130. uint32_t mod;
  131. xkb_keysym_t keysym;
  132. void (*func)(const Arg *);
  133. const Arg arg;
  134. } Shortcut;
  135. void spawn(const Arg *arg);
  136. void focus_view(struct inaban_view *view, struct wlr_surface *surface);
  137. void quit(const Arg *arg);
  138. void lock(const Arg *arg);
  139. #endif /* INABAN_H */