Merge pull request #13 from xsoder/floating
Browse files
feat: Adding floating mode for OXWM
+1 −0 src/default_config.rs
| @@ -100,6 +100,7 @@ pub const KEYBINDINGS: &[Key] = &[ | |||
| 100 | Key::new(&[MODKEY], keycodes::D, KeyAction::Spawn, Arg::Array(DMENU_CMD)), | 100 | Key::new(&[MODKEY], keycodes::D, KeyAction::Spawn, Arg::Array(DMENU_CMD)), |
| 101 | Key::new(&[MODKEY], keycodes::Q, KeyAction::KillClient, Arg::None), | 101 | Key::new(&[MODKEY], keycodes::Q, KeyAction::KillClient, Arg::None), |
| 102 | Key::new(&[MODKEY, SHIFT], keycodes::F, KeyAction::ToggleFullScreen, Arg::None), | 102 | Key::new(&[MODKEY, SHIFT], keycodes::F, KeyAction::ToggleFullScreen, Arg::None), |
| 103 | + Key::new(&[MODKEY, SHIFT], keycodes::SPACE, KeyAction::ToggleFloating, Arg::None), | ||
| 103 | Key::new(&[MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None), | 104 | Key::new(&[MODKEY], keycodes::A, KeyAction::ToggleGaps, Arg::None), |
| 104 | Key::new(&[MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None), | 105 | Key::new(&[MODKEY, SHIFT], keycodes::Q, KeyAction::Quit, Arg::None), |
| 105 | Key::new(&[MODKEY, SHIFT], keycodes::R, KeyAction::Restart, Arg::None), | 106 | Key::new(&[MODKEY, SHIFT], keycodes::R, KeyAction::Restart, Arg::None), |
+1 −0 src/keyboard/handlers.rs
| @@ -17,6 +17,7 @@ pub enum KeyAction { | |||
| 17 | ViewTag, | 17 | ViewTag, |
| 18 | ToggleGaps, | 18 | ToggleGaps, |
| 19 | ToggleFullScreen, | 19 | ToggleFullScreen, |
| 20 | + ToggleFloating, | ||
| 20 | MoveToTag, | 21 | MoveToTag, |
| 21 | None, | 22 | None, |
| 22 | } | 23 | } |
+22 −0 src/window_manager.rs
| @@ -316,6 +316,24 @@ impl WindowManager { | |||
| 316 | } | 316 | } |
| 317 | } | 317 | } |
| 318 | 318 | ||
| 319 | + fn toggle_floating(&mut self) -> WmResult<()> { | ||
| 320 | + if let Some(focused) = self.focused_window { | ||
| 321 | + if self.floating_windows.contains(&focused) { | ||
| 322 | + self.floating_windows.remove(&focused); | ||
| 323 | + self.apply_layout()?; | ||
| 324 | + } else { | ||
| 325 | + self.floating_windows.insert(focused); | ||
| 326 | + self.connection.configure_window( | ||
| 327 | + focused, | ||
| 328 | + &ConfigureWindowAux::new().stack_mode(StackMode::ABOVE), | ||
| 329 | + )?; | ||
| 330 | + self.apply_layout()?; | ||
| 331 | + self.connection.flush()?; | ||
| 332 | + } | ||
| 333 | + } | ||
| 334 | + Ok(()) | ||
| 335 | + } | ||
| 336 | + | ||
| 319 | fn toggle_fullscreen(&mut self) -> WmResult<()> { | 337 | fn toggle_fullscreen(&mut self) -> WmResult<()> { |
| 320 | if let Some(focused) = self.focused_window { | 338 | if let Some(focused) = self.focused_window { |
| 321 | if self.fullscreen_window == Some(focused) { | 339 | if self.fullscreen_window == Some(focused) { |
| @@ -380,6 +398,10 @@ impl WindowManager { | |||
| 380 | KeyAction::ToggleFullScreen => { | 398 | KeyAction::ToggleFullScreen => { |
| 381 | self.toggle_fullscreen()?; | 399 | self.toggle_fullscreen()?; |
| 382 | } | 400 | } |
| 401 | + KeyAction::ToggleFloating => { | ||
| 402 | + self.toggle_floating()?; | ||
| 403 | + } | ||
| 404 | + | ||
| 383 | KeyAction::FocusStack => { | 405 | KeyAction::FocusStack => { |
| 384 | if let Arg::Int(direction) = arg { | 406 | if let Arg::Int(direction) = arg { |
| 385 | self.cycle_focus(*direction)?; | 407 | self.cycle_focus(*direction)?; |