Skip to content

Commit

Permalink
Merge pull request #2978 from MirServer/feature/2974
Browse files Browse the repository at this point in the history
(#2974) Removal of MIR_LIBINPUT_HAS_VALUE120 and now-dead code surrounding it
  • Loading branch information
AlanGriffiths authored Jul 17, 2023
2 parents c63da81 + c435b1e commit fbdeb72
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 110 deletions.
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,6 @@ set(MIR_GENERATED_INCLUDE_DIRECTORIES)
add_subdirectory(src/)
include_directories(${MIR_GENERATED_INCLUDE_DIRECTORIES})

# Used to fall back to discrete scrolling if hi-res not implemented
if ("${LIBINPUT_VERSION}" VERSION_GREATER_EQUAL "1.19")
add_compile_definitions(MIR_LIBINPUT_HAS_VALUE120)
endif ()

add_subdirectory(examples/)
add_subdirectory(guides/)
add_subdirectory(cmake/)
Expand Down
4 changes: 0 additions & 4 deletions src/platforms/evdev/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
if ("${LIBINPUT_VERSION}" VERSION_GREATER_EQUAL "1.19")
add_compile_definitions(MIR_LIBINPUT_HAS_VALUE120)
endif ()

include_directories(
${LIBINPUT_CFLAGS}
${PROJECT_SOURCE_DIR}/src/include/platform # udev Context
Expand Down
33 changes: 0 additions & 33 deletions src/platforms/evdev/libinput_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ auto get_scroll_axis(
return {};
}

#ifdef MIR_LIBINPUT_HAS_VALUE120
auto const libinput_event_type = libinput_event_get_type(libinput_event_pointer_get_base_event(event));

mir::geometry::generic::Value<float, Tag> const precise{
Expand All @@ -110,41 +109,19 @@ auto get_scroll_axis(
accumulator += value120;
mir::geometry::generic::Value<int, Tag> const discrete{accumulator / 120};
accumulator = geom::generic::Value<int, Tag>{accumulator.as_value() % 120};
#else
(void)accumulator;
mir::geometry::generic::Value<float, Tag> const precise{
libinput_event_pointer_get_axis_value(event, axis) * scale};
auto const stop = precise.as_value() == 0;
mir::geometry::generic::Value<int, Tag> const discrete{
libinput_event_pointer_get_axis_source(event) == LIBINPUT_POINTER_AXIS_SOURCE_WHEEL ?
libinput_event_pointer_get_axis_value_discrete(event, axis) :
0};
mir::geometry::generic::Value<int, Tag> const value120{discrete * 120};
#endif

return {precise, discrete, value120, stop};
}

auto get_axis_source(libinput_event_pointer* pointer) -> MirPointerAxisSource
{
#ifdef MIR_LIBINPUT_HAS_VALUE120
switch (libinput_event_get_type(libinput_event_pointer_get_base_event(pointer)))
{
case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL: return mir_pointer_axis_source_wheel;
case LIBINPUT_EVENT_POINTER_SCROLL_FINGER: return mir_pointer_axis_source_finger;
case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS: return mir_pointer_axis_source_continuous;
default: return mir_pointer_axis_source_none;
}
#else
switch (libinput_event_pointer_get_axis_source(pointer))
{
case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL: return mir_pointer_axis_source_wheel;
case LIBINPUT_POINTER_AXIS_SOURCE_FINGER: return mir_pointer_axis_source_finger;
case LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS: return mir_pointer_axis_source_continuous;
case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL_TILT: return mir_pointer_axis_source_wheel_tilt;
default: return mir_pointer_axis_source_none;
}
#endif
}
}

Expand Down Expand Up @@ -220,19 +197,9 @@ void mie::LibInputDevice::process_event(libinput_event* event)
case LIBINPUT_EVENT_POINTER_BUTTON:
sink->handle_input(convert_button_event(libinput_event_get_pointer_event(event)));
break;
#ifdef MIR_LIBINPUT_HAS_VALUE120
case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL:
case LIBINPUT_EVENT_POINTER_SCROLL_FINGER:
case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS:
#else
/*
* This event is deprecated as of libinput 1.19. Use
* @ref LIBINPUT_EVENT_POINTER_SCROLL_WHEEL,
* @ref LIBINPUT_EVENT_POINTER_SCROLL_FINGER, and
* @ref LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS instead.
*/
case LIBINPUT_EVENT_POINTER_AXIS:
#endif
sink->handle_input(convert_axis_event(libinput_event_get_pointer_event(event)));
break;
// touch events are processed as a batch of changes over all touch pointts
Expand Down
59 changes: 0 additions & 59 deletions tests/mir_test_doubles/mock_libinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ double libinput_event_pointer_get_axis_value_discrete(libinput_event_pointer* ev
return global_libinput->libinput_event_pointer_get_axis_value_discrete(event, axis);
}

#ifdef MIR_LIBINPUT_HAS_VALUE120
double libinput_event_pointer_get_scroll_value_v120(libinput_event_pointer* event, libinput_pointer_axis axis)
{
return global_libinput->libinput_event_pointer_get_scroll_value_v120(event, axis);
Expand All @@ -243,12 +242,6 @@ double libinput_event_pointer_get_scroll_value(libinput_event_pointer* event, li
{
return global_libinput->libinput_event_pointer_get_scroll_value(event, axis);
}
#else
double libinput_event_pointer_get_scroll_value_v120(libinput_event_pointer* event, libinput_pointer_axis axis)
{
return global_libinput->libinput_event_pointer_get_axis_value_discrete(event, axis) * 120;
}
#endif

libinput_event* libinput_event_pointer_get_base_event(libinput_event_pointer* event)
{
Expand Down Expand Up @@ -823,38 +816,8 @@ libinput_event* mtd::MockLibInput::setup_axis_event(
std::optional<double> horizontal, std::optional<double> vertical,
double horizontal_discrete, double vertical_discrete)
{
#ifdef MIR_LIBINPUT_HAS_VALUE120
return setup_pointer_scroll_wheel_event(dev, event_time, horizontal, vertical,
120*horizontal_discrete, 120*vertical_discrete);
#else
auto event = get_next_fake_ptr<libinput_event*>();
auto pointer_event = reinterpret_cast<libinput_event_pointer*>(event);
push_back(event);

ON_CALL(*this, libinput_event_get_type(event))
.WillByDefault(Return(LIBINPUT_EVENT_POINTER_AXIS));
ON_CALL(*this, libinput_event_get_pointer_event(event))
.WillByDefault(Return(pointer_event));
ON_CALL(*this, libinput_event_get_device(event))
.WillByDefault(Return(dev));
ON_CALL(*this, libinput_event_pointer_get_time_usec(pointer_event))
.WillByDefault(Return(event_time));
ON_CALL(*this, libinput_event_pointer_get_axis_source(pointer_event))
.WillByDefault(Return(LIBINPUT_POINTER_AXIS_SOURCE_WHEEL));
ON_CALL(*this, libinput_event_pointer_has_axis(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
.WillByDefault(Return(horizontal.operator bool()));
ON_CALL(*this, libinput_event_pointer_has_axis(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
.WillByDefault(Return(vertical.operator bool()));
ON_CALL(*this, libinput_event_pointer_get_axis_value_discrete(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
.WillByDefault(Return(vertical_discrete));
ON_CALL(*this, libinput_event_pointer_get_axis_value_discrete(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
.WillByDefault(Return(horizontal_discrete));
ON_CALL(*this, libinput_event_pointer_get_axis_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
.WillByDefault(Return(vertical.value_or(0.0)));
ON_CALL(*this, libinput_event_pointer_get_axis_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
.WillByDefault(Return(horizontal.value_or(0.0)));
return event;
#endif
}

libinput_event* mtd::MockLibInput::setup_pointer_scroll_wheel_event(
Expand All @@ -866,7 +829,6 @@ libinput_event* mtd::MockLibInput::setup_pointer_scroll_wheel_event(
auto pointer_event = reinterpret_cast<libinput_event_pointer*>(event);
push_back(event);

#ifdef MIR_LIBINPUT_HAS_VALUE120
ON_CALL(*this, libinput_event_get_type(event))
.WillByDefault(Return(LIBINPUT_EVENT_POINTER_SCROLL_WHEEL));
ON_CALL(*this, libinput_event_pointer_get_scroll_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
Expand All @@ -893,18 +855,6 @@ libinput_event* mtd::MockLibInput::setup_pointer_scroll_wheel_event(
BOOST_THROW_EXCEPTION((
std::logic_error{"axis_value_discrete only returns a non-zero value on EVENT_POINTER_AXIS events"}));
}));
#else
ON_CALL(*this, libinput_event_get_type(event))
.WillByDefault(Return(LIBINPUT_EVENT_POINTER_AXIS));
ON_CALL(*this, libinput_event_pointer_get_axis_value_discrete(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
.WillByDefault(Return(vertical_value120/120));
ON_CALL(*this, libinput_event_pointer_get_axis_value_discrete(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
.WillByDefault(Return(horizontal_value120/120));
ON_CALL(*this, libinput_event_pointer_get_axis_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
.WillByDefault(Return(vertical.value_or(0.0)));
ON_CALL(*this, libinput_event_pointer_get_axis_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
.WillByDefault(Return(horizontal.value_or(0.0)));
#endif
ON_CALL(*this, libinput_event_get_pointer_event(event))
.WillByDefault(Return(pointer_event));
ON_CALL(*this, libinput_event_get_device(event))
Expand All @@ -931,7 +881,6 @@ libinput_event* mtd::MockLibInput::setup_finger_axis_event(
auto event = get_next_fake_ptr<libinput_event*>();
auto pointer_event = reinterpret_cast<libinput_event_pointer*>(event);
push_back(event);
#ifdef MIR_LIBINPUT_HAS_VALUE120
ON_CALL(*this, libinput_event_get_type(event))
.WillByDefault(Return(LIBINPUT_EVENT_POINTER_SCROLL_FINGER));
ON_CALL(*this, libinput_event_pointer_get_scroll_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
Expand All @@ -942,14 +891,6 @@ libinput_event* mtd::MockLibInput::setup_finger_axis_event(
.WillByDefault(Return(0));
ON_CALL(*this, libinput_event_pointer_get_scroll_value_v120(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
.WillByDefault(Return(0));
#else
ON_CALL(*this, libinput_event_get_type(event))
.WillByDefault(Return(LIBINPUT_EVENT_POINTER_AXIS));
ON_CALL(*this, libinput_event_pointer_get_axis_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))
.WillByDefault(Return(vertical.value_or(0.0)));
ON_CALL(*this, libinput_event_pointer_get_axis_value(pointer_event, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))
.WillByDefault(Return(horizontal.value_or(0.0)));
#endif
ON_CALL(*this, libinput_event_get_device(event))
.WillByDefault(Return(dev));
ON_CALL(*this, libinput_event_get_pointer_event(event))
Expand Down
9 changes: 0 additions & 9 deletions tests/unit-tests/input/evdev/test_libinput_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,13 +604,8 @@ TEST_F(LibInputDeviceOnMouse, process_event_handles_scroll)

TEST_F(LibInputDeviceOnMouse, hi_res_scroll_is_picked_up)
{
#ifdef MIR_LIBINPUT_HAS_VALUE120
auto const expected_v120 = 165;
auto const expected_discrete = 1;
#else
auto const expected_v120 = 120;
auto const expected_discrete = 1;
#endif

EXPECT_CALL(mock_builder, pointer_event(
{time_stamp_1}, mir_pointer_action_motion, 0,
Expand Down Expand Up @@ -655,7 +650,6 @@ TEST_F(LibInputDeviceOnMouse, hi_res_scroll_scroll_can_be_negative)
process_events(mouse);
}

#ifdef MIR_LIBINPUT_HAS_VALUE120
TEST_F(LibInputDeviceOnMouse, hi_res_scroll_scroll_is_accumulated)
{
mouse.start(&mock_sink, &mock_builder);
Expand Down Expand Up @@ -684,9 +678,7 @@ TEST_F(LibInputDeviceOnMouse, hi_res_scroll_scroll_is_accumulated)
env.mock_libinput.setup_pointer_scroll_wheel_event(fake_device, event_time_3, {}, 1.0f, 0.0f, 50.0f);
process_events(mouse);
}
#endif

#ifdef MIR_LIBINPUT_HAS_VALUE120
TEST_F(LibInputDeviceOnMouse, hi_res_scroll_scroll_is_accumulated_negative)
{
mouse.start(&mock_sink, &mock_builder);
Expand All @@ -706,7 +698,6 @@ TEST_F(LibInputDeviceOnMouse, hi_res_scroll_scroll_is_accumulated_negative)
env.mock_libinput.setup_pointer_scroll_wheel_event(fake_device, event_time_2, {}, -1.0f, 0.0f, -10.0f);
process_events(mouse);
}
#endif

TEST_F(LibInputDeviceOnTouchScreen, process_event_ignores_uncorrelated_touch_up_events)
{
Expand Down

0 comments on commit fbdeb72

Please sign in to comment.