Improve input sensitivity

We now use doubles until the last minute, which makes it so we can move
the pointer more precisely. This also includes a fix for tablet tools,
which move absolutely and sometimes do not update the X or Y axis.
master
Drew DeVault 7 years ago
parent 86b8729998
commit 6d8e1abfc0

@ -70,6 +70,8 @@ void handle_tablet_tool_axis(struct libinput_event *event,
wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL; wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL;
wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent); wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent);
} }
wlr_log(L_DEBUG, "Tablet tool axis event %d @ %f,%f",
wlr_event.updated_axes, wlr_event.x_mm, wlr_event.y_mm);
wl_signal_emit(&wlr_dev->tablet_tool->events.axis, &wlr_event); wl_signal_emit(&wlr_dev->tablet_tool->events.axis, &wlr_event);
} }

@ -14,7 +14,7 @@ struct wlr_output_mode {
struct wlr_output_cursor { struct wlr_output_cursor {
struct wlr_output *output; struct wlr_output *output;
int32_t x, y; double x, y;
bool enabled; bool enabled;
uint32_t width, height; uint32_t width, height;
int32_t hotspot_x, hotspot_y; int32_t hotspot_x, hotspot_y;
@ -95,7 +95,8 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor,
int32_t hotspot_x, int32_t hotspot_y); int32_t hotspot_x, int32_t hotspot_y);
void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor, void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y); struct wlr_surface *surface, int32_t hotspot_x, int32_t hotspot_y);
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y); bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
double x, double y);
void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor); void wlr_output_cursor_destroy(struct wlr_output_cursor *cursor);
#endif #endif

@ -378,11 +378,20 @@ static void handle_touch_motion(struct wl_listener *listener, void *data) {
static void handle_tool_axis(struct wl_listener *listener, void *data) { static void handle_tool_axis(struct wl_listener *listener, void *data) {
struct roots_input *input = wl_container_of(listener, input, cursor_tool_axis); struct roots_input *input = wl_container_of(listener, input, cursor_tool_axis);
struct wlr_event_tablet_tool_axis *event = data; struct wlr_event_tablet_tool_axis *event = data;
if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) && if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X) &&
(event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) { (event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
wlr_cursor_warp_absolute(input->cursor, event->device, wlr_cursor_warp_absolute(input->cursor, event->device,
event->x_mm / event->width_mm, event->y_mm / event->height_mm); event->x_mm / event->width_mm, event->y_mm / event->height_mm);
cursor_update_position(input, event->time_msec); cursor_update_position(input, event->time_msec);
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_X)) {
wlr_cursor_warp_absolute(input->cursor, event->device,
event->x_mm / event->width_mm, -1);
cursor_update_position(input, event->time_msec);
} else if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_Y)) {
wlr_cursor_warp_absolute(input->cursor, event->device,
-1, event->y_mm / event->height_mm);
cursor_update_position(input, event->time_msec);
} }
} }

@ -261,8 +261,8 @@ void wlr_cursor_warp_absolute(struct wlr_cursor *cur,
mapping = wlr_output_layout_get_box(cur->state->layout, NULL); mapping = wlr_output_layout_get_box(cur->state->layout, NULL);
} }
double x = mapping->width * x_mm + mapping->x; double x = x_mm > 0 ? mapping->width * x_mm + mapping->x : cur->x;
double y = mapping->height * y_mm + mapping->y; double y = y_mm > 0 ? mapping->height * y_mm + mapping->y : cur->y;
wlr_cursor_warp_unchecked(cur, x, y); wlr_cursor_warp_unchecked(cur, x, y);
} }

@ -472,9 +472,11 @@ void wlr_output_cursor_set_surface(struct wlr_output_cursor *cursor,
} }
} }
bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y) { bool wlr_output_cursor_move(struct wlr_output_cursor *cursor,
double x, double y) {
x *= cursor->output->scale; x *= cursor->output->scale;
y *= cursor->output->scale; y *= cursor->output->scale;
wlr_log(L_DEBUG, "Moving cursor to %f,%f", x, y);
cursor->x = x; cursor->x = x;
cursor->y = y; cursor->y = y;
@ -486,7 +488,7 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, int x, int y) {
if (!cursor->output->impl->move_cursor) { if (!cursor->output->impl->move_cursor) {
return false; return false;
} }
return cursor->output->impl->move_cursor(cursor->output, x, y); return cursor->output->impl->move_cursor(cursor->output, (int)x, (int)y);
} }
struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output) { struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output) {

Loading…
Cancel
Save