shell: Allow triggering zoom
This commit is contained in:
parent
2e2943d99c
commit
c01de20b2b
3 changed files with 40 additions and 0 deletions
|
|
@ -70,6 +70,9 @@
|
||||||
(modifiers: [Super], key: "r"): Resizing(Outwards),
|
(modifiers: [Super], key: "r"): Resizing(Outwards),
|
||||||
(modifiers: [Super, Shift], key: "r"): Resizing(Inwards),
|
(modifiers: [Super, Shift], key: "r"): Resizing(Inwards),
|
||||||
|
|
||||||
|
(modifiers: [Super], key: "equal"): ZoomIn,
|
||||||
|
(modifiers: [Super], key: "minus"): ZoomOut,
|
||||||
|
|
||||||
(modifiers: [Super], key: "b"): System(WebBrowser),
|
(modifiers: [Super], key: "b"): System(WebBrowser),
|
||||||
(modifiers: [Super], key: "f"): System(HomeFolder),
|
(modifiers: [Super], key: "f"): System(HomeFolder),
|
||||||
(modifiers: [Super], key: "t"): System(Terminal),
|
(modifiers: [Super], key: "t"): System(Terminal),
|
||||||
|
|
|
||||||
|
|
@ -1026,6 +1026,25 @@ impl State {
|
||||||
|
|
||||||
Action::Spawn(command) => self.spawn_command(command),
|
Action::Spawn(command) => self.spawn_command(command),
|
||||||
|
|
||||||
|
x @ Action::ZoomIn | x @ Action::ZoomOut => {
|
||||||
|
let mut shell = self.common.shell.write().unwrap();
|
||||||
|
let pointer_loc = seat.get_pointer().unwrap().current_location().as_global();
|
||||||
|
let (zoom_seat, _, current_level) = shell
|
||||||
|
.zoom_level()
|
||||||
|
.unwrap_or_else(|| (seat.clone(), pointer_loc, 1.0));
|
||||||
|
if &zoom_seat == seat {
|
||||||
|
shell.trigger_zoom(
|
||||||
|
seat,
|
||||||
|
pointer_loc,
|
||||||
|
match x {
|
||||||
|
Action::ZoomIn => current_level + 1.0,
|
||||||
|
Action::ZoomOut => (current_level - 1.0).max(1.0),
|
||||||
|
_ => unreachable!(),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do nothing
|
// Do nothing
|
||||||
Action::Disable => (),
|
Action::Disable => (),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1966,6 +1966,24 @@ impl Shell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn trigger_zoom(
|
||||||
|
&mut self,
|
||||||
|
seat: &Seat<State>,
|
||||||
|
focal_point: Point<f64, Global>,
|
||||||
|
level: f64,
|
||||||
|
) {
|
||||||
|
if level == 1. {
|
||||||
|
self.zoom_state.take();
|
||||||
|
} else {
|
||||||
|
self.zoom_state = Some(ZoomState {
|
||||||
|
seat: seat.clone(),
|
||||||
|
level,
|
||||||
|
focal_point,
|
||||||
|
previous: None,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn zoom_level(&self) -> Option<(Seat<State>, Point<f64, Global>, f64)> {
|
pub fn zoom_level(&self) -> Option<(Seat<State>, Point<f64, Global>, f64)> {
|
||||||
self.zoom_state.as_ref().map(|s| s.level())
|
self.zoom_state.as_ref().map(|s| s.level())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue