зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
b21eb76306
Коммит
d989852fdd
|
@ -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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче