mirror of
https://github.com/servo/servo.git
synced 2025-09-07 13:38:20 +01:00
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.
This commit is contained in:
parent
484c0e4546
commit
f71f7ba783
1 changed files with 10 additions and 17 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue