tony / oxwm

added scrolling layout with animations. Browse files
tonybtw committed 2025-12-20 parent fa421d2 commit 5db567510170fd1fb0013d240cccea7747c48595
Showing 12 changed files with 518 additions and 4 deletions. UnifiedSplit
+4 −0 resources/test-config.lua
@@ -75,8 +75,12 @@ oxwm.key.bind({ modkey, "Shift" }, "Space", oxwm.client.toggle_floating())
75 75
76 76 oxwm.key.bind({ modkey }, "F", oxwm.layout.set("normie"))
77 77 oxwm.key.bind({ modkey }, "C", oxwm.layout.set("tiling"))
78 +oxwm.key.bind({ modkey }, "G", oxwm.layout.set("scrolling"))
78 79 oxwm.key.bind({ modkey }, "N", oxwm.layout.cycle())
79 80
81 +oxwm.key.bind({ modkey }, "Left", oxwm.layout.scroll_left())
82 +oxwm.key.bind({ modkey }, "Right", oxwm.layout.scroll_right())
83 +
80 84 oxwm.key.bind({ modkey }, "A", oxwm.toggle_gaps())
81 85
82 86 -- Master area controls
+42 −0 src/animations/mod.rs new file mode 100644
@@ -0,0 +1,42 @@
1 +mod scroll;
2 +
3 +pub use scroll::ScrollAnimation;
4 +
5 +use std::time::Duration;
6 +
7 +#[derive(Debug, Clone, Copy)]
8 +pub enum Easing {
9 + Linear,
10 + EaseOut,
11 + EaseInOut,
12 +}
13 +
14 +impl Easing {
15 + pub fn apply(&self, t: f64) -> f64 {
16 + match self {
17 + Easing::Linear => t,
18 + Easing::EaseOut => 1.0 - (1.0 - t).powi(3),
19 + Easing::EaseInOut => {
20 + if t < 0.5 {
21 + 4.0 * t * t * t
22 + } else {
23 + 1.0 - (-2.0 * t + 2.0).powi(3) / 2.0
24 + }
25 + }
26 + }
27 + }
28 +}
29 +
30 +pub struct AnimationConfig {
31 + pub duration: Duration,
32 + pub easing: Easing,
33 +}
34 +
35 +impl Default for AnimationConfig {
36 + fn default() -> Self {
37 + Self {
38 + duration: Duration::from_millis(150),
39 + easing: Easing::EaseOut,
40 + }
41 + }
42 +}
+76 −0 src/animations/scroll.rs new file mode 100644
@@ -0,0 +1,76 @@
1 +use std::time::Instant;
2 +use super::{AnimationConfig, Easing};
3 +
4 +pub struct ScrollAnimation {
5 + start_value: i32,
6 + end_value: i32,
7 + start_time: Instant,
8 + duration_ms: u64,
9 + easing: Easing,
10 + active: bool,
11 +}
12 +
13 +impl ScrollAnimation {
14 + pub fn new() -> Self {
15 + Self {
16 + start_value: 0,
17 + end_value: 0,
18 + start_time: Instant::now(),
19 + duration_ms: 150,
20 + easing: Easing::EaseOut,
21 + active: false,
22 + }
23 + }
24 +
25 + pub fn start(&mut self, from: i32, to: i32, config: &AnimationConfig) {
26 + if from == to {
27 + self.active = false;
28 + return;
29 + }
30 + self.start_value = from;
31 + self.end_value = to;
32 + self.start_time = Instant::now();
33 + self.duration_ms = config.duration.as_millis() as u64;
34 + self.easing = config.easing;
35 + self.active = true;
36 + }
37 +
38 + pub fn update(&mut self) -> Option<i32> {
39 + if !self.active {
40 + return None;
41 + }
42 +
43 + let elapsed = self.start_time.elapsed().as_millis() as u64;
44 +
45 + if elapsed >= self.duration_ms {
46 + self.active = false;
47 + return Some(self.end_value);
48 + }
49 +
50 + let t = elapsed as f64 / self.duration_ms as f64;
51 + let eased_t = self.easing.apply(t);
52 +
53 + let delta = (self.end_value - self.start_value) as f64;
54 + let current = self.start_value as f64 + delta * eased_t;
55 +
56 + Some(current.round() as i32)
57 + }
58 +
59 + pub fn is_active(&self) -> bool {
60 + self.active
61 + }
62 +
63 + pub fn target(&self) -> i32 {
64 + self.end_value
65 + }
66 +
67 + pub fn cancel(&mut self) {
68 + self.active = false;
69 + }
70 +}
71 +
72 +impl Default for ScrollAnimation {
73 + fn default() -> Self {
74 + Self::new()
75 + }
76 +}
+10 −0 src/config/lua_api.rs
@@ -298,8 +298,16 @@ fn register_layout_module(lua: &Lua, parent: &Table) -> Result<(), ConfigError>
298 298 )
299 299 })?;
300 300
301 + let scroll_left =
302 + lua.create_function(|lua, ()| create_action_table(lua, "ScrollLeft", Value::Nil))?;
303 +
304 + let scroll_right =
305 + lua.create_function(|lua, ()| create_action_table(lua, "ScrollRight", Value::Nil))?;
306 +
301 307 layout_table.set("cycle", cycle)?;
302 308 layout_table.set("set", set)?;
309 + layout_table.set("scroll_left", scroll_left)?;
310 + layout_table.set("scroll_right", scroll_right)?;
303 311 parent.set("layout", layout_table)?;
304 312 Ok(())
305 313 }
@@ -918,6 +926,8 @@ fn string_to_action(s: &str) -> mlua::Result<KeyAction> {
918 926 "FocusMonitor" => Ok(KeyAction::FocusMonitor),
919 927 "TagMonitor" => Ok(KeyAction::TagMonitor),
920 928 "ShowKeybindOverlay" => Ok(KeyAction::ShowKeybindOverlay),
929 + "ScrollLeft" => Ok(KeyAction::ScrollLeft),
930 + "ScrollRight" => Ok(KeyAction::ScrollRight),
921 931 _ => Err(mlua::Error::RuntimeError(format!(
922 932 "unknown action '{}'. this is an internal error, please report it",
923 933 s
+2 −0 src/keyboard/handlers.rs
@@ -41,6 +41,8 @@ pub enum KeyAction {
41 41 ShowKeybindOverlay,
42 42 SetMasterFactor,
43 43 IncNumMaster,
44 + ScrollLeft,
45 + ScrollRight,
44 46 None,
45 47 }
46 48
+7 −1 src/layout/mod.rs
@@ -1,6 +1,7 @@
1 1 pub mod grid;
2 2 pub mod monocle;
3 3 pub mod normie;
4 +pub mod scrolling;
4 5 pub mod tabbed;
5 6 pub mod tiling;
6 7
@@ -23,6 +24,7 @@ pub enum LayoutType {
23 24 Grid,
24 25 Monocle,
25 26 Tabbed,
27 + Scrolling,
26 28 }
27 29
28 30 impl LayoutType {
@@ -33,6 +35,7 @@ impl LayoutType {
33 35 Self::Grid => Box::new(grid::GridLayout),
34 36 Self::Monocle => Box::new(monocle::MonocleLayout),
35 37 Self::Tabbed => Box::new(tabbed::TabbedLayout),
38 + Self::Scrolling => Box::new(scrolling::ScrollingLayout),
36 39 }
37 40 }
38 41
@@ -42,7 +45,8 @@ impl LayoutType {
42 45 Self::Normie => Self::Grid,
43 46 Self::Grid => Self::Monocle,
44 47 Self::Monocle => Self::Tabbed,
45 - Self::Tabbed => Self::Tiling,
48 + Self::Tabbed => Self::Scrolling,
49 + Self::Scrolling => Self::Tiling,
46 50 }
47 51 }
48 52
@@ -53,6 +57,7 @@ impl LayoutType {
53 57 Self::Grid => "grid",
54 58 Self::Monocle => "monocle",
55 59 Self::Tabbed => "tabbed",
60 + Self::Scrolling => "scrolling",
56 61 }
57 62 }
58 63 }
@@ -67,6 +72,7 @@ impl FromStr for LayoutType {
67 72 "grid" => Ok(Self::Grid),
68 73 "monocle" => Ok(Self::Monocle),
69 74 "tabbed" => Ok(Self::Tabbed),
75 + "scrolling" => Ok(Self::Scrolling),
70 76 _ => Err(format!("Invalid Layout Type: {}", s)),
71 77 }
72 78 }
+100 −0 src/layout/scrolling.rs new file mode 100644
@@ -0,0 +1,100 @@
1 +use super::{GapConfig, Layout, WindowGeometry};
2 +use x11rb::protocol::xproto::Window;
3 +
4 +pub struct ScrollingLayout;
5 +
6 +struct GapValues {
7 + outer_horizontal: u32,
8 + outer_vertical: u32,
9 + inner_vertical: u32,
10 +}
11 +
12 +impl ScrollingLayout {
13 + fn getgaps(gaps: &GapConfig, window_count: usize, smartgaps_enabled: bool) -> GapValues {
14 + let outer_enabled = if smartgaps_enabled && window_count == 1 {
15 + 0
16 + } else {
17 + 1
18 + };
19 +
20 + GapValues {
21 + outer_horizontal: gaps.outer_horizontal * outer_enabled,
22 + outer_vertical: gaps.outer_vertical * outer_enabled,
23 + inner_vertical: gaps.inner_vertical,
24 + }
25 + }
26 +}
27 +
28 +impl Layout for ScrollingLayout {
29 + fn name(&self) -> &'static str {
30 + "scrolling"
31 + }
32 +
33 + fn symbol(&self) -> &'static str {
34 + "[>>]"
35 + }
36 +
37 + fn arrange(
38 + &self,
39 + windows: &[Window],
40 + screen_width: u32,
41 + screen_height: u32,
42 + gaps: &GapConfig,
43 + _master_factor: f32,
44 + num_master: i32,
45 + smartgaps_enabled: bool,
46 + ) -> Vec<WindowGeometry> {
47 + let window_count = windows.len();
48 + if window_count == 0 {
49 + return Vec::new();
50 + }
51 +
52 + let gap_values = Self::getgaps(gaps, window_count, smartgaps_enabled);
53 +
54 + let outer_horizontal = gap_values.outer_horizontal;
55 + let outer_vertical = gap_values.outer_vertical;
56 + let inner_vertical = gap_values.inner_vertical;
57 +
58 + let visible_count = if num_master > 0 {
59 + num_master as usize
60 + } else {
61 + 2
62 + };
63 +
64 + let available_width = screen_width.saturating_sub(2 * outer_vertical);
65 + let available_height = screen_height.saturating_sub(2 * outer_horizontal);
66 +
67 + let total_inner_gaps = if visible_count > 1 {
68 + inner_vertical * (visible_count.min(window_count) - 1) as u32
69 + } else {
70 + 0
71 + };
72 + let window_width = if window_count <= visible_count {
73 + let num_windows = window_count as u32;
74 + let total_gaps = if num_windows > 1 {
75 + inner_vertical * (num_windows - 1)
76 + } else {
77 + 0
78 + };
79 + (available_width.saturating_sub(total_gaps)) / num_windows
80 + } else {
81 + (available_width.saturating_sub(total_inner_gaps)) / visible_count as u32
82 + };
83 +
84 + let mut geometries = Vec::with_capacity(window_count);
85 + let mut x = outer_vertical as i32;
86 +
87 + for _window in windows.iter() {
88 + geometries.push(WindowGeometry {
89 + x_coordinate: x,
90 + y_coordinate: outer_horizontal as i32,
91 + width: window_width,
92 + height: available_height,
93 + });
94 +
95 + x += window_width as i32 + inner_vertical as i32;
96 + }
97 +
98 + geometries
99 + }
100 +}
+1 −0 src/lib.rs
@@ -1,5 +1,6 @@
1 1 use std::path::PathBuf;
2 2
3 +pub mod animations;
3 4 pub mod bar;
4 5 pub mod client;
5 6 pub mod config;
+2 −0 src/monitor.rs
@@ -35,6 +35,7 @@ pub struct Monitor {
35 35 pub stack_head: Option<Window>,
36 36 pub bar_window: Option<Window>,
37 37 pub layout_indices: [usize; 2],
38 + pub scroll_offset: i32,
38 39 }
39 40
40 41 impl Monitor {
@@ -67,6 +68,7 @@ impl Monitor {
67 68 stack_head: None,
68 69 bar_window: None,
69 70 layout_indices: [0, 1],
71 + scroll_offset: 0,
70 72 }
71 73 }
72 74
+2 −0 src/overlay/keybind.rs
@@ -239,6 +239,8 @@ impl KeybindOverlay {
239 239 KeyAction::TagMonitor => "Send Window to Monitor".to_string(),
240 240 KeyAction::SetMasterFactor => "Adjust Master Area Size".to_string(),
241 241 KeyAction::IncNumMaster => "Adjust Number of Master Windows".to_string(),
242 + KeyAction::ScrollLeft => "Scroll Layout Left".to_string(),
243 + KeyAction::ScrollRight => "Scroll Layout Right".to_string(),
242 244 KeyAction::None => "No Action".to_string(),
243 245 }
244 246 }
+263 −2 src/window_manager.rs
@@ -1,4 +1,5 @@
1 1 use crate::Config;
2 +use crate::animations::{AnimationConfig, ScrollAnimation};
2 3 use crate::bar::Bar;
3 4 use crate::client::{Client, TagMask};
4 5 use crate::errors::WmError;
@@ -144,6 +145,8 @@ pub struct WindowManager {
144 145 error_message: Option<String>,
145 146 overlay: ErrorOverlay,
146 147 keybind_overlay: KeybindOverlay,
148 + scroll_animation: ScrollAnimation,
149 + animation_config: AnimationConfig,
147 150 }
148 151
149 152 type WmResult<T> = Result<T, WmError>;
@@ -303,6 +306,8 @@ impl WindowManager {
303 306 error_message: None,
304 307 overlay,
305 308 keybind_overlay,
309 + scroll_animation: ScrollAnimation::new(),
310 + animation_config: AnimationConfig::default(),
306 311 };
307 312
308 313 for tab_bar in &window_manager.tab_bars {
@@ -528,6 +533,8 @@ impl WindowManager {
528 533 last_bar_update = std::time::Instant::now();
529 534 }
530 535
536 + self.tick_animations()?;
537 +
531 538 self.connection.flush()?;
532 539 std::thread::sleep(std::time::Duration::from_millis(16));
533 540 }
@@ -610,8 +617,219 @@ impl WindowManager {
610 617 Ok(())
611 618 }
612 619
620 + fn tick_animations(&mut self) -> WmResult<()> {
621 + if self.scroll_animation.is_active() {
622 + if let Some(new_offset) = self.scroll_animation.update() {
623 + if let Some(m) = self.monitors.get_mut(self.selected_monitor) {
624 + m.scroll_offset = new_offset;
625 + }
626 + self.apply_layout()?;
627 + self.update_bar()?;
628 + }
629 + }
630 + Ok(())
631 + }
632 +
633 + fn scroll_layout(&mut self, direction: i32) -> WmResult<()> {
634 + if self.layout.name() != "scrolling" {
635 + return Ok(());
636 + }
637 +
638 + let monitor_index = self.selected_monitor;
639 + let monitor = match self.monitors.get(monitor_index) {
640 + Some(m) => m.clone(),
641 + None => return Ok(()),
642 + };
643 +
644 + let visible_count = if monitor.num_master > 0 {
645 + monitor.num_master as usize
646 + } else {
647 + 2
648 + };
649 +
650 + let mut tiled_count = 0;
651 + let mut current = self.next_tiled(monitor.clients_head, &monitor);
652 + while let Some(window) = current {
653 + tiled_count += 1;
654 + if let Some(client) = self.clients.get(&window) {
655 + current = self.next_tiled(client.next, &monitor);
656 + } else {
657 + break;
658 + }
659 + }
660 +
661 + if tiled_count <= visible_count {
662 + if let Some(m) = self.monitors.get_mut(monitor_index) {
663 + m.scroll_offset = 0;
664 + }
665 + return Ok(());
666 + }
667 +
668 + let outer_gap = if self.gaps_enabled {
669 + self.config.gap_outer_vertical
670 + } else {
671 + 0
672 + };
673 + let inner_gap = if self.gaps_enabled {
674 + self.config.gap_inner_vertical
675 + } else {
676 + 0
677 + };
678 +
679 + let available_width = monitor.screen_width - 2 * outer_gap as i32;
680 + let total_inner_gaps = inner_gap as i32 * (visible_count - 1) as i32;
681 + let window_width = (available_width - total_inner_gaps) / visible_count as i32;
682 + let scroll_amount = window_width + inner_gap as i32;
683 +
684 + let total_width = tiled_count as i32 * window_width + (tiled_count - 1) as i32 * inner_gap as i32;
685 + let max_scroll = (total_width - available_width).max(0);
686 +
687 + let current_offset = monitor.scroll_offset;
688 + let target_offset = if self.scroll_animation.is_active() {
689 + self.scroll_animation.target() + direction * scroll_amount
690 + } else {
691 + current_offset + direction * scroll_amount
692 + };
693 + let target_offset = target_offset.clamp(0, max_scroll);
694 +
695 + self.scroll_animation.start(current_offset, target_offset, &self.animation_config);
696 +
697 + Ok(())
698 + }
699 +
700 + fn scroll_to_window(&mut self, target_window: Window, animate: bool) -> WmResult<()> {
701 + if self.layout.name() != "scrolling" {
702 + return Ok(());
703 + }
704 +
705 + let monitor_index = self.selected_monitor;
706 + let monitor = match self.monitors.get(monitor_index) {
707 + Some(m) => m.clone(),
708 + None => return Ok(()),
709 + };
710 +
711 + let visible_count = if monitor.num_master > 0 {
712 + monitor.num_master as usize
713 + } else {
714 + 2
715 + };
716 +
717 + let outer_gap = if self.gaps_enabled {
718 + self.config.gap_outer_vertical
719 + } else {
720 + 0
721 + };
722 + let inner_gap = if self.gaps_enabled {
723 + self.config.gap_inner_vertical
724 + } else {
725 + 0
726 + };
727 +
728 + let mut tiled_windows = Vec::new();
729 + let mut current = self.next_tiled(monitor.clients_head, &monitor);
730 + while let Some(window) = current {
731 + tiled_windows.push(window);
732 + if let Some(client) = self.clients.get(&window) {
733 + current = self.next_tiled(client.next, &monitor);
734 + } else {
735 + break;
736 + }
737 + }
738 +
739 + let target_idx = tiled_windows.iter().position(|&w| w == target_window);
740 + let target_idx = match target_idx {
741 + Some(idx) => idx,
742 + None => return Ok(()),
743 + };
744 +
745 + let tiled_count = tiled_windows.len();
746 + if tiled_count <= visible_count {
747 + if let Some(m) = self.monitors.get_mut(monitor_index) {
748 + m.scroll_offset = 0;
749 + }
750 + return Ok(());
751 + }
752 +
753 + let available_width = monitor.screen_width - 2 * outer_gap as i32;
754 + let total_inner_gaps = inner_gap as i32 * (visible_count - 1) as i32;
755 + let window_width = (available_width - total_inner_gaps) / visible_count as i32;
756 + let scroll_step = window_width + inner_gap as i32;
757 +
758 + let total_width = tiled_count as i32 * window_width + (tiled_count - 1) as i32 * inner_gap as i32;
759 + let max_scroll = (total_width - available_width).max(0);
760 +
761 + let target_scroll = (target_idx as i32) * scroll_step;
762 + let new_offset = target_scroll.clamp(0, max_scroll);
763 +
764 + let current_offset = monitor.scroll_offset;
765 + if current_offset != new_offset {
766 + if animate {
767 + self.scroll_animation.start(current_offset, new_offset, &self.animation_config);
768 + } else {
769 + if let Some(m) = self.monitors.get_mut(monitor_index) {
770 + m.scroll_offset = new_offset;
771 + }
772 + }
773 + }
774 +
775 + Ok(())
776 + }
777 +
613 778 fn get_layout_symbol(&self) -> String {
614 779 let layout_name = self.layout.name();
780 +
781 + if layout_name == "scrolling" {
782 + if let Some(monitor) = self.monitors.get(self.selected_monitor) {
783 + let visible_count = if monitor.num_master > 0 {
784 + monitor.num_master as usize
785 + } else {
786 + 2
787 + };
788 +
789 + let mut tiled_count = 0;
790 + let mut current = self.next_tiled(monitor.clients_head, monitor);
791 + while let Some(window) = current {
792 + tiled_count += 1;
793 + if let Some(client) = self.clients.get(&window) {
794 + current = self.next_tiled(client.next, monitor);
795 + } else {
796 + break;
797 + }
798 + }
799 +
800 + if tiled_count > 0 {
801 + let outer_gap = if self.gaps_enabled {
802 + self.config.gap_outer_vertical
803 + } else {
804 + 0
805 + };
806 + let inner_gap = if self.gaps_enabled {
807 + self.config.gap_inner_vertical
808 + } else {
809 + 0
810 + };
811 +
812 + let available_width = monitor.screen_width - 2 * outer_gap as i32;
813 + let total_inner_gaps = inner_gap as i32 * (visible_count.min(tiled_count) - 1) as i32;
814 + let window_width = if tiled_count <= visible_count {
815 + (available_width - total_inner_gaps) / tiled_count as i32
816 + } else {
817 + (available_width - inner_gap as i32 * (visible_count - 1) as i32) / visible_count as i32
818 + };
819 +
820 + let scroll_step = window_width + inner_gap as i32;
821 + let first_visible = if scroll_step > 0 {
822 + (monitor.scroll_offset / scroll_step) + 1
823 + } else {
824 + 1
825 + };
826 + let last_visible = (first_visible + visible_count as i32 - 1).min(tiled_count as i32);
827 +
828 + return format!("[{}-{}/{}]", first_visible, last_visible, tiled_count);
829 + }
830 + }
831 + }
832 +
615 833 self.config
616 834 .layout_symbols
617 835 .iter()
@@ -908,6 +1126,12 @@ impl WindowManager {
908 1126 self.inc_num_master(*delta)?;
909 1127 }
910 1128 }
1129 + KeyAction::ScrollLeft => {
1130 + self.scroll_layout(-1)?;
1131 + }
1132 + KeyAction::ScrollRight => {
1133 + self.scroll_layout(1)?;
1134 + }
911 1135 KeyAction::None => {}
912 1136 }
913 1137 Ok(())
@@ -1953,7 +2177,15 @@ impl WindowManager {
1953 2177 )?;
1954 2178 }
1955 2179
1956 - self.attach_aside(window, client_monitor);
2180 + if self.layout.name() == "scrolling" {
2181 + if let Some(selected) = self.monitors.get(client_monitor).and_then(|m| m.selected_client) {
2182 + self.attach_after(window, selected, client_monitor);
2183 + } else {
2184 + self.attach_aside(window, client_monitor);
2185 + }
2186 + } else {
2187 + self.attach_aside(window, client_monitor);
2188 + }
1957 2189 self.attach_stack(window, client_monitor);
1958 2190 self.windows.push(window);
1959 2191
@@ -1985,6 +2217,10 @@ impl WindowManager {
1985 2217 m.selected_client = Some(window);
1986 2218 }
1987 2219
2220 + if self.layout.name() == "scrolling" {
2221 + self.scroll_to_window(window, false)?;
2222 + }
2223 +
1988 2224 self.apply_layout()?;
1989 2225 self.connection.map_window(window)?;
1990 2226 self.focus(Some(window))?;
@@ -2224,6 +2460,11 @@ impl WindowManager {
2224 2460 };
2225 2461
2226 2462 self.focus(Some(next_window))?;
2463 +
2464 + if self.layout.name() == "scrolling" {
2465 + self.scroll_to_window(next_window, true)?;
2466 + }
2467 +
2227 2468 self.update_tab_bars()?;
2228 2469
2229 2470 Ok(())
@@ -3434,6 +3675,7 @@ impl WindowManager {
3434 3675 let monitor_y = monitor.screen_y;
3435 3676 let monitor_width = monitor.screen_width;
3436 3677 let monitor_height = monitor.screen_height;
3678 + let scroll_offset = monitor.scroll_offset;
3437 3679
3438 3680 let mut visible: Vec<Window> = Vec::new();
3439 3681 let mut current = self.next_tiled(monitor.clients_head, monitor);
@@ -3487,7 +3729,12 @@ impl WindowManager {
3487 3729 adjusted_height = hint_height as u32;
3488 3730 }
3489 3731
3490 - let adjusted_x = geometry.x_coordinate + monitor_x;
3732 + let is_scrolling = self.layout.name() == "scrolling";
3733 + let adjusted_x = if is_scrolling {
3734 + geometry.x_coordinate + monitor_x - scroll_offset
3735 + } else {
3736 + geometry.x_coordinate + monitor_x
3737 + };
3491 3738 let adjusted_y = geometry.y_coordinate + monitor_y + bar_height as i32;
3492 3739
3493 3740 if let Some(client) = self.clients.get_mut(window) {
@@ -4046,6 +4293,20 @@ impl WindowManager {
4046 4293 }
4047 4294 }
4048 4295
4296 + fn attach_after(&mut self, window: Window, after_window: Window, monitor_index: usize) {
4297 + if let Some(after_client) = self.clients.get(&after_window) {
4298 + let old_next = after_client.next;
4299 + if let Some(new_client) = self.clients.get_mut(&window) {
4300 + new_client.next = old_next;
4301 + }
4302 + if let Some(after_client_mut) = self.clients.get_mut(&after_window) {
4303 + after_client_mut.next = Some(window);
4304 + }
4305 + } else {
4306 + self.attach(window, monitor_index);
4307 + }
4308 + }
4309 +
4049 4310 fn attach_aside(&mut self, window: Window, monitor_index: usize) {
4050 4311 let monitor = match self.monitors.get(monitor_index) {
4051 4312 Some(m) => m,
+9 −1 templates/oxwm.lua
@@ -192,10 +192,18 @@ oxwm.layout = {}
192 192 function oxwm.layout.cycle() end
193 193
194 194 ---Set specific layout
195 ----@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle")
195 +---@param name string Layout name (e.g., "tiling", "normie", "tabbed", "grid", "monocle", "scrolling")
196 196 ---@return table Action table for keybinding
197 197 function oxwm.layout.set(name) end
198 198
199 +---Scroll layout left (for scrolling layout)
200 +---@return table Action table for keybinding
201 +function oxwm.layout.scroll_left() end
202 +
203 +---Scroll layout right (for scrolling layout)
204 +---@return table Action table for keybinding
205 +function oxwm.layout.scroll_right() end
206 +
199 207 ---Tag/workspace management module
200 208 ---@class oxwm.tag
201 209 oxwm.tag = {}