zoom: Fix config/state changes
This commit is contained in:
parent
d30671c984
commit
b92879e60b
4 changed files with 46 additions and 16 deletions
|
|
@ -72,7 +72,17 @@ pub fn init_backend_auto(
|
|||
.write()
|
||||
.unwrap()
|
||||
.seats
|
||||
.add_seat(initial_seat);
|
||||
.add_seat(initial_seat.clone());
|
||||
|
||||
if state
|
||||
.common
|
||||
.config
|
||||
.cosmic_conf
|
||||
.accessibility_zoom
|
||||
.start_on_login
|
||||
{
|
||||
state.update_zoom(&initial_seat, 1.0, true);
|
||||
}
|
||||
|
||||
let desired_numlock = state
|
||||
.common
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ pub struct Config {
|
|||
pub struct DynamicConfig {
|
||||
outputs: (Option<PathBuf>, OutputsConfig),
|
||||
numlock: (Option<PathBuf>, NumlockStateConfig),
|
||||
accessibility_zoom: (Option<PathBuf>, ZoomState),
|
||||
pub accessibility_zoom: (Option<PathBuf>, ZoomState),
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use crate::{
|
|||
handlers::xdg_activation::ActivationContext, protocols::workspace::WorkspaceUpdateGuard,
|
||||
},
|
||||
};
|
||||
use calloop::timer::{TimeoutAction, Timer};
|
||||
use cosmic_comp_config::{workspace::WorkspaceLayout, TileBehavior};
|
||||
use cosmic_config::ConfigSet;
|
||||
use cosmic_settings_config::shortcuts;
|
||||
|
|
@ -19,11 +20,11 @@ use smithay::{
|
|||
input::{pointer::MotionEvent, Seat},
|
||||
utils::{Point, Serial},
|
||||
};
|
||||
use tracing::error;
|
||||
#[cfg(not(feature = "debug"))]
|
||||
use tracing::info;
|
||||
use tracing::{error, warn};
|
||||
|
||||
use std::{os::unix::process::CommandExt, thread};
|
||||
use std::{os::unix::process::CommandExt, thread, time::Duration};
|
||||
|
||||
use super::gestures;
|
||||
|
||||
|
|
@ -1045,7 +1046,7 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
fn spawn_command(&mut self, command: String) {
|
||||
pub fn spawn_command(&mut self, command: String) {
|
||||
let mut shell = self.common.shell.write().unwrap();
|
||||
|
||||
let (token, data) = self.common.xdg_activation_state.create_external_token(None);
|
||||
|
|
@ -1095,7 +1096,7 @@ impl State {
|
|||
.map(|state| (state.current_seat(), state.current_level()))
|
||||
.unwrap_or_else(|| (seat.clone(), 1.0));
|
||||
let change = if current_level == 1.0 && animate {
|
||||
self.common.config.dynamic_conf.zoom_state().last_level
|
||||
self.common.config.dynamic_conf.zoom_state().last_level - 1.0
|
||||
} else {
|
||||
change
|
||||
};
|
||||
|
|
@ -1114,19 +1115,35 @@ impl State {
|
|||
&self.common.event_loop_handle,
|
||||
);
|
||||
|
||||
/* TODO: debounce
|
||||
if new_level > 1.
|
||||
&& self
|
||||
.common
|
||||
if new_level > 1. {
|
||||
// bypass the persistence guard, so that `update_zoom` call pick up the latest value
|
||||
self.common
|
||||
.config
|
||||
.cosmic_conf
|
||||
.dynamic_conf
|
||||
.accessibility_zoom
|
||||
.start_on_login
|
||||
{
|
||||
self.common.config.dynamic_conf.zoom_state_mut().last_level =
|
||||
new_level;
|
||||
.1
|
||||
.last_level = new_level;
|
||||
|
||||
// and then debounce the config write, because of `Super+<Scroll Wheel>`
|
||||
if let Some(token) = self.common.zoom_config_debounce.take() {
|
||||
self.common.event_loop_handle.remove(token);
|
||||
}
|
||||
match self.common.event_loop_handle.insert_source(
|
||||
Timer::from_duration(Duration::from_secs(5)),
|
||||
move |_, _, state| {
|
||||
state.common.config.dynamic_conf.zoom_state_mut().last_level = new_level;
|
||||
let _ = state.common.zoom_config_debounce.take();
|
||||
TimeoutAction::Drop
|
||||
},
|
||||
) {
|
||||
Ok(token) => {
|
||||
self.common.zoom_config_debounce = Some(token);
|
||||
}
|
||||
Err(err) => {
|
||||
warn!("Failed to schedule debounced configuration write: {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ use crate::{
|
|||
xwayland::XWaylandState,
|
||||
};
|
||||
use anyhow::Context;
|
||||
use calloop::RegistrationToken;
|
||||
use i18n_embed::{
|
||||
fluent::{fluent_language_loader, FluentLanguageLoader},
|
||||
DesktopLanguageRequester,
|
||||
|
|
@ -185,6 +186,7 @@ pub struct Common {
|
|||
|
||||
pub popups: PopupManager,
|
||||
pub shell: Arc<RwLock<Shell>>,
|
||||
pub zoom_config_debounce: Option<RegistrationToken>,
|
||||
|
||||
pub clock: Clock<Monotonic>,
|
||||
pub startup_done: Arc<AtomicBool>,
|
||||
|
|
@ -592,6 +594,7 @@ impl State {
|
|||
|
||||
popups: PopupManager::default(),
|
||||
shell,
|
||||
zoom_config_debounce: None,
|
||||
|
||||
local_offset,
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue