config: Handle zoom updates in Common::update_config

This commit is contained in:
Victoria Brekenfeld 2025-02-13 21:08:31 +01:00 committed by Victoria Brekenfeld
parent df9441804d
commit 55e4dd7c0f
2 changed files with 18 additions and 27 deletions

View file

@ -909,31 +909,8 @@ fn config_changed(config: cosmic_config::Config, keys: Vec<String>, state: &mut
"accessibility_zoom" => {
let new = get_config::<ZoomConfig>(&config, "accessibility_zoom");
if new != state.common.config.cosmic_conf.accessibility_zoom {
if new.start_on_login
&& !state
.common
.config
.cosmic_conf
.accessibility_zoom
.start_on_login
{
let level = state
.common
.shell
.read()
.unwrap()
.zoom_level(None)
.map_or(1., |(_, _, level)| level);
state.common.config.dynamic_conf.zoom_state_mut().last_level = if level
!= 1.
{
level
} else {
1. + state.common.config.cosmic_conf.accessibility_zoom.increment as f64
/ 100.
};
}
state.common.config.cosmic_conf.accessibility_zoom = new;
state.common.update_config();
}
}
_ => {}

View file

@ -16,7 +16,7 @@ use crate::{
};
use cosmic_comp_config::{
workspace::{WorkspaceLayout, WorkspaceMode},
TileBehavior, ZoomMovement,
TileBehavior, ZoomConfig, ZoomMovement,
};
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::TilingState;
use cosmic_settings_config::shortcuts::action::{Direction, FocusDirection, ResizeDirection};
@ -1317,10 +1317,24 @@ impl Common {
pub fn update_config(&mut self) {
let mut shell = self.shell.write().unwrap();
shell.active_hint = self.config.cosmic_conf.active_hint;
let shell_ref = &mut *shell;
shell_ref.active_hint = self.config.cosmic_conf.active_hint;
if let Some(zoom_state) = shell_ref.zoom_state.as_mut() {
zoom_state.increment = self.config.cosmic_conf.accessibility_zoom.increment;
zoom_state.movement = self.config.cosmic_conf.accessibility_zoom.view_moves;
for output in shell_ref.workspaces.sets.keys() {
let output_state = output.user_data().get::<Mutex<OutputZoomState>>().unwrap();
output_state.lock().unwrap().update(
zoom_state.level,
zoom_state.movement,
zoom_state.increment,
);
}
}
let mut workspace_state = self.workspace_state.update();
shell.workspaces.update_config(
shell_ref.workspaces.update_config(
&self.config,
&mut workspace_state,
&self.xdg_activation_state,