From e60f02c3bacf66cd986012212c3028e888fa065b Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Thu, 22 Oct 2015 09:08:01 +0200 Subject: [PATCH] Remove zoom-on-ctrl-scroll and make quit-on-escape preventable --- ports/glutin/window.rs | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index 9b851384141..781fdc7643b 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -170,7 +170,6 @@ impl Window { (_, VirtualKeyCode::RAlt) => self.toggle_modifier(RIGHT_ALT), (_, VirtualKeyCode::LWin) => self.toggle_modifier(LEFT_SUPER), (_, VirtualKeyCode::RWin) => self.toggle_modifier(RIGHT_SUPER), - (ElementState::Pressed, VirtualKeyCode::Escape) => return true, (_, key_code) => { match Window::glutin_key_to_script_key(key_code) { Ok(key) => { @@ -203,24 +202,11 @@ impl Window { WindowEvent::MouseWindowMoveEventClass(Point2D::typed(x as f32, y as f32))); } Event::MouseWheel(delta) => { - if self.ctrl_pressed() { - // Ctrl-Scrollwheel simulates a "pinch zoom" gesture. - let dy = match delta { - MouseScrollDelta::LineDelta(_, dy) => dy, - MouseScrollDelta::PixelDelta(_, dy) => dy - }; - if dy < 0.0 { - self.event_queue.borrow_mut().push(WindowEvent::PinchZoom(1.0 / 1.1)); - } else if dy > 0.0 { - self.event_queue.borrow_mut().push(WindowEvent::PinchZoom(1.1)); - } - } else { - match delta { - MouseScrollDelta::LineDelta(dx, dy) => { - self.scroll_window(dx, dy * LINE_HEIGHT); - } - MouseScrollDelta::PixelDelta(dx, dy) => self.scroll_window(dx, dy) + match delta { + MouseScrollDelta::LineDelta(dx, dy) => { + self.scroll_window(dx, dy * LINE_HEIGHT); } + MouseScrollDelta::PixelDelta(dx, dy) => self.scroll_window(dx, dy) } }, Event::Refresh => { @@ -235,11 +221,6 @@ impl Window { false } - #[inline] - fn ctrl_pressed(&self) -> bool { - self.key_modifiers.get().intersects(LEFT_CONTROL | RIGHT_CONTROL) - } - fn toggle_modifier(&self, modifier: KeyModifiers) { let mut modifiers = self.key_modifiers.get(); modifiers.toggle(modifier); @@ -672,6 +653,10 @@ impl WindowMethods for Window { self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Back)); } + (NONE, Key::Escape) => { + self.event_queue.borrow_mut().push(WindowEvent::Quit); + } + (CMD_OR_ALT, Key::Right) => { self.event_queue.borrow_mut().push(WindowEvent::Navigation(WindowNavigateMsg::Forward)); }