mirror of
https://github.com/YaLTeR/niri.git
synced 2025-10-06 00:23:14 +02:00
[cfg-breaking] Move prefer-no-csd and spawn-at-startup to new clients scope
This commit is contained in:
@@ -136,11 +136,6 @@ layout {
|
||||
}
|
||||
}
|
||||
|
||||
// Add lines like this to spawn processes at startup.
|
||||
// Note that running niri as a session supports xdg-desktop-autostart,
|
||||
// which may be more convenient to use.
|
||||
// spawn-at-startup "alacritty" "-e" "fish"
|
||||
|
||||
cursor {
|
||||
// Change the theme and size of the cursor as well as set the
|
||||
// `XCURSOR_THEME` and `XCURSOR_SIZE` env variables.
|
||||
@@ -148,10 +143,17 @@ cursor {
|
||||
// xcursor-size 24
|
||||
}
|
||||
|
||||
// Uncomment this line to ask the clients to omit their client-side decorations if possible.
|
||||
// If the client will specifically ask for CSD, the request will be honored.
|
||||
// Additionally, clients will be informed that they are tiled, removing some rounded corners.
|
||||
// prefer-no-csd
|
||||
clients {
|
||||
// Uncomment this line to ask the clients to omit their client-side decorations if possible.
|
||||
// If the client will specifically ask for CSD, the request will be honored.
|
||||
// Additionally, clients will be informed that they are tiled, removing some rounded corners.
|
||||
// prefer-no-csd
|
||||
|
||||
// Add lines like this to spawn processes at startup.
|
||||
// Note that running niri as a session supports xdg-desktop-autostart,
|
||||
// which may be more convenient to use.
|
||||
// spawn-at-startup "alacritty" "-e" "fish"
|
||||
}
|
||||
|
||||
screenshot-ui {
|
||||
// You can change the path where screenshots are saved.
|
||||
|
@@ -14,12 +14,10 @@ pub struct Config {
|
||||
pub input: Input,
|
||||
#[knuffel(children(name = "output"))]
|
||||
pub outputs: Vec<Output>,
|
||||
#[knuffel(children(name = "spawn-at-startup"))]
|
||||
pub spawn_at_startup: Vec<SpawnAtStartup>,
|
||||
#[knuffel(child, default)]
|
||||
pub layout: Layout,
|
||||
#[knuffel(child, default)]
|
||||
pub prefer_no_csd: bool,
|
||||
pub clients: Clients,
|
||||
#[knuffel(child, default)]
|
||||
pub cursor: Cursor,
|
||||
#[knuffel(child, default)]
|
||||
@@ -227,6 +225,14 @@ impl From<Color> for [f32; 4] {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(knuffel::Decode, Debug, Default, PartialEq, Eq)]
|
||||
pub struct Clients {
|
||||
#[knuffel(child, default)]
|
||||
pub prefer_no_csd: bool,
|
||||
#[knuffel(children(name = "spawn-at-startup"))]
|
||||
pub spawn_at_startup: Vec<SpawnAtStartup>,
|
||||
}
|
||||
|
||||
#[derive(knuffel::Decode, Debug, PartialEq)]
|
||||
pub struct Cursor {
|
||||
#[knuffel(child, unwrap(argument), default = String::from("default"))]
|
||||
@@ -663,9 +669,11 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
spawn-at-startup "alacritty" "-e" "fish"
|
||||
clients {
|
||||
prefer-no-csd
|
||||
|
||||
prefer-no-csd
|
||||
spawn-at-startup "alacritty" "-e" "fish"
|
||||
}
|
||||
|
||||
cursor {
|
||||
xcursor-theme "breeze_cursors"
|
||||
@@ -774,10 +782,12 @@ mod tests {
|
||||
bottom: 0,
|
||||
},
|
||||
},
|
||||
spawn_at_startup: vec![SpawnAtStartup {
|
||||
command: vec!["alacritty".to_owned(), "-e".to_owned(), "fish".to_owned()],
|
||||
}],
|
||||
prefer_no_csd: true,
|
||||
clients: Clients {
|
||||
spawn_at_startup: vec![SpawnAtStartup {
|
||||
command: vec!["alacritty".to_owned(), "-e".to_owned(), "fish".to_owned()],
|
||||
}],
|
||||
prefer_no_csd: true,
|
||||
},
|
||||
cursor: Cursor {
|
||||
xcursor_theme: String::from("breeze_cursors"),
|
||||
xcursor_size: 16,
|
||||
|
@@ -39,7 +39,7 @@ impl XdgShellHandler for State {
|
||||
// If the user prefers no CSD, it's a reasonable assumption that they would prefer to get
|
||||
// rid of the various client-side rounded corners also by using the tiled state.
|
||||
let config = self.niri.config.borrow();
|
||||
if config.prefer_no_csd {
|
||||
if config.clients.prefer_no_csd {
|
||||
window.toplevel().with_pending_state(|state| {
|
||||
state.states.set(xdg_toplevel::State::TiledLeft);
|
||||
state.states.set(xdg_toplevel::State::TiledRight);
|
||||
@@ -192,7 +192,7 @@ delegate_xdg_shell!(State);
|
||||
|
||||
impl XdgDecorationHandler for State {
|
||||
fn new_decoration(&mut self, toplevel: ToplevelSurface) {
|
||||
let mode = if self.niri.config.borrow().prefer_no_csd {
|
||||
let mode = if self.niri.config.borrow().clients.prefer_no_csd {
|
||||
Some(zxdg_toplevel_decoration_v1::Mode::ServerSide)
|
||||
} else {
|
||||
None
|
||||
@@ -214,7 +214,7 @@ impl XdgDecorationHandler for State {
|
||||
}
|
||||
|
||||
fn unset_mode(&mut self, toplevel: ToplevelSurface) {
|
||||
let mode = if self.niri.config.borrow().prefer_no_csd {
|
||||
let mode = if self.niri.config.borrow().clients.prefer_no_csd {
|
||||
Some(zxdg_toplevel_decoration_v1::Mode::ServerSide)
|
||||
} else {
|
||||
None
|
||||
|
@@ -138,7 +138,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
};
|
||||
animation::ANIMATION_SLOWDOWN.store(config.debug.animation_slowdown, Ordering::Relaxed);
|
||||
let spawn_at_startup = mem::take(&mut config.spawn_at_startup);
|
||||
let spawn_at_startup = mem::take(&mut config.clients.spawn_at_startup);
|
||||
|
||||
// Create the compositor.
|
||||
let mut event_loop = EventLoop::try_new().unwrap();
|
||||
|
@@ -643,7 +643,7 @@ impl Niri {
|
||||
let xdg_decoration_state = XdgDecorationState::new::<State>(&display_handle);
|
||||
let kde_decoration_state = KdeDecorationState::new::<State>(
|
||||
&display_handle,
|
||||
if config_.prefer_no_csd {
|
||||
if config_.clients.prefer_no_csd {
|
||||
KdeDecorationsMode::Server
|
||||
} else {
|
||||
KdeDecorationsMode::Client
|
||||
|
Reference in New Issue
Block a user