aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2018-07-16 20:10:38 -0700
committerGitHub <noreply@github.com>2018-07-16 20:10:38 -0700
commit7f20ab644347b11fd8242beaf7a6fe42c910d014 (patch)
tree808d0e88c28561d5853be09f7c2ab7968ce70e3f /include
parent4984ea49eeaa292d66be9e535d93a4d8185f3e18 (diff)
parent9a6f77fc2ceb59f4b5bcd1e1f8c00aa974b5192b (diff)
Merge pull request #960 from Ongy/tablet
tablet-unstable-v2 support
Diffstat (limited to 'include')
-rw-r--r--include/backend/libinput.h2
-rw-r--r--include/rootston/cursor.h2
-rw-r--r--include/rootston/desktop.h1
-rw-r--r--include/rootston/seat.h38
-rw-r--r--include/types/wlr_tablet_v2.h93
-rw-r--r--include/util/array.h9
-rw-r--r--include/wlr/interfaces/wlr_tablet_tool.h10
-rw-r--r--include/wlr/types/wlr_input_device.h2
-rw-r--r--include/wlr/types/wlr_seat.h2
-rw-r--r--include/wlr/types/wlr_tablet_pad.h25
-rw-r--r--include/wlr/types/wlr_tablet_tool.h50
-rw-r--r--include/wlr/types/wlr_tablet_v2.h171
12 files changed, 392 insertions, 13 deletions
diff --git a/include/backend/libinput.h b/include/backend/libinput.h
index f0928133..d1fb3a44 100644
--- a/include/backend/libinput.h
+++ b/include/backend/libinput.h
@@ -65,7 +65,7 @@ void handle_touch_motion(struct libinput_event *event,
void handle_touch_cancel(struct libinput_event *event,
struct libinput_device *device);
-struct wlr_tablet_tool *create_libinput_tablet_tool(
+struct wlr_tablet *create_libinput_tablet(
struct libinput_device *device);
void handle_tablet_tool_axis(struct libinput_event *event,
struct libinput_device *device);
diff --git a/include/rootston/cursor.h b/include/rootston/cursor.h
index a1a466c2..f7410dec 100644
--- a/include/rootston/cursor.h
+++ b/include/rootston/cursor.h
@@ -40,6 +40,8 @@ struct roots_cursor {
struct wl_listener tool_axis;
struct wl_listener tool_tip;
+ struct wl_listener tool_proximity;
+ struct wl_listener tool_button;
struct wl_listener request_set_cursor;
};
diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h
index 88c5ca90..d9add26a 100644
--- a/include/rootston/desktop.h
+++ b/include/rootston/desktop.h
@@ -56,6 +56,7 @@ struct roots_desktop {
struct wlr_layer_shell *layer_shell;
struct wlr_virtual_keyboard_manager_v1 *virtual_keyboard;
struct wlr_screencopy_manager_v1 *screencopy;
+ struct wlr_tablet_manager_v2 *tablet_v2;
struct wl_listener new_output;
struct wl_listener layout_change;
diff --git a/include/rootston/seat.h b/include/rootston/seat.h
index 0e3043dd..3ddb97c5 100644
--- a/include/rootston/seat.h
+++ b/include/rootston/seat.h
@@ -30,7 +30,8 @@ struct roots_seat {
struct wl_list keyboards;
struct wl_list pointers;
struct wl_list touch;
- struct wl_list tablet_tools;
+ struct wl_list tablets;
+ struct wl_list tablet_pads;
struct wl_listener new_drag_icon;
struct wl_listener destroy;
@@ -77,9 +78,11 @@ struct roots_touch {
struct wl_list link;
};
-struct roots_tablet_tool {
+struct roots_tablet {
struct roots_seat *seat;
struct wlr_input_device *device;
+ struct wlr_tablet_v2_tablet *tablet_v2;
+
struct wl_listener device_destroy;
struct wl_listener axis;
struct wl_listener proximity;
@@ -88,6 +91,37 @@ struct roots_tablet_tool {
struct wl_list link;
};
+struct roots_tablet_pad {
+ struct wl_list link;
+ struct wlr_tablet_v2_tablet_pad *tablet_v2_pad;
+
+ struct roots_seat *seat;
+ struct wlr_input_device *device;
+
+ struct wl_listener device_destroy;
+ struct wl_listener attach;
+ struct wl_listener button;
+ struct wl_listener ring;
+ struct wl_listener strip;
+
+ struct roots_tablet *tablet;
+ struct wl_listener tablet_destroy;
+};
+
+struct roots_tablet_tool {
+ struct wl_list link;
+ struct wl_list tool_link;
+ struct wlr_tablet_v2_tablet_tool *tablet_v2_tool;
+
+ struct roots_seat *seat;
+
+ struct wl_listener set_cursor;
+ struct wl_listener tool_destroy;
+
+ struct roots_tablet *current_tablet;
+ struct wl_listener tablet_destroy;
+};
+
struct roots_seat *roots_seat_create(struct roots_input *input, char *name);
void roots_seat_destroy(struct roots_seat *seat);
diff --git a/include/types/wlr_tablet_v2.h b/include/types/wlr_tablet_v2.h
new file mode 100644
index 00000000..4b9e727d
--- /dev/null
+++ b/include/types/wlr_tablet_v2.h
@@ -0,0 +1,93 @@
+#ifndef TYPES_WLR_TABLET_V2_H
+#define TYPES_WLR_TABLET_V2_H
+
+#include "tablet-unstable-v2-protocol.h"
+#include <wayland-server.h>
+#include <wlr/types/wlr_tablet_v2.h>
+
+struct wlr_tablet_seat_v2 {
+ struct wl_list link;
+ struct wlr_seat *wlr_seat;
+ struct wlr_tablet_manager_v2 *manager;
+
+ struct wl_list tablets; // wlr_tablet_v2_tablet::link
+ struct wl_list tools;
+ struct wl_list pads;
+
+ struct wl_list clients; //wlr_tablet_seat_v2_client::link;
+
+ struct wl_listener seat_destroy;
+};
+
+struct wlr_tablet_seat_client_v2 {
+ struct wl_list seat_link;
+ struct wl_list client_link;
+ struct wl_client *wl_client;
+ struct wl_resource *resource;
+
+ struct wlr_tablet_manager_client_v2 *client;
+ struct wlr_seat_client *seat_client;
+
+ struct wl_listener seat_client_destroy;
+
+ struct wl_list tools; //wlr_tablet_tool_client_v2::link
+ struct wl_list tablets; //wlr_tablet_client_v2::link
+ struct wl_list pads; //wlr_tablet_pad_client_v2::link
+};
+
+struct wlr_tablet_client_v2 {
+ struct wl_list seat_link; // wlr_tablet_seat_client_v2::tablet
+ struct wl_list tablet_link; // wlr_tablet_v2_tablet::clients
+ struct wl_client *client;
+ struct wl_resource *resource;
+};
+
+struct wlr_tablet_pad_client_v2 {
+ struct wl_list seat_link;
+ struct wl_list pad_link;
+ struct wl_client *client;
+ struct wl_resource *resource;
+ struct wlr_tablet_v2_tablet_pad *pad;
+
+ size_t button_count;
+
+ size_t group_count;
+ struct wl_resource **groups;
+
+ size_t ring_count;
+ struct wl_resource **rings;
+
+ size_t strip_count;
+ struct wl_resource **strips;
+};
+
+struct wlr_tablet_tool_client_v2 {
+ struct wl_list seat_link;
+ struct wl_list tool_link;
+ struct wl_client *client;
+ struct wl_resource *resource;
+ struct wlr_tablet_v2_tablet_tool *tool;
+ struct wlr_tablet_seat_client_v2 *seat;
+
+ struct wl_event_source *frame_source;
+};
+
+struct wlr_tablet_client_v2 *tablet_client_from_resource(struct wl_resource *resource);
+void destroy_tablet_v2(struct wl_resource *resource);
+void add_tablet_client(struct wlr_tablet_seat_client_v2 *seat, struct wlr_tablet_v2_tablet *tablet);
+
+void destroy_tablet_pad_v2(struct wl_resource *resource);
+struct wlr_tablet_pad_client_v2 *tablet_pad_client_from_resource(struct wl_resource *resource);
+void add_tablet_pad_client(struct wlr_tablet_seat_client_v2 *seat, struct wlr_tablet_v2_tablet_pad *pad);
+
+void destroy_tablet_tool_v2(struct wl_resource *resource);
+struct wlr_tablet_tool_client_v2 *tablet_tool_client_from_resource(struct wl_resource *resource);
+void add_tablet_tool_client(struct wlr_tablet_seat_client_v2 *seat, struct wlr_tablet_v2_tablet_tool *tool);
+
+struct wlr_tablet_seat_client_v2 *tablet_seat_client_from_resource(struct wl_resource *resource);
+void tablet_seat_client_v2_destroy(struct wl_resource *resource);
+struct wlr_tablet_seat_v2 *get_or_create_tablet_seat(
+ struct wlr_tablet_manager_v2 *manager,
+ struct wlr_seat *wlr_seat);
+
+#endif /* TYPES_WLR_TABLET_V2_H */
diff --git a/include/util/array.h b/include/util/array.h
new file mode 100644
index 00000000..1c046e1d
--- /dev/null
+++ b/include/util/array.h
@@ -0,0 +1,9 @@
+#ifndef UTIL_ARRAY_H
+#define UTIL_ARRAY_H
+
+#include <stdint.h>
+#include <stdlib.h>
+
+size_t push_zeroes_to_end(uint32_t arr[], size_t n);
+
+#endif
diff --git a/include/wlr/interfaces/wlr_tablet_tool.h b/include/wlr/interfaces/wlr_tablet_tool.h
index 347a0003..12b2e32e 100644
--- a/include/wlr/interfaces/wlr_tablet_tool.h
+++ b/include/wlr/interfaces/wlr_tablet_tool.h
@@ -3,12 +3,12 @@
#include <wlr/types/wlr_tablet_tool.h>
-struct wlr_tablet_tool_impl {
- void (*destroy)(struct wlr_tablet_tool *tool);
+struct wlr_tablet_impl {
+ void (*destroy)(struct wlr_tablet *tablet);
};
-void wlr_tablet_tool_init(struct wlr_tablet_tool *tool,
- struct wlr_tablet_tool_impl *impl);
-void wlr_tablet_tool_destroy(struct wlr_tablet_tool *tool);
+void wlr_tablet_init(struct wlr_tablet *tablet,
+ struct wlr_tablet_impl *impl);
+void wlr_tablet_destroy(struct wlr_tablet *tablet);
#endif
diff --git a/include/wlr/types/wlr_input_device.h b/include/wlr/types/wlr_input_device.h
index 5cf26b65..cce15d90 100644
--- a/include/wlr/types/wlr_input_device.h
+++ b/include/wlr/types/wlr_input_device.h
@@ -39,7 +39,7 @@ struct wlr_input_device {
struct wlr_keyboard *keyboard;
struct wlr_pointer *pointer;
struct wlr_touch *touch;
- struct wlr_tablet_tool *tablet_tool;
+ struct wlr_tablet *tablet;
struct wlr_tablet_pad *tablet_pad;
};
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index 1c7a1472..92d0a233 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -540,6 +540,4 @@ bool wlr_seat_validate_grab_serial(struct wlr_seat *seat, uint32_t serial);
struct wlr_seat_client *wlr_seat_client_from_resource(
struct wl_resource *resource);
-bool wlr_surface_is_pointer_cursor(struct wlr_surface *surface);
-
#endif
diff --git a/include/wlr/types/wlr_tablet_pad.h b/include/wlr/types/wlr_tablet_pad.h
index 73082c56..23ac464d 100644
--- a/include/wlr/types/wlr_tablet_pad.h
+++ b/include/wlr/types/wlr_tablet_pad.h
@@ -4,6 +4,7 @@
#include <stdint.h>
#include <wayland-server.h>
#include <wlr/types/wlr_input_device.h>
+#include <wlr/types/wlr_list.h>
/*
* NOTE: the wlr tablet pad implementation does not currently support tablets
@@ -20,16 +21,40 @@ struct wlr_tablet_pad {
struct wl_signal button;
struct wl_signal ring;
struct wl_signal strip;
+ struct wl_signal attach_tablet; //struct wlr_tablet_tool
} events;
+ size_t button_count;
+ size_t ring_count;
+ size_t strip_count;
+
+ struct wl_list groups; // wlr_tablet_pad_group::link
+ struct wlr_list paths; // char *
+
void *data;
};
+struct wlr_tablet_pad_group {
+ struct wl_list link;
+
+ size_t button_count;
+ unsigned int *buttons;
+
+ size_t strip_count;
+ unsigned int *strips;
+
+ size_t ring_count;
+ unsigned int *rings;
+
+ unsigned int mode_count;
+};
+
struct wlr_event_tablet_pad_button {
uint32_t time_msec;
uint32_t button;
enum wlr_button_state state;
unsigned int mode;
+ unsigned int group;
};
enum wlr_tablet_pad_ring_source {
diff --git a/include/wlr/types/wlr_tablet_tool.h b/include/wlr/types/wlr_tablet_tool.h
index 22bf2649..bfa2e1f7 100644
--- a/include/wlr/types/wlr_tablet_tool.h
+++ b/include/wlr/types/wlr_tablet_tool.h
@@ -4,11 +4,47 @@
#include <stdint.h>
#include <wayland-server.h>
#include <wlr/types/wlr_input_device.h>
+#include <wlr/types/wlr_list.h>
-struct wlr_tablet_tool_impl;
+/*
+ * Copy+Paste from libinput, but this should neither use libinput, nor
+ * tablet-unstable-v2 headers, so we can't include them
+ */
+enum wlr_tablet_tool_type {
+ WLR_TABLET_TOOL_TYPE_PEN = 1, /**< A generic pen */
+ WLR_TABLET_TOOL_TYPE_ERASER, /**< Eraser */
+ WLR_TABLET_TOOL_TYPE_BRUSH, /**< A paintbrush-like tool */
+ WLR_TABLET_TOOL_TYPE_PENCIL, /**< Physical drawing tool, e.g.
+ Wacom Inking Pen */
+ WLR_TABLET_TOOL_TYPE_AIRBRUSH, /**< An airbrush-like tool */
+ WLR_TABLET_TOOL_TYPE_MOUSE, /**< A mouse bound to the tablet */
+ WLR_TABLET_TOOL_TYPE_LENS, /**< A mouse tool with a lens */
+};
struct wlr_tablet_tool {
- struct wlr_tablet_tool_impl *impl;
+ enum wlr_tablet_tool_type type;
+ uint64_t hardware_serial;
+ uint64_t hardware_wacom;
+
+ // Capabilities
+ bool tilt;
+ bool pressure;
+ bool distance;
+ bool rotation;
+ bool slider;
+ bool wheel;
+
+ struct {
+ struct wl_signal destroy;
+ } events;
+
+ void *data;
+};
+
+struct wlr_tablet_impl;
+
+struct wlr_tablet {
+ struct wlr_tablet_impl *impl;
struct {
struct wl_signal axis;
@@ -17,6 +53,9 @@ struct wlr_tablet_tool {
struct wl_signal button;
} events;
+ const char *name;
+ struct wlr_list paths; // char *
+
void *data;
};
@@ -34,10 +73,14 @@ enum wlr_tablet_tool_axes {
struct wlr_event_tablet_tool_axis {
struct wlr_input_device *device;
+ struct wlr_tablet_tool *tool;
+
uint32_t time_msec;
uint32_t updated_axes;
// From 0..1
double x, y;
+ // Relative to last event
+ double dx, dy;
double pressure;
double distance;
double tilt_x, tilt_y;
@@ -53,6 +96,7 @@ enum wlr_tablet_tool_proximity_state {
struct wlr_event_tablet_tool_proximity {
struct wlr_input_device *device;
+ struct wlr_tablet_tool *tool;
uint32_t time_msec;
// From 0..1
double x, y;
@@ -66,6 +110,7 @@ enum wlr_tablet_tool_tip_state {
struct wlr_event_tablet_tool_tip {
struct wlr_input_device *device;
+ struct wlr_tablet_tool *tool;
uint32_t time_msec;
// From 0..1
double x, y;
@@ -74,6 +119,7 @@ struct wlr_event_tablet_tool_tip {
struct wlr_event_tablet_tool_button {
struct wlr_input_device *device;
+ struct wlr_tablet_tool *tool;
uint32_t time_msec;
uint32_t button;
enum wlr_button_state state;
diff --git a/include/wlr/types/wlr_tablet_v2.h b/include/wlr/types/wlr_tablet_v2.h
new file mode 100644
index 00000000..afa74d05
--- /dev/null
+++ b/include/wlr/types/wlr_tablet_v2.h
@@ -0,0 +1,171 @@
+#ifndef WLR_TYPES_WLR_TABLET_V2_H
+#define WLR_TYPES_WLR_TABLET_V2_H
+
+#include <wayland-server.h>
+#include <wlr/types/wlr_seat.h>
+#include <wlr/types/wlr_input_device.h>
+
+#include "tablet-unstable-v2-protocol.h"
+
+/* This can probably be even lower,the tools don't have a lot of buttons */
+#define WLR_TABLET_V2_TOOL_BUTTONS_CAP 16
+
+struct wlr_tablet_client_v2;
+struct wlr_tablet_tool_client_v2;
+struct wlr_tablet_pad_client_v2;
+
+struct wlr_tablet_manager_v2 {
+ struct wl_global *wl_global;
+ struct wl_list clients; // wlr_tablet_manager_client_v2::link
+ struct wl_list seats; // wlr_tablet_seat_v2::link
+
+ struct wl_listener display_destroy;
+
+ void *data;
+};
+
+struct wlr_tablet_v2_tablet {
+ struct wl_list link; // wlr_tablet_seat_v2::tablets
+ struct wlr_tablet *wlr_tablet;
+ struct wlr_input_device *wlr_device;
+ struct wl_list clients; // wlr_tablet_client_v2::tablet_link
+
+ struct wl_listener tool_destroy;
+
+ struct wlr_tablet_client_v2 *current_client;
+};
+
+struct wlr_tablet_v2_tablet_tool {
+ struct wl_list link; // wlr_tablet_seat_v2::tablets
+ struct wlr_tablet_tool *wlr_tool;
+ struct wl_list clients; // wlr_tablet_tool_client_v2::tool_link
+
+ struct wl_listener tool_destroy;
+
+ struct wlr_tablet_tool_client_v2 *current_client;
+ struct wlr_surface *focused_surface;
+ struct wl_listener surface_destroy;
+
+ uint32_t proximity_serial;
+ bool is_down;
+ uint32_t down_serial;
+ size_t num_buttons;
+ uint32_t pressed_buttons[WLR_TABLET_V2_TOOL_BUTTONS_CAP];
+ uint32_t pressed_serials[WLR_TABLET_V2_TOOL_BUTTONS_CAP];
+
+ struct {
+ struct wl_signal set_cursor; // struct wlr_tablet_v2_event_cursor
+ } events;
+};
+
+struct wlr_tablet_v2_tablet_pad {
+ struct wl_list link; // wlr_tablet_seat_v2::pads
+ struct wlr_tablet_pad *wlr_pad;
+ struct wlr_input_device *wlr_device;
+ struct wl_list clients; // wlr_tablet_pad_client_v2::pad_link
+
+ size_t group_count;
+ uint32_t *groups;
+
+ struct wl_listener pad_destroy;
+
+ struct wlr_tablet_pad_client_v2 *current_client;
+
+ struct {
+ struct wl_signal button_feedback; // struct wlr_tablet_v2_event_feedback
+ struct wl_signal strip_feedback; // struct wlr_tablet_v2_event_feedback
+ struct wl_signal ring_feedback; // struct wlr_tablet_v2_event_feedback
+ } events;
+};
+
+struct wlr_tablet_v2_event_cursor {
+ struct wlr_surface *surface;
+ uint32_t serial;
+ int32_t hotspot_x;
+ int32_t hotspot_y;
+ struct wlr_seat_client *seat_client;
+};
+
+struct wlr_tablet_v2_event_feedback {
+ const char *description;
+ size_t index;
+ uint32_t serial;
+};
+
+struct wlr_tablet_v2_tablet *wlr_tablet_create(
+ struct wlr_tablet_manager_v2 *manager,
+ struct wlr_seat *wlr_seat,
+ struct wlr_input_device *wlr_device);
+
+struct wlr_tablet_v2_tablet_pad *wlr_tablet_pad_create(
+ struct wlr_tablet_manager_v2 *manager,
+ struct wlr_seat *wlr_seat,
+ struct wlr_input_device *wlr_device);
+
+struct wlr_tablet_v2_tablet_tool *wlr_tablet_tool_create(
+ struct wlr_tablet_manager_v2 *manager,
+ struct wlr_seat *wlr_seat,
+ struct wlr_tablet_tool *wlr_tool);
+
+struct wlr_tablet_manager_v2 *wlr_tablet_v2_create(struct wl_display *display);
+void wlr_tablet_v2_destroy(struct wlr_tablet_manager_v2 *manager);
+
+void wlr_send_tablet_v2_tablet_tool_proximity_in(
+ struct wlr_tablet_v2_tablet_tool *tool,
+ struct wlr_tablet_v2_tablet *tablet,
+ struct wlr_surface *surface);
+
+void wlr_send_tablet_v2_tablet_tool_down(struct wlr_tablet_v2_tablet_tool *tool);
+void wlr_send_tablet_v2_tablet_tool_up(struct wlr_tablet_v2_tablet_tool *tool);
+
+void wlr_send_tablet_v2_tablet_tool_motion(
+ struct wlr_tablet_v2_tablet_tool *tool, double x, double y);
+
+void wlr_send_tablet_v2_tablet_tool_pressure(
+ struct wlr_tablet_v2_tablet_tool *tool, double pressure);
+
+void wlr_send_tablet_v2_tablet_tool_distance(
+ struct wlr_tablet_v2_tablet_tool *tool, double distance);
+
+void wlr_send_tablet_v2_tablet_tool_tilt(
+ struct wlr_tablet_v2_tablet_tool *tool, double x, double y);
+
+void wlr_send_tablet_v2_tablet_tool_rotation(
+ struct wlr_tablet_v2_tablet_tool *tool, double degrees);
+
+void wlr_send_tablet_v2_tablet_tool_slider(
+ struct wlr_tablet_v2_tablet_tool *tool, double position);
+
+void wlr_send_tablet_v2_tablet_tool_wheel(
+ struct wlr_tablet_v2_tablet_tool *tool, double degrees, int32_t clicks);
+
+void wlr_send_tablet_v2_tablet_tool_proximity_out(
+ struct wlr_tablet_v2_tablet_tool *tool);
+
+void wlr_send_tablet_v2_tablet_tool_button(
+ struct wlr_tablet_v2_tablet_tool *tool, uint32_t button,
+ enum zwp_tablet_pad_v2_button_state state);
+
+uint32_t wlr_send_tablet_v2_tablet_pad_enter(
+ struct wlr_tablet_v2_tablet_pad *pad,
+ struct wlr_tablet_v2_tablet *tablet,
+ struct wlr_surface *surface);
+
+void wlr_send_tablet_v2_tablet_pad_button(
+ struct wlr_tablet_v2_tablet_pad *pad, size_t button,
+ uint32_t time, enum zwp_tablet_pad_v2_button_state state);
+
+void wlr_send_tablet_v2_tablet_pad_strip( struct wlr_tablet_v2_tablet_pad *pad,
+ uint32_t strip, double position, bool finger, uint32_t time);
+void wlr_send_tablet_v2_tablet_pad_ring(struct wlr_tablet_v2_tablet_pad *pad,
+ uint32_t ring, double position, bool finger, uint32_t time);
+
+uint32_t wlr_send_tablet_v2_tablet_pad_leave(struct wlr_tablet_v2_tablet_pad *pad,
+ struct wlr_surface *surface);
+
+uint32_t wlr_send_tablet_v2_tablet_pad_mode(struct wlr_tablet_v2_tablet_pad *pad,
+ size_t group, uint32_t mode, uint32_t time);
+
+bool wlr_surface_accepts_tablet_v2(struct wlr_tablet_v2_tablet *tablet,
+ struct wlr_surface *surface);
+#endif /* WLR_TYPES_WLR_TABLET_V2_H */