2014-10-24 22:38:30 +00:00
|
|
|
#ifndef _BM_WAYLAND_H_
|
|
|
|
#define _BM_WAYLAND_H_
|
|
|
|
|
2021-10-17 16:33:37 +00:00
|
|
|
#include "internal.h"
|
|
|
|
|
2014-10-24 22:38:30 +00:00
|
|
|
#include <wayland-client.h>
|
|
|
|
#include <xkbcommon/xkbcommon.h>
|
2021-08-14 15:31:28 +00:00
|
|
|
#include <linux/input-event-codes.h>
|
2014-10-24 22:38:30 +00:00
|
|
|
|
2020-02-07 13:56:50 +00:00
|
|
|
#include "wlr-layer-shell-unstable-v1.h"
|
2021-02-05 07:50:58 +00:00
|
|
|
#include "xdg-output-unstable-v1.h"
|
2021-05-07 14:38:15 +00:00
|
|
|
#include "renderers/cairo_renderer.h"
|
2014-10-24 22:38:30 +00:00
|
|
|
|
|
|
|
struct bm_menu;
|
|
|
|
|
|
|
|
enum mod_bit {
|
|
|
|
MOD_SHIFT = 1<<0,
|
|
|
|
MOD_CAPS = 1<<1,
|
|
|
|
MOD_CTRL = 1<<2,
|
|
|
|
MOD_ALT = 1<<3,
|
|
|
|
MOD_MOD2 = 1<<4,
|
|
|
|
MOD_MOD3 = 1<<5,
|
|
|
|
MOD_LOGO = 1<<6,
|
|
|
|
MOD_MOD5 = 1<<7,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum mask {
|
|
|
|
MASK_SHIFT,
|
|
|
|
MASK_CAPS,
|
|
|
|
MASK_CTRL,
|
|
|
|
MASK_ALT,
|
|
|
|
MASK_MOD2,
|
|
|
|
MASK_MOD3,
|
|
|
|
MASK_LOGO,
|
|
|
|
MASK_MOD5,
|
|
|
|
MASK_LAST
|
|
|
|
};
|
|
|
|
|
2020-02-06 16:35:20 +00:00
|
|
|
extern const char *BM_XKB_MASK_NAMES[MASK_LAST];
|
|
|
|
extern const enum mod_bit BM_XKB_MODS[MASK_LAST];
|
2014-10-24 22:38:30 +00:00
|
|
|
|
|
|
|
struct xkb {
|
|
|
|
struct xkb_state *state;
|
|
|
|
struct xkb_context *context;
|
|
|
|
struct xkb_keymap *keymap;
|
|
|
|
xkb_mod_mask_t masks[MASK_LAST];
|
|
|
|
};
|
|
|
|
|
2021-08-14 15:31:28 +00:00
|
|
|
struct pointer_event {
|
|
|
|
uint32_t event_mask;
|
|
|
|
wl_fixed_t surface_x, surface_y;
|
|
|
|
uint32_t button, state;
|
|
|
|
uint32_t time;
|
|
|
|
uint32_t serial;
|
|
|
|
struct {
|
|
|
|
bool valid;
|
|
|
|
wl_fixed_t value;
|
|
|
|
int32_t discrete;
|
|
|
|
} axes[2];
|
|
|
|
uint32_t axis_source;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct touch_point {
|
|
|
|
bool valid;
|
|
|
|
int32_t id;
|
|
|
|
uint32_t event_mask;
|
|
|
|
wl_fixed_t surface_x, surface_y;
|
|
|
|
wl_fixed_t surface_start_x, surface_start_y;
|
|
|
|
wl_fixed_t major, minor;
|
|
|
|
wl_fixed_t orientation;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct touch_event {
|
|
|
|
uint32_t time;
|
|
|
|
uint32_t serial;
|
|
|
|
uint16_t active;
|
|
|
|
struct touch_point points[2];
|
|
|
|
};
|
|
|
|
|
2014-10-24 22:38:30 +00:00
|
|
|
struct input {
|
2014-11-02 04:48:53 +00:00
|
|
|
int *repeat_fd;
|
|
|
|
|
2021-06-06 14:25:15 +00:00
|
|
|
struct wl_seat *seat;
|
2014-10-24 22:38:30 +00:00
|
|
|
struct wl_keyboard *keyboard;
|
2021-08-14 15:31:28 +00:00
|
|
|
struct wl_pointer *pointer;
|
|
|
|
struct wl_touch *touch;
|
|
|
|
struct pointer_event pointer_event;
|
|
|
|
struct touch_event touch_event;
|
2014-10-24 22:38:30 +00:00
|
|
|
struct xkb xkb;
|
|
|
|
|
|
|
|
xkb_keysym_t sym;
|
|
|
|
uint32_t code;
|
|
|
|
uint32_t modifiers;
|
|
|
|
|
2014-11-02 04:48:53 +00:00
|
|
|
xkb_keysym_t repeat_sym;
|
|
|
|
uint32_t repeat_key;
|
|
|
|
|
|
|
|
int32_t repeat_rate_sec;
|
|
|
|
int32_t repeat_rate_nsec;
|
|
|
|
int32_t repeat_delay_sec;
|
|
|
|
int32_t repeat_delay_nsec;
|
|
|
|
|
2014-10-24 22:38:30 +00:00
|
|
|
struct {
|
|
|
|
void (*key)(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code);
|
|
|
|
} notify;
|
2020-10-09 00:12:08 +00:00
|
|
|
|
|
|
|
bool key_pending;
|
2014-10-24 22:38:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct buffer {
|
|
|
|
struct cairo cairo;
|
|
|
|
struct wl_buffer *buffer;
|
|
|
|
uint32_t width, height;
|
|
|
|
bool busy;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct window {
|
|
|
|
struct wl_surface *surface;
|
2014-11-02 04:48:53 +00:00
|
|
|
struct wl_callback *frame_cb;
|
2018-04-08 15:05:20 +00:00
|
|
|
struct zwlr_layer_surface_v1 *layer_surface;
|
2014-10-24 22:38:30 +00:00
|
|
|
struct wl_shm *shm;
|
|
|
|
struct buffer buffers[2];
|
2014-11-02 05:58:34 +00:00
|
|
|
uint32_t width, height, max_height;
|
2021-10-17 06:22:24 +00:00
|
|
|
uint32_t hmargin_size;
|
2021-12-26 16:38:11 +00:00
|
|
|
float width_factor;
|
2019-06-05 21:43:41 +00:00
|
|
|
int32_t scale;
|
2014-10-25 17:02:34 +00:00
|
|
|
uint32_t displayed;
|
2018-04-08 15:05:20 +00:00
|
|
|
struct wl_list link;
|
2021-10-17 16:33:37 +00:00
|
|
|
enum bm_align align;
|
|
|
|
uint32_t align_anchor;
|
2019-03-24 19:18:59 +00:00
|
|
|
bool render_pending;
|
2014-10-24 22:38:30 +00:00
|
|
|
|
|
|
|
struct {
|
2019-05-31 20:32:02 +00:00
|
|
|
void (*render)(struct cairo *cairo, uint32_t width, uint32_t max_height, const struct bm_menu *menu, struct cairo_paint_result *result);
|
2014-10-24 22:38:30 +00:00
|
|
|
} notify;
|
|
|
|
};
|
|
|
|
|
2018-04-08 15:05:20 +00:00
|
|
|
struct output {
|
|
|
|
struct wl_output *output;
|
2021-02-05 07:50:58 +00:00
|
|
|
struct zxdg_output_v1 *xdg_output;
|
2018-04-08 15:05:20 +00:00
|
|
|
struct wl_list link;
|
|
|
|
int height;
|
2019-06-05 21:43:41 +00:00
|
|
|
int scale;
|
2021-02-05 07:50:58 +00:00
|
|
|
char *name;
|
2018-04-08 15:05:20 +00:00
|
|
|
};
|
|
|
|
|
2014-10-24 22:38:30 +00:00
|
|
|
struct wayland {
|
2014-11-02 04:48:53 +00:00
|
|
|
struct {
|
|
|
|
int32_t display;
|
|
|
|
int32_t repeat;
|
|
|
|
} fds;
|
|
|
|
|
2014-10-24 22:38:30 +00:00
|
|
|
struct wl_display *display;
|
|
|
|
struct wl_registry *registry;
|
|
|
|
struct wl_compositor *compositor;
|
2018-04-08 15:05:20 +00:00
|
|
|
struct wl_list outputs;
|
2014-10-24 22:38:30 +00:00
|
|
|
struct wl_seat *seat;
|
2018-04-08 15:05:20 +00:00
|
|
|
struct zwlr_layer_shell_v1 *layer_shell;
|
2014-10-24 22:38:30 +00:00
|
|
|
struct wl_shm *shm;
|
|
|
|
struct input input;
|
2018-04-08 15:05:20 +00:00
|
|
|
struct wl_list windows;
|
2021-02-05 07:50:58 +00:00
|
|
|
struct zxdg_output_manager_v1 *xdg_output_manager;
|
2014-10-24 22:38:30 +00:00
|
|
|
uint32_t formats;
|
|
|
|
};
|
|
|
|
|
2014-11-02 04:48:53 +00:00
|
|
|
void bm_wl_repeat(struct wayland *wayland);
|
2014-10-24 22:38:30 +00:00
|
|
|
bool bm_wl_registry_register(struct wayland *wayland);
|
|
|
|
void bm_wl_registry_destroy(struct wayland *wayland);
|
2019-03-24 19:18:59 +00:00
|
|
|
void bm_wl_window_schedule_render(struct window *window);
|
2018-04-27 23:16:21 +00:00
|
|
|
void bm_wl_window_render(struct window *window, struct wl_display *display, const struct bm_menu *menu);
|
2021-12-26 16:38:11 +00:00
|
|
|
void bm_wl_window_set_width(struct window *window, struct wl_display *display, uint32_t margin, float factor);
|
2021-10-17 16:33:37 +00:00
|
|
|
void bm_wl_window_set_align(struct window *window, struct wl_display *display, enum bm_align align);
|
2018-04-27 23:17:58 +00:00
|
|
|
void bm_wl_window_grab_keyboard(struct window *window, struct wl_display *display, bool grab);
|
2019-03-25 21:21:17 +00:00
|
|
|
void bm_wl_window_set_overlap(struct window *window, struct wl_display *display, bool overlap);
|
2018-04-08 15:05:20 +00:00
|
|
|
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);
|
2014-10-24 22:38:30 +00:00
|
|
|
void bm_wl_window_destroy(struct window *window);
|
|
|
|
|
|
|
|
#endif /* _BM_WAYLAND_H_ */
|
|
|
|
|
|
|
|
/* vim: set ts=8 sw=4 tw=0 :*/
|