tony / oxwm

feat: Adding floating mode for OXWM Browse files
xsoder committed 2025-10-14 parent 40d6e3c commit 5875fada0e0840869a21befd4d7e0ad2bfd7ae83
Showing 3 changed files with 24 additions and 0 deletions. UnifiedSplit
+1 −0 src/default_config.rs
@@ -100,6 +100,7 @@ pub const KEYBINDINGS: &[Key] = &[
100 100 Key::new(&[MODKEY], keycodes::D, KeyAction::Spawn, Arg::Array(DMENU_CMD)),
101 101 Key::new(&[MODKEY], keycodes::Q, KeyAction::KillClient, Arg::None),
102 102 Key::new(&[MODKEY, SHIFT], keycodes::F, KeyAction::ToggleFullScreen, Arg::None),
103 + Key::new(&[MODKEY, SHIFT], keycodes::SPACE, KeyAction::ToggleFloating, Arg::None),
103 104 Key::new(&[MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None),
104 105 Key::new(&[MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None),
105 106 Key::new(&[MODKEY, SHIFT], keycodes::R, KeyAction::Restart, Arg::None),
+1 −0 src/keyboard/handlers.rs
@@ -15,6 +15,7 @@ pub enum KeyAction {
15 15 ViewTag,
16 16 ToggleGaps,
17 17 ToggleFullScreen,
18 + ToggleFloating,
18 19 MoveToTag,
19 20 None,
20 21 }
+22 −0 src/window_manager.rs
@@ -389,6 +389,24 @@ impl WindowManager {
389 389 }
390 390 }
391 391
392 + fn toggle_floating(&mut self) -> Result<()> {
393 + if let Some(focused) = self.focused_window {
394 + if self.floating_windows.contains(&focused) {
395 + self.floating_windows.remove(&focused);
396 + self.apply_layout()?;
397 + } else {
398 + self.floating_windows.insert(focused);
399 + self.connection.configure_window(
400 + focused,
401 + &ConfigureWindowAux::new().stack_mode(StackMode::ABOVE),
402 + )?;
403 + self.apply_layout()?;
404 + self.connection.flush()?;
405 + }
406 + }
407 + Ok(())
408 + }
409 +
392 410 fn toggle_fullscreen(&mut self) -> Result<()> {
393 411 if let Some(focused) = self.focused_window {
394 412 if self.fullscreen_window == Some(focused) {
@@ -453,6 +471,10 @@ impl WindowManager {
453 471 KeyAction::ToggleFullScreen => {
454 472 self.toggle_fullscreen()?;
455 473 }
474 + KeyAction::ToggleFloating => {
475 + self.toggle_floating()?;
476 + }
477 +
456 478 KeyAction::FocusStack => {
457 479 if let Arg::Int(direction) = arg {
458 480 self.cycle_focus(*direction)?;