feat: add tiling variables to cosmic config
This commit is contained in:
parent
e43c0f648d
commit
5eb5af4675
5 changed files with 189 additions and 44 deletions
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
state::{BackendData, State},
|
||||
wayland::protocols::output_configuration::OutputConfigurationState,
|
||||
};
|
||||
use cosmic_config::ConfigGet;
|
||||
use cosmic_config::{ConfigGet, CosmicConfigEntry};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use smithay::input::Seat;
|
||||
pub use smithay::{
|
||||
|
|
@ -32,25 +32,20 @@ pub use self::types::*;
|
|||
use cosmic_comp_config::{
|
||||
input::InputConfig,
|
||||
workspace::{WorkspaceConfig, WorkspaceLayout},
|
||||
XkbConfig,
|
||||
CosmicCompConfig, TileBehavior, XkbConfig,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Config {
|
||||
pub static_conf: StaticConfig,
|
||||
pub dynamic_conf: DynamicConfig,
|
||||
pub config: cosmic_config::Config,
|
||||
pub xkb: XkbConfig,
|
||||
pub input_default: InputConfig,
|
||||
pub input_touchpad: InputConfig,
|
||||
pub input_devices: HashMap<String, InputConfig>,
|
||||
pub workspace: WorkspaceConfig,
|
||||
pub cosmic_helper: cosmic_config::Config,
|
||||
pub cosmic_conf: CosmicCompConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct StaticConfig {
|
||||
pub key_bindings: HashMap<key_bindings::KeyPattern, key_bindings::Action>,
|
||||
pub tiling_enabled: bool,
|
||||
pub data_control_enabled: bool,
|
||||
}
|
||||
|
||||
|
|
@ -172,15 +167,18 @@ impl Config {
|
|||
.expect("Failed to add cosmic-config to the event loop");
|
||||
let xdg = xdg::BaseDirectories::new().ok();
|
||||
let workspace = get_config::<WorkspaceConfig>(&config, "workspaces");
|
||||
let cosmic_comp_config =
|
||||
CosmicCompConfig::get_entry(&config).unwrap_or_else(|(errs, c)| {
|
||||
for err in errs {
|
||||
error!(?err, "");
|
||||
}
|
||||
c
|
||||
});
|
||||
Config {
|
||||
static_conf: Self::load_static(xdg.as_ref(), workspace.workspace_layout),
|
||||
dynamic_conf: Self::load_dynamic(xdg.as_ref()),
|
||||
xkb: get_config(&config, "xkb_config"),
|
||||
input_default: get_config(&config, "input_default"),
|
||||
input_touchpad: get_config(&config, "input_touchpad"),
|
||||
input_devices: get_config(&config, "input_devices"),
|
||||
workspace,
|
||||
config,
|
||||
cosmic_conf: cosmic_comp_config,
|
||||
cosmic_helper: config,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -221,7 +219,6 @@ impl Config {
|
|||
|
||||
StaticConfig {
|
||||
key_bindings: HashMap::new(),
|
||||
tiling_enabled: false,
|
||||
data_control_enabled: false,
|
||||
}
|
||||
}
|
||||
|
|
@ -410,7 +407,7 @@ impl Config {
|
|||
}
|
||||
|
||||
pub fn xkb_config(&self) -> XkbConfig {
|
||||
self.xkb.clone()
|
||||
self.cosmic_conf.xkb_config.clone()
|
||||
}
|
||||
|
||||
pub fn read_device(&self, device: &mut InputDevice) {
|
||||
|
|
@ -438,11 +435,11 @@ impl Config {
|
|||
|
||||
fn get_device_config(&self, device: &InputDevice) -> (Option<&InputConfig>, &InputConfig) {
|
||||
let default_config = if device.config_tap_finger_count() > 0 {
|
||||
&self.input_touchpad
|
||||
&self.cosmic_conf.input_touchpad
|
||||
} else {
|
||||
&self.input_default
|
||||
&self.cosmic_conf.input_default
|
||||
};
|
||||
let device_config = self.input_devices.get(device.name());
|
||||
let device_config = self.cosmic_conf.input_devices.get(device.name());
|
||||
(device_config, default_config)
|
||||
}
|
||||
}
|
||||
|
|
@ -525,28 +522,61 @@ fn config_changed(config: cosmic_config::Config, keys: Vec<String>, state: &mut
|
|||
}
|
||||
}
|
||||
}
|
||||
state.common.config.xkb = value;
|
||||
state.common.config.cosmic_conf.xkb_config = value;
|
||||
}
|
||||
"input_default" => {
|
||||
let value = get_config::<InputConfig>(&config, "input_default");
|
||||
state.common.config.input_default = value;
|
||||
state.common.config.cosmic_conf.input_default = value;
|
||||
update_input(state);
|
||||
}
|
||||
"input_touchpad" => {
|
||||
let value = get_config::<InputConfig>(&config, "input_touchpad");
|
||||
state.common.config.input_touchpad = value;
|
||||
state.common.config.cosmic_conf.input_touchpad = value;
|
||||
update_input(state);
|
||||
}
|
||||
"input_devices" => {
|
||||
let value = get_config::<HashMap<String, InputConfig>>(&config, "input_devices");
|
||||
state.common.config.input_devices = value;
|
||||
state.common.config.cosmic_conf.input_devices = value;
|
||||
update_input(state);
|
||||
}
|
||||
"workspaces" => {
|
||||
state.common.config.workspace =
|
||||
state.common.config.cosmic_conf.workspaces =
|
||||
get_config::<WorkspaceConfig>(&config, "workspaces");
|
||||
state.common.shell.update_config(&state.common.config);
|
||||
}
|
||||
"autotile" => {
|
||||
let new = get_config::<bool>(&config, "autotile");
|
||||
if new != state.common.config.cosmic_conf.autotile {
|
||||
state.common.config.cosmic_conf.autotile = new;
|
||||
let seats: Vec<_> = state.common.seats().cloned().collect();
|
||||
let mut guard = state.common.shell.workspace_state.update();
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.workspaces
|
||||
.update_autotile(new, &mut guard, seats);
|
||||
}
|
||||
}
|
||||
"autotile_behavior" => {
|
||||
let new = get_config::<TileBehavior>(&config, "autotile_behavior");
|
||||
if new != state.common.config.cosmic_conf.autotile_behavior {
|
||||
state.common.config.cosmic_conf.autotile_behavior = new;
|
||||
let seats: Vec<_> = state.common.seats().cloned().collect();
|
||||
let mut guard = state.common.shell.workspace_state.update();
|
||||
state
|
||||
.common
|
||||
.shell
|
||||
.workspaces
|
||||
.update_autotile_behavior(new, &mut guard, seats);
|
||||
}
|
||||
}
|
||||
"active_hint" => {
|
||||
let new = get_config::<bool>(&config, "active_hint");
|
||||
if new != state.common.config.cosmic_conf.active_hint {
|
||||
state.common.config.cosmic_conf.active_hint = new;
|
||||
state.common.shell.update_config(&state.common.config);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue