zoom: Handle multiple outputs

This commit is contained in:
Victoria Brekenfeld 2025-01-24 18:07:33 +01:00 committed by Victoria Brekenfeld
parent 61d44b3a9d
commit 531a1c951f
4 changed files with 259 additions and 32 deletions

View file

@ -1028,20 +1028,24 @@ impl State {
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));
let (zoom_seat, current_level) = shell
.zoom_level(None)
.map(|(s, _, l)| (s, l))
.unwrap_or_else(|| (seat.clone(), 1.0));
if &zoom_seat == seat {
let increment =
self.common.config.cosmic_conf.accessibility_zoom.increment as f64 / 100.0;
shell.trigger_zoom(
seat,
pointer_loc,
match x {
Action::ZoomIn => current_level + 1.0,
Action::ZoomOut => (current_level - 1.0).max(1.0),
Action::ZoomIn => current_level + increment,
Action::ZoomOut => (current_level - increment).max(1.0),
_ => unreachable!(),
},
self.common.config.cosmic_conf.accessibility_zoom.view_moves,
);
// TODO: persist state, if enable_on_startup
}
}

View file

@ -518,6 +518,11 @@ impl State {
let mut shell = self.common.shell.write().unwrap();
shell.update_pointer_position(position.to_local(&output), &output);
shell.update_focal_point(
&seat,
original_position,
self.common.config.cosmic_conf.accessibility_zoom.view_moves,
);
if output != current_output {
for session in cursor_sessions_for_output(&*shell, &current_output) {