mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-22 02:01:55 +07: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 {
|
cursor {
|
||||||
// Change the theme and size of the cursor as well as set the
|
// Change the theme and size of the cursor as well as set the
|
||||||
// `XCURSOR_THEME` and `XCURSOR_SIZE` env variables.
|
// `XCURSOR_THEME` and `XCURSOR_SIZE` env variables.
|
||||||
@@ -148,10 +143,17 @@ cursor {
|
|||||||
// xcursor-size 24
|
// xcursor-size 24
|
||||||
}
|
}
|
||||||
|
|
||||||
// Uncomment this line to ask the clients to omit their client-side decorations if possible.
|
clients {
|
||||||
// If the client will specifically ask for CSD, the request will be honored.
|
// Uncomment this line to ask the clients to omit their client-side decorations if possible.
|
||||||
// Additionally, clients will be informed that they are tiled, removing some rounded corners.
|
// If the client will specifically ask for CSD, the request will be honored.
|
||||||
// prefer-no-csd
|
// 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 {
|
screenshot-ui {
|
||||||
// You can change the path where screenshots are saved.
|
// You can change the path where screenshots are saved.
|
||||||
|
|||||||
+19
-9
@@ -14,12 +14,10 @@ pub struct Config {
|
|||||||
pub input: Input,
|
pub input: Input,
|
||||||
#[knuffel(children(name = "output"))]
|
#[knuffel(children(name = "output"))]
|
||||||
pub outputs: Vec<Output>,
|
pub outputs: Vec<Output>,
|
||||||
#[knuffel(children(name = "spawn-at-startup"))]
|
|
||||||
pub spawn_at_startup: Vec<SpawnAtStartup>,
|
|
||||||
#[knuffel(child, default)]
|
#[knuffel(child, default)]
|
||||||
pub layout: Layout,
|
pub layout: Layout,
|
||||||
#[knuffel(child, default)]
|
#[knuffel(child, default)]
|
||||||
pub prefer_no_csd: bool,
|
pub clients: Clients,
|
||||||
#[knuffel(child, default)]
|
#[knuffel(child, default)]
|
||||||
pub cursor: Cursor,
|
pub cursor: Cursor,
|
||||||
#[knuffel(child, default)]
|
#[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)]
|
#[derive(knuffel::Decode, Debug, PartialEq)]
|
||||||
pub struct Cursor {
|
pub struct Cursor {
|
||||||
#[knuffel(child, unwrap(argument), default = String::from("default"))]
|
#[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 {
|
cursor {
|
||||||
xcursor-theme "breeze_cursors"
|
xcursor-theme "breeze_cursors"
|
||||||
@@ -774,10 +782,12 @@ mod tests {
|
|||||||
bottom: 0,
|
bottom: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
spawn_at_startup: vec![SpawnAtStartup {
|
clients: Clients {
|
||||||
command: vec!["alacritty".to_owned(), "-e".to_owned(), "fish".to_owned()],
|
spawn_at_startup: vec![SpawnAtStartup {
|
||||||
}],
|
command: vec!["alacritty".to_owned(), "-e".to_owned(), "fish".to_owned()],
|
||||||
prefer_no_csd: true,
|
}],
|
||||||
|
prefer_no_csd: true,
|
||||||
|
},
|
||||||
cursor: Cursor {
|
cursor: Cursor {
|
||||||
xcursor_theme: String::from("breeze_cursors"),
|
xcursor_theme: String::from("breeze_cursors"),
|
||||||
xcursor_size: 16,
|
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
|
// 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.
|
// rid of the various client-side rounded corners also by using the tiled state.
|
||||||
let config = self.niri.config.borrow();
|
let config = self.niri.config.borrow();
|
||||||
if config.prefer_no_csd {
|
if config.clients.prefer_no_csd {
|
||||||
window.toplevel().with_pending_state(|state| {
|
window.toplevel().with_pending_state(|state| {
|
||||||
state.states.set(xdg_toplevel::State::TiledLeft);
|
state.states.set(xdg_toplevel::State::TiledLeft);
|
||||||
state.states.set(xdg_toplevel::State::TiledRight);
|
state.states.set(xdg_toplevel::State::TiledRight);
|
||||||
@@ -192,7 +192,7 @@ delegate_xdg_shell!(State);
|
|||||||
|
|
||||||
impl XdgDecorationHandler for State {
|
impl XdgDecorationHandler for State {
|
||||||
fn new_decoration(&mut self, toplevel: ToplevelSurface) {
|
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)
|
Some(zxdg_toplevel_decoration_v1::Mode::ServerSide)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@@ -214,7 +214,7 @@ impl XdgDecorationHandler for State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn unset_mode(&mut self, toplevel: ToplevelSurface) {
|
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)
|
Some(zxdg_toplevel_decoration_v1::Mode::ServerSide)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|||||||
+1
-1
@@ -138,7 +138,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
animation::ANIMATION_SLOWDOWN.store(config.debug.animation_slowdown, Ordering::Relaxed);
|
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.
|
// Create the compositor.
|
||||||
let mut event_loop = EventLoop::try_new().unwrap();
|
let mut event_loop = EventLoop::try_new().unwrap();
|
||||||
|
|||||||
+1
-1
@@ -643,7 +643,7 @@ impl Niri {
|
|||||||
let xdg_decoration_state = XdgDecorationState::new::<State>(&display_handle);
|
let xdg_decoration_state = XdgDecorationState::new::<State>(&display_handle);
|
||||||
let kde_decoration_state = KdeDecorationState::new::<State>(
|
let kde_decoration_state = KdeDecorationState::new::<State>(
|
||||||
&display_handle,
|
&display_handle,
|
||||||
if config_.prefer_no_csd {
|
if config_.clients.prefer_no_csd {
|
||||||
KdeDecorationsMode::Server
|
KdeDecorationsMode::Server
|
||||||
} else {
|
} else {
|
||||||
KdeDecorationsMode::Client
|
KdeDecorationsMode::Client
|
||||||
|
|||||||
Reference in New Issue
Block a user