mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 21:05:58 +01:00
Send all tablet tool axis events
This commit is contained in:
parent
6a40561e4c
commit
2c12011472
3 changed files with 117 additions and 2 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue