tony / oxwm

Fixed wrapping on next/prev and next_nonempty/prev_nonempty with remainder (rem_euclid), similar to dwms "adjacent_tag" patch. Browse files
tonybtw committed 2025-12-14 parent 183a8e1 commit b856bdad934654760f47bb271074f36f8fc49258
Showing 2 changed files with 28 additions and 20 deletions. UnifiedSplit
+6 −0 resources/test-config.lua
@@ -145,6 +145,12 @@ oxwm.key.bind({ modkey, "Control", "Shift" }, "7", oxwm.tag.toggletag(6))
145 oxwm.key.bind({ modkey, "Control", "Shift" }, "8", oxwm.tag.toggletag(7)) 145 oxwm.key.bind({ modkey, "Control", "Shift" }, "8", oxwm.tag.toggletag(7))
146 oxwm.key.bind({ modkey, "Control", "Shift" }, "9", oxwm.tag.toggletag(8)) 146 oxwm.key.bind({ modkey, "Control", "Shift" }, "9", oxwm.tag.toggletag(8))
147 147
148 +oxwm.key.bind({ modkey }, "Tab", oxwm.tag.view_next())
149 +oxwm.key.bind({ modkey, "Shift" }, "Tab", oxwm.tag.view_previous())
150 +
151 +oxwm.key.bind({ modkey, "Control" }, "Tab", oxwm.tag.view_next_nonempty())
152 +oxwm.key.bind({ modkey, "Control", "Shift" }, "Tab", oxwm.tag.view_previous_nonempty())
153 +
148 oxwm.bar.set_blocks({ 154 oxwm.bar.set_blocks({
149 oxwm.bar.block.battery({ 155 oxwm.bar.block.battery({
150 format = "Bat: {}%", 156 format = "Bat: {}%",
+22 −20 src/window_manager.rs
@@ -813,38 +813,40 @@ impl WindowManager {
813 } 813 }
814 KeyAction::ViewNextTag => { 814 KeyAction::ViewNextTag => {
815 let monitor = self.get_selected_monitor(); 815 let monitor = self.get_selected_monitor();
816 - let current_tag_mask = monitor.get_selected_tag(); 816 + let current_tag_index = unmask_tag(monitor.get_selected_tag()) as i32;
817 - 817 + let len = self.config.tags.len() as i32;
818 - let current_tag_index = unmask_tag(current_tag_mask); 818 + self.view_tag((current_tag_index + 1).rem_euclid(len) as usize)?;
819 - self.view_tag(current_tag_index.saturating_add(1))?;
820 } 819 }
821 KeyAction::ViewPreviousTag => { 820 KeyAction::ViewPreviousTag => {
822 let monitor = self.get_selected_monitor(); 821 let monitor = self.get_selected_monitor();
823 - let current_tag_mask = monitor.get_selected_tag(); 822 + let current_tag_index = unmask_tag(monitor.get_selected_tag()) as i32;
824 - 823 + let len = self.config.tags.len() as i32;
825 - let current_tag_index = unmask_tag(current_tag_mask); 824 + self.view_tag((current_tag_index - 1).rem_euclid(len) as usize)?;
826 - self.view_tag(current_tag_index.saturating_sub(1))?;
827 } 825 }
828 KeyAction::ViewNextNonEmptyTag => { 826 KeyAction::ViewNextNonEmptyTag => {
829 let monitor = self.get_selected_monitor(); 827 let monitor = self.get_selected_monitor();
830 - let current_tag_mask = monitor.get_selected_tag(); 828 + let current = unmask_tag(monitor.get_selected_tag()) as i32;
831 - let current_tag_index = unmask_tag(current_tag_mask); 829 + let len = self.config.tags.len() as i32;
832 - 830 + let mon_num = monitor.monitor_number;
833 - for next_tag_index in (current_tag_index + 1)..self.config.tags.len() { 831 +
834 - if self.has_windows_on_tag(monitor.monitor_number, next_tag_index) { 832 + for offset in 1..len {
835 - self.view_tag(next_tag_index)?; 833 + let next = (current + offset).rem_euclid(len) as usize;
834 + if self.has_windows_on_tag(mon_num, next) {
835 + self.view_tag(next)?;
836 break; 836 break;
837 } 837 }
838 } 838 }
839 } 839 }
840 KeyAction::ViewPreviousNonEmptyTag => { 840 KeyAction::ViewPreviousNonEmptyTag => {
841 let monitor = self.get_selected_monitor(); 841 let monitor = self.get_selected_monitor();
842 - let current_tag_mask = monitor.get_selected_tag(); 842 + let current = unmask_tag(monitor.get_selected_tag()) as i32;
843 - let current_tag_index = unmask_tag(current_tag_mask); 843 + let len = self.config.tags.len() as i32;
844 - 844 + let mon_num = monitor.monitor_number;
845 - for prev_tag_index in (0..current_tag_index).rev() { 845 +
846 - if self.has_windows_on_tag(monitor.monitor_number, prev_tag_index) { 846 + for offset in 1..len {
847 - self.view_tag(prev_tag_index)?; 847 + let prev = (current - offset).rem_euclid(len) as usize;
848 + if self.has_windows_on_tag(mon_num, prev) {
849 + self.view_tag(prev)?;
848 break; 850 break;
849 } 851 }
850 } 852 }