input: Zoom on Super+Scroll
This commit is contained in:
parent
58f96e6f4a
commit
b7d4a66c22
3 changed files with 81 additions and 29 deletions
|
|
@ -1053,6 +1053,7 @@ impl State {
|
||||||
seat,
|
seat,
|
||||||
new_level,
|
new_level,
|
||||||
self.common.config.cosmic_conf.accessibility_zoom.view_moves,
|
self.common.config.cosmic_conf.accessibility_zoom.view_moves,
|
||||||
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
if new_level > 1.
|
if new_level > 1.
|
||||||
|
|
|
||||||
|
|
@ -835,37 +835,82 @@ impl State {
|
||||||
if let Some(seat) = maybe_seat {
|
if let Some(seat) = maybe_seat {
|
||||||
self.common.idle_notifier_state.notify_activity(&seat);
|
self.common.idle_notifier_state.notify_activity(&seat);
|
||||||
|
|
||||||
let mut frame = AxisFrame::new(event.time_msec()).source(event.source());
|
if seat.get_keyboard().unwrap().modifier_state().logo {
|
||||||
if let Some(horizontal_amount) = event.amount(Axis::Horizontal) {
|
if let Some(mut percentage) = event
|
||||||
if horizontal_amount != 0.0 {
|
.amount_v120(Axis::Vertical)
|
||||||
frame =
|
.map(|val| val / 120.)
|
||||||
frame.value(Axis::Horizontal, scroll_factor * horizontal_amount);
|
.or_else(|| event.amount(Axis::Vertical))
|
||||||
if let Some(discrete) = event.amount_v120(Axis::Horizontal) {
|
.map(|val| val * scroll_factor)
|
||||||
frame = frame.v120(
|
{
|
||||||
Axis::Horizontal,
|
let mut shell = self.common.shell.write().unwrap();
|
||||||
(discrete * scroll_factor).round() as i32,
|
let (zoom_seat, current_level) = shell
|
||||||
);
|
.zoom_level(None)
|
||||||
|
.map(|(s, _, l)| (s, l))
|
||||||
|
.unwrap_or_else(|| (seat.clone(), 1.0));
|
||||||
|
|
||||||
|
if current_level == 1. && percentage.is_sign_positive() {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else if event.source() == AxisSource::Finger {
|
if event.source() == AxisSource::Wheel {
|
||||||
frame = frame.stop(Axis::Horizontal);
|
percentage *= 5.;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if let Some(vertical_amount) = event.amount(Axis::Vertical) {
|
let new_level = (current_level - percentage as f64 / 100.).max(1.0);
|
||||||
if vertical_amount != 0.0 {
|
if zoom_seat == seat {
|
||||||
frame = frame.value(Axis::Vertical, scroll_factor * vertical_amount);
|
shell.trigger_zoom(
|
||||||
if let Some(discrete) = event.amount_v120(Axis::Vertical) {
|
&seat,
|
||||||
frame = frame.v120(
|
new_level,
|
||||||
Axis::Vertical,
|
self.common.config.cosmic_conf.accessibility_zoom.view_moves,
|
||||||
(discrete * scroll_factor).round() as i32,
|
event.source() == AxisSource::Wheel,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if new_level > 1.
|
||||||
|
&& self
|
||||||
|
.common
|
||||||
|
.config
|
||||||
|
.cosmic_conf
|
||||||
|
.accessibility_zoom
|
||||||
|
.start_on_login
|
||||||
|
{
|
||||||
|
self.common.config.dynamic_conf.zoom_state_mut().last_level =
|
||||||
|
new_level;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if event.source() == AxisSource::Finger {
|
|
||||||
frame = frame.stop(Axis::Vertical);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
let mut frame = AxisFrame::new(event.time_msec()).source(event.source());
|
||||||
|
if let Some(horizontal_amount) = event.amount(Axis::Horizontal) {
|
||||||
|
if horizontal_amount != 0.0 {
|
||||||
|
frame = frame
|
||||||
|
.value(Axis::Horizontal, scroll_factor * horizontal_amount);
|
||||||
|
if let Some(discrete) = event.amount_v120(Axis::Horizontal) {
|
||||||
|
frame = frame.v120(
|
||||||
|
Axis::Horizontal,
|
||||||
|
(discrete * scroll_factor).round() as i32,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if event.source() == AxisSource::Finger {
|
||||||
|
frame = frame.stop(Axis::Horizontal);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(vertical_amount) = event.amount(Axis::Vertical) {
|
||||||
|
if vertical_amount != 0.0 {
|
||||||
|
frame =
|
||||||
|
frame.value(Axis::Vertical, scroll_factor * vertical_amount);
|
||||||
|
if let Some(discrete) = event.amount_v120(Axis::Vertical) {
|
||||||
|
frame = frame.v120(
|
||||||
|
Axis::Vertical,
|
||||||
|
(discrete * scroll_factor).round() as i32,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if event.source() == AxisSource::Finger {
|
||||||
|
frame = frame.stop(Axis::Vertical);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let ptr = seat.get_pointer().unwrap();
|
||||||
|
ptr.axis(self, frame);
|
||||||
|
ptr.frame(self);
|
||||||
}
|
}
|
||||||
let ptr = seat.get_pointer().unwrap();
|
|
||||||
ptr.axis(self, frame);
|
|
||||||
ptr.frame(self);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2074,7 +2074,13 @@ impl Shell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn trigger_zoom(&mut self, seat: &Seat<State>, level: f64, movement: ZoomMovement) {
|
pub fn trigger_zoom(
|
||||||
|
&mut self,
|
||||||
|
seat: &Seat<State>,
|
||||||
|
level: f64,
|
||||||
|
movement: ZoomMovement,
|
||||||
|
animate: bool,
|
||||||
|
) {
|
||||||
if self.zoom_state.is_none() && level == 1. {
|
if self.zoom_state.is_none() && level == 1. {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -2099,7 +2105,7 @@ impl Shell {
|
||||||
seat: seat.clone(),
|
seat: seat.clone(),
|
||||||
level,
|
level,
|
||||||
movement,
|
movement,
|
||||||
previous_level: Some((previous_level, Instant::now())),
|
previous_level: animate.then_some((previous_level, Instant::now())),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue