Skip to content

Commit 78c67e5

Browse files
committed
feat: stack layout
1 parent 50b50b3 commit 78c67e5

File tree

10 files changed

+527
-8
lines changed

10 files changed

+527
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
- Binary Space Partitioning (bspwm-like)
2727
- Master-stack (dwm-like)
2828
- Scrolling columns (niri-style)
29+
- Stack (accordion)
2930
- Menubar icon that opens a menu for switching workspaces, changing layouts, and accessing quick Rift controls <details> <summary><sup>click to see the menu bar icon</sup></summary><img src="assets/menu_menu.png" alt="Rift menu bar icon" /></details>
3031
- MacOS-style mission control that allows you to visually navigate between workspaces <details><summary><sup>click to see mission control</sup></summary><img src="assets/mission_control.png" alt="Rift Mission Control view" /></details>
3132
- Focus follows the mouse with auto raise

rift.default.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ hot_reload = true
6868
# Layout Types:
6969
# - "traditional" (i3/sway-like containers)
7070
# - "bsp" (binary space partitioning),
71+
# - "stack" (single stacked container)
7172
# - "master_stack" (master area + stack area)
7273
# defaults to "traditional" if omitted
7374
#
@@ -238,7 +239,7 @@ reapply_app_rules_on_title_change = false
238239

239240
# Workspace-specific rules
240241
# - workspace: target workspace by index (integer) or name (string)
241-
# - layout: layout mode to use ("traditional", "bsp", "master_stack", "scrolling")
242+
# - layout: layout mode to use ("traditional", "bsp", "stack", "master_stack", "scrolling")
242243
# workspace_rules = [
243244
# { workspace = 1, layout = "bsp" },
244245
# { workspace = "second", layout = "scrolling" }
@@ -348,8 +349,8 @@ comb1 = "Alt + Shift"
348349
# - move_window_to_workspace = N / move_window_to_workspace = { workspace = N, window_id = 123 } (optional window id)
349350
# - create_workspace
350351
# - switch_to_last_workspace
351-
# - set_workspace_layout = { mode = "traditional"|"bsp"|"master_stack"|"scrolling" } (active workspace)
352-
# - set_workspace_layout = { workspace = N, mode = "traditional"|"bsp"|"master_stack"|"scrolling" }
352+
# - set_workspace_layout = { mode = "traditional"|"bsp"|"stack"|"master_stack"|"scrolling" } (active workspace)
353+
# - set_workspace_layout = { workspace = N, mode = "traditional"|"bsp"|"stack"|"master_stack"|"scrolling" }
353354
# - next_window / prev_window (focus wraps when it reaches last window in current workspace)
354355
# - ascend / descend
355356
# - move_focus = "left"|"right"|"up"|"down"

src/bin/rift-cli.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ enum WorkspaceCommands {
188188
/// Workspace index (0-based). Defaults to active workspace if omitted.
189189
#[arg(long)]
190190
workspace_id: Option<usize>,
191-
/// Layout mode: traditional, bsp, master_stack, scrolling
191+
/// Layout mode: traditional, bsp, stack, master_stack, scrolling
192192
mode: String,
193193
},
194194
}
@@ -613,10 +613,11 @@ fn parse_layout_mode(value: &str) -> Result<LayoutMode, String> {
613613
match value.trim().to_ascii_lowercase().as_str() {
614614
"traditional" => Ok(LayoutMode::Traditional),
615615
"bsp" => Ok(LayoutMode::Bsp),
616+
"stack" => Ok(LayoutMode::Stack),
616617
"master_stack" => Ok(LayoutMode::MasterStack),
617618
"scrolling" => Ok(LayoutMode::Scrolling),
618619
other => Err(format!(
619-
"Invalid layout mode '{}'; must be traditional, bsp, master_stack, or scrolling",
620+
"Invalid layout mode '{}'; must be traditional, bsp, stack, master_stack, or scrolling",
620621
other
621622
)),
622623
}

src/common/config.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ impl StackLineSettings {
551551
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Default)]
552552
#[serde(deny_unknown_fields)]
553553
pub struct LayoutSettings {
554-
/// Layout mode: "traditional" (i3/sway style containers)
554+
/// Layout mode: "traditional", "bsp", "stack", "master_stack", or "scrolling"
555555
#[serde(default)]
556556
pub mode: LayoutMode,
557557
/// Stack system configuration
@@ -577,6 +577,8 @@ pub enum LayoutMode {
577577
Traditional,
578578
/// Binary space partitioning tiling
579579
Bsp,
580+
/// Dedicated stacked layout (single stack container)
581+
Stack,
580582
/// Master/stack layout (master area + stack area)
581583
MasterStack,
582584
/// Scrolling column layout (niri-style)
@@ -588,6 +590,7 @@ impl ToString for LayoutMode {
588590
match self {
589591
LayoutMode::Traditional => "traditional".to_string(),
590592
LayoutMode::Bsp => "bsp".to_string(),
593+
LayoutMode::Stack => "stack".to_string(),
591594
LayoutMode::MasterStack => "master_stack".to_string(),
592595
LayoutMode::Scrolling => "scrolling".to_string(),
593596
}
@@ -1070,7 +1073,9 @@ fn yes() -> bool { true }
10701073

10711074
fn default_stack_offset() -> f64 { 40.0 }
10721075

1073-
fn default_stack_orientation() -> StackDefaultOrientation { StackDefaultOrientation::Perpendicular }
1076+
pub fn default_stack_orientation() -> StackDefaultOrientation {
1077+
StackDefaultOrientation::Perpendicular
1078+
}
10741079

10751080
fn default_master_stack_new_window_placement() -> MasterStackNewWindowPlacement {
10761081
MasterStackNewWindowPlacement::Master

src/layout_engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub use graph::{Direction, LayoutKind, Orientation};
1111
pub(crate) use systems::LayoutId;
1212
pub use systems::{
1313
BspLayoutSystem, LayoutSystem, LayoutSystemKind, MasterStackLayoutSystem,
14-
ScrollingLayoutSystem, TraditionalLayoutSystem,
14+
ScrollingLayoutSystem, StackLayoutSystem, TraditionalLayoutSystem,
1515
};
1616
pub(crate) use workspaces::WorkspaceLayouts;
1717

src/layout_engine/engine.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,29 @@ impl LayoutEngine {
330330
)
331331
}
332332
}
333+
LayoutSystemKind::Stack(s) => {
334+
if selection_path_only {
335+
s.collect_group_containers_in_selection_path(
336+
layout_id,
337+
screen,
338+
stack_offset,
339+
gaps,
340+
stack_line_thickness,
341+
stack_line_horiz,
342+
stack_line_vert,
343+
)
344+
} else {
345+
s.collect_group_containers(
346+
layout_id,
347+
screen,
348+
stack_offset,
349+
gaps,
350+
stack_line_thickness,
351+
stack_line_horiz,
352+
stack_line_vert,
353+
)
354+
}
355+
}
333356
LayoutSystemKind::MasterStack(s) => {
334357
if selection_path_only {
335358
s.collect_group_containers_in_selection_path(
@@ -364,6 +387,9 @@ impl LayoutEngine {
364387

365388
for (_, ws) in self.virtual_workspace_manager.workspaces.iter_mut() {
366389
match &mut ws.layout_system {
390+
LayoutSystemKind::Stack(system) => {
391+
system.update_settings(settings.stack.default_orientation);
392+
}
367393
LayoutSystemKind::MasterStack(system) => {
368394
system.update_settings(settings.master_stack.clone());
369395
}
@@ -405,6 +431,7 @@ impl LayoutEngine {
405431
match self.workspace_tree(ws_id) {
406432
LayoutSystemKind::Traditional(_) => "traditional",
407433
LayoutSystemKind::Bsp(_) => "bsp",
434+
LayoutSystemKind::Stack(_) => "stack",
408435
LayoutSystemKind::MasterStack(_) => "master_stack",
409436
LayoutSystemKind::Scrolling(_) => "scrolling",
410437
}
@@ -418,6 +445,7 @@ impl LayoutEngine {
418445
match self.workspace_tree(ws_id) {
419446
LayoutSystemKind::Traditional(_) => crate::common::config::LayoutMode::Traditional,
420447
LayoutSystemKind::Bsp(_) => crate::common::config::LayoutMode::Bsp,
448+
LayoutSystemKind::Stack(_) => crate::common::config::LayoutMode::Stack,
421449
LayoutSystemKind::MasterStack(_) => crate::common::config::LayoutMode::MasterStack,
422450
LayoutSystemKind::Scrolling(_) => crate::common::config::LayoutMode::Scrolling,
423451
}
@@ -1589,6 +1617,9 @@ impl LayoutEngine {
15891617
LayoutSystemKind::Bsp(s) => {
15901618
Self::toggle_orientation_for_system(s, layout, default_orientation)
15911619
}
1620+
LayoutSystemKind::Stack(s) => {
1621+
Self::toggle_orientation_for_system(s, layout, default_orientation)
1622+
}
15921623
LayoutSystemKind::MasterStack(s) => {
15931624
Self::toggle_orientation_for_system(s, layout, default_orientation)
15941625
}

src/layout_engine/systems.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ mod master_stack;
104104
pub use master_stack::MasterStackLayoutSystem;
105105
mod scrolling;
106106
pub use scrolling::ScrollingLayoutSystem;
107+
mod stack;
108+
pub use stack::StackLayoutSystem;
107109

108110
#[derive(Serialize, Deserialize)]
109111
#[serde(tag = "kind", rename_all = "snake_case")]
@@ -114,4 +116,5 @@ pub enum LayoutSystemKind {
114116
Bsp(BspLayoutSystem),
115117
MasterStack(MasterStackLayoutSystem),
116118
Scrolling(ScrollingLayoutSystem),
119+
Stack(StackLayoutSystem),
117120
}

0 commit comments

Comments
 (0)