| 1 |
#ifndef _BM_WAYLAND_H_ |
| 2 |
#define _BM_WAYLAND_H_ |
| 3 |
|
| 4 |
#include "internal.h" |
| 5 |
|
| 6 |
#include <wayland-client.h> |
| 7 |
#include <xkbcommon/xkbcommon.h> |
| 8 |
#include <linux/input-event-codes.h> |
| 9 |
|
| 10 |
#include "wlr-layer-shell-unstable-v1.h" |
| 11 |
#include "fractional-scale-v1.h" |
| 12 |
#include "viewporter.h" |
| 13 |
#include "renderers/cairo_renderer.h" |
| 14 |
|
| 15 |
struct bm_menu; |
| 16 |
|
| 17 |
enum mod_bit { |
| 18 |
MOD_SHIFT = 1<<0, |
| 19 |
MOD_CAPS = 1<<1, |
| 20 |
MOD_CTRL = 1<<2, |
| 21 |
MOD_ALT = 1<<3, |
| 22 |
MOD_MOD2 = 1<<4, |
| 23 |
MOD_MOD3 = 1<<5, |
| 24 |
MOD_LOGO = 1<<6, |
| 25 |
MOD_MOD5 = 1<<7, |
| 26 |
}; |
| 27 |
|
| 28 |
enum mask { |
| 29 |
MASK_SHIFT, |
| 30 |
MASK_CAPS, |
| 31 |
MASK_CTRL, |
| 32 |
MASK_ALT, |
| 33 |
MASK_MOD2, |
| 34 |
MASK_MOD3, |
| 35 |
MASK_LOGO, |
| 36 |
MASK_MOD5, |
| 37 |
MASK_LAST |
| 38 |
}; |
| 39 |
|
| 40 |
extern const char *BM_XKB_MASK_NAMES[MASK_LAST]; |
| 41 |
extern const enum mod_bit BM_XKB_MODS[MASK_LAST]; |
| 42 |
|
| 43 |
struct xkb { |
| 44 |
struct xkb_state *state; |
| 45 |
struct xkb_context *context; |
| 46 |
struct xkb_keymap *keymap; |
| 47 |
xkb_mod_mask_t masks[MASK_LAST]; |
| 48 |
}; |
| 49 |
|
| 50 |
struct pointer_event { |
| 51 |
uint32_t event_mask; |
| 52 |
wl_fixed_t surface_x, surface_y; |
| 53 |
uint32_t button, state; |
| 54 |
uint32_t time; |
| 55 |
uint32_t serial; |
| 56 |
struct { |
| 57 |
bool valid; |
| 58 |
wl_fixed_t value; |
| 59 |
int32_t discrete; |
| 60 |
} axes[2]; |
| 61 |
uint32_t axis_source; |
| 62 |
}; |
| 63 |
|
| 64 |
struct touch_point { |
| 65 |
bool valid; |
| 66 |
int32_t id; |
| 67 |
uint32_t event_mask; |
| 68 |
wl_fixed_t surface_x, surface_y; |
| 69 |
wl_fixed_t surface_start_x, surface_start_y; |
| 70 |
wl_fixed_t major, minor; |
| 71 |
wl_fixed_t orientation; |
| 72 |
}; |
| 73 |
|
| 74 |
struct touch_event { |
| 75 |
uint32_t time; |
| 76 |
uint32_t serial; |
| 77 |
uint16_t active; |
| 78 |
struct touch_point points[2]; |
| 79 |
}; |
| 80 |
|
| 81 |
struct input { |
| 82 |
int *repeat_fd; |
| 83 |
|
| 84 |
struct wl_keyboard *keyboard; |
| 85 |
struct wl_pointer *pointer; |
| 86 |
struct wl_touch *touch; |
| 87 |
struct pointer_event pointer_event; |
| 88 |
struct touch_event touch_event; |
| 89 |
struct xkb xkb; |
| 90 |
|
| 91 |
xkb_keysym_t sym; |
| 92 |
uint32_t code; |
| 93 |
uint32_t modifiers; |
| 94 |
|
| 95 |
xkb_keysym_t repeat_sym; |
| 96 |
uint32_t repeat_key; |
| 97 |
|
| 98 |
int32_t repeat_rate_sec; |
| 99 |
int32_t repeat_rate_nsec; |
| 100 |
int32_t repeat_delay_sec; |
| 101 |
int32_t repeat_delay_nsec; |
| 102 |
|
| 103 |
struct { |
| 104 |
void (*key)(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code); |
| 105 |
} notify; |
| 106 |
|
| 107 |
bool key_pending; |
| 108 |
}; |
| 109 |
|
| 110 |
struct buffer { |
| 111 |
struct cairo cairo; |
| 112 |
struct wl_buffer *buffer; |
| 113 |
uint32_t width, height; |
| 114 |
bool busy; |
| 115 |
}; |
| 116 |
|
| 117 |
struct window { |
| 118 |
struct wayland *wayland; |
| 119 |
struct wl_list surf_outputs; |
| 120 |
struct wl_surface *surface; |
| 121 |
struct wl_callback *frame_cb; |
| 122 |
struct zwlr_layer_surface_v1 *layer_surface; |
| 123 |
struct wp_viewport *viewport_surface; |
| 124 |
struct wl_shm *shm; |
| 125 |
struct buffer buffers[2]; |
| 126 |
uint32_t width, height, max_height; |
| 127 |
uint32_t hmargin_size; |
| 128 |
float width_factor; |
| 129 |
double scale; |
| 130 |
uint32_t displayed; |
| 131 |
struct wl_list link; |
| 132 |
enum bm_align align; |
| 133 |
int32_t y_offset; |
| 134 |
uint32_t align_anchor; |
| 135 |
bool render_pending; |
| 136 |
|
| 137 |
struct { |
| 138 |
void (*render)(struct cairo *cairo, uint32_t width, uint32_t max_height, struct bm_menu *menu, struct cairo_paint_result *result); |
| 139 |
} notify; |
| 140 |
}; |
| 141 |
|
| 142 |
struct output { |
| 143 |
struct wl_output *output; |
| 144 |
struct wl_list link; |
| 145 |
uint32_t height; |
| 146 |
int scale; |
| 147 |
char *name; |
| 148 |
}; |
| 149 |
|
| 150 |
struct surf_output { |
| 151 |
struct output *output; |
| 152 |
struct wl_list link; |
| 153 |
}; |
| 154 |
|
| 155 |
struct wayland { |
| 156 |
struct { |
| 157 |
int32_t display; |
| 158 |
int32_t repeat; |
| 159 |
} fds; |
| 160 |
|
| 161 |
struct wl_display *display; |
| 162 |
struct wl_registry *registry; |
| 163 |
struct wl_compositor *compositor; |
| 164 |
struct wl_list outputs; |
| 165 |
struct output *selected_output; |
| 166 |
struct wl_seat *seat; |
| 167 |
struct zwlr_layer_shell_v1 *layer_shell; |
| 168 |
struct wl_shm *shm; |
| 169 |
struct input input; |
| 170 |
struct wl_list windows; |
| 171 |
uint32_t formats; |
| 172 |
struct wp_fractional_scale_manager_v1 *wfs_mgr; |
| 173 |
struct wp_viewporter *viewporter; |
| 174 |
bool fractional_scaling; |
| 175 |
}; |
| 176 |
|
| 177 |
void bm_wl_repeat(struct wayland *wayland); |
| 178 |
bool bm_wl_registry_register(struct wayland *wayland); |
| 179 |
void bm_wl_registry_destroy(struct wayland *wayland); |
| 180 |
void bm_wl_window_schedule_render(struct window *window); |
| 181 |
void bm_wl_window_render(struct window *window, struct wl_display *display, struct bm_menu *menu); |
| 182 |
void bm_wl_window_set_width(struct window *window, struct wl_display *display, uint32_t margin, float factor); |
| 183 |
void bm_wl_window_set_align(struct window *window, struct wl_display *display, enum bm_align align); |
| 184 |
void bm_wl_window_set_y_offset(struct window *window, struct wl_display *display, int32_t y_offset); |
| 185 |
void bm_wl_window_grab_keyboard(struct window *window, struct wl_display *display, bool grab); |
| 186 |
void bm_wl_window_set_overlap(struct window *window, struct wl_display *display, bool overlap); |
| 187 |
bool bm_wl_window_create(struct window *window, struct wl_display *display, struct wl_shm *shm, struct wl_output *output, struct zwlr_layer_shell_v1 *layer_shell, struct wl_surface *surface); |
| 188 |
void bm_wl_window_destroy(struct window *window); |
| 189 |
|
| 190 |
void recreate_windows(const struct bm_menu *menu, struct wayland *wayland); |
| 191 |
void window_update_output(struct window *window); |
| 192 |
|
| 193 |
#endif /* _BM_WAYLAND_H_ */ |
| 194 |
|
| 195 |
/* vim: set ts=8 sw=4 tw=0 :*/ |