Repository: alacritty/alacritty
File: alacritty/src/input.rs (Rust)

Code before:
                *touch_purpose = Touch::Scroll(touch);

                self.scroll_terminal(0., delta_y * TOUCH_SCROLL_FACTOR);
            },
            Touch::Select(_) => self.mouse_moved(touch.location),
            Touch::Invalid(_) => (),
        }
    }

    /// Handle end of touch input.
    pub fn on_touch_end(&mut self, touch: TouchEvent) {
        // Finalize the touch motion up to the release point.
        self.on_touch_motion(touch);

        let touch_purpose = self.ctx.touch();
        match touch_purpose {
            // Simulate LMB clicks.
            Touch::Tap(start) => {
                let start_location = start.location;
                *touch_purpose = Default::default();

                self.mouse_moved(start_location);
                self.mouse_input(ElementState::Pressed, MouseButton::Left);
                self.mouse_input(ElementState::Released, MouseButton::Left);
            },
            // Invalidate zoom once a finger was released.
            Touch::Zoom(zoom) => {
                let mut slots = zoom.slots();
                slots.remove(&touch.id);
                *touch_purpose = Touch::Invalid(slots);
            },
            // Reset touch state once all slots were released.
            Touch::Invalid(slots) => {
                slots.remove(&touch.id);
                if slots.is_empty() {
                    *touch_purpose = Default::default();
                }
            },
            // Release simulated LMB.
            Touch::Select(_) => {
                *touch_purpose = Default::default();
                self.mouse_input(ElementState::Released, MouseButton::Left);
            },
            // Reset touch state on scroll finish.
            Touch::Scroll(_) => *touch_purpose = Default::default(),
            Touch::None => (),
        }
    }

    pub fn mouse_input(&mut self, state: ElementState, button: MouseButton) {
        match button {

Review comment (suggestion):
That should consider slots, otherwise you can 3-ple click with 3 fingers? So the tap should be counted from first/last insert or maybe when there's only a single finger at a time.

Code after:
                // Calculate delta and update last touch position.
                let delta_y = touch.location.y - last_touch.location.y;
                *touch_purpose = TouchPurpose::Scroll(touch);

                self.scroll_terminal(0., delta_y * TOUCH_SCROLL_FACTOR);
            },
            TouchPurpose::Select(_) => self.mouse_moved(touch.location),
            TouchPurpose::Invalid(_) => (),
        }
    }

    /// Handle end of touch input.
    pub fn on_touch_end(&mut self, touch: TouchEvent) {
        // Finalize the touch motion up to the release point.
        self.on_touch_motion(touch);

        let touch_purpose = self.ctx.touch_purpose();
        match touch_purpose {
            // Simulate LMB clicks.
            TouchPurpose::Tap(start) => {
                let start_location = start.location;
                *touch_purpose = Default::default();

                self.mouse_moved(start_location);
                self.mouse_input(ElementState::Pressed, MouseButton::Left);
                self.mouse_input(ElementState::Released, MouseButton::Left);
            },
            // Invalidate zoom once a finger was released.
            TouchPurpose::Zoom(zoom) => {
                let mut slots = zoom.slots();
                slots.remove(&touch.id);
                *touch_purpose = TouchPurpose::Invalid(slots);
            },
            // Reset touch state once all slots were released.
            TouchPurpose::Invalid(slots) => {
                slots.remove(&touch.id);
                if slots.is_empty() {
                    *touch_purpose = Default::default();
                }
            },
            // Release simulated LMB.
            TouchPurpose::Select(_) => {
                *touch_purpose = Default::default();
                self.mouse_input(ElementState::Released, MouseButton::Left);
            },
            // Reset touch state on scroll finish.
            TouchPurpose::Scroll(_) => *touch_purpose = Default::default(),
            TouchPurpose::None => (),
        }
    }