a11y/zoom: Allow hiding the overlay

This commit is contained in:
Victoria Brekenfeld 2025-03-25 14:38:35 +01:00 committed by Victoria Brekenfeld
parent b0d0bfb034
commit b62e47ef8d
4 changed files with 19 additions and 15 deletions

View file

@ -130,6 +130,7 @@ fn default_repeat_delay() -> u32 {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
pub struct ZoomConfig { pub struct ZoomConfig {
pub start_on_login: bool, pub start_on_login: bool,
pub show_overlay: bool,
pub increment: u32, pub increment: u32,
pub view_moves: ZoomMovement, pub view_moves: ZoomMovement,
} }
@ -138,6 +139,7 @@ impl Default for ZoomConfig {
fn default() -> Self { fn default() -> Self {
ZoomConfig { ZoomConfig {
start_on_login: false, start_on_login: false,
show_overlay: true,
increment: 50, increment: 50,
view_moves: ZoomMovement::Continuously, view_moves: ZoomMovement::Continuously,
} }

View file

@ -73,7 +73,7 @@ fn render_input_order_internal<R: 'static>(
if shell if shell
.zoom_state .zoom_state
.as_ref() .as_ref()
.is_some_and(|state| state.current_level() != 1.0) .is_some_and(|state| state.show_overlay && state.current_level() != 1.0)
{ {
callback(Stage::ZoomUI)?; callback(Stage::ZoomUI)?;
} }

View file

@ -1249,6 +1249,7 @@ impl Common {
if let Some(zoom_state) = shell_ref.zoom_state.as_mut() { if let Some(zoom_state) = shell_ref.zoom_state.as_mut() {
zoom_state.increment = self.config.cosmic_conf.accessibility_zoom.increment; zoom_state.increment = self.config.cosmic_conf.accessibility_zoom.increment;
zoom_state.movement = self.config.cosmic_conf.accessibility_zoom.view_moves; zoom_state.movement = self.config.cosmic_conf.accessibility_zoom.view_moves;
zoom_state.show_overlay = self.config.cosmic_conf.accessibility_zoom.show_overlay;
for output in shell_ref.workspaces.sets.keys() { for output in shell_ref.workspaces.sets.keys() {
let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap(); let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap();
@ -2051,6 +2052,7 @@ impl Shell {
self.theme.clone(), self.theme.clone(),
); );
} }
1. 1.
}; };
@ -2064,6 +2066,7 @@ impl Shell {
self.zoom_state = Some(ZoomState { self.zoom_state = Some(ZoomState {
seat: seat.clone(), seat: seat.clone(),
show_overlay: zoom_config.show_overlay,
level, level,
increment: zoom_config.increment, increment: zoom_config.increment,
movement: zoom_config.view_moves, movement: zoom_config.view_moves,

View file

@ -51,6 +51,7 @@ use super::{
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct ZoomState { pub struct ZoomState {
pub(super) seat: Seat<State>, pub(super) seat: Seat<State>,
pub(super) show_overlay: bool,
pub(super) level: f64, pub(super) level: f64,
pub(super) increment: u32, pub(super) increment: u32,
pub(super) movement: ZoomMovement, pub(super) movement: ZoomMovement,
@ -780,21 +781,19 @@ impl Program for ZoomProgram {
} }
ZoomMessage::Close => { ZoomMessage::Close => {
let _ = loop_handle.insert_idle(|state| { let _ = loop_handle.insert_idle(|state| {
let seat = state state
.common .common
.shell .config
.read() .cosmic_conf
.unwrap() .accessibility_zoom
.seats .show_overlay = false;
.last_active() if let Err(err) = state.common.config.cosmic_helper.set(
.clone(); "accessibility_zoom",
state.common.shell.write().unwrap().trigger_zoom( state.common.config.cosmic_conf.accessibility_zoom,
&seat, ) {
1.0, error!(?err, "Failed to update zoom config");
&state.common.config.cosmic_conf.accessibility_zoom, }
true, state.common.update_config();
&state.common.event_loop_handle,
);
}); });
} }
ZoomMessage::Update { ZoomMessage::Update {