Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat: it compiles

Lars Bergerdac64cade456
diff --git a/Cargo.toml b/Cargo.toml
index 067f4ff7..7f116ec6 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,7 +24,3 @@ windows = { version = "0.52", features = [
"Win32_UI_WindowsAndMessaging",
"Win32_System_SystemServices",
] }
-
-[unstable]
-# Enables Cargo artifact dependencies.
-bindeps = true
diff --git a/packages/wm/Cargo.toml b/packages/wm/Cargo.toml
index 43433903..2b833b8e 100644
--- a/packages/wm/Cargo.toml
+++ b/packages/wm/Cargo.toml
@@ -25,7 +25,3 @@ tracing = "0.1"
tracing-subscriber = "0.3"
windows = { workspace = true }
wineventhook = "0.9"
-
-[unstable]
-# Enables Cargo artifact dependencies.
-bindeps = true
diff --git a/packages/wm/src/containers/container.rs b/packages/wm/src/containers/container.rs
index 131e8469..af051fbe 100644
--- a/packages/wm/src/containers/container.rs
+++ b/packages/wm/src/containers/container.rs
@@ -2,7 +2,6 @@ use std::{
cell::RefCell,
collections::VecDeque,
rc::{Rc, Weak},
- sync::Arc,
};
use uuid::Uuid;
@@ -26,17 +25,13 @@ pub struct InnerContainer {
}
impl InnerContainer {
- pub fn new(
- parent: Option<Arc<Container>>,
- children: Vec<Arc<Container>>,
- ) -> Self {
+ pub fn new(container_type: ContainerType) -> Self {
Self {
id: Uuid::new_v4(),
- // TODO
- container_type: ContainerType::RootContainer,
- parent,
- children,
- child_focus_order: children,
+ container_type,
+ parent: None,
+ children: VecDeque::new(),
+ child_focus_order: VecDeque::new(),
}
}
}
@@ -71,107 +66,107 @@ impl Container {
}
}
- /// Height of the container. Implementation varies by container type.
- pub fn height(&self) -> u32 {
- match self.value {
- Self::Monitor(c) => c.height,
- Self::Workspace(c) => c.height,
- Self::SplitContainer(c) => c.height(),
- Self::Window(c) => c.height(),
- _ => 0,
- }
- }
-
- /// Width of the container. Implementation varies by container type.
- pub fn width(&self) -> u32 {
- match self.value {
- Self::Monitor(c) => c.width,
- Self::Workspace(c) => c.width,
- Self::SplitContainer(c) => c.width(),
- Self::Window(c) => c.width(),
- _ => 0,
- }
- }
-
- /// X-coordinate of the container. Implementation varies by container type.
- pub fn x(&self) -> u32 {
- match self.value {
- Self::Monitor(c) => c.x,
- Self::Workspace(c) => c.x,
- Self::SplitContainer(c) => c.x(),
- Self::Window(c) => c.x(),
- _ => 0,
- }
- }
-
- /// Y-coordinate of the container. Implementation varies by container type.
- pub fn y(&self) -> u32 {
- match self.value {
- Self::Monitor(c) => c.y,
- Self::Workspace(c) => c.y,
- Self::SplitContainer(c) => c.y(),
- Self::Window(c) => c.y(),
- _ => 0,
- }
- }
-
- /// Whether the container can be tiled.
- pub fn can_tile(&self) -> bool {
- match self.value {
- Self::Window(c) => c.state == WindowState::Tiling,
- _ => true,
- }
- }
-
- /// Unique identifier for the container.
- fn id(&self) -> Uuid {
- self.inner().id
- }
-
- pub fn parent(&self) -> Option<Arc<Container>> {
- self.inner().parent.clone()
- }
-
- pub fn set_parent(&mut self, parent: Option<Arc<Container>>) {
- self.inner_mut().parent = parent;
- }
-
- pub fn children(&self) -> Vec<Arc<Container>> {
- self.inner().children.clone()
- }
-
- pub fn set_children(&self, children: Vec<Arc<Container>>) {
- self.inner().children = children;
- }
-
- /// Order of which child containers last had focus.
- pub fn child_focus_order(&self) -> Vec<Arc<Container>> {
- self.inner().child_focus_order.clone()
- }
-
- pub fn set_child_focus_order(
- &mut self,
- child_focus_order: Vec<Arc<Container>>,
- ) {
- self.inner().child_focus_order = child_focus_order;
- }
-
- /// Child container that last had focus.
- pub fn last_focused_child(&self) -> Option<Arc<Container>> {
- self.child_focus_order().get(0).cloned()
- }
-
- /// Index of this container in parent's child focus order.
- pub fn focus_index(&self) -> u32 {
- match &self.inner().parent {
- None => 0,
- Some(p) => p
- .child_focus_order()
- .iter()
- .position(|child| child.id() == self.id())
- .unwrap()
- .try_into()
- .unwrap(),
- }
- }
+ // / Height of the container. Implementation varies by container type.
+ // pub fn height(&self) -> u32 {
+ // match self.value {
+ // Self::Monitor(c) => c.height,
+ // Self::Workspace(c) => c.height,
+ // Self::SplitContainer(c) => c.height(),
+ // Self::Window(c) => c.height(),
+ // _ => 0,
+ // }
+ // }
+
+ // /// Width of the container. Implementation varies by container type.
+ // pub fn width(&self) -> u32 {
+ // match self.value {
+ // Self::Monitor(c) => c.width,
+ // Self::Workspace(c) => c.width,
+ // Self::SplitContainer(c) => c.width(),
+ // Self::Window(c) => c.width(),
+ // _ => 0,
+ // }
+ // }
+
+ // /// X-coordinate of the container. Implementation varies by container type.
+ // pub fn x(&self) -> u32 {
+ // match self.value {
+ // Self::Monitor(c) => c.x,
+ // Self::Workspace(c) => c.x,
+ // Self::SplitContainer(c) => c.x(),
+ // Self::Window(c) => c.x(),
+ // _ => 0,
+ // }
+ // }
+
+ // /// Y-coordinate of the container. Implementation varies by container type.
+ // pub fn y(&self) -> u32 {
+ // match self.value {
+ // Self::Monitor(c) => c.y,
+ // Self::Workspace(c) => c.y,
+ // Self::SplitContainer(c) => c.y(),
+ // Self::Window(c) => c.y(),
+ // _ => 0,
+ // }
+ // }
+
+ // /// Whether the container can be tiled.
+ // pub fn can_tile(&self) -> bool {
+ // match self.value {
+ // Self::Window(c) => c.state == WindowState::Tiling,
+ // _ => true,
+ // }
+ // }
+
+ // /// Unique identifier for the container.
+ // fn id(&self) -> Uuid {
+ // self.inner().id
+ // }
+
+ // pub fn parent(&self) -> Option<Arc<Container>> {
+ // self.inner().parent.clone()
+ // }
+
+ // pub fn set_parent(&mut self, parent: Option<Arc<Container>>) {
+ // self.inner_mut().parent = parent;
+ // }
+
+ // pub fn children(&self) -> Vec<Arc<Container>> {
+ // self.inner().children.clone()
+ // }
+
+ // pub fn set_children(&self, children: Vec<Arc<Container>>) {
+ // self.inner().children = children;
+ // }
+
+ // /// Order of which child containers last had focus.
+ // pub fn child_focus_order(&self) -> Vec<Arc<Container>> {
+ // self.inner().child_focus_order.clone()
+ // }
+
+ // pub fn set_child_focus_order(
+ // &mut self,
+ // child_focus_order: Vec<Arc<Container>>,
+ // ) {
+ // self.inner().child_focus_order = child_focus_order;
+ // }
+
+ // /// Child container that last had focus.
+ // pub fn last_focused_child(&self) -> Option<Arc<Container>> {
+ // self.child_focus_order().get(0).cloned()
+ // }
+
+ // /// Index of this container in parent's child focus order.
+ // pub fn focus_index(&self) -> u32 {
+ // match &self.inner().parent {
+ // None => 0,
+ // Some(p) => p
+ // .child_focus_order()
+ // .iter()
+ // .position(|child| child.id() == self.id())
+ // .unwrap()
+ // .try_into()
+ // .unwrap(),
+ // }
+ // }
}
diff --git a/packages/wm/src/containers/root_container.rs b/packages/wm/src/containers/root_container.rs
index 69f80578..099656fa 100644
--- a/packages/wm/src/containers/root_container.rs
+++ b/packages/wm/src/containers/root_container.rs
@@ -1,4 +1,4 @@
-use super::InnerContainer;
+use super::{ContainerType, InnerContainer};
#[derive(Debug)]
pub struct RootContainer {
@@ -12,7 +12,7 @@ pub struct RootContainer {
impl RootContainer {
pub fn new() -> Self {
Self {
- inner: InnerContainer::new(None, vec![]),
+ inner: InnerContainer::new(ContainerType::RootContainer),
width: 0,
height: 0,
x: 0,
diff --git a/packages/wm/src/containers/split_container.rs b/packages/wm/src/containers/split_container.rs
index 6a4d74bb..0b06b6f0 100644
--- a/packages/wm/src/containers/split_container.rs
+++ b/packages/wm/src/containers/split_container.rs
@@ -1,6 +1,6 @@
use crate::containers::ContainerType;
-use super::{ContainerVariant, InnerContainer};
+use super::InnerContainer;
#[derive(Debug)]
pub struct SplitContainer {
@@ -14,7 +14,7 @@ pub struct SplitContainer {
impl SplitContainer {
pub fn new() -> Self {
Self {
- inner: InnerContainer::new(None, vec![]),
+ inner: InnerContainer::new(ContainerType::SplitContainer),
width: 0,
height: 0,
x: 0,
@@ -22,29 +22,3 @@ impl SplitContainer {
}
}
}
-
-impl ContainerVariant for SplitContainer {
- fn inner(&self) -> InnerContainer {
- self.inner
- }
-
- fn r#type(&self) -> ContainerType {
- ContainerType::SplitContainer
- }
-
- fn height(&self) -> u32 {
- self.height
- }
-
- fn width(&self) -> u32 {
- self.width
- }
-
- fn x(&self) -> u32 {
- self.x
- }
-
- fn y(&self) -> u32 {
- self.y
- }
-}
diff --git a/packages/wm/src/monitors/monitor.rs b/packages/wm/src/monitors/monitor.rs
index a74ec199..46394842 100644
--- a/packages/wm/src/monitors/monitor.rs
+++ b/packages/wm/src/monitors/monitor.rs
@@ -1,4 +1,4 @@
-use crate::containers::{ContainerType, ContainerVariant, InnerContainer};
+use crate::containers::{ContainerType, InnerContainer};
#[derive(Debug)]
pub struct Monitor {
@@ -19,7 +19,7 @@ impl Monitor {
y: u32,
) -> Self {
Self {
- inner: InnerContainer::new(None, vec![]),
+ inner: InnerContainer::new(ContainerType::Monitor),
device_name,
width,
height,
@@ -28,29 +28,3 @@ impl Monitor {
}
}
}
-
-// impl ContainerVariant for Monitor {
-// fn inner(&self) -> InnerContainer {
-// self.inner
-// }
-
-// fn r#type(&self) -> ContainerType {
-// ContainerType::Monitor
-// }
-
-// fn height(&self) -> u32 {
-// self.height
-// }
-
-// fn width(&self) -> u32 {
-// self.width
-// }
-
-// fn x(&self) -> u32 {
-// self.x
-// }
-
-// fn y(&self) -> u32 {
-// self.y
-// }
-// }
diff --git a/packages/wm/src/windows/window.rs b/packages/wm/src/windows/window.rs
index 9a7a87be..1badffb1 100644
--- a/packages/wm/src/windows/window.rs
+++ b/packages/wm/src/windows/window.rs
@@ -1,4 +1,4 @@
-use crate::containers::InnerContainer;
+use crate::containers::{ContainerType, InnerContainer};
#[derive(Debug)]
pub struct Window {
@@ -12,7 +12,7 @@ pub struct Window {
impl Window {
pub fn new() -> Self {
Self {
- inner: InnerContainer::new(None, vec![]),
+ inner: InnerContainer::new(ContainerType::Window),
width: 0,
height: 0,
x: 0,
diff --git a/packages/wm/src/workspaces/workspace.rs b/packages/wm/src/workspaces/workspace.rs
index 761a9271..ef44afa8 100644
--- a/packages/wm/src/workspaces/workspace.rs
+++ b/packages/wm/src/workspaces/workspace.rs
@@ -1,6 +1,6 @@
use crate::{
common::RectDelta,
- containers::{ContainerType, ContainerVariant, InnerContainer},
+ containers::{ContainerType, InnerContainer},
};
#[derive(Debug)]
@@ -20,7 +20,7 @@ impl Workspace {
outer_gaps: RectDelta,
) -> Self {
Self {
- inner: InnerContainer::new(None, vec![]),
+ inner: InnerContainer::new(ContainerType::Workspace),
name,
display_name,
keep_alive,
@@ -28,29 +28,3 @@ impl Workspace {
}
}
}
-
-impl ContainerVariant for Workspace {
- fn inner(&self) -> InnerContainer {
- self.inner
- }
-
- fn r#type(&self) -> ContainerType {
- ContainerType::Workspace
- }
-
- fn height(&self) -> u32 {
- todo!()
- }
-
- fn width(&self) -> u32 {
- todo!()
- }
-
- fn x(&self) -> u32 {
- todo!()
- }
-
- fn y(&self) -> u32 {
- todo!()
- }
-}
diff --git a/resources/sample-config.yaml b/resources/sample-config.yaml
index f537afaf..ed0851a1 100644
--- a/resources/sample-config.yaml
+++ b/resources/sample-config.yaml
@@ -41,42 +41,6 @@ focus_borders:
enabled: false
color: "#ff0000"
-bar:
- height: "30px"
- position: "top"
- opacity: 1.0
- background: "#20242cc4"
- foreground: "#ffffff"
- font_family: "Segoe UI"
- font_size: "13px"
- padding: "4px 6px"
- offset_x: "0"
- offset_y: "0"
- border_radius: "0"
- components_left:
- - type: "workspaces"
- focused_workspace_background: "#ffffff33"
- displayed_workspace_background: "#00000033"
- default_workspace_background: "transparent"
- components_center:
- - type: "window title"
- components_right:
- - type: "system tray"
- - type: "tiling direction"
- label_horizontal: "⮂"
- label_vertical: "⮁"
- background: "#ffffff33"
- margin: "0 4px"
- padding: "0 8px"
- - type: "binding mode"
- background: "#ffffff33"
- margin: "0 4px 0 0"
- padding: "0 8px"
- - type: "clock"
- # Documentation on formatting date/time string:
- # https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
- time_formatting: "hh:mm tt ddd MMM d"
-
workspaces:
- name: "1"
- name: "2"