tony / oxwm

Fixed bug where floating mode toggle wasnt actually fullscreening floating windows, and fixed to take into consideration gaps in geometries. also persist size of floating windows after toggling back from fullscreen. Browse files
tonybtw committed 2025-11-17 parent 0b92dec commit 3045776f6c898b85f275cf0cfe33ff5725ea87fc
Showing 1 changed file with 73 additions and 6 deletions. UnifiedSplit
+73 −6 src/window_manager.rs
@@ -90,6 +90,7 @@ pub struct WindowManager {
90 gaps_enabled: bool, 90 gaps_enabled: bool,
91 floating_windows: HashSet<Window>, 91 floating_windows: HashSet<Window>,
92 fullscreen_windows: HashSet<Window>, 92 fullscreen_windows: HashSet<Window>,
93 + floating_geometry_before_fullscreen: std::collections::HashMap<Window, (i16, i16, u16, u16, u16)>,
93 bars: Vec<Bar>, 94 bars: Vec<Bar>,
94 show_bar: bool, 95 show_bar: bool,
95 last_layout: Option<&'static str>, 96 last_layout: Option<&'static str>,
@@ -215,6 +216,7 @@ impl WindowManager {
215 gaps_enabled, 216 gaps_enabled,
216 floating_windows: HashSet::new(), 217 floating_windows: HashSet::new(),
217 fullscreen_windows: HashSet::new(), 218 fullscreen_windows: HashSet::new(),
219 + floating_geometry_before_fullscreen: std::collections::HashMap::new(),
218 bars, 220 bars,
219 show_bar: true, 221 show_bar: true,
220 last_layout: None, 222 last_layout: None,
@@ -1554,14 +1556,80 @@ impl WindowManager {
1554 if let Ok(layout) = layout_from_str("monocle") { 1556 if let Ok(layout) = layout_from_str("monocle") {
1555 self.layout = layout; 1557 self.layout = layout;
1556 } 1558 }
1559 + self.toggle_bar()?;
1560 + self.apply_layout()?;
1561 +
1562 + let border_width = self.config.border_width;
1563 + let windows: Vec<Window> = self.windows.iter()
1564 + .filter(|&&w| self.floating_windows.contains(&w) && self.is_window_visible(w))
1565 + .copied()
1566 + .collect();
1567 +
1568 + for window in windows {
1569 + if let Ok(geom) = self.connection.get_geometry(window)?.reply() {
1570 + self.floating_geometry_before_fullscreen.insert(
1571 + window,
1572 + (geom.x, geom.y, geom.width, geom.height, geom.border_width as u16),
1573 + );
1574 + }
1575 +
1576 + let monitor_idx = *self.window_monitor.get(&window).unwrap_or(&self.selected_monitor);
1577 + let monitor = &self.monitors[monitor_idx];
1578 +
1579 + let (outer_gap_h, outer_gap_v) = if self.gaps_enabled {
1580 + (
1581 + self.config.gap_outer_horizontal,
1582 + self.config.gap_outer_vertical,
1583 + )
1584 + } else {
1585 + (0, 0)
1586 + };
1587 +
1588 + let x = monitor.x + outer_gap_h as i32;
1589 + let y = monitor.y + outer_gap_v as i32;
1590 + let width = monitor.width.saturating_sub(2 * outer_gap_h).saturating_sub(2 * border_width);
1591 + let height = monitor.height.saturating_sub(2 * outer_gap_v).saturating_sub(2 * border_width);
1592 +
1593 + self.connection.configure_window(
1594 + window,
1595 + &x11rb::protocol::xproto::ConfigureWindowAux::new()
1596 + .x(x)
1597 + .y(y)
1598 + .width(width)
1599 + .height(height),
1600 + )?;
1601 + }
1602 + self.connection.flush()?;
1557 } else { 1603 } else {
1558 if let Some(last) = self.last_layout { 1604 if let Some(last) = self.last_layout {
1559 if let Ok(layout) = layout_from_str(last) { 1605 if let Ok(layout) = layout_from_str(last) {
1560 self.layout = layout; 1606 self.layout = layout;
1561 } 1607 }
1562 } 1608 }
1609 + self.toggle_bar()?;
1610 + self.apply_layout()?;
1611 +
1612 + let windows: Vec<Window> = self.windows.iter()
1613 + .filter(|&&w| self.floating_windows.contains(&w) && self.is_window_visible(w))
1614 + .copied()
1615 + .collect();
1616 +
1617 + for window in windows {
1618 + if let Some(&(x, y, width, height, border_width)) = self.floating_geometry_before_fullscreen.get(&window) {
1619 + self.connection.configure_window(
1620 + window,
1621 + &x11rb::protocol::xproto::ConfigureWindowAux::new()
1622 + .x(x as i32)
1623 + .y(y as i32)
1624 + .width(width as u32)
1625 + .height(height as u32)
1626 + .border_width(border_width as u32),
1627 + )?;
1628 + self.floating_geometry_before_fullscreen.remove(&window);
1629 + }
1630 + }
1631 + self.connection.flush()?;
1563 } 1632 }
1564 - self.toggle_bar()?;
1565 Ok(()) 1633 Ok(())
1566 } 1634 }
1567 1635
@@ -1579,7 +1647,6 @@ impl WindowManager {
1579 )?; 1647 )?;
1580 1648
1581 self.fullscreen_windows.insert(window); 1649 self.fullscreen_windows.insert(window);
1582 - self.floating_windows.insert(window);
1583 1650
1584 let monitor_idx = *self.window_monitor.get(&window).unwrap_or(&self.selected_monitor); 1651 let monitor_idx = *self.window_monitor.get(&window).unwrap_or(&self.selected_monitor);
1585 let monitor = &self.monitors[monitor_idx]; 1652 let monitor = &self.monitors[monitor_idx];
@@ -1602,6 +1669,7 @@ impl WindowManager {
1602 )?; 1669 )?;
1603 1670
1604 self.connection.flush()?; 1671 self.connection.flush()?;
1672 + self.update_bar()?;
1605 } else if !fullscreen && self.fullscreen_windows.contains(&window) { 1673 } else if !fullscreen && self.fullscreen_windows.contains(&window) {
1606 self.connection.change_property( 1674 self.connection.change_property(
1607 PropMode::REPLACE, 1675 PropMode::REPLACE,
@@ -1615,10 +1683,6 @@ impl WindowManager {
1615 1683
1616 self.fullscreen_windows.remove(&window); 1684 self.fullscreen_windows.remove(&window);
1617 1685
1618 - if !self.is_transient_window(window) {
1619 - self.floating_windows.remove(&window);
1620 - }
1621 -
1622 self.connection.configure_window( 1686 self.connection.configure_window(
1623 window, 1687 window,
1624 &x11rb::protocol::xproto::ConfigureWindowAux::new() 1688 &x11rb::protocol::xproto::ConfigureWindowAux::new()
@@ -2173,6 +2237,9 @@ impl WindowManager {
2173 if self.floating_windows.contains(&w) { 2237 if self.floating_windows.contains(&w) {
2174 return false; 2238 return false;
2175 } 2239 }
2240 + if self.fullscreen_windows.contains(&w) {
2241 + return false;
2242 + }
2176 if let Some(&tags) = self.window_tags.get(&w) { 2243 if let Some(&tags) = self.window_tags.get(&w) {
2177 (tags & monitor.selected_tags) != 0 2244 (tags & monitor.selected_tags) != 0
2178 } else { 2245 } else {