mirror of
https://github.com/servo/servo.git
synced 2025-07-16 03:43:38 +01:00
Auto merge of #11794 - mrmiywj:update-mouse-coordinate-when-focus, r=KiChjang
when window gains focus, update mouse coordinate <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #11130 (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [X] These changes do not require tests because these cannot be tested automated. <!-- 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="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/11794) <!-- Reviewable:end -->
This commit is contained in:
commit
d99ff8d857
1 changed files with 15 additions and 6 deletions
|
@ -260,13 +260,22 @@ impl Window {
|
|||
Event::Resized(width, height) => {
|
||||
self.event_queue.borrow_mut().push(WindowEvent::Resize(Size2D::typed(width, height)));
|
||||
}
|
||||
Event::MouseInput(element_state, mouse_button, _) => {
|
||||
// FIXME(#11130, pcwalton): The third field should be used.
|
||||
Event::MouseInput(element_state, mouse_button, pos) => {
|
||||
if mouse_button == MouseButton::Left ||
|
||||
mouse_button == MouseButton::Right {
|
||||
let mouse_pos = self.mouse_pos.get();
|
||||
self.handle_mouse(mouse_button, element_state, mouse_pos.x, mouse_pos.y);
|
||||
}
|
||||
mouse_button == MouseButton::Right {
|
||||
match pos {
|
||||
Some((x, y)) => {
|
||||
self.mouse_pos.set(Point2D::new(x, y));
|
||||
self.event_queue.borrow_mut().push(
|
||||
WindowEvent::MouseWindowMoveEventClass(Point2D::typed(x as f32, y as f32)));
|
||||
self.handle_mouse(mouse_button, element_state, x, y);
|
||||
}
|
||||
None => {
|
||||
let mouse_pos = self.mouse_pos.get();
|
||||
self.handle_mouse(mouse_button, element_state, mouse_pos.x, mouse_pos.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Event::MouseMoved(x, y) => {
|
||||
self.mouse_pos.set(Point2D::new(x, y));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue