mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Add keyboard shortcuts to glutin browser
This commit is contained in:
parent
8892f8175d
commit
1ff4fe02d9
4 changed files with 90 additions and 15 deletions
|
@ -851,6 +851,10 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
self.on_zoom_window_event(magnification);
|
||||
}
|
||||
|
||||
WindowEvent::ResetZoom => {
|
||||
self.on_zoom_reset_window_event();
|
||||
}
|
||||
|
||||
WindowEvent::PinchZoom(magnification) => {
|
||||
self.on_pinch_zoom_window_event(magnification);
|
||||
}
|
||||
|
@ -1066,6 +1070,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
self.scene.set_root_layer_size(self.window_size.as_f32());
|
||||
}
|
||||
|
||||
fn on_zoom_reset_window_event(&mut self) {
|
||||
self.page_zoom = ScaleFactor::new(1.0);
|
||||
self.update_zoom_transform();
|
||||
self.send_window_size();
|
||||
}
|
||||
|
||||
fn on_zoom_window_event(&mut self, magnification: f32) {
|
||||
self.page_zoom = ScaleFactor::new((self.page_zoom.get() * magnification).max(1.0));
|
||||
self.update_zoom_transform();
|
||||
|
|
|
@ -64,6 +64,8 @@ pub enum WindowEvent {
|
|||
Zoom(f32),
|
||||
/// Simulated "pinch zoom" gesture for non-touch platforms (e.g. ctrl-scrollwheel).
|
||||
PinchZoom(f32),
|
||||
/// Sent when the user resets zoom to default.
|
||||
ResetZoom,
|
||||
/// Sent when the user uses chrome navigation (i.e. backspace or shift-backspace).
|
||||
Navigation(WindowNavigateMsg),
|
||||
/// Sent when the user quits the application
|
||||
|
@ -86,6 +88,7 @@ impl Debug for WindowEvent {
|
|||
WindowEvent::Scroll(..) => write!(f, "Scroll"),
|
||||
WindowEvent::Zoom(..) => write!(f, "Zoom"),
|
||||
WindowEvent::PinchZoom(..) => write!(f, "PinchZoom"),
|
||||
WindowEvent::ResetZoom => write!(f, "ResetZoom"),
|
||||
WindowEvent::Navigation(..) => write!(f, "Navigation"),
|
||||
WindowEvent::Quit => write!(f, "Quit"),
|
||||
}
|
||||
|
|
|
@ -192,6 +192,7 @@ pub enum Key {
|
|||
|
||||
bitflags! {
|
||||
flags KeyModifiers: u8 {
|
||||
const NONE = 0x00,
|
||||
const SHIFT = 0x01,
|
||||
const CONTROL = 0x02,
|
||||
const ALT = 0x04,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue