mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #8121 - paulrouget:disableControls, r=jdm
make it possible to disable default keybindings For browser.html, we want to let the top level webpage handle these keybindings. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8121) <!-- Reviewable:end -->
This commit is contained in:
commit
0d4641b640
1 changed files with 8 additions and 23 deletions
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue