Skip to content
Permalink
Browse files

when window gains focus, update mouse coordinate

  • Loading branch information...
mrmiywj committed Jun 19, 2016
1 parent 87c7772 commit 6bcca8ebc5a30cfe46694120401f8f0abc8544f8
Showing with 15 additions and 6 deletions.
  1. +15 −6 ports/glutin/window.rs
@@ -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));

0 comments on commit 6bcca8e

Please sign in to comment.
You can’t perform that action at this time.