Add config reloading for tiling exceptions
This commit is contained in:
parent
5fe9ba29eb
commit
5482ff65e5
3 changed files with 45 additions and 11 deletions
|
|
@ -8,8 +8,8 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use cosmic_config::{ConfigGet, CosmicConfigEntry};
|
use cosmic_config::{ConfigGet, CosmicConfigEntry};
|
||||||
use cosmic_settings_config::{shortcuts, Shortcuts, window_rules};
|
|
||||||
use cosmic_settings_config::window_rules::ApplicationException;
|
use cosmic_settings_config::window_rules::ApplicationException;
|
||||||
|
use cosmic_settings_config::{shortcuts, window_rules, Shortcuts};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use smithay::wayland::xdg_activation::XdgActivationState;
|
use smithay::wayland::xdg_activation::XdgActivationState;
|
||||||
pub use smithay::{
|
pub use smithay::{
|
||||||
|
|
@ -208,9 +208,6 @@ impl Config {
|
||||||
let system_actions = shortcuts::system_actions(&config);
|
let system_actions = shortcuts::system_actions(&config);
|
||||||
let mut shortcuts = shortcuts::shortcuts(&settings_context);
|
let mut shortcuts = shortcuts::shortcuts(&settings_context);
|
||||||
|
|
||||||
let tiling_context = window_rules::context().expect("Failed to load window rules config");
|
|
||||||
let tiling_exceptions = window_rules::tiling_exceptions(&tiling_context);
|
|
||||||
|
|
||||||
// Add any missing default shortcuts recommended by the compositor.
|
// Add any missing default shortcuts recommended by the compositor.
|
||||||
key_bindings::add_default_bindings(&mut shortcuts, workspace.workspace_layout);
|
key_bindings::add_default_bindings(&mut shortcuts, workspace.workspace_layout);
|
||||||
|
|
||||||
|
|
@ -250,6 +247,41 @@ impl Config {
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let window_rules_context =
|
||||||
|
window_rules::context().expect("Failed to load window rules config");
|
||||||
|
let tiling_exceptions = window_rules::tiling_exceptions(&window_rules_context);
|
||||||
|
|
||||||
|
match cosmic_config::calloop::ConfigWatchSource::new(&window_rules_context) {
|
||||||
|
Ok(source) => {
|
||||||
|
if let Err(err) = loop_handle.insert_source(source, |(config, keys), (), state| {
|
||||||
|
for key in keys {
|
||||||
|
match key.as_str() {
|
||||||
|
"tiling_exception_defaults" | "tiling_exception_custom" => {
|
||||||
|
let new_exceptions = window_rules::tiling_exceptions(&config);
|
||||||
|
state.common.config.tiling_exceptions = new_exceptions;
|
||||||
|
state
|
||||||
|
.common
|
||||||
|
.shell
|
||||||
|
.write()
|
||||||
|
.unwrap()
|
||||||
|
.update_tiling_exceptions(&state.common.config.tiling_exceptions);
|
||||||
|
}
|
||||||
|
_ => (),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}) {
|
||||||
|
warn!(
|
||||||
|
?err,
|
||||||
|
"Failed to watch com.system76.CosmicSettings.WindowRules config"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => warn!(
|
||||||
|
?err,
|
||||||
|
"failed to create config watch source for com.system76.CosmicSettings.WindowRules"
|
||||||
|
),
|
||||||
|
};
|
||||||
|
|
||||||
Config {
|
Config {
|
||||||
dynamic_conf: Self::load_dynamic(xdg.as_ref()),
|
dynamic_conf: Self::load_dynamic(xdg.as_ref()),
|
||||||
cosmic_conf: cosmic_comp_config,
|
cosmic_conf: cosmic_comp_config,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use cosmic_settings_config::shortcuts::action::Orientation;
|
use cosmic_settings_config::{shortcuts::action::Orientation, window_rules::ApplicationException};
|
||||||
use regex::{Regex, RegexSet};
|
use regex::{Regex, RegexSet};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
desktop::WindowSurface,
|
desktop::WindowSurface,
|
||||||
|
|
@ -9,8 +9,6 @@ use smithay::{
|
||||||
};
|
};
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
use crate::config::Config;
|
|
||||||
|
|
||||||
use super::CosmicSurface;
|
use super::CosmicSurface;
|
||||||
|
|
||||||
pub mod floating;
|
pub mod floating;
|
||||||
|
|
@ -63,11 +61,11 @@ pub struct TilingExceptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TilingExceptions {
|
impl TilingExceptions {
|
||||||
pub fn new(config: &Config) -> Self {
|
pub fn new(exceptions_config: &Vec<ApplicationException>) -> Self {
|
||||||
let mut app_ids = Vec::new();
|
let mut app_ids = Vec::new();
|
||||||
let mut titles = Vec::new();
|
let mut titles = Vec::new();
|
||||||
|
|
||||||
for exception in &config.tiling_exceptions {
|
for exception in exceptions_config {
|
||||||
if let Err(e) = Regex::new(&exception.appid) {
|
if let Err(e) = Regex::new(&exception.appid) {
|
||||||
warn!("Invalid regex for appid: {}, {}", exception.appid, e);
|
warn!("Invalid regex for appid: {}, {}", exception.appid, e);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use cosmic_comp_config::{
|
||||||
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::{
|
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::{
|
||||||
State as WState, TilingState,
|
State as WState, TilingState,
|
||||||
};
|
};
|
||||||
use cosmic_settings_config::shortcuts;
|
use cosmic_settings_config::{shortcuts, window_rules::ApplicationException};
|
||||||
use cosmic_settings_config::shortcuts::action::{Direction, FocusDirection, ResizeDirection};
|
use cosmic_settings_config::shortcuts::action::{Direction, FocusDirection, ResizeDirection};
|
||||||
use keyframe::{ease, functions::EaseInOutCubic};
|
use keyframe::{ease, functions::EaseInOutCubic};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
|
|
@ -1235,7 +1235,7 @@ impl Shell {
|
||||||
pub fn new(config: &Config) -> Self {
|
pub fn new(config: &Config) -> Self {
|
||||||
let theme = cosmic::theme::system_preference();
|
let theme = cosmic::theme::system_preference();
|
||||||
|
|
||||||
let tiling_exceptions = layout::TilingExceptions::new(config);
|
let tiling_exceptions = layout::TilingExceptions::new(&config.tiling_exceptions);
|
||||||
|
|
||||||
Shell {
|
Shell {
|
||||||
workspaces: Workspaces::new(config, theme.clone()),
|
workspaces: Workspaces::new(config, theme.clone()),
|
||||||
|
|
@ -3577,6 +3577,10 @@ impl Shell {
|
||||||
&self.theme
|
&self.theme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update_tiling_exceptions(&mut self, exceptions: &Vec<ApplicationException>) {
|
||||||
|
self.tiling_exceptions = layout::TilingExceptions::new(exceptions);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn take_presentation_feedback(
|
pub fn take_presentation_feedback(
|
||||||
&self,
|
&self,
|
||||||
output: &Output,
|
output: &Output,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue