From c435b1e409142d100c8420231125d563b006e6d5 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Fri, 14 Jul 2023 09:37:39 -0400 Subject: [PATCH] (#2974) Removal of MIR_LIBINPUT_HAS_VALUE120 and now-dead code surrounding it --- CMakeLists.txt | 5 -- src/platforms/evdev/CMakeLists.txt | 4 -- src/platforms/evdev/libinput_device.cpp | 33 ----------- tests/mir_test_doubles/mock_libinput.cpp | 59 ------------------- .../input/evdev/test_libinput_device.cpp | 9 --- 5 files changed, 110 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af92e2590c7..778d1081170 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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/) diff --git a/src/platforms/evdev/CMakeLists.txt b/src/platforms/evdev/CMakeLists.txt index 8cbbb5e101a..9a7f2efc94a 100644 --- a/src/platforms/evdev/CMakeLists.txt +++ b/src/platforms/evdev/CMakeLists.txt @@ -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 diff --git a/src/platforms/evdev/libinput_device.cpp b/src/platforms/evdev/libinput_device.cpp index f5ec7fce003..bb537ac9fc9 100644 --- a/src/platforms/evdev/libinput_device.cpp +++ b/src/platforms/evdev/libinput_device.cpp @@ -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 const precise{ @@ -110,24 +109,12 @@ auto get_scroll_axis( accumulator += value120; mir::geometry::generic::Value const discrete{accumulator / 120}; accumulator = geom::generic::Value{accumulator.as_value() % 120}; -#else - (void)accumulator; - mir::geometry::generic::Value const precise{ - libinput_event_pointer_get_axis_value(event, axis) * scale}; - auto const stop = precise.as_value() == 0; - mir::geometry::generic::Value 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 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; @@ -135,16 +122,6 @@ auto get_axis_source(libinput_event_pointer* pointer) -> MirPointerAxisSource 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 } } @@ -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 diff --git a/tests/mir_test_doubles/mock_libinput.cpp b/tests/mir_test_doubles/mock_libinput.cpp index 8087c9f6c69..c7970659f71 100644 --- a/tests/mir_test_doubles/mock_libinput.cpp +++ b/tests/mir_test_doubles/mock_libinput.cpp @@ -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); @@ -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) { @@ -823,38 +816,8 @@ libinput_event* mtd::MockLibInput::setup_axis_event( std::optional horizontal, std::optional 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(); - auto pointer_event = reinterpret_cast(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( @@ -866,7 +829,6 @@ libinput_event* mtd::MockLibInput::setup_pointer_scroll_wheel_event( auto pointer_event = reinterpret_cast(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)) @@ -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)) @@ -931,7 +881,6 @@ libinput_event* mtd::MockLibInput::setup_finger_axis_event( auto event = get_next_fake_ptr(); auto pointer_event = reinterpret_cast(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)) @@ -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)) diff --git a/tests/unit-tests/input/evdev/test_libinput_device.cpp b/tests/unit-tests/input/evdev/test_libinput_device.cpp index 9001a94b6e8..9ea37847615 100644 --- a/tests/unit-tests/input/evdev/test_libinput_device.cpp +++ b/tests/unit-tests/input/evdev/test_libinput_device.cpp @@ -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, @@ -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); @@ -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); @@ -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) {