tony / oxwm

deprecated directional/exchange client movement for now since they interfere with core window/client management structural logic. Browse files
tonybtw committed 2025-12-01 parent c755274 commit 51b0e02282faa1af7cbb79a55e9e1e8518cb9ca3
Showing 7 changed files with 9 additions and 305 deletions. UnifiedSplit
+0 −7 resources/test-config.lua
@@ -94,13 +94,6 @@ oxwm.key.bind({ modkey, "Shift" }, "R", oxwm.restart())
94 94
95 95 oxwm.key.bind({ modkey }, "J", oxwm.client.focus_stack(1))
96 96 oxwm.key.bind({ modkey }, "K", oxwm.client.focus_stack(-1))
97 -oxwm.key.bind({ modkey }, "H", oxwm.client.focus_direction("left"))
98 -oxwm.key.bind({ modkey }, "L", oxwm.client.focus_direction("right"))
99 -
100 -oxwm.key.bind({ modkey, "Shift" }, "H", oxwm.client.swap_direction("left"))
101 -oxwm.key.bind({ modkey, "Shift" }, "J", oxwm.client.swap_direction("down"))
102 -oxwm.key.bind({ modkey, "Shift" }, "K", oxwm.client.swap_direction("up"))
103 -oxwm.key.bind({ modkey, "Shift" }, "L", oxwm.client.swap_direction("right"))
104 97
105 98 -- View tag (switch workspace)
106 99 oxwm.key.bind({ modkey }, "1", oxwm.tag.view(0))
+0 −20 src/config/lua_api.rs
@@ -255,27 +255,10 @@ fn register_client_module(lua: &Lua, parent: &Table) -> Result<(), ConfigError>
255 255 create_action_table(lua, "FocusStack", Value::Integer(dir as i64))
256 256 })?;
257 257
258 - let focus_direction = lua.create_function(|lua, dir: String| {
259 - let dir_int = direction_string_to_int(&dir)?;
260 - create_action_table(lua, "FocusDirection", Value::Integer(dir_int))
261 - })?;
262 -
263 - let swap_direction = lua.create_function(|lua, dir: String| {
264 - let dir_int = direction_string_to_int(&dir)?;
265 - create_action_table(lua, "SwapDirection", Value::Integer(dir_int))
266 - })?;
267 -
268 - let exchange = lua.create_function(|lua, ()| {
269 - create_action_table(lua, "ExchangeClient", Value::Nil)
270 - })?;
271 -
272 258 client_table.set("kill", kill)?;
273 259 client_table.set("toggle_fullscreen", toggle_fullscreen)?;
274 260 client_table.set("toggle_floating", toggle_floating)?;
275 261 client_table.set("focus_stack", focus_stack)?;
276 - client_table.set("focus_direction", focus_direction)?;
277 - client_table.set("swap_direction", swap_direction)?;
278 - client_table.set("exchange", exchange)?;
279 262
280 263 parent.set("client", client_table)?;
281 264 Ok(())
@@ -790,8 +773,6 @@ fn string_to_action(s: &str) -> mlua::Result<KeyAction> {
790 773 "SpawnTerminal" => Ok(KeyAction::SpawnTerminal),
791 774 "KillClient" => Ok(KeyAction::KillClient),
792 775 "FocusStack" => Ok(KeyAction::FocusStack),
793 - "FocusDirection" => Ok(KeyAction::FocusDirection),
794 - "SwapDirection" => Ok(KeyAction::SwapDirection),
795 776 "Quit" => Ok(KeyAction::Quit),
796 777 "Restart" => Ok(KeyAction::Restart),
797 778 "Recompile" => Ok(KeyAction::Recompile),
@@ -808,7 +789,6 @@ fn string_to_action(s: &str) -> mlua::Result<KeyAction> {
808 789 "CycleLayout" => Ok(KeyAction::CycleLayout),
809 790 "FocusMonitor" => Ok(KeyAction::FocusMonitor),
810 791 "TagMonitor" => Ok(KeyAction::TagMonitor),
811 - "ExchangeClient" => Ok(KeyAction::ExchangeClient),
812 792 "ShowKeybindOverlay" => Ok(KeyAction::ShowKeybindOverlay),
813 793 _ => Err(mlua::Error::RuntimeError(format!("unknown action '{}'. this is an internal error, please report it", s))),
814 794 }
+0 −3 src/keyboard/handlers.rs
@@ -15,8 +15,6 @@ pub enum KeyAction {
15 15 SpawnTerminal,
16 16 KillClient,
17 17 FocusStack,
18 - FocusDirection,
19 - SwapDirection,
20 18 Quit,
21 19 Restart,
22 20 Recompile,
@@ -31,7 +29,6 @@ pub enum KeyAction {
31 29 CycleLayout,
32 30 FocusMonitor,
33 31 TagMonitor,
34 - ExchangeClient,
35 32 ShowKeybindOverlay,
36 33 SetMasterFactor,
37 34 IncNumMaster,
+4 −23 src/layout/normie.rs
@@ -15,33 +15,14 @@ impl Layout for NormieLayout {
15 15
16 16 fn arrange(
17 17 &self,
18 - windows: &[Window],
19 - screen_width: u32,
20 - screen_height: u32,
18 + _windows: &[Window],
19 + _screen_width: u32,
20 + _screen_height: u32,
21 21 _gaps: &GapConfig,
22 22 _master_factor: f32,
23 23 _num_master: i32,
24 24 _smartgaps_enabled: bool,
25 25 ) -> Vec<WindowGeometry> {
26 - const DEFAULT_WIDTH_RATIO: f32 = 0.6;
27 - const DEFAULT_HEIGHT_RATIO: f32 = 0.6;
28 -
29 - windows
30 - .iter()
31 - .map(|_| {
32 - let width = ((screen_width as f32) * DEFAULT_WIDTH_RATIO) as u32;
33 - let height = ((screen_height as f32) * DEFAULT_HEIGHT_RATIO) as u32;
34 -
35 - let x = ((screen_width - width) / 2) as i32;
36 - let y = ((screen_height - height) / 2) as i32;
37 -
38 - WindowGeometry {
39 - x_coordinate: x,
40 - y_coordinate: y,
41 - width,
42 - height,
43 - }
44 - })
45 - .collect()
26 + Vec::new()
46 27 }
47 28 }
+0 −24 src/lib.rs
@@ -174,30 +174,6 @@ impl Default for Config {
174 174 KeyAction::FocusStack,
175 175 Arg::Int(1),
176 176 ),
177 - KeyBinding::single_key(
178 - vec![MODKEY, SHIFT],
179 - keysyms::XK_K,
180 - KeyAction::ExchangeClient,
181 - Arg::Int(0), // UP
182 - ),
183 - KeyBinding::single_key(
184 - vec![MODKEY, SHIFT],
185 - keysyms::XK_J,
186 - KeyAction::ExchangeClient,
187 - Arg::Int(1), // DOWN
188 - ),
189 - KeyBinding::single_key(
190 - vec![MODKEY, SHIFT],
191 - keysyms::XK_H,
192 - KeyAction::ExchangeClient,
193 - Arg::Int(2), // LEFT
194 - ),
195 - KeyBinding::single_key(
196 - vec![MODKEY, SHIFT],
197 - keysyms::XK_L,
198 - KeyAction::ExchangeClient,
199 - Arg::Int(3), // RIGHT
200 - ),
201 177 KeyBinding::single_key(
202 178 vec![MODKEY],
203 179 keysyms::XK_1,
+0 −3 src/overlay/keybind.rs
@@ -203,8 +203,6 @@ impl KeybindOverlay {
203 203 },
204 204 KeyAction::SpawnTerminal => "Launch Terminal".to_string(),
205 205 KeyAction::FocusStack => "Focus Next/Previous Window".to_string(),
206 - KeyAction::FocusDirection => "Focus Window in Direction".to_string(),
207 - KeyAction::SwapDirection => "Swap Window in Direction".to_string(),
208 206 KeyAction::ViewTag => match &binding.arg {
209 207 Arg::Int(n) => format!("View Workspace {}", n),
210 208 _ => "View Workspace".to_string(),
@@ -222,7 +220,6 @@ impl KeybindOverlay {
222 220 KeyAction::CycleLayout => "Cycle Through Layouts".to_string(),
223 221 KeyAction::FocusMonitor => "Focus Next Monitor".to_string(),
224 222 KeyAction::TagMonitor => "Send Window to Monitor".to_string(),
225 - KeyAction::ExchangeClient => "Exchange Client Windows".to_string(),
226 223 KeyAction::SetMasterFactor => "Adjust Master Area Size".to_string(),
227 224 KeyAction::IncNumMaster => "Adjust Number of Master Windows".to_string(),
228 225 KeyAction::None => "No Action".to_string(),
+5 −225 src/window_manager.rs
@@ -597,75 +597,6 @@ impl WindowManager {
597 597 Ok(())
598 598 }
599 599
600 - fn exchange_client(&mut self, direction: i32) -> WmResult<()> {
601 - let focused = match self
602 - .monitors
603 - .get(self.selected_monitor)
604 - .and_then(|m| m.selected_client)
605 - {
606 - Some(win) => win,
607 - None => return Ok(()),
608 - };
609 -
610 - if self.floating_windows.contains(&focused) {
611 - return Ok(());
612 - }
613 -
614 - let visible = self.visible_windows();
615 - if visible.len() < 2 {
616 - return Ok(());
617 - }
618 -
619 - let current_idx = match visible.iter().position(|&w| w == focused) {
620 - Some(idx) => idx,
621 - None => return Ok(()),
622 - };
623 -
624 - let target_idx = match direction {
625 - 0 | 2 => {
626 - // UP or LEFT - previous in stack
627 - if current_idx == 0 {
628 - visible.len() - 1
629 - } else {
630 - current_idx - 1
631 - }
632 - }
633 - 1 | 3 => {
634 - // DOWN or RIGHT - next in stack
635 - (current_idx + 1) % visible.len()
636 - }
637 - _ => return Ok(()),
638 - };
639 -
640 - let target = visible[target_idx];
641 -
642 - let focused_pos = self.windows.iter().position(|&w| w == focused);
643 - let target_pos = self.windows.iter().position(|&w| w == target);
644 -
645 - if let (Some(f_pos), Some(t_pos)) = (focused_pos, target_pos) {
646 - self.windows.swap(f_pos, t_pos);
647 -
648 - self.apply_layout()?;
649 -
650 - self.focus(Some(focused))?;
651 -
652 - if let Ok(geometry) = self.connection.get_geometry(focused)?.reply() {
653 - self.connection.warp_pointer(
654 - x11rb::NONE,
655 - focused,
656 - 0,
657 - 0,
658 - 0,
659 - 0,
660 - geometry.width as i16 / 2,
661 - geometry.height as i16 / 2,
662 - )?;
663 - }
664 - }
665 -
666 - Ok(())
667 - }
668 -
669 600
670 601 fn get_layout_symbol(&self) -> String {
671 602 let layout_name = self.layout.name();
@@ -846,27 +777,11 @@ impl WindowManager {
846 777 self.restack()?;
847 778 }
848 779
849 - KeyAction::ExchangeClient => {
850 - if let Arg::Int(direction) = arg {
851 - self.exchange_client(*direction)?;
852 - }
853 - }
854 -
855 780 KeyAction::FocusStack => {
856 781 if let Arg::Int(direction) = arg {
857 782 self.focusstack(*direction)?;
858 783 }
859 784 }
860 - KeyAction::FocusDirection => {
861 - if let Arg::Int(direction) = arg {
862 - self.focus_direction(*direction)?;
863 - }
864 - }
865 - KeyAction::SwapDirection => {
866 - if let Arg::Int(direction) = arg {
867 - self.swap_direction(*direction)?;
868 - }
869 - }
870 785 KeyAction::Quit | KeyAction::Restart => {
871 786 // Handled in handle_event
872 787 }
@@ -1296,104 +1211,6 @@ impl WindowManager {
1296 1211 Ok(())
1297 1212 }
1298 1213
1299 - fn find_directional_window_candidate(&mut self, focused_window: Window, direction: i32) -> Option<Window> {
1300 - let visible_windows = self.visible_windows();
1301 - if visible_windows.len() < 2 {
1302 - return None;
1303 - }
1304 -
1305 - let focused_geometry = self.get_or_query_geometry(focused_window).ok()?;
1306 - let focused_center_x = focused_geometry.x_position + (focused_geometry.width as i16 / 2);
1307 - let focused_center_y = focused_geometry.y_position + (focused_geometry.height as i16 / 2);
1308 -
1309 - let mut candidates = Vec::new();
1310 -
1311 - for &window in &visible_windows {
1312 - if window == focused_window {
1313 - continue;
1314 - }
1315 -
1316 - let geometry = match self.get_or_query_geometry(window) {
1317 - Ok(geometry) => geometry,
1318 - Err(_) => continue,
1319 - };
1320 -
1321 - let center_x = geometry.x_position + (geometry.width as i16 / 2);
1322 - let center_y = geometry.y_position + (geometry.height as i16 / 2);
1323 -
1324 - let is_valid_direction = match direction {
1325 - 0 => center_y < focused_center_y,
1326 - 1 => center_y > focused_center_y,
1327 - 2 => center_x < focused_center_x,
1328 - 3 => center_x > focused_center_x,
1329 - _ => false,
1330 - };
1331 -
1332 - if is_valid_direction {
1333 - let delta_x = (center_x - focused_center_x) as i32;
1334 - let delta_y = (center_y - focused_center_y) as i32;
1335 - let distance_squared = delta_x * delta_x + delta_y * delta_y;
1336 - candidates.push((window, distance_squared));
1337 - }
1338 - }
1339 -
1340 - candidates.iter().min_by_key(|&(_window, distance)| distance).map(|&(window, _distance)| window)
1341 - }
1342 -
1343 - pub fn focus_direction(&mut self, direction: i32) -> WmResult<()> {
1344 - let focused_window = match self
1345 - .monitors
1346 - .get(self.selected_monitor)
1347 - .and_then(|monitor| monitor.selected_client)
1348 - {
1349 - Some(window) => window,
1350 - None => return Ok(()),
1351 - };
1352 -
1353 - if let Some(target_window) = self.find_directional_window_candidate(focused_window, direction) {
1354 - self.focus(Some(target_window))?;
1355 - }
1356 -
1357 - Ok(())
1358 - }
1359 -
1360 - pub fn swap_direction(&mut self, direction: i32) -> WmResult<()> {
1361 - let focused_window = match self
1362 - .monitors
1363 - .get(self.selected_monitor)
1364 - .and_then(|monitor| monitor.selected_client)
1365 - {
1366 - Some(window) => window,
1367 - None => return Ok(()),
1368 - };
1369 -
1370 - if let Some(target_window) = self.find_directional_window_candidate(focused_window, direction) {
1371 - let focused_position = self.windows.iter().position(|&window| window == focused_window);
1372 - let target_position = self.windows.iter().position(|&window| window == target_window);
1373 -
1374 - if let (Some(focused_index), Some(target_index)) = (focused_position, target_position) {
1375 - self.windows.swap(focused_index, target_index);
1376 - self.apply_layout()?;
1377 - self.focus(Some(focused_window))?;
1378 -
1379 - if let Ok(geometry) = self.get_or_query_geometry(focused_window) {
1380 - self.connection.warp_pointer(
1381 - x11rb::NONE,
1382 - focused_window,
1383 - 0,
1384 - 0,
1385 - 0,
1386 - 0,
1387 - geometry.width as i16 / 2,
1388 - geometry.height as i16 / 2,
1389 - )?;
1390 - }
1391 - }
1392 - }
1393 -
1394 - Ok(())
1395 - }
1396 -
1397 1214 fn grab_next_keys(&self, candidates: &[usize], keys_pressed: usize) -> WmResult<()> {
1398 1215 use std::collections::HashMap;
1399 1216 use x11rb::protocol::xproto::Keycode;
@@ -2191,43 +2008,6 @@ impl WindowManager {
2191 2008 )?;
2192 2009 }
2193 2010
2194 - let is_normie_layout = self.layout.name() == "normie";
2195 - if is_normie_layout && !is_transient && !is_dialog && !is_rule_floating {
2196 - if let Ok(pointer) = self.connection.query_pointer(self.root)?.reply() {
2197 - let cursor_monitor = self.get_monitor_at_point(pointer.root_x as i32, pointer.root_y as i32)
2198 - .and_then(|idx| self.monitors.get(idx))
2199 - .unwrap_or(&monitor);
2200 -
2201 - let float_width = (cursor_monitor.screen_width as f32 * 0.6) as u32;
2202 - let float_height = (cursor_monitor.screen_height as f32 * 0.6) as u32;
2203 - let spawn_x = pointer.root_x as i32 - (float_width as i32 / 2);
2204 - let spawn_y = pointer.root_y as i32 - (float_height as i32 / 2);
2205 -
2206 - let clamped_x = spawn_x
2207 - .max(cursor_monitor.screen_x)
2208 - .min(cursor_monitor.screen_x + cursor_monitor.screen_width as i32 - float_width as i32);
2209 - let clamped_y = spawn_y
2210 - .max(cursor_monitor.screen_y)
2211 - .min(cursor_monitor.screen_y + cursor_monitor.screen_height as i32 - float_height as i32);
2212 -
2213 - self.connection.configure_window(
2214 - window,
2215 - &ConfigureWindowAux::new()
2216 - .x(clamped_x)
2217 - .y(clamped_y)
2218 - .width(float_width)
2219 - .height(float_height)
2220 - .border_width(border_width)
2221 - .stack_mode(StackMode::ABOVE),
2222 - )?;
2223 -
2224 - if let Some(client) = self.clients.get_mut(&window) {
2225 - client.is_floating = true;
2226 - }
2227 - self.floating_windows.insert(window);
2228 - }
2229 - }
2230 -
2231 2011 self.set_wm_state(window, 1)?;
2232 2012 if let Err(error) = self.save_client_tag(window, window_tags) {
2233 2013 eprintln!("Failed to save client tag for new window: {:?}", error);
@@ -3083,12 +2863,11 @@ impl WindowManager {
3083 2863 }
3084 2864
3085 2865 fn apply_layout(&mut self) -> WmResult<()> {
3086 - if self.layout.name() == LayoutType::Normie.as_str() {
3087 - return Ok(());
3088 - }
2866 + let is_normie = self.layout.name() == LayoutType::Normie.as_str();
3089 2867
3090 - let monitor_count = self.monitors.len();
3091 - for monitor_index in 0..monitor_count {
2868 + if !is_normie {
2869 + let monitor_count = self.monitors.len();
2870 + for monitor_index in 0..monitor_count {
3092 2871 let monitor = &self.monitors[monitor_index];
3093 2872 let border_width = self.config.border_width;
3094 2873
@@ -3191,6 +2970,7 @@ impl WindowManager {
3191 2970 border_width: border_width as u16,
3192 2971 });
3193 2972 }
2973 + }
3194 2974 }
3195 2975
3196 2976 for monitor_index in 0..self.monitors.len() {