tony / oxwm

Merge pull request #13 from xsoder/floating Browse files
feat: Adding floating mode for OXWM
Emzy committed 2025-10-14 parents fe6d8c8 246177a commit 459411451c646943376c31e92af1bf10804ee54b
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
@@ -17,6 +17,7 @@ pub enum KeyAction {
17 17 ViewTag,
18 18 ToggleGaps,
19 19 ToggleFullScreen,
20 + ToggleFloating,
20 21 MoveToTag,
21 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 337 fn toggle_fullscreen(&mut self) -> WmResult<()> {
320 338 if let Some(focused) = self.focused_window {
321 339 if self.fullscreen_window == Some(focused) {
@@ -380,6 +398,10 @@ impl WindowManager {
380 398 KeyAction::ToggleFullScreen => {
381 399 self.toggle_fullscreen()?;
382 400 }
401 + KeyAction::ToggleFloating => {
402 + self.toggle_floating()?;
403 + }
404 +
383 405 KeyAction::FocusStack => {
384 406 if let Arg::Int(direction) = arg {
385 407 self.cycle_focus(*direction)?;