mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-23 02:19:49 +01:00
Handle relative motion for mouse tools
This commit is contained in:
parent
503f9d6e52
commit
48e2cba9b6
3 changed files with 17 additions and 6 deletions
|
@ -204,10 +204,12 @@ void handle_tablet_tool_axis(struct libinput_event *event,
|
|||
if (libinput_event_tablet_tool_x_has_changed(tevent)) {
|
||||
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_X;
|
||||
wlr_event.x = libinput_event_tablet_tool_get_x_transformed(tevent, 1);
|
||||
wlr_event.dx = libinput_event_tablet_tool_get_dx(tevent);
|
||||
}
|
||||
if (libinput_event_tablet_tool_y_has_changed(tevent)) {
|
||||
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_Y;
|
||||
wlr_event.y = libinput_event_tablet_tool_get_y_transformed(tevent, 1);
|
||||
wlr_event.dy = libinput_event_tablet_tool_get_dy(tevent);
|
||||
}
|
||||
if (libinput_event_tablet_tool_pressure_has_changed(tevent)) {
|
||||
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_PRESSURE;
|
||||
|
|
|
@ -79,6 +79,8 @@ struct wlr_event_tablet_tool_axis {
|
|||
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;
|
||||
|
|
|
@ -104,14 +104,21 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
|
|||
static void handle_tablet_tool_position(struct roots_cursor *cursor,
|
||||
struct roots_tablet_tool *tool,
|
||||
struct wlr_tablet_tool_tool *tool_tool,
|
||||
bool change_x, bool change_y, double x, double y,
|
||||
uint32_t time) {
|
||||
bool change_x, bool change_y,
|
||||
double x, double y, double dx, double dy) {
|
||||
if (!change_x && !change_y) {
|
||||
return;
|
||||
}
|
||||
|
||||
wlr_cursor_warp_absolute(cursor->cursor, tool->device,
|
||||
change_x ? x : NAN, change_y ? y : NAN);
|
||||
switch (tool_tool->type) {
|
||||
case WLR_TABLET_TOOL_TYPE_MOUSE:
|
||||
// They are 0 either way when they weren't modified
|
||||
wlr_cursor_move(cursor->cursor, tool->device, dx, dy);
|
||||
break;
|
||||
default:
|
||||
wlr_cursor_warp_absolute(cursor->cursor, tool->device,
|
||||
change_x ? x : NAN, change_y ? y : NAN);
|
||||
}
|
||||
|
||||
double sx, sy;
|
||||
struct roots_view *view = NULL;
|
||||
|
@ -159,7 +166,7 @@ static void handle_tool_axis(struct wl_listener *listener, void *data) {
|
|||
handle_tablet_tool_position(cursor, event->device->data, event->tool,
|
||||
event->updated_axes & WLR_TABLET_TOOL_AXIS_X,
|
||||
event->updated_axes & WLR_TABLET_TOOL_AXIS_Y,
|
||||
event->x, event->y, event->time_msec);
|
||||
event->x, event->y, event->dx, event->dy);
|
||||
|
||||
if (event->updated_axes & WLR_TABLET_TOOL_AXIS_PRESSURE) {
|
||||
wlr_send_tablet_v2_tablet_tool_pressure(roots_tool->tablet_v2_tool, event->pressure);
|
||||
|
@ -271,7 +278,7 @@ static void handle_tool_proximity(struct wl_listener *listener, void *data) {
|
|||
}
|
||||
|
||||
handle_tablet_tool_position(cursor, event->device->data, event->tool,
|
||||
true, true, event->x, event->y, event->time_msec);
|
||||
true, true, event->x, event->y, 0, 0);
|
||||
}
|
||||
|
||||
static void handle_request_set_cursor(struct wl_listener *listener,
|
||||
|
|
Loading…
Reference in a new issue