Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21a46533 authored by Harry Cutts's avatar Harry Cutts
Browse files

InputVerifier: put parameters into a struct

This makes it clearer which parameter is which when calling, and also
allows us to make the tests much more succinct by using struct update
syntax.

Bug: 245989146
Test: $ atest --host libinput_rust_test
Flag: EXEMPT refactor
Change-Id: If68332d652186b7283435cbc41af78bf12aa5b94
parent 26640c99
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ pub enum SourceClass {

bitflags! {
    /// Source of the input device or input events.
    #[derive(Debug, PartialEq)]
    #[derive(Clone, Copy, Debug, PartialEq)]
    pub struct Source: u32 {
        // Constants from SourceClass, added here for compatibility reasons
        /// SourceClass::Button
@@ -219,7 +219,7 @@ bitflags! {
    /// MotionEvent flags.
    /// The source of truth for the flag definitions are the MotionEventFlag AIDL enum.
    /// The flag values are redefined here as a bitflags API.
    #[derive(Debug)]
    #[derive(Clone, Copy, Debug)]
    pub struct MotionFlags: u32 {
        /// FLAG_WINDOW_IS_OBSCURED
        const WINDOW_IS_OBSCURED = MotionEventFlag::WINDOW_IS_OBSCURED.0 as u32;
+460 −679

File changed.

Preview size limit exceeded, changes collapsed.

+8 −8
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ pub use input::{
    DeviceClass, DeviceId, InputDevice, KeyboardType, ModifierState, MotionAction, MotionButton,
    MotionFlags, Source,
};
pub use input_verifier::InputVerifier;
pub use input_verifier::{InputVerifier, NotifyMotionArgs};
pub use keyboard_classifier::KeyboardClassifier;

#[cxx::bridge(namespace = "android::input")]
@@ -155,15 +155,15 @@ fn process_movement(
             buttons need to be added to MotionButton."
        );
    }
    let result = verifier.process_movement(
        DeviceId(device_id),
        Source::from_bits(source).unwrap(),
    let result = verifier.process_movement(NotifyMotionArgs {
        device_id: DeviceId(device_id),
        source: Source::from_bits(source).unwrap(),
        action,
        motion_action_button.unwrap(),
        action_button: motion_action_button.unwrap(),
        pointer_properties,
        motion_flags.unwrap(),
        motion_button_state.unwrap(),
    );
        flags: motion_flags.unwrap(),
        button_state: motion_button_state.unwrap(),
    });
    match result {
        Ok(()) => "".to_string(),
        Err(e) => e,