Skip to content

Commit

Permalink
Add smart window gaps
Browse files Browse the repository at this point in the history
  • Loading branch information
JCapucho committed Aug 29, 2024
1 parent 59b0e0e commit cd4d372
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 60 deletions.
3 changes: 3 additions & 0 deletions cosmic-comp-config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ pub struct CosmicCompConfig {
pub autotile_behavior: TileBehavior,
/// Active hint enabled
pub active_hint: bool,
/// Smart gaps enabled
pub smart_gaps: bool,
}

impl Default for CosmicCompConfig {
Expand All @@ -48,6 +50,7 @@ impl Default for CosmicCompConfig {
autotile: Default::default(),
autotile_behavior: Default::default(),
active_hint: true,
smart_gaps: Default::default(),
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,13 @@ fn config_changed(config: cosmic_config::Config, keys: Vec<String>, state: &mut
state.common.update_config();
}
}
"smart_gaps" => {
let new = get_config::<bool>(&config, "smart_gaps");
if new != state.common.config.cosmic_conf.smart_gaps {
state.common.config.cosmic_conf.smart_gaps = new;
state.common.update_config();
}
}
_ => {}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/shell/layout/tiling/grabs/resize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ impl ResizeForkGrab {
let mut shell = data.common.shell.write().unwrap();
let tiling_layer = &mut shell.active_space_mut(&output).tiling_layer;
let gaps = tiling_layer.gaps();
let is_smart_gaps = data.common.config.cosmic_conf.smart_gaps;

let tree = &mut tiling_layer.queue.trees.back_mut().unwrap().0;
match &mut self.old_tree {
Expand Down Expand Up @@ -317,7 +318,7 @@ impl ResizeForkGrab {
}

self.last_loc = location.as_global();
let blocker = TilingLayout::update_positions(&output, tree, gaps);
let blocker = TilingLayout::update_positions(&output, tree, gaps, is_smart_gaps);
tiling_layer.pending_blockers.extend(blocker);
} else {
return true;
Expand Down
Loading

0 comments on commit cd4d372

Please sign in to comment.