2017-06-13 16:13:11 +02:00
|
|
|
#ifndef _EXAMPLE_SHARED_H
|
|
|
|
#define _EXAMPLE_SHARED_H
|
2017-06-21 20:33:39 +02:00
|
|
|
#ifndef _POSIX_C_SOURCE
|
|
|
|
#define _POSIX_C_SOURCE 200112L
|
|
|
|
#endif
|
2017-06-13 16:13:11 +02:00
|
|
|
#include <time.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <xkbcommon/xkbcommon.h>
|
|
|
|
#include <wayland-server-protocol.h>
|
|
|
|
#include <wlr/backend.h>
|
2017-07-11 09:18:34 +02:00
|
|
|
#include <wlr/backend/session.h>
|
2017-06-21 16:27:45 +02:00
|
|
|
#include <wlr/types/wlr_output.h>
|
|
|
|
#include <wlr/types/wlr_input_device.h>
|
2017-06-13 16:13:11 +02:00
|
|
|
|
2017-08-18 23:44:10 +02:00
|
|
|
struct output_config {
|
|
|
|
char *name;
|
|
|
|
enum wl_output_transform transform;
|
|
|
|
int x, y;
|
|
|
|
struct wl_list link;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct example_config {
|
|
|
|
struct wl_list outputs;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct example_config *parse_args(int argc, char *argv[]);
|
|
|
|
|
|
|
|
void example_config_destroy(struct example_config *config);
|
|
|
|
|
2017-08-19 01:31:16 +02:00
|
|
|
struct wlr_output_layout *configure_layout(struct example_config *config,
|
|
|
|
struct wl_list *outputs);
|
|
|
|
|
2017-06-13 16:13:11 +02:00
|
|
|
struct output_state {
|
|
|
|
struct compositor_state *compositor;
|
|
|
|
struct wlr_output *output;
|
|
|
|
struct wl_listener frame;
|
2017-08-17 22:19:08 +02:00
|
|
|
struct wl_listener resolution;
|
2017-06-13 16:13:11 +02:00
|
|
|
struct timespec last_frame;
|
|
|
|
struct wl_list link;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct keyboard_state {
|
|
|
|
struct compositor_state *compositor;
|
|
|
|
struct wlr_input_device *device;
|
|
|
|
struct wl_listener key;
|
|
|
|
struct wl_list link;
|
|
|
|
struct xkb_keymap *keymap;
|
|
|
|
struct xkb_state *xkb_state;
|
2017-06-19 21:15:37 +02:00
|
|
|
xkb_led_index_t leds[WLR_LED_LAST];
|
2017-06-13 16:13:11 +02:00
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2017-06-13 18:21:36 +02:00
|
|
|
struct pointer_state {
|
|
|
|
struct compositor_state *compositor;
|
|
|
|
struct wlr_input_device *device;
|
|
|
|
struct wl_listener motion;
|
|
|
|
struct wl_listener motion_absolute;
|
|
|
|
struct wl_listener button;
|
|
|
|
struct wl_listener axis;
|
|
|
|
struct wl_list link;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2017-06-14 20:50:09 +02:00
|
|
|
struct touch_state {
|
|
|
|
struct compositor_state *compositor;
|
|
|
|
struct wlr_input_device *device;
|
|
|
|
struct wl_listener down;
|
|
|
|
struct wl_listener up;
|
|
|
|
struct wl_listener motion;
|
|
|
|
struct wl_listener cancel;
|
|
|
|
struct wl_list link;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2017-06-15 22:15:12 +02:00
|
|
|
struct tablet_tool_state {
|
|
|
|
struct compositor_state *compositor;
|
|
|
|
struct wlr_input_device *device;
|
|
|
|
struct wl_listener axis;
|
|
|
|
struct wl_listener proximity;
|
|
|
|
struct wl_listener tip;
|
|
|
|
struct wl_listener button;
|
|
|
|
struct wl_list link;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2017-06-19 20:49:07 +02:00
|
|
|
struct tablet_pad_state {
|
|
|
|
struct compositor_state *compositor;
|
|
|
|
struct wlr_input_device *device;
|
|
|
|
struct wl_listener button;
|
|
|
|
struct wl_list link;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2017-06-13 16:13:11 +02:00
|
|
|
struct compositor_state {
|
2017-08-20 22:02:39 +02:00
|
|
|
void (*input_add_cb)(struct compositor_state *compositor,
|
|
|
|
struct wlr_input_device *device);
|
2017-06-13 16:13:11 +02:00
|
|
|
void (*output_add_cb)(struct output_state *s);
|
|
|
|
void (*keyboard_add_cb)(struct keyboard_state *s);
|
|
|
|
void (*output_frame_cb)(struct output_state *s, struct timespec *ts);
|
|
|
|
void (*output_remove_cb)(struct output_state *s);
|
2017-08-17 22:19:08 +02:00
|
|
|
void (*output_resolution_cb)(struct compositor_state *compositor,
|
|
|
|
struct output_state *s);
|
2017-06-13 16:13:11 +02:00
|
|
|
void (*keyboard_remove_cb)(struct keyboard_state *s);
|
2017-08-17 12:55:59 +02:00
|
|
|
void (*keyboard_key_cb)(struct keyboard_state *s, uint32_t keycode,
|
|
|
|
xkb_keysym_t sym, enum wlr_key_state key_state);
|
2017-06-13 18:31:24 +02:00
|
|
|
void (*pointer_motion_cb)(struct pointer_state *s,
|
|
|
|
double d_x, double d_y);
|
2017-06-22 18:21:28 +02:00
|
|
|
void (*pointer_motion_absolute_cb)(struct pointer_state *s,
|
|
|
|
double x, double y);
|
2017-06-13 18:31:24 +02:00
|
|
|
void (*pointer_button_cb)(struct pointer_state *s,
|
|
|
|
uint32_t button, enum wlr_button_state state);
|
2017-06-13 18:38:57 +02:00
|
|
|
void (*pointer_axis_cb)(struct pointer_state *s,
|
|
|
|
enum wlr_axis_source source,
|
|
|
|
enum wlr_axis_orientation orientation,
|
|
|
|
double delta);
|
2017-06-14 20:50:09 +02:00
|
|
|
void (*touch_down_cb)(struct touch_state *s, int32_t slot,
|
|
|
|
double x, double y, double width, double height);
|
|
|
|
void (*touch_motion_cb)(struct touch_state *s, int32_t slot,
|
|
|
|
double x, double y, double width, double height);
|
|
|
|
void (*touch_up_cb)(struct touch_state *s, int32_t slot);
|
|
|
|
void (*touch_cancel_cb)(struct touch_state *s, int32_t slot);
|
2017-06-15 22:15:12 +02:00
|
|
|
void (*tool_axis_cb)(struct tablet_tool_state *s,
|
2017-06-21 20:07:09 +02:00
|
|
|
struct wlr_event_tablet_tool_axis *event);
|
2017-06-15 22:15:12 +02:00
|
|
|
void (*tool_proximity_cb)(struct tablet_tool_state *s,
|
|
|
|
enum wlr_tablet_tool_proximity_state proximity);
|
|
|
|
void (*tool_tip_cb)(struct tablet_tool_state *s,
|
|
|
|
enum wlr_tablet_tool_tip_state state);
|
|
|
|
void (*tool_button_cb)(struct tablet_tool_state *s,
|
|
|
|
uint32_t button, enum wlr_button_state state);
|
2017-06-19 20:49:07 +02:00
|
|
|
void (*pad_button_cb)(struct tablet_pad_state *s,
|
|
|
|
uint32_t button, enum wlr_button_state state);
|
2017-06-13 16:13:11 +02:00
|
|
|
|
|
|
|
struct wl_display *display;
|
|
|
|
struct wl_event_loop *event_loop;
|
|
|
|
struct wlr_backend *backend;
|
|
|
|
struct wlr_session *session;
|
|
|
|
|
|
|
|
struct wl_list keyboards;
|
2017-06-13 18:21:36 +02:00
|
|
|
struct wl_list pointers;
|
2017-06-14 20:50:09 +02:00
|
|
|
struct wl_list touch;
|
2017-06-15 22:15:12 +02:00
|
|
|
struct wl_list tablet_tools;
|
2017-06-19 20:49:07 +02:00
|
|
|
struct wl_list tablet_pads;
|
2017-06-13 16:13:11 +02:00
|
|
|
struct wl_listener input_add;
|
|
|
|
struct wl_listener input_remove;
|
|
|
|
|
|
|
|
struct timespec last_frame;
|
|
|
|
struct wl_listener output_add;
|
|
|
|
struct wl_listener output_remove;
|
|
|
|
struct wl_list outputs;
|
|
|
|
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
void compositor_init(struct compositor_state *state);
|
2017-08-19 09:26:25 +02:00
|
|
|
void compositor_fini(struct compositor_state *state);
|
2017-06-13 16:13:11 +02:00
|
|
|
|
|
|
|
#endif
|