diff --git a/mk/sub.mk b/mk/sub.mk index 80bcb003826..b01f34329e8 100644 --- a/mk/sub.mk +++ b/mk/sub.mk @@ -42,6 +42,7 @@ DEPS_rust-glut += \ DEPS_rust-layers += \ rust-azure \ + rust-cocoa \ rust-geom \ rust-glut \ rust-opengles \ @@ -130,6 +131,10 @@ DEPS_rust-layers += \ rust-core-text \ $(NULL) +DEPS_rust-glut += \ + rust-cocoa \ + $(NULL) + endif ifeq ($(CFG_OSTYPE),unknown-linux-gnu) diff --git a/src/components/main/platform/common/glut_windowing.rs b/src/components/main/platform/common/glut_windowing.rs index 613064f2110..07a2f3bf9c2 100644 --- a/src/components/main/platform/common/glut_windowing.rs +++ b/src/components/main/platform/common/glut_windowing.rs @@ -16,6 +16,7 @@ use geom::point::Point2D; use geom::size::Size2D; use glut::glut::{DOUBLE, WindowHeight, WindowWidth}; use glut::glut; +use glut::machack; /// A structure responsible for setting up and tearing down the entire windowing system. pub struct Application; @@ -78,14 +79,16 @@ impl WindowMethods for Window { do glut::keyboard_func |key, _, _| { window.handle_key(key) } - do glut::mouse_func |_, _, x, y| { - window.handle_click(x, y); - window.start_drag(x, y) - } - do glut::motion_func |x, y| { - window.continue_drag(x, y) + do glut::mouse_func |button, _, x, y| { + if button < 3 { + window.handle_click(x, y); + } else { + window.handle_scroll(if button == 4 { -30.0 } else { 30.0 }); + } } + machack::perform_scroll_wheel_hack(); + window } @@ -152,20 +155,11 @@ impl Window { } } - /// Helper function to start a drag. - fn start_drag(&mut self, x: c_int, y: c_int) { - self.drag_origin = Point2D(x, y) - } - - /// Helper function to continue a drag. - fn continue_drag(&mut self, x: c_int, y: c_int) { - let new_point = Point2D(x, y); - let delta = new_point - self.drag_origin; - self.drag_origin = new_point; - + /// Helper function to handle a scroll. + fn handle_scroll(&mut self, delta: f32) { match self.scroll_callback { None => {} - Some(callback) => callback(Point2D(delta.x as f32, delta.y as f32)), + Some(callback) => callback(Point2D(0.0, delta)), } } diff --git a/src/platform/macos/rust-cocoa b/src/platform/macos/rust-cocoa index 61c99b4b1aa..ff8e2a63938 160000 --- a/src/platform/macos/rust-cocoa +++ b/src/platform/macos/rust-cocoa @@ -1 +1 @@ -Subproject commit 61c99b4b1aa8653b8ee8511b6c15099de441ac44 +Subproject commit ff8e2a63938ded5d2688619680a981c73d25080d diff --git a/src/support/glut/rust-glut b/src/support/glut/rust-glut index eb35e395783..969af0260ef 160000 --- a/src/support/glut/rust-glut +++ b/src/support/glut/rust-glut @@ -1 +1 @@ -Subproject commit eb35e3957834264e99f42274f9c5c442e747ed3b +Subproject commit 969af0260ef38d2c80ef2f51037da7ed1fc5cc85