mirror of
https://github.com/servo/servo.git
synced 2025-07-19 05:13:55 +01:00
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:
commit
2e37eb6ee9
1 changed files with 19 additions and 13 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue