From f71f7ba78333d3ff520330353d31ab7d1b226ed8 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 27 Oct 2015 08:13:14 -0700 Subject: [PATCH] Make executing synthesized pinch zoom more similar to zoom Synthesized pinch zoom was removed in #8121 so that this combination of mouse wheel and key press can be handled by the page. I mistakenly re-implemented it #8215. In order to preserve synthesized pinch zoom, which is very useful for testing on desktop computers, have it work similarly to page zoom except with the ALT key pressed. --- ports/glutin/window.rs | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/ports/glutin/window.rs b/ports/glutin/window.rs index af8cf8a242b..1ff972f9b64 100644 --- a/ports/glutin/window.rs +++ b/ports/glutin/window.rs @@ -204,17 +204,7 @@ impl Window { MouseScrollDelta::LineDelta(dx, dy) => (dx, dy * LINE_HEIGHT), MouseScrollDelta::PixelDelta(dx, dy) => (dx, dy), }; - - if !self.key_modifiers.get().intersects(LEFT_CONTROL | RIGHT_CONTROL) { - self.scroll_window(dx, dy); - } else { - let factor = if dy > 0. { - 1.1 - } else { - 1.0 / 1.1 - }; - self.pinch_zoom(factor); - } + self.scroll_window(dx, dy); }, Event::Refresh => { self.event_queue.borrow_mut().push(WindowEvent::Refresh); @@ -234,10 +224,6 @@ impl Window { self.key_modifiers.set(modifiers); } - fn pinch_zoom(&self, factor: f32) { - self.event_queue.borrow_mut().push(WindowEvent::PinchZoom(factor)); - } - /// Helper function to send a scroll event. fn scroll_window(&self, dx: f32, dy: f32) { let mouse_pos = self.mouse_pos.get(); @@ -646,12 +632,19 @@ impl WindowMethods for Window { fn handle_key(&self, key: Key, mods: constellation_msg::KeyModifiers) { match (mods, key) { - (_, Key::Equal) if mods & !SHIFT == CMD_OR_CONTROL => { - self.event_queue.borrow_mut().push(WindowEvent::Zoom(1.1)); + (_, Key::Equal) => { + if mods & !SHIFT == CMD_OR_CONTROL { + self.event_queue.borrow_mut().push(WindowEvent::Zoom(1.1)); + } else if mods & !SHIFT == CMD_OR_CONTROL | ALT { + self.event_queue.borrow_mut().push(WindowEvent::PinchZoom(1.1)); + } } (CMD_OR_CONTROL, Key::Minus) => { self.event_queue.borrow_mut().push(WindowEvent::Zoom(1.0 / 1.1)); } + (_, Key::Minus) if mods == CMD_OR_CONTROL | ALT => { + self.event_queue.borrow_mut().push(WindowEvent::PinchZoom(1.0 / 1.1)); + } (CMD_OR_CONTROL, Key::Num0) | (CMD_OR_CONTROL, Key::Kp0) => { self.event_queue.borrow_mut().push(WindowEvent::ResetZoom);