From d989852fdd74f9488211dfb5c2c84c9478b13ad7 Mon Sep 17 00:00:00 2001 From: Martin Robinson Date: Tue, 3 Nov 2015 18:53:38 +0501 Subject: [PATCH] servo: Merge #8223 - Make executing synthesized pinch zoom more similar to zoom (from mrobinson:pinch-zoom-2); r=pcwalton 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. Source-Repo: https://github.com/servo/servo Source-Revision: 526a3c8df3882c83a0512dbb341cf7f1781ac402 --- servo/ports/glutin/window.rs | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/servo/ports/glutin/window.rs b/servo/ports/glutin/window.rs index af8cf8a242be..1ff972f9b643 100644 --- a/servo/ports/glutin/window.rs +++ b/servo/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);