tony / oxwm

Merge pull request #116 from tonybanters/scrolling Browse files
Scrolling Layout
Tony, btw. committed 2026-01-11 parents 45257ca 4f07f4b commit 2a705540258b78df9c128b98350eab40b92982b4
Showing 14 changed files with 545 additions and 7 deletions. UnifiedSplit
+1 −1 Cargo.lock
@@ -291,7 +291,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
291 291
292 292 [[package]]
293 293 name = "oxwm"
294 -version = "0.10.0"
294 +version = "0.10.2"
295 295 dependencies = [
296 296 "chrono",
297 297 "dirs",
+1 −1 Cargo.toml
@@ -1,6 +1,6 @@
1 1 [package]
2 2 name = "oxwm"
3 -version = "0.10.0"
3 +version = "0.10.2"
4 4 edition = "2024"
5 5
6 6 [lib]
+4 −0 resources/test-config.lua
@@ -77,8 +77,12 @@ oxwm.key.bind({ modkey, "Shift" }, "Space", oxwm.client.toggle_floating())
77 77
78 78 oxwm.key.bind({ modkey }, "F", oxwm.layout.set("normie"))
79 79 oxwm.key.bind({ modkey }, "C", oxwm.layout.set("tiling"))
80 +oxwm.key.bind({ modkey }, "G", oxwm.layout.set("scrolling"))
80 81 oxwm.key.bind({ modkey }, "N", oxwm.layout.cycle())
81 82
83 +oxwm.key.bind({ modkey }, "Left", oxwm.layout.scroll_left())
84 +oxwm.key.bind({ modkey }, "Right", oxwm.layout.scroll_right())
85 +
82 86 oxwm.key.bind({ modkey }, "A", oxwm.toggle_gaps())
83 87
84 88 -- 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
@@ -300,8 +300,16 @@ fn register_layout_module(lua: &Lua, parent: &Table) -> Result<(), ConfigError>
300 300 )
301 301 })?;
302 302
303 + let scroll_left =
304 + lua.create_function(|lua, ()| create_action_table(lua, "ScrollLeft", Value::Nil))?;
305 +
306 + let scroll_right =
307 + lua.create_function(|lua, ()| create_action_table(lua, "ScrollRight", Value::Nil))?;
308 +
303 309 layout_table.set("cycle", cycle)?;
304 310 layout_table.set("set", set)?;
311 + layout_table.set("scroll_left", scroll_left)?;
312 + layout_table.set("scroll_right", scroll_right)?;
305 313 parent.set("layout", layout_table)?;
306 314 Ok(())
307 315 }
@@ -929,6 +937,8 @@ fn string_to_action(s: &str) -> mlua::Result<KeyAction> {
929 937 "FocusMonitor" => Ok(KeyAction::FocusMonitor),
930 938 "TagMonitor" => Ok(KeyAction::TagMonitor),
931 939 "ShowKeybindOverlay" => Ok(KeyAction::ShowKeybindOverlay),
940 + "ScrollLeft" => Ok(KeyAction::ScrollLeft),
941 + "ScrollRight" => Ok(KeyAction::ScrollRight),
932 942 _ => Err(mlua::Error::RuntimeError(format!(
933 943 "unknown action '{}'. this is an internal error, please report it",
934 944 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;
+9 −1 src/monitor.rs
@@ -17,7 +17,13 @@ pub struct Pertag {
17 17 }
18 18
19 19 impl Pertag {
20 - pub fn new(num_tags: usize, default_num_master: i32, default_master_factor: f32, default_show_bar: bool, default_layout: &str) -> Self {
20 + pub fn new(
21 + num_tags: usize,
22 + default_num_master: i32,
23 + default_master_factor: f32,
24 + default_show_bar: bool,
25 + default_layout: &str,
26 + ) -> Self {
21 27 let len = num_tags + 1;
22 28 Self {
23 29 current_tag: 1,
@@ -59,6 +65,7 @@ pub struct Monitor {
59 65 pub stack_head: Option<Window>,
60 66 pub bar_window: Option<Window>,
61 67 pub layout_indices: [usize; 2],
68 + pub scroll_offset: i32,
62 69 pub pertag: Option<Pertag>,
63 70 }
64 71
@@ -92,6 +99,7 @@ impl Monitor {
92 99 stack_head: None,
93 100 bar_window: None,
94 101 layout_indices: [0, 1],
102 + scroll_offset: 0,
95 103 pertag: None,
96 104 }
97 105 }
+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 }
+281 −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::{ConfigError, WmError};
@@ -174,6 +175,8 @@ pub struct WindowManager {
174 175 error_message: Option<String>,
175 176 overlay: ErrorOverlay,
176 177 keybind_overlay: KeybindOverlay,
178 + scroll_animation: ScrollAnimation,
179 + animation_config: AnimationConfig,
177 180 }
178 181
179 182 type WmResult<T> = Result<T, WmError>;
@@ -407,6 +410,8 @@ impl WindowManager {
407 410 error_message: None,
408 411 overlay,
409 412 keybind_overlay,
413 + scroll_animation: ScrollAnimation::new(),
414 + animation_config: AnimationConfig::default(),
410 415 };
411 416
412 417 for tab_bar in &window_manager.tab_bars {
@@ -645,6 +650,8 @@ impl WindowManager {
645 650 last_bar_update = std::time::Instant::now();
646 651 }
647 652
653 + self.tick_animations()?;
654 +
648 655 self.connection.flush()?;
649 656 std::thread::sleep(std::time::Duration::from_millis(16));
650 657 }
@@ -733,6 +740,166 @@ impl WindowManager {
733 740 Ok(())
734 741 }
735 742
743 + fn tick_animations(&mut self) -> WmResult<()> {
744 + if self.scroll_animation.is_active() {
745 + if let Some(new_offset) = self.scroll_animation.update() {
746 + if let Some(m) = self.monitors.get_mut(self.selected_monitor) {
747 + m.scroll_offset = new_offset;
748 + }
749 + self.apply_layout()?;
750 + self.update_bar()?;
751 + }
752 + }
753 + Ok(())
754 + }
755 +
756 + fn scroll_layout(&mut self, direction: i32) -> WmResult<()> {
757 + if self.layout.name() != "scrolling" {
758 + return Ok(());
759 + }
760 +
761 + let monitor_index = self.selected_monitor;
762 + let monitor = match self.monitors.get(monitor_index) {
763 + Some(m) => m.clone(),
764 + None => return Ok(()),
765 + };
766 +
767 + let visible_count = if monitor.num_master > 0 {
768 + monitor.num_master as usize
769 + } else {
770 + 2
771 + };
772 +
773 + let mut tiled_count = 0;
774 + let mut current = self.next_tiled(monitor.clients_head, &monitor);
775 + while let Some(window) = current {
776 + tiled_count += 1;
777 + if let Some(client) = self.clients.get(&window) {
778 + current = self.next_tiled(client.next, &monitor);
779 + } else {
780 + break;
781 + }
782 + }
783 +
784 + if tiled_count <= visible_count {
785 + if let Some(m) = self.monitors.get_mut(monitor_index) {
786 + m.scroll_offset = 0;
787 + }
788 + return Ok(());
789 + }
790 +
791 + let outer_gap = if self.gaps_enabled {
792 + self.config.gap_outer_vertical
793 + } else {
794 + 0
795 + };
796 + let inner_gap = if self.gaps_enabled {
797 + self.config.gap_inner_vertical
798 + } else {
799 + 0
800 + };
801 +
802 + let available_width = monitor.screen_width - 2 * outer_gap as i32;
803 + let total_inner_gaps = inner_gap as i32 * (visible_count - 1) as i32;
804 + let window_width = (available_width - total_inner_gaps) / visible_count as i32;
805 + let scroll_amount = window_width + inner_gap as i32;
806 +
807 + let total_width = tiled_count as i32 * window_width + (tiled_count - 1) as i32 * inner_gap as i32;
808 + let max_scroll = (total_width - available_width).max(0);
809 +
810 + let current_offset = monitor.scroll_offset;
811 + let target_offset = if self.scroll_animation.is_active() {
812 + self.scroll_animation.target() + direction * scroll_amount
813 + } else {
814 + current_offset + direction * scroll_amount
815 + };
816 + let target_offset = target_offset.clamp(0, max_scroll);
817 +
818 + self.scroll_animation.start(current_offset, target_offset, &self.animation_config);
819 +
820 + Ok(())
821 + }
822 +
823 + fn scroll_to_window(&mut self, target_window: Window, animate: bool) -> WmResult<()> {
824 + if self.layout.name() != "scrolling" {
825 + return Ok(());
826 + }
827 +
828 + let monitor_index = self.selected_monitor;
829 + let monitor = match self.monitors.get(monitor_index) {
830 + Some(m) => m.clone(),
831 + None => return Ok(()),
832 + };
833 +
834 + let visible_count = if monitor.num_master > 0 {
835 + monitor.num_master as usize
836 + } else {
837 + 2
838 + };
839 +
840 + let outer_gap = if self.gaps_enabled {
841 + self.config.gap_outer_vertical
842 + } else {
843 + 0
844 + };
845 + let inner_gap = if self.gaps_enabled {
846 + self.config.gap_inner_vertical
847 + } else {
848 + 0
849 + };
850 +
851 + let mut tiled_windows = Vec::new();
852 + let mut current = self.next_tiled(monitor.clients_head, &monitor);
853 + while let Some(window) = current {
854 + tiled_windows.push(window);
855 + if let Some(client) = self.clients.get(&window) {
856 + current = self.next_tiled(client.next, &monitor);
857 + } else {
858 + break;
859 + }
860 + }
861 +
862 + let target_idx = tiled_windows.iter().position(|&w| w == target_window);
863 + let target_idx = match target_idx {
864 + Some(idx) => idx,
865 + None => return Ok(()),
866 + };
867 +
868 + let tiled_count = tiled_windows.len();
869 + if tiled_count <= visible_count {
870 + if animate && monitor.scroll_offset != 0 {
871 + self.scroll_animation.start(monitor.scroll_offset, 0, &self.animation_config);
872 + } else if let Some(m) = self.monitors.get_mut(monitor_index) {
873 + m.scroll_offset = 0;
874 + }
875 + return Ok(());
876 + }
877 +
878 + let available_width = monitor.screen_width - 2 * outer_gap as i32;
879 + let total_inner_gaps = inner_gap as i32 * (visible_count - 1) as i32;
880 + let window_width = (available_width - total_inner_gaps) / visible_count as i32;
881 + let scroll_step = window_width + inner_gap as i32;
882 +
883 + let total_width = tiled_count as i32 * window_width + (tiled_count - 1) as i32 * inner_gap as i32;
884 + let max_scroll = (total_width - available_width).max(0);
885 +
886 + let target_scroll = (target_idx as i32) * scroll_step;
887 + let new_offset = target_scroll.clamp(0, max_scroll);
888 +
889 + let current_offset = monitor.scroll_offset;
890 + if current_offset != new_offset {
891 + if animate {
892 + self.scroll_animation.start(current_offset, new_offset, &self.animation_config);
893 + } else {
894 + if let Some(m) = self.monitors.get_mut(monitor_index) {
895 + m.scroll_offset = new_offset;
896 + }
897 + }
898 + }
899 +
900 + Ok(())
901 + }
902 +
736 903 fn toggle_bar(&mut self) -> WmResult<()> {
737 904 if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) {
738 905 monitor.show_bar = !monitor.show_bar;
@@ -748,6 +915,59 @@ impl WindowManager {
748 915
749 916 fn get_layout_symbol(&self) -> String {
750 917 let layout_name = self.layout.name();
918 +
919 + if layout_name == "scrolling" {
920 + if let Some(monitor) = self.monitors.get(self.selected_monitor) {
921 + let visible_count = if monitor.num_master > 0 {
922 + monitor.num_master as usize
923 + } else {
924 + 2
925 + };
926 +
927 + let mut tiled_count = 0;
928 + let mut current = self.next_tiled(monitor.clients_head, monitor);
929 + while let Some(window) = current {
930 + tiled_count += 1;
931 + if let Some(client) = self.clients.get(&window) {
932 + current = self.next_tiled(client.next, monitor);
933 + } else {
934 + break;
935 + }
936 + }
937 +
938 + if tiled_count > 0 {
939 + let outer_gap = if self.gaps_enabled {
940 + self.config.gap_outer_vertical
941 + } else {
942 + 0
943 + };
944 + let inner_gap = if self.gaps_enabled {
945 + self.config.gap_inner_vertical
946 + } else {
947 + 0
948 + };
949 +
950 + let available_width = monitor.screen_width - 2 * outer_gap as i32;
951 + let total_inner_gaps = inner_gap as i32 * (visible_count.min(tiled_count) - 1) as i32;
952 + let window_width = if tiled_count <= visible_count {
953 + (available_width - total_inner_gaps) / tiled_count as i32
954 + } else {
955 + (available_width - inner_gap as i32 * (visible_count - 1) as i32) / visible_count as i32
956 + };
957 +
958 + let scroll_step = window_width + inner_gap as i32;
959 + let first_visible = if scroll_step > 0 {
960 + (monitor.scroll_offset / scroll_step) + 1
961 + } else {
962 + 1
963 + };
964 + let last_visible = (first_visible + visible_count as i32 - 1).min(tiled_count as i32);
965 +
966 + return format!("[{}-{}/{}]", first_visible, last_visible, tiled_count);
967 + }
968 + }
969 + }
970 +
751 971 self.config
752 972 .layout_symbols
753 973 .iter()
@@ -1045,6 +1265,12 @@ impl WindowManager {
1045 1265 self.inc_num_master(*delta)?;
1046 1266 }
1047 1267 }
1268 + KeyAction::ScrollLeft => {
1269 + self.scroll_layout(-1)?;
1270 + }
1271 + KeyAction::ScrollRight => {
1272 + self.scroll_layout(1)?;
1273 + }
1048 1274 KeyAction::None => {}
1049 1275 }
1050 1276 Ok(())
@@ -2047,7 +2273,15 @@ impl WindowManager {
2047 2273 )?;
2048 2274 }
2049 2275
2050 - self.attach_aside(window, client_monitor);
2276 + if self.layout.name() == "scrolling" {
2277 + if let Some(selected) = self.monitors.get(client_monitor).and_then(|m| m.selected_client) {
2278 + self.attach_after(window, selected, client_monitor);
2279 + } else {
2280 + self.attach_aside(window, client_monitor);
2281 + }
2282 + } else {
2283 + self.attach_aside(window, client_monitor);
2284 + }
2051 2285 self.attach_stack(window, client_monitor);
2052 2286 self.windows.push(window);
2053 2287
@@ -2067,6 +2301,23 @@ impl WindowManager {
2067 2301 let final_tags = self.clients.get(&window).map(|c| c.tags).unwrap_or(tags);
2068 2302 let _ = self.save_client_tag(window, final_tags);
2069 2303
2304 + if client_monitor == self.selected_monitor
2305 + && let Some(old_sel) = self
2306 + .monitors
2307 + .get(self.selected_monitor)
2308 + .and_then(|m| m.selected_client)
2309 + {
2310 + self.unfocus(old_sel, false)?;
2311 + }
2312 +
2313 + if let Some(m) = self.monitors.get_mut(client_monitor) {
2314 + m.selected_client = Some(window);
2315 + }
2316 +
2317 + if self.layout.name() == "scrolling" {
2318 + self.scroll_to_window(window, true)?;
2319 + }
2320 +
2070 2321 self.apply_layout()?;
2071 2322 self.connection.map_window(window)?;
2072 2323 self.focus(None)?;
@@ -2403,6 +2654,11 @@ impl WindowManager {
2403 2654 };
2404 2655
2405 2656 self.focus(Some(next_window))?;
2657 +
2658 + if self.layout.name() == "scrolling" {
2659 + self.scroll_to_window(next_window, true)?;
2660 + }
2661 +
2406 2662 self.restack()?;
2407 2663 self.update_tab_bars()?;
2408 2664
@@ -3644,6 +3900,7 @@ impl WindowManager {
3644 3900 let monitor_y = monitor.screen_y;
3645 3901 let monitor_width = monitor.screen_width;
3646 3902 let monitor_height = monitor.screen_height;
3903 + let scroll_offset = monitor.scroll_offset;
3647 3904
3648 3905 let mut visible: Vec<Window> = Vec::new();
3649 3906 let mut current = self.next_tiled(monitor.clients_head, monitor);
@@ -3697,7 +3954,12 @@ impl WindowManager {
3697 3954 adjusted_height = hint_height as u32;
3698 3955 }
3699 3956
3700 - let adjusted_x = geometry.x_coordinate + monitor_x;
3957 + let is_scrolling = self.layout.name() == "scrolling";
3958 + let adjusted_x = if is_scrolling {
3959 + geometry.x_coordinate + monitor_x - scroll_offset
3960 + } else {
3961 + geometry.x_coordinate + monitor_x
3962 + };
3701 3963 let adjusted_y = geometry.y_coordinate + monitor_y + bar_height as i32;
3702 3964
3703 3965 if let Some(client) = self.clients.get_mut(window) {
@@ -4295,6 +4557,20 @@ impl WindowManager {
4295 4557 }
4296 4558 }
4297 4559
4560 + fn attach_after(&mut self, window: Window, after_window: Window, monitor_index: usize) {
4561 + if let Some(after_client) = self.clients.get(&after_window) {
4562 + let old_next = after_client.next;
4563 + if let Some(new_client) = self.clients.get_mut(&window) {
4564 + new_client.next = old_next;
4565 + }
4566 + if let Some(after_client_mut) = self.clients.get_mut(&after_window) {
4567 + after_client_mut.next = Some(window);
4568 + }
4569 + } else {
4570 + self.attach(window, monitor_index);
4571 + }
4572 + }
4573 +
4298 4574 fn attach_aside(&mut self, window: Window, monitor_index: usize) {
4299 4575 let monitor = match self.monitors.get(monitor_index) {
4300 4576 Some(m) => m,
@@ -4447,6 +4723,9 @@ impl WindowManager {
4447 4723 let visible = self.visible_windows_on_monitor(self.selected_monitor);
4448 4724 if let Some(&new_win) = visible.last() {
4449 4725 self.focus(Some(new_win))?;
4726 + if self.layout.name() == "scrolling" {
4727 + self.scroll_to_window(new_win, true)?;
4728 + }
4450 4729 } else if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) {
4451 4730 monitor.selected_client = None;
4452 4731 }
+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 = {}