From 0b124a1a5d5e8d49d2a75af7da741f004b58ebbe Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 5 Jan 2016 14:08:01 +1000 Subject: [PATCH] tablet: insert "STATE" into proximity/tip states Makes it even longer, but at least it's consistent with button and key state. Signed-off-by: Peter Hutterer Reviewed-by: Jason Gerecke --- src/evdev-tablet.c | 4 ++-- src/libinput.c | 6 +++--- src/libinput.h | 8 ++++---- test/tablet.c | 28 ++++++++++++++-------------- tools/event-debug.c | 4 ++-- tools/event-gui.c | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/evdev-tablet.c b/src/evdev-tablet.c index 7804c91c..8eb69a56 100644 --- a/src/evdev-tablet.c +++ b/src/evdev-tablet.c @@ -513,7 +513,7 @@ tablet_check_notify_axes(struct tablet_dispatch *tablet, tablet_notify_proximity(&device->base, time, tool, - LIBINPUT_TABLET_TOOL_PROXIMITY_IN, + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN, tablet->changed_axes, axes); } else { @@ -1230,7 +1230,7 @@ tablet_flush(struct tablet_dispatch *tablet, tablet_notify_proximity(&device->base, time, tool, - LIBINPUT_TABLET_TOOL_PROXIMITY_OUT, + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT, tablet->changed_axes, tablet->axes); diff --git a/src/libinput.c b/src/libinput.c index 3a10df43..d73637a8 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -2170,7 +2170,7 @@ tablet_notify_axis(struct libinput_device *device, *axis_event = (struct libinput_event_tablet_tool) { .time = time, .tool = tool, - .proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_IN, + .proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN, .tip_state = tip_state, .wheel_discrete = wheel_discrete, }; @@ -2238,7 +2238,7 @@ tablet_notify_tip(struct libinput_device *device, .time = time, .tool = tool, .tip_state = tip_state, - .proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_IN, + .proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN, }; memcpy(tip_event->axes, axes, @@ -2276,7 +2276,7 @@ tablet_notify_button(struct libinput_device *device, .button = button, .state = state, .seat_button_count = seat_button_count, - .proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_IN, + .proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN, .tip_state = tip_state, }; memcpy(button_event->axes, axes, sizeof(button_event->axes)); diff --git a/src/libinput.h b/src/libinput.h index e29b01a6..9848d59e 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -197,8 +197,8 @@ enum libinput_tablet_tool_type { * distance (a few cm) off the surface. */ enum libinput_tablet_tool_proximity_state { - LIBINPUT_TABLET_TOOL_PROXIMITY_OUT = 0, - LIBINPUT_TABLET_TOOL_PROXIMITY_IN = 1, + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT = 0, + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN = 1, }; /** @@ -284,9 +284,9 @@ enum libinput_event_type { * with @ref LIBINPUT_EVENT_TABLET_TOOL_AXIS events. * * Some tools may always be in proximity. For these tools, events of - * type @ref LIBINPUT_TABLET_TOOL_PROXIMITY_IN are sent only once after @ref + * type @ref LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN are sent only once after @ref * LIBINPUT_EVENT_DEVICE_ADDED, and events of type @ref - * LIBINPUT_TABLET_TOOL_PROXIMITY_OUT are sent only once before @ref + * LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT are sent only once before @ref * LIBINPUT_EVENT_DEVICE_REMOVED. * * If the tool that comes into proximity supports x/y coordinates, diff --git a/test/tablet.c b/test/tablet.c index 3c509e77..6c5d625c 100644 --- a/test/tablet.c +++ b/test/tablet.c @@ -100,7 +100,7 @@ START_TEST(tip_down_prox_in) tablet_event = litest_is_tablet_event(event, LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY); ck_assert_int_eq(libinput_event_tablet_tool_get_proximity_state(tablet_event), - LIBINPUT_TABLET_TOOL_PROXIMITY_IN); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN); libinput_event_destroy(event); libinput_dispatch(li); @@ -150,7 +150,7 @@ START_TEST(tip_up_prox_out) tablet_event = litest_is_tablet_event(event, LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY); ck_assert_int_eq(libinput_event_tablet_tool_get_proximity_state(tablet_event), - LIBINPUT_TABLET_TOOL_PROXIMITY_OUT); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT); libinput_event_destroy(event); litest_assert_empty_queue(li); @@ -601,7 +601,7 @@ START_TEST(proximity_in_out) libinput_event_get_tablet_tool_event(event); if (libinput_event_tablet_tool_get_proximity_state(t) == - LIBINPUT_TABLET_TOOL_PROXIMITY_OUT) + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) have_proximity_out = true; } @@ -641,7 +641,7 @@ START_TEST(proximity_in_button_down) libinput_dispatch(li); litest_assert_tablet_proximity_event(li, - LIBINPUT_TABLET_TOOL_PROXIMITY_IN); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN); litest_assert_tablet_button_event(li, BTN_STYLUS, LIBINPUT_BUTTON_STATE_PRESSED); @@ -674,7 +674,7 @@ START_TEST(proximity_out_button_up) BTN_STYLUS, LIBINPUT_BUTTON_STATE_RELEASED); litest_assert_tablet_proximity_event(li, - LIBINPUT_TABLET_TOOL_PROXIMITY_OUT); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT); litest_assert_empty_queue(li); } END_TEST @@ -892,13 +892,13 @@ START_TEST(proximity_range_enter) libinput_dispatch(li); litest_assert_tablet_proximity_event(li, - LIBINPUT_TABLET_TOOL_PROXIMITY_IN); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN); litest_axis_set_value(axes, ABS_DISTANCE, 90); litest_tablet_motion(dev, 10, 10, axes); libinput_dispatch(li); litest_assert_tablet_proximity_event(li, - LIBINPUT_TABLET_TOOL_PROXIMITY_OUT); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT); litest_tablet_proximity_out(dev); litest_assert_empty_queue(li); @@ -927,13 +927,13 @@ START_TEST(proximity_range_in_out) litest_pop_event_frame(dev); libinput_dispatch(li); litest_assert_tablet_proximity_event(li, - LIBINPUT_TABLET_TOOL_PROXIMITY_IN); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN); litest_axis_set_value(axes, ABS_DISTANCE, 90); litest_tablet_motion(dev, 10, 10, axes); libinput_dispatch(li); litest_assert_tablet_proximity_event(li, - LIBINPUT_TABLET_TOOL_PROXIMITY_OUT); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT); litest_tablet_motion(dev, 30, 30, axes); litest_assert_empty_queue(li); @@ -942,11 +942,11 @@ START_TEST(proximity_range_in_out) litest_tablet_motion(dev, 10, 10, axes); libinput_dispatch(li); litest_assert_tablet_proximity_event(li, - LIBINPUT_TABLET_TOOL_PROXIMITY_IN); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN); litest_tablet_proximity_out(dev); litest_assert_tablet_proximity_event(li, - LIBINPUT_TABLET_TOOL_PROXIMITY_OUT); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT); litest_assert_empty_queue(li); } END_TEST @@ -1022,7 +1022,7 @@ START_TEST(proximity_range_button_press) BTN_STYLUS, LIBINPUT_BUTTON_STATE_RELEASED); litest_assert_tablet_proximity_event(li, - LIBINPUT_TABLET_TOOL_PROXIMITY_OUT); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT); litest_event(dev, EV_KEY, BTN_STYLUS, 0); litest_event(dev, EV_SYN, SYN_REPORT, 0); @@ -1062,7 +1062,7 @@ START_TEST(proximity_range_button_release) libinput_dispatch(li); litest_assert_tablet_proximity_event(li, - LIBINPUT_TABLET_TOOL_PROXIMITY_IN); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN); /* expect fake button press */ litest_assert_tablet_button_event(li, BTN_STYLUS, @@ -1078,7 +1078,7 @@ START_TEST(proximity_range_button_release) litest_tablet_proximity_out(dev); litest_assert_tablet_proximity_event(li, - LIBINPUT_TABLET_TOOL_PROXIMITY_OUT); + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT); } END_TEST diff --git a/tools/event-debug.c b/tools/event-debug.c index ddebc136..48f6e948 100644 --- a/tools/event-debug.c +++ b/tools/event-debug.c @@ -449,10 +449,10 @@ print_proximity_event(struct libinput_event *ev) print_event_time(libinput_event_tablet_tool_get_time(t)); - if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_IN) { + if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN) { print_tablet_axes(t); state_str = "proximity-in"; - } else if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_OUT) { + } else if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) { state_str = "proximity-out"; printf("\t"); } else { diff --git a/tools/event-gui.c b/tools/event-gui.c index 64a84da1..a2691d9e 100644 --- a/tools/event-gui.c +++ b/tools/event-gui.c @@ -605,7 +605,7 @@ handle_event_tablet(struct libinput_event *ev, struct window *w) switch (libinput_event_get_type(ev)) { case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY: if (libinput_event_tablet_tool_get_proximity_state(t) == - LIBINPUT_TABLET_TOOL_PROXIMITY_OUT) { + LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_OUT) { w->tool.x_in = 0; w->tool.y_in = 0; w->tool.x_down = 0;