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 Sep 6, 2024
1 parent 79ae56c commit b87a3d9
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 @@ -31,6 +31,8 @@ pub struct CosmicCompConfig {
pub focus_follows_cursor_delay: u64,
/// Let X11 applications scale themselves
pub descale_xwayland: bool,
/// Smart gaps enabled
pub smart_gaps: bool,
}

impl Default for CosmicCompConfig {
Expand Down Expand Up @@ -60,6 +62,7 @@ impl Default for CosmicCompConfig {
cursor_follows_focus: false,
focus_follows_cursor_delay: 250,
descale_xwayland: false,
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 @@ -716,6 +716,13 @@ fn config_changed(config: cosmic_config::Config, keys: Vec<String>, state: &mut
state.common.config.cosmic_conf.focus_follows_cursor_delay = new;
}
}
"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 b87a3d9

Please sign in to comment.