summaryrefslogtreecommitdiff
path: root/src/evdev-tablet.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2015-12-15 11:18:14 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2015-12-23 07:33:39 +1000
commit7309fd0ed38170757946bf21e4542a249be0452c (patch)
tree1f862070ead762def2864f74a94a7221905c8e99 /src/evdev-tablet.c
parentc39a91200e1a8214eeb554546d12cf628d8c1395 (diff)
tablet: simplify marking axes as changed
The only time we need this is on proximity in, so move it to where we handle that to have better locality. And rather than looping through and checking each bit, just memcpy the axis capabilities, because by definition they represent the set of axes that can possibly change. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src/evdev-tablet.c')
-rw-r--r--src/evdev-tablet.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c
index af705b7..24a54df 100644
--- a/src/evdev-tablet.c
+++ b/src/evdev-tablet.c
@@ -156,20 +156,6 @@ tablet_process_absolute(struct tablet_dispatch *tablet,
}
static void
-tablet_mark_all_axes_changed(struct tablet_dispatch *tablet,
- struct evdev_device *device)
-{
- enum libinput_tablet_tool_axis a;
-
- for (a = LIBINPUT_TABLET_TOOL_AXIS_X; a <= LIBINPUT_TABLET_TOOL_AXIS_MAX; a++) {
- if (tablet_device_has_axis(tablet, a))
- set_bit(tablet->changed_axes, a);
- }
-
- tablet_set_status(tablet, TABLET_AXES_UPDATED);
-}
-
-static void
tablet_change_to_left_handed(struct evdev_device *device)
{
struct tablet_dispatch *tablet =
@@ -194,7 +180,6 @@ tablet_update_tool(struct tablet_dispatch *tablet,
if (enabled) {
tablet->current_tool_type = tool;
- tablet_mark_all_axes_changed(tablet, device);
tablet_set_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY);
tablet_unset_status(tablet, TABLET_TOOL_OUT_OF_PROXIMITY);
}
@@ -782,6 +767,9 @@ tool_set_bits(const struct tablet_dispatch *tablet,
{
enum libinput_tablet_tool_type type = tool->type;
+ copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_X);
+ copy_axis_cap(tablet, tool, LIBINPUT_TABLET_TOOL_AXIS_Y);
+
#if HAVE_LIBWACOM
if (tool_set_bits_from_libwacom(tablet, tool) == 0)
return;
@@ -1059,6 +1047,20 @@ detect_pressure_offset(struct tablet_dispatch *tablet,
}
static void
+tablet_mark_all_axes_changed(struct tablet_dispatch *tablet,
+ struct evdev_device *device,
+ struct libinput_tablet_tool *tool)
+{
+ static_assert(sizeof(tablet->changed_axes) ==
+ sizeof(tool->axis_caps),
+ "Mismatching array sizes");
+
+ memcpy(tablet->changed_axes,
+ tool->axis_caps,
+ sizeof(tablet->changed_axes));
+}
+
+static void
tablet_flush(struct tablet_dispatch *tablet,
struct evdev_device *device,
uint64_t time)
@@ -1082,6 +1084,9 @@ tablet_flush(struct tablet_dispatch *tablet,
tablet_set_status(tablet, TABLET_TOOL_LEAVING_CONTACT);
} else if (tablet_has_status(tablet, TABLET_AXES_UPDATED) ||
tablet_has_status(tablet, TABLET_TOOL_ENTERING_PROXIMITY)) {
+ if (tablet_has_status(tablet,
+ TABLET_TOOL_ENTERING_PROXIMITY))
+ tablet_mark_all_axes_changed(tablet, device, tool);
detect_pressure_offset(tablet, device, tool);
sanitize_tablet_axes(tablet);
tablet_check_notify_axes(tablet, device, time, tool);