diff options
author | Matt Brubeck <mbrubeck@limpet.net> | 2014-12-18 10:55:14 -0800 |
---|---|---|
committer | Matt Brubeck <mbrubeck@limpet.net> | 2014-12-18 10:55:14 -0800 |
commit | f534ce2ab0a809682a2fa3a31007789529129e7b (patch) | |
tree | e2bb626dd3ac206edd897fbb3d926656207fa8f5 | |
parent | 1f342638c46d6b43bca4cfbd405aceedc0465a85 (diff) | |
download | servo-f534ce2ab0a809682a2fa3a31007789529129e7b.tar.gz servo-f534ce2ab0a809682a2fa3a31007789529129e7b.zip |
Code cleanup in glfw_app::Window::scroll_window
More code re-use, fewer unchecked units.
-rw-r--r-- | ports/glfw/window.rs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/ports/glfw/window.rs b/ports/glfw/window.rs index 377bb2839b6..a31ba820875 100644 --- a/ports/glfw/window.rs +++ b/ports/glfw/window.rs @@ -322,16 +322,8 @@ impl Window { /// Helper function to send a scroll event. fn scroll_window(&self, dx: f32, dy: f32) { - let (x, y) = self.glfw_window.get_cursor_pos(); - //handle hidpi displays, since GLFW returns non-hi-def coordinates. - let (backing_size, _) = self.glfw_window.get_framebuffer_size(); - let (window_size, _) = self.glfw_window.get_size(); - let hidpi = (backing_size as f32) / (window_size as f32); - let x = x as f32 * hidpi; - let y = y as f32 * hidpi; - - self.event_queue.borrow_mut().push(Scroll(TypedPoint2D(dx, dy), - TypedPoint2D(x as i32, y as i32))); + let cursor_pos = self.cursor_position().cast().unwrap(); + self.event_queue.borrow_mut().push(Scroll(TypedPoint2D(dx, dy), cursor_pos)); } /// Helper function to set the window title in accordance with the ready state. |