Skip to content

Commit

Permalink
layouts: take coordinates into account (layouts now working in X11!)
Browse files Browse the repository at this point in the history
  • Loading branch information
Antikyth committed Nov 19, 2023
1 parent e583e6d commit d095b9a
Show file tree
Hide file tree
Showing 5 changed files with 228 additions and 95 deletions.
19 changes: 14 additions & 5 deletions src/display_server/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl DisplayServer for X11 {
let setup = connection.setup();
let screen = &setup.roots[screen_num];
// Get the root window of the screen.
let root = screen.root;
let (width, height, root) = (screen.width_in_pixels, screen.height_in_pixels, screen.root);

// Wrap the connection to provide easy access to utility methods.
let wm = Self { conn: connection, root };
Expand All @@ -124,7 +124,13 @@ impl DisplayServer for X11 {
},
}

let mut state = state::AquariWm::with_windows(wm.query_windows().await?);
let mut state = state::AquariWm::with_tiling_layout_and_windows::<layout::managers::Stack<x11::Window>>(
0,
0,
width as u32,
height as u32,
wm.query_windows().await?,
);

if testing {
event!(Level::INFO, "Testing mode enabled");
Expand All @@ -139,7 +145,7 @@ impl DisplayServer for X11 {
init_span.exit();
let event_loop_span = span!(Level::DEBUG, "Event loop");

let resize_window = |window: &_, width, height| wm.resize_window(*window, width, height);
let resize_window = |window: &_, x, y, width, height| wm.reconfigure_window(*window, x, y, width, height);

loop {
let _span = event_loop_span.enter();
Expand Down Expand Up @@ -214,10 +220,13 @@ impl X11 {
///
/// The `resize_window` closure is required because
/// [`state::AquariWm::apply_changes_async`] does not expect a [`Self`] parameter.
async fn resize_window(&self, window: x11::Window, width: u32, height: u32) -> Result<()> {
async fn reconfigure_window(&self, window: x11::Window, x: i32, y: i32, width: u32, height: u32) -> Result<()> {
Ok(self
.conn
.configure_window(window, &x11::ConfigureWindowAux::new().width(width).height(height))
.configure_window(
window,
&x11::ConfigureWindowAux::new().x(x).y(y).width(width).height(height),
)
.await?
.check()
.await?)
Expand Down
12 changes: 11 additions & 1 deletion src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ mod implementations;
/// Default [layout managers] that come with AquariWM.
///
/// [layout managers]: TilingLayoutManager
mod managers;
pub mod managers;

/// Whether a window is [`Tiled`] or [`Floating`].
///
Expand Down Expand Up @@ -145,11 +145,18 @@ pub struct GroupNode<Window> {
/// [`add_window`]: TilingLayoutManager::add_window
/// [`remove_window`]: TilingLayoutManager::remove_window
new_orientation: Option<Orientation>,

new_width: Option<u32>,
new_height: Option<u32>,

new_x: Option<i32>,
new_y: Option<i32>,

width: u32,
height: u32,

x: i32,
y: i32,
}

/// Represents a [node] containing a window.
Expand All @@ -166,6 +173,9 @@ pub struct WindowNode<Window> {

width: u32,
height: u32,

x: i32,
y: i32,
}

/// Manages a [tiling layout], restructuring the layout when a window needs to be [added] or
Expand Down
Loading

0 comments on commit d095b9a

Please sign in to comment.