Auto merge of #22333 - asajeffrey:magicleap-mouse-pos-while-scrolling, r=jdm

Generate mouse move events as well as scroll events while scrolling

<!-- Please describe your changes on the following line: -->

Generate mouse move events as well as scroll events while scrolling. This is needed for sites which have their own semantics for moving the mouse with the button down.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because it's UI changes

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22333)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2018-11-30 15:44:26 -05:00 committed by GitHub
commit 2e37eb6ee9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -200,10 +200,10 @@ pub unsafe extern "C" fn move_servo(servo: *mut ServoInstance, x: f32, y: f32) {
// Servo's cursor was moved
if let Some(servo) = servo.as_mut() {
let point = DevicePoint::new(x, y);
let (new_state, window_event) = match servo.scroll_state {
let (new_state, window_events) = match servo.scroll_state {
ScrollState::TriggerUp => (
ScrollState::TriggerUp,
WindowEvent::MouseWindowMoveEventClass(point),
vec![WindowEvent::MouseWindowMoveEventClass(point)],
),
ScrollState::TriggerDown(start)
if (start - point).square_length() < DRAG_CUTOFF_SQUARED =>
@ -212,23 +212,29 @@ pub unsafe extern "C" fn move_servo(servo: *mut ServoInstance, x: f32, y: f32) {
},
ScrollState::TriggerDown(start) => (
ScrollState::TriggerDragging(start, point),
vec![
WindowEvent::MouseWindowMoveEventClass(point),
WindowEvent::Scroll(
ScrollLocation::Delta((point - start) * servo.scroll_scale),
start.to_i32(),
TouchEventType::Down,
),
],
),
ScrollState::TriggerDragging(start, prev) => (
ScrollState::TriggerDragging(start, point),
vec![
WindowEvent::MouseWindowMoveEventClass(point),
WindowEvent::Scroll(
ScrollLocation::Delta((point - prev) * servo.scroll_scale),
start.to_i32(),
TouchEventType::Move,
),
],
),
};
servo.scroll_state = new_state;
servo.servo.handle_events(vec![window_event]);
servo.servo.handle_events(window_events);
}
}