bemenu 1.0.0
Dynamic menu library and client program inspired by dmenu
wayland.h
1 #ifndef _BM_WAYLAND_H_
2 #define _BM_WAYLAND_H_
3 
4 #include <wayland-client.h>
5 #include <xkbcommon/xkbcommon.h>
6 
7 #include "wayland-xdg-shell-client-protocol.h"
8 
9 #include "renderers/cairo.h"
10 
11 struct bm_menu;
12 
13 enum mod_bit {
14  MOD_SHIFT = 1<<0,
15  MOD_CAPS = 1<<1,
16  MOD_CTRL = 1<<2,
17  MOD_ALT = 1<<3,
18  MOD_MOD2 = 1<<4,
19  MOD_MOD3 = 1<<5,
20  MOD_LOGO = 1<<6,
21  MOD_MOD5 = 1<<7,
22 };
23 
24 enum mask {
25  MASK_SHIFT,
26  MASK_CAPS,
27  MASK_CTRL,
28  MASK_ALT,
29  MASK_MOD2,
30  MASK_MOD3,
31  MASK_LOGO,
32  MASK_MOD5,
33  MASK_LAST
34 };
35 
36 const char *BM_XKB_MASK_NAMES[MASK_LAST];
37 const enum mod_bit BM_XKB_MODS[MASK_LAST];
38 
39 struct xkb {
40  struct xkb_state *state;
41  struct xkb_context *context;
42  struct xkb_keymap *keymap;
43  xkb_mod_mask_t masks[MASK_LAST];
44 };
45 
46 struct input {
47  int *repeat_fd;
48 
49  struct wl_keyboard *keyboard;
50  struct xkb xkb;
51 
52  xkb_keysym_t sym;
53  uint32_t code;
54  uint32_t last_code;
55  uint32_t modifiers;
56 
57  xkb_keysym_t repeat_sym;
58  uint32_t repeat_key;
59 
60  int32_t repeat_rate_sec;
61  int32_t repeat_rate_nsec;
62  int32_t repeat_delay_sec;
63  int32_t repeat_delay_nsec;
64 
65  struct {
66  void (*key)(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code);
67  } notify;
68 };
69 
70 struct buffer {
71  struct cairo cairo;
72  struct wl_buffer *buffer;
73  uint32_t width, height;
74  bool busy;
75 };
76 
77 struct window {
78  struct wl_surface *surface;
79  struct wl_shell_surface *shell_surface;
80  struct wl_callback *frame_cb;
81  struct xdg_surface *xdg_surface;
82  struct wl_shm *shm;
83  struct buffer buffers[2];
84  uint32_t width, height, max_height;
85  uint32_t displayed;
86 
87  struct {
88  void (*render)(struct cairo *cairo, uint32_t width, uint32_t height, uint32_t max_height, const struct bm_menu *menu, struct cairo_paint_result *result);
89  } notify;
90 };
91 
92 struct wayland {
93  struct {
94  int32_t display;
95  int32_t repeat;
96  } fds;
97 
98  struct wl_display *display;
99  struct wl_registry *registry;
100  struct wl_compositor *compositor;
101  struct wl_output *output;
102  struct wl_seat *seat;
103  struct xdg_shell *xdg_shell;
104  struct wl_shell *shell;
105  struct wl_shm *shm;
106  struct input input;
107  struct window window;
108  uint32_t formats;
109 };
110 
111 void bm_wl_repeat(struct wayland *wayland);
112 bool bm_wl_registry_register(struct wayland *wayland);
113 void bm_wl_registry_destroy(struct wayland *wayland);
114 void bm_wl_window_render(struct window *window, const struct bm_menu *menu);
115 bool bm_wl_window_create(struct window *window, struct wl_shm *shm, struct wl_shell *shell, struct xdg_shell *xdg_shell, struct wl_surface *surface);
116 void bm_wl_window_destroy(struct window *window);
117 
118 #endif /* _BM_WAYLAND_H_ */
119 
120 /* vim: set ts=8 sw=4 tw=0 :*/
Definition: wayland.h:39
Definition: wayland.h:46
Definition: cairo.h:11
Definition: cairo.h:42
Definition: wayland.h:77
Definition: wayland.h:70
Definition: wayland.h:92