diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/backend/drm.h | 8 | ||||
-rw-r--r-- | include/backend/libinput.h | 71 | ||||
-rw-r--r-- | include/backend/multi.h | 13 | ||||
-rw-r--r-- | include/render/gles3.h | 3 | ||||
-rw-r--r-- | include/types.h | 46 | ||||
-rw-r--r-- | include/wlr/backend.h | 8 | ||||
-rw-r--r-- | include/wlr/backend/libinput.h | 15 | ||||
-rw-r--r-- | include/wlr/backend/multi.h | 10 | ||||
-rw-r--r-- | include/wlr/render.h | 10 | ||||
-rw-r--r-- | include/wlr/render/interface.h | 4 | ||||
-rw-r--r-- | include/wlr/session.h | 2 | ||||
-rw-r--r-- | include/wlr/session/interface.h | 2 | ||||
-rw-r--r-- | include/wlr/types.h | 237 |
13 files changed, 418 insertions, 11 deletions
diff --git a/include/backend/drm.h b/include/backend/drm.h index e001186d..10850d1f 100644 --- a/include/backend/drm.h +++ b/include/backend/drm.h @@ -73,10 +73,12 @@ struct wlr_output_state { drmModeCrtc *old_crtc; struct wlr_drm_renderer *renderer; - struct gbm_surface *gbm; - struct gbm_bo *bo_last; - struct gbm_bo *bo_current; EGLSurface *egl; + struct gbm_surface *gbm; + struct gbm_bo *bo[2]; + struct gbm_bo *cursor_bo[2]; + int current_cursor; + uint32_t cursor_width, cursor_height; bool pageflip_pending; bool cleanup; diff --git a/include/backend/libinput.h b/include/backend/libinput.h new file mode 100644 index 00000000..80f57177 --- /dev/null +++ b/include/backend/libinput.h @@ -0,0 +1,71 @@ +#ifndef _WLR_BACKEND_LIBINPUT_INTERNAL_H +#define _WLR_BACKEND_LIBINPUT_INTERNAL_H +#include <libinput.h> +#include <wlr/backend/interface.h> +#include <wlr/common/list.h> +#include <wayland-server-core.h> +#include "backend/udev.h" +#include "types.h" + +struct wlr_backend_state { + struct wlr_backend *backend; + struct wlr_session *session; + struct wlr_udev *udev; + struct wl_display *display; + + struct libinput *libinput; + struct wl_event_source *input_event; + + list_t *devices; +}; + +struct wlr_input_device_state { + struct libinput_device *handle; +}; + +void wlr_libinput_event(struct wlr_backend_state *state, + struct libinput_event *event); + +struct wlr_input_device *get_appropriate_device( + enum wlr_input_device_type desired_type, + struct libinput_device *device); + +struct wlr_keyboard *wlr_libinput_keyboard_create( + struct libinput_device *device); +void handle_keyboard_key(struct libinput_event *event, + struct libinput_device *device); + +struct wlr_pointer *wlr_libinput_pointer_create( + struct libinput_device *device); +void handle_pointer_motion(struct libinput_event *event, + struct libinput_device *device); +void handle_pointer_motion_abs(struct libinput_event *event, + struct libinput_device *device); +void handle_pointer_button(struct libinput_event *event, + struct libinput_device *device); +void handle_pointer_axis(struct libinput_event *event, + struct libinput_device *device); + +struct wlr_touch *wlr_libinput_touch_create( + struct libinput_device *device); +void handle_touch_down(struct libinput_event *event, + struct libinput_device *device); +void handle_touch_up(struct libinput_event *event, + struct libinput_device *device); +void handle_touch_motion(struct libinput_event *event, + struct libinput_device *device); +void handle_touch_cancel(struct libinput_event *event, + struct libinput_device *device); + +struct wlr_tablet_tool *wlr_libinput_tablet_tool_create( + struct libinput_device *device); +void handle_tablet_tool_axis(struct libinput_event *event, + struct libinput_device *device); +void handle_tablet_tool_proximity(struct libinput_event *event, + struct libinput_device *device); +void handle_tablet_tool_tip(struct libinput_event *event, + struct libinput_device *device); +void handle_tablet_tool_button(struct libinput_event *event, + struct libinput_device *device); + +#endif diff --git a/include/backend/multi.h b/include/backend/multi.h new file mode 100644 index 00000000..5e6930bb --- /dev/null +++ b/include/backend/multi.h @@ -0,0 +1,13 @@ +#ifndef _WLR_MULTI_BACKEND_INTERNAL +#define _WLR_MULTI_BACKEND_INTERNAL + +#include <wlr/backend/interface.h> +#include <wlr/backend/multi.h> +#include <wlr/common/list.h> + +struct wlr_backend_state { + struct wlr_backend *backend; + list_t *backends; +}; + +#endif diff --git a/include/render/gles3.h b/include/render/gles3.h index 5efb197e..9acc1088 100644 --- a/include/render/gles3.h +++ b/include/render/gles3.h @@ -13,6 +13,9 @@ struct wlr_surface_state { struct wlr_surface *gles3_surface_init(); +extern const GLchar quad_vertex_src[]; +extern const GLchar quad_fragment_src[]; +extern const GLchar ellipse_fragment_src[]; extern const GLchar vertex_src[]; extern const GLchar fragment_src_RGB[]; extern const GLchar fragment_src_RGBA[]; diff --git a/include/types.h b/include/types.h index d2c8d008..e2930a9f 100644 --- a/include/types.h +++ b/include/types.h @@ -11,6 +11,9 @@ struct wlr_output_impl { struct wlr_output_mode *mode); void (*transform)(struct wlr_output_state *state, enum wl_output_transform transform); + bool (*set_cursor)(struct wlr_output_state *state, + const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height); + bool (*move_cursor)(struct wlr_output_state *state, int x, int y); void (*destroy)(struct wlr_output_state *state); }; @@ -18,4 +21,47 @@ struct wlr_output *wlr_output_create(struct wlr_output_impl *impl, struct wlr_output_state *state); void wlr_output_free(struct wlr_output *output); +struct wlr_keyboard_impl { + void (*destroy)(struct wlr_keyboard_state *state); +}; + +struct wlr_keyboard *wlr_keyboard_create(struct wlr_keyboard_impl *impl, + struct wlr_keyboard_state *state); +void wlr_keyboard_destroy(struct wlr_keyboard *keyboard); + +struct wlr_pointer_impl { + void (*destroy)(struct wlr_pointer_state *state); +}; + +struct wlr_pointer *wlr_pointer_create(struct wlr_pointer_impl *impl, + struct wlr_pointer_state *state); +void wlr_pointer_destroy(struct wlr_pointer *pointer); + +struct wlr_touch_impl { + void (*destroy)(struct wlr_touch_state *state); +}; + +struct wlr_touch *wlr_touch_create(struct wlr_touch_impl *impl, + struct wlr_touch_state *state); +void wlr_touch_destroy(struct wlr_touch *touch); + +struct wlr_tablet_tool_impl { + void (*destroy)(struct wlr_tablet_tool_state *tool); +}; + +struct wlr_tablet_tool *wlr_tablet_tool_create(struct wlr_tablet_tool_impl *impl, + struct wlr_tablet_tool_state *state); +void wlr_tablet_tool_destroy(struct wlr_tablet_tool *tool); + +struct wlr_input_device_impl { + void (*destroy)(struct wlr_input_device_state *state); +}; + +struct wlr_input_device *wlr_input_device_create( + enum wlr_input_device_type type, + struct wlr_input_device_impl *impl, + struct wlr_input_device_state *state, + const char *name, int vendor, int product); +void wlr_input_device_destroy(struct wlr_input_device *dev); + #endif diff --git a/include/wlr/backend.h b/include/wlr/backend.h index 32d96a8d..db85c169 100644 --- a/include/wlr/backend.h +++ b/include/wlr/backend.h @@ -12,14 +12,10 @@ struct wlr_backend { struct wlr_backend_state *state; struct { + struct wl_signal input_add; + struct wl_signal input_remove; struct wl_signal output_add; struct wl_signal output_remove; - struct wl_signal keyboard_add; - struct wl_signal keyboard_remove; - struct wl_signal pointer_add; - struct wl_signal pointer_remove; - struct wl_signal touch_add; - struct wl_signal touch_remove; } events; }; diff --git a/include/wlr/backend/libinput.h b/include/wlr/backend/libinput.h new file mode 100644 index 00000000..7108f42c --- /dev/null +++ b/include/wlr/backend/libinput.h @@ -0,0 +1,15 @@ +#ifndef WLR_BACKEND_LIBINPUT_H +#define WLR_BACKEND_LIBINPUT_H + +#include <libinput.h> +#include <wayland-server.h> +#include <wlr/session.h> +#include <wlr/backend.h> +#include <wlr/backend/udev.h> +#include <wlr/types.h> + +struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display, + struct wlr_session *session, struct wlr_udev *udev); +struct libinput_device *wlr_libinput_get_device_handle(struct wlr_input_device *dev); + +#endif diff --git a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h new file mode 100644 index 00000000..a07ca770 --- /dev/null +++ b/include/wlr/backend/multi.h @@ -0,0 +1,10 @@ +#ifndef _WLR_BACKEND_MULTI_H +#define _WLR_BACKEND_MULTI_H + +#include <wlr/backend.h> + +struct wlr_backend *wlr_multi_backend_create(); +void wlr_multi_backend_add(struct wlr_backend *multi, + struct wlr_backend *backend); + +#endif diff --git a/include/wlr/render.h b/include/wlr/render.h index 88aa615e..3c0bd04b 100644 --- a/include/wlr/render.h +++ b/include/wlr/render.h @@ -29,6 +29,16 @@ struct wlr_surface *wlr_render_surface_init(struct wlr_renderer *r); bool wlr_render_with_matrix(struct wlr_renderer *r, struct wlr_surface *surface, const float (*matrix)[16]); /** + * Renders a solid quad in the specified color. + */ +void wlr_render_colored_quad(struct wlr_renderer *r, + const float (*color)[4], const float (*matrix)[16]); +/** + * Renders a solid ellipse in the specified color. + */ +void wlr_render_colored_ellipse(struct wlr_renderer *r, + const float (*color)[4], const float (*matrix)[16]); +/** * Destroys this wlr_renderer. Surfaces must be destroyed separately. */ void wlr_renderer_destroy(struct wlr_renderer *renderer); diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index 80471ac8..a934f49e 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -19,6 +19,10 @@ struct wlr_renderer_impl { struct wlr_surface *(*surface_init)(struct wlr_renderer_state *state); bool (*render_with_matrix)(struct wlr_renderer_state *state, struct wlr_surface *surface, const float (*matrix)[16]); + void (*render_quad)(struct wlr_renderer_state *state, + const float (*color)[4], const float (*matrix)[16]); + void (*render_ellipse)(struct wlr_renderer_state *state, + const float (*color)[4], const float (*matrix)[16]); void (*destroy)(struct wlr_renderer_state *state); }; diff --git a/include/wlr/session.h b/include/wlr/session.h index bd5a96c0..28ccb526 100644 --- a/include/wlr/session.h +++ b/include/wlr/session.h @@ -22,7 +22,7 @@ struct wlr_session { struct wlr_session *wlr_session_start(struct wl_display *disp); void wlr_session_finish(struct wlr_session *session); int wlr_session_open_file(struct wlr_session *restrict session, - const char *restrict path); + const char *restrict path); void wlr_session_close_file(struct wlr_session *session, int fd); bool wlr_session_change_vt(struct wlr_session *session, int vt); diff --git a/include/wlr/session/interface.h b/include/wlr/session/interface.h index 78256dd6..f75acfa4 100644 --- a/include/wlr/session/interface.h +++ b/include/wlr/session/interface.h @@ -7,7 +7,7 @@ struct session_impl { struct wlr_session *(*start)(struct wl_display *disp); void (*finish)(struct wlr_session *session); int (*open)(struct wlr_session *restrict session, - const char *restrict path); + const char *restrict path); void (*close)(struct wlr_session *session, int fd); bool (*change_vt)(struct wlr_session *session, int vt); }; diff --git a/include/wlr/types.h b/include/wlr/types.h index 51ea45cf..3afc361e 100644 --- a/include/wlr/types.h +++ b/include/wlr/types.h @@ -46,8 +46,245 @@ bool wlr_output_set_mode(struct wlr_output *output, struct wlr_output_mode *mode); void wlr_output_transform(struct wlr_output *output, enum wl_output_transform transform); +bool wlr_output_set_cursor(struct wlr_output *output, + const uint8_t *buf, int32_t stride, uint32_t width, uint32_t height); +bool wlr_output_move_cursor(struct wlr_output *output, int x, int y); void wlr_output_destroy(struct wlr_output *output); void wlr_output_effective_resolution(struct wlr_output *output, int *width, int *height); +struct wlr_keyboard_state; +struct wlr_keyboard_impl; + +struct wlr_keyboard { + struct wlr_keyboard_state *state; + struct wlr_keyboard_impl *impl; + + struct { + struct wl_signal key; + } events; +}; + +enum wlr_key_state { + WLR_KEY_RELEASED, + WLR_KEY_PRESSED, +}; + +struct wlr_keyboard_key { + uint32_t time_sec; + uint64_t time_usec; + uint32_t keycode; + enum wlr_key_state state; +}; + +struct wlr_pointer_state; +struct wlr_pointer_impl; + +struct wlr_pointer { + struct wlr_pointer_state *state; + struct wlr_pointer_impl *impl; + + struct { + struct wl_signal motion; + struct wl_signal motion_absolute; + struct wl_signal button; + struct wl_signal axis; + } events; +}; + +struct wlr_pointer_motion { + uint32_t time_sec; + uint64_t time_usec; + double delta_x, delta_y; +}; + +struct wlr_pointer_motion_absolute { + uint32_t time_sec; + uint64_t time_usec; + double x_mm, y_mm; + double width_mm, height_mm; +}; + +enum wlr_button_state { + WLR_BUTTON_RELEASED, + WLR_BUTTON_PRESSED, +}; + +struct wlr_pointer_button { + uint32_t time_sec; + uint64_t time_usec; + uint32_t button; + enum wlr_button_state state; +}; + +enum wlr_axis_source { + WLR_AXIS_SOURCE_WHEEL, + WLR_AXIS_SOURCE_FINGER, + WLR_AXIS_SOURCE_CONTINUOUS, + WLR_AXIS_SOURCE_WHEEL_TILT, +}; + +enum wlr_axis_orientation { + WLR_AXIS_ORIENTATION_VERTICAL, + WLR_AXIS_ORIENTATION_HORIZONTAL, +}; + +struct wlr_pointer_axis { + uint32_t time_sec; + uint64_t time_usec; + enum wlr_axis_source source; + enum wlr_axis_orientation orientation; + double delta; +}; + +struct wlr_touch_state; +struct wlr_touch_impl; + +struct wlr_touch { + struct wlr_touch_state *state; + struct wlr_touch_impl *impl; + + struct { + struct wl_signal down; + struct wl_signal up; + struct wl_signal motion; + struct wl_signal cancel; + } events; +}; + +struct wlr_touch_down { + uint32_t time_sec; + uint64_t time_usec; + int32_t slot; + double x_mm, y_mm; + double width_mm, height_mm; +}; + +struct wlr_touch_up { + uint32_t time_sec; + uint64_t time_usec; + int32_t slot; +}; + +struct wlr_touch_motion { + uint32_t time_sec; + uint64_t time_usec; + int32_t slot; + double x_mm, y_mm; + double width_mm, height_mm; +}; + +struct wlr_touch_cancel { + uint32_t time_sec; + uint64_t time_usec; + int32_t slot; +}; + +struct wlr_tablet_tool_impl; +struct wlr_tablet_tool_state; + +struct wlr_tablet_tool { + struct wlr_tablet_tool_impl *impl; + struct wlr_tablet_tool_state *state; + + struct { + struct wl_signal axis; + struct wl_signal proximity; + struct wl_signal tip; + struct wl_signal button; + } events; +}; + +enum wlr_tablet_tool_axes { + WLR_TABLET_TOOL_AXIS_X = 1, + WLR_TABLET_TOOL_AXIS_Y = 2, + WLR_TABLET_TOOL_AXIS_DISTANCE = 4, + WLR_TABLET_TOOL_AXIS_PRESSURE = 8, + WLR_TABLET_TOOL_AXIS_TILT_X = 16, + WLR_TABLET_TOOL_AXIS_TILT_Y = 32, + WLR_TABLET_TOOL_AXIS_ROTATION = 64, + WLR_TABLET_TOOL_AXIS_SLIDER = 128, + WLR_TABLET_TOOL_AXIS_WHEEL = 256, +}; + +struct wlr_tablet_tool_axis { + uint32_t time_sec; + uint64_t time_usec; + uint32_t updated_axes; + double x_mm, y_mm; + double width_mm, height_mm; + double pressure; + double distance; + double tilt_x, tilt_y; + double rotation; + double slider; + double wheel_delta; +}; + +enum wlr_tablet_tool_proximity_state { + WLR_TABLET_TOOL_PROXIMITY_OUT, + WLR_TABLET_TOOL_PROXIMITY_IN, +}; + +struct wlr_tablet_tool_proximity { + uint32_t time_sec; + uint64_t time_usec; + double x, y; + double width_mm, height_mm; + enum wlr_tablet_tool_proximity_state state; +}; + +enum wlr_tablet_tool_tip_state { + WLR_TABLET_TOOL_TIP_UP, + WLR_TABLET_TOOL_TIP_DOWN, +}; + +struct wlr_tablet_tool_tip { + uint32_t time_sec; + uint64_t time_usec; + double x, y; + double width_mm, height_mm; + enum wlr_tablet_tool_tip_state state; +}; + +struct wlr_tablet_tool_button { + uint32_t time_sec; + uint64_t time_usec; + uint32_t button; + enum wlr_button_state state; +}; + +// TODO: tablet pad +// TODO: switch + +enum wlr_input_device_type { + WLR_INPUT_DEVICE_KEYBOARD, + WLR_INPUT_DEVICE_POINTER, + WLR_INPUT_DEVICE_TOUCH, + WLR_INPUT_DEVICE_TABLET_TOOL, + WLR_INPUT_DEVICE_TABLET_PAD, + WLR_INPUT_DEVICE_GESTURE, + WLR_INPUT_DEVICE_SWITCH, +}; + +struct wlr_input_device_state; +struct wlr_input_device_impl; + +struct wlr_input_device { + struct wlr_input_device_state *state; + struct wlr_input_device_impl *impl; + + enum wlr_input_device_type type; + int vendor, product; + char *name; + + union { + void *_device; + struct wlr_keyboard *keyboard; + struct wlr_pointer *pointer; + struct wlr_touch *touch; + struct wlr_tablet_tool *tablet_tool; + }; +}; + #endif |