aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Ongyerth <ongy@ongy.net>2018-05-17 12:22:15 +0200
committerMarkus Ongyerth <ongy@ongy.net>2018-07-14 09:47:16 +0200
commit2c120114723aaaf270e3a44df958faeda91b3f5a (patch)
treee7cdfa3b3fba3404e57a0e31525338efb4a7fc20
parent6a40561e4cddae0f6c3325afd96c7f38e8f649d1 (diff)
Send all tablet tool axis events
-rw-r--r--include/wlr/types/wlr_tablet_v2.h17
-rw-r--r--rootston/seat.c25
-rw-r--r--types/wlr_tablet_v2.c77
3 files changed, 117 insertions, 2 deletions
diff --git a/include/wlr/types/wlr_tablet_v2.h b/include/wlr/types/wlr_tablet_v2.h
index 5de12ec8..3268c0b5 100644
--- a/include/wlr/types/wlr_tablet_v2.h
+++ b/include/wlr/types/wlr_tablet_v2.h
@@ -47,6 +47,8 @@ struct wlr_tablet_v2_tablet_tool {
struct wl_listener surface_destroy;
struct wl_listener client_destroy;
+ uint32_t down_serial;
+ bool is_down;
uint32_t button_serial;
size_t num_buttons;
uint32_t pressed_buttons[WLR_TABLEt_V2_TOOL_BUTTONS_CAP];
@@ -113,12 +115,27 @@ uint32_t wlr_send_tablet_v2_tablet_tool_proximity_in(
struct wlr_tablet_v2_tablet *tablet,
struct wlr_surface *surface);
+uint32_t 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, uint32_t pressure);
+
void wlr_send_tablet_v2_tablet_tool_distance(
struct wlr_tablet_v2_tablet_tool *tool, uint32_t 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, int32_t position);
+
void wlr_send_tablet_v2_tablet_tool_wheel(
struct wlr_tablet_v2_tablet_tool *tool, double delta, int32_t clicks);
diff --git a/rootston/seat.c b/rootston/seat.c
index d49d71cc..56b9c50e 100644
--- a/rootston/seat.c
+++ b/rootston/seat.c
@@ -161,14 +161,29 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
event->updated_axes & WLR_TABLET_TOOL_AXIS_Y,
event->x, event->y, event->time_msec);
+ if (event->updated_axes & WLR_TABLET_TOOL_AXIS_PRESSURE) {
+ wlr_send_tablet_v2_tablet_tool_pressure(roots_tool->tablet_v2_tool, event->pressure);
+ }
+
if (event->updated_axes & WLR_TABLET_TOOL_AXIS_DISTANCE) {
wlr_send_tablet_v2_tablet_tool_distance(roots_tool->tablet_v2_tool, event->distance);
}
+ if (event->updated_axes & (WLR_TABLET_TOOL_AXIS_TILT_X | WLR_TABLET_TOOL_AXIS_TILT_Y)) {
+ wlr_send_tablet_v2_tablet_tool_tilt(roots_tool->tablet_v2_tool, event->tilt_x, event->tilt_y);
+ }
+
+ if (event->updated_axes & WLR_TABLET_TOOL_AXIS_ROTATION) {
+ wlr_send_tablet_v2_tablet_tool_rotation(roots_tool->tablet_v2_tool, event->rotation);
+ }
+
+ if (event->updated_axes & WLR_TABLET_TOOL_AXIS_SLIDER) {
+ wlr_send_tablet_v2_tablet_tool_slider(roots_tool->tablet_v2_tool, event->slider);
+ }
+
if (event->updated_axes & WLR_TABLET_TOOL_AXIS_WHEEL) {
wlr_send_tablet_v2_tablet_tool_wheel(roots_tool->tablet_v2_tool, event->wheel_delta, 0);
}
- //roots_cursor_handle_tool_axis(cursor, event);
}
static void handle_tool_tip(struct wl_listener *listener, void *data) {
@@ -177,7 +192,13 @@ static void handle_tool_tip(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop = cursor->seat->input->server->desktop;
wlr_idle_notify_activity(desktop->idle, cursor->seat->seat);
struct wlr_event_tablet_tool_tip *event = data;
- roots_cursor_handle_tool_tip(cursor, event);
+ struct roots_tablet_tool_tool *roots_tool = event->tool->data;
+
+ if (event->state == WLR_TABLET_TOOL_TIP_DOWN) {
+ wlr_send_tablet_v2_tablet_tool_down(roots_tool->tablet_v2_tool);
+ } else {
+ wlr_send_tablet_v2_tablet_tool_up(roots_tool->tablet_v2_tool);
+ }
}
static void handle_tablet_tool_tool_destroy(struct wl_listener *listener, void *data) {
diff --git a/types/wlr_tablet_v2.c b/types/wlr_tablet_v2.c
index 74327c9c..48de6b68 100644
--- a/types/wlr_tablet_v2.c
+++ b/types/wlr_tablet_v2.c
@@ -1224,6 +1224,16 @@ void wlr_send_tablet_v2_tablet_tool_proximity_out(
}
}
+void wlr_send_tablet_v2_tablet_tool_pressure(
+ struct wlr_tablet_v2_tablet_tool *tool, uint32_t pressure) {
+ if (tool->current_client) {
+ zwp_tablet_tool_v2_send_pressure(tool->current_client->resource,
+ pressure);
+
+ queue_tool_frame(tool->current_client);
+ }
+}
+
void wlr_send_tablet_v2_tablet_tool_distance(
struct wlr_tablet_v2_tablet_tool *tool, uint32_t distance) {
if (tool->current_client) {
@@ -1234,6 +1244,42 @@ void wlr_send_tablet_v2_tablet_tool_distance(
}
}
+void wlr_send_tablet_v2_tablet_tool_tilt(
+ struct wlr_tablet_v2_tablet_tool *tool, double x, double y) {
+ if (!tool->current_client) {
+ return;
+ }
+
+ zwp_tablet_tool_v2_send_tilt(tool->current_client->resource,
+ wl_fixed_from_double(x), wl_fixed_from_double(y));
+
+ queue_tool_frame(tool->current_client);
+}
+
+void wlr_send_tablet_v2_tablet_tool_rotation(
+ struct wlr_tablet_v2_tablet_tool *tool, double degrees) {
+ if (!tool->current_client) {
+ return;
+ }
+
+ zwp_tablet_tool_v2_send_rotation(tool->current_client->resource,
+ wl_fixed_from_double(degrees));
+
+ queue_tool_frame(tool->current_client);
+}
+
+void wlr_send_tablet_v2_tablet_tool_slider(
+ struct wlr_tablet_v2_tablet_tool *tool, int32_t position) {
+ if (!tool->current_client) {
+ return;
+ }
+
+ zwp_tablet_tool_v2_send_slider(tool->current_client->resource,
+ position);
+
+ queue_tool_frame(tool->current_client);
+}
+
uint32_t 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) {
@@ -1262,6 +1308,37 @@ void wlr_send_tablet_v2_tablet_tool_wheel(
}
}
+uint32_t wlr_send_tablet_v2_tablet_tool_down(struct wlr_tablet_v2_tablet_tool *tool) {
+ if (tool->is_down) {
+ return 0;
+ }
+
+ tool->is_down = true;
+ if (tool->current_client) {
+ uint32_t serial = ++tool->down_serial;
+
+ zwp_tablet_tool_v2_send_down(tool->current_client->resource,
+ serial);
+ queue_tool_frame(tool->current_client);
+
+ return serial;
+ }
+
+ return 0;
+}
+
+void wlr_send_tablet_v2_tablet_tool_up(struct wlr_tablet_v2_tablet_tool *tool) {
+ if (!tool->is_down) {
+ return;
+ }
+ tool->is_down = false;
+
+ if (tool->current_client) {
+ zwp_tablet_tool_v2_send_up(tool->current_client->resource);
+ queue_tool_frame(tool->current_client);
+ }
+}
+
uint32_t wlr_send_tablet_v2_tablet_pad_enter(
struct wlr_tablet_v2_tablet_pad *pad,
struct wlr_tablet_v2_tablet *tablet,