diff --git a/.run/Run AquariWM (Wayland).run.xml b/.run/Run AquariWM (Wayland).run.xml new file mode 100644 index 0000000..44bc9e9 --- /dev/null +++ b/.run/Run AquariWM (Wayland).run.xml @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/.run/Run AquariWM (X11).run.xml b/.run/Run AquariWM (X11).run.xml new file mode 100644 index 0000000..75fe281 --- /dev/null +++ b/.run/Run AquariWM (X11).run.xml @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/src/cli.rs b/src/cli.rs index d5d9e9d..4e7cb06 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -16,6 +16,10 @@ pub struct Cli { #[arg(long = "no-testing", alias = "no-test", overrides_with = "testing")] pub no_testing: bool, + #[arg(long = "window-gap", alias = "gap")] + /// The gap between windows in a tiling layout. + pub window_gap: Option, + #[command(subcommand)] pub subcommand: Subcommand, } diff --git a/src/display_server.rs b/src/display_server.rs index 6197882..3d0b4db 100644 --- a/src/display_server.rs +++ b/src/display_server.rs @@ -9,6 +9,8 @@ pub use wayland::Wayland; #[cfg(feature = "x11")] pub use x11::X11; +use crate::layout::LayoutSettings; + #[cfg(feature = "wayland")] pub mod wayland; #[cfg(feature = "x11")] @@ -24,7 +26,7 @@ pub trait DisplayServer { const NAME: &'static str; /// Runs the AquariWM implementation for this display server. - fn run(testing: bool) -> Self::Output; + fn run(testing: bool, settings: LayoutSettings) -> Self::Output; /// Returns AquariWM's title, formatted with the display server [`NAME`]. /// diff --git a/src/display_server/wayland.rs b/src/display_server/wayland.rs index 0a5a4c7..577dfe1 100644 --- a/src/display_server/wayland.rs +++ b/src/display_server/wayland.rs @@ -24,7 +24,10 @@ use smithay::{ use thiserror::Error; use tracing::{event, span, Level}; -use crate::display_server::{DisplayServer, SyncDisplayServer}; +use crate::{ + display_server::{DisplayServer, SyncDisplayServer}, + layout::LayoutSettings, +}; pub mod grabs; mod input; @@ -62,14 +65,14 @@ impl DisplayServer for Wayland { type Output = Result<(), Error>; const NAME: &'static str = "Wayland"; - fn run(testing: bool) -> Result<(), Error> { + fn run(testing: bool, settings: LayoutSettings) -> Result<(), Error> { // Log initialisation. let init_span = span!(Level::INFO, "Initialising").entered(); // Create an event loop for the compositor to run with. let mut event_loop = >::try_new()?; // Initialise the AquariWM state. - let mut state = state::WaylandState::new(Display::new()?, &mut event_loop); + let mut state = state::WaylandState::new(Display::new()?, &mut event_loop, settings); // Init winit for testing if the testing feature is enabled. #[cfg(feature = "testing")] diff --git a/src/display_server/wayland/state.rs b/src/display_server/wayland/state.rs index 3f790a1..23386ed 100644 --- a/src/display_server/wayland/state.rs +++ b/src/display_server/wayland/state.rs @@ -292,7 +292,7 @@ delegate_shm!(WaylandState); // }}} impl WaylandState { - pub fn new(display: Display, event_loop: &mut EventLoop) -> Self { + pub fn new(display: Display, event_loop: &mut EventLoop, settings: LayoutSettings) -> Self { let start_time = time::Instant::now(); let display_handle = display.handle(); @@ -319,7 +319,7 @@ impl WaylandState { space: Space::default(), loop_signal: event_loop.get_signal(), - aquariwm_state: crate::state::AquariWm::new(LayoutSettings::default()), + aquariwm_state: crate::state::AquariWm::new(settings), // A whole bunch of Smithay-related state. compositor_state: CompositorState::new::(&display_handle), diff --git a/src/display_server/x11.rs b/src/display_server/x11.rs index c15cae4..9dd6d9f 100644 --- a/src/display_server/x11.rs +++ b/src/display_server/x11.rs @@ -83,7 +83,7 @@ impl DisplayServer for X11 { type Output = impl Future>; const NAME: &'static str = "X11"; - fn run(testing: bool) -> Self::Output { + fn run(testing: bool, settings: LayoutSettings) -> Self::Output { async move { let init_span = span!(Level::INFO, "Initialisation").entered(); @@ -167,7 +167,7 @@ impl DisplayServer for X11 { width as u32, height as u32, wm.query_windows().await?, - LayoutSettings::default(), + settings, ); if testing { diff --git a/src/layout.rs b/src/layout.rs index 1aee614..f0fe124 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -31,7 +31,7 @@ pub struct LayoutSettings { /// /// [nodes]: Node /// [tiling layout]: TilingLayout - #[default = 10] + #[default = 15] pub window_gap: u32, } diff --git a/src/main.rs b/src/main.rs index 5a2fa67..dac97fe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,7 +13,7 @@ use std::{env, ffi::OsString, io, process}; use clap::Parser; use thiserror::Error; -use crate::display_server::DisplayServer; +use crate::{display_server::DisplayServer, layout::LayoutSettings}; mod cli; pub mod display_server; @@ -49,16 +49,21 @@ fn main() -> Result<()> { // Whether testing is enabled. let testing = args.testing(); + let settings = match args.window_gap { + Some(window_gap) => LayoutSettings::new().window_gap(window_gap), + None => LayoutSettings::default(), + }; + match &args.subcommand { #[cfg(feature = "wayland")] - cli::Subcommand::Wayland => Ok(display_server::Wayland::run(testing)?), + cli::Subcommand::Wayland => Ok(display_server::Wayland::run(testing, settings)?), #[cfg(feature = "x11")] cli::Subcommand::X11 => Ok(tokio::runtime::Builder::new_multi_thread() .enable_all() .build() .unwrap() - .block_on(async { display_server::X11::run(testing).await })?), + .block_on(async { display_server::X11::run(testing, settings).await })?), } }