tony / oxwm

cleanup fullscreen fix Browse files
use let-else and move focused_window check up to return earlier if none
is found
emzywastaken committed 2025-12-12 parent 93ceb27 commit 3b3c45cb0627ada8975ae15eaf50b421748612d0
Showing 1 changed file with 14 additions and 16 deletions. UnifiedSplit
+14 −16 src/window_manager.rs
@@ -1413,6 +1413,16 @@ impl WindowManager {
1413 1413
1414 fn fullscreen(&mut self) -> WmResult<()> { 1414 fn fullscreen(&mut self) -> WmResult<()> {
1415 if self.show_bar { 1415 if self.show_bar {
1416 + let Some(focused_window) = self
1417 + .monitors
1418 + .get(self.selected_monitor)
1419 + .and_then(|m| m.selected_client)
1420 + else {
1421 + return Ok(());
1422 + };
1423 +
1424 + self.fullscreen_windows.insert(focused_window);
1425 +
1416 let windows: Vec<Window> = self 1426 let windows: Vec<Window> = self
1417 .windows 1427 .windows
1418 .iter() 1428 .iter()
@@ -1420,17 +1430,6 @@ impl WindowManager {
1420 .copied() 1430 .copied()
1421 .collect(); 1431 .collect();
1422 1432
1423 - let focused = match self
1424 - .monitors
1425 - .get(self.selected_monitor)
1426 - .and_then(|m| m.selected_client)
1427 - {
1428 - Some(window) => window,
1429 - None => return Ok(()),
1430 - };
1431 -
1432 - self.fullscreen_windows.insert(focused);
1433 -
1434 for window in &windows { 1433 for window in &windows {
1435 if let Ok(geom) = self.connection.get_geometry(*window)?.reply() { 1434 if let Ok(geom) = self.connection.get_geometry(*window)?.reply() {
1436 self.floating_geometry_before_fullscreen.insert( 1435 self.floating_geometry_before_fullscreen.insert(
@@ -1499,16 +1498,15 @@ impl WindowManager {
1499 } 1498 }
1500 self.connection.flush()?; 1499 self.connection.flush()?;
1501 } else { 1500 } else {
1502 - let focused = match self 1501 + let Some(focused_window) = self
1503 .monitors 1502 .monitors
1504 .get(self.selected_monitor) 1503 .get(self.selected_monitor)
1505 .and_then(|m| m.selected_client) 1504 .and_then(|m| m.selected_client)
1506 - { 1505 + else {
1507 - Some(window) => window, 1506 + return Ok(());
1508 - None => return Ok(()),
1509 }; 1507 };
1510 1508
1511 - self.fullscreen_windows.remove(&focused); 1509 + self.fullscreen_windows.remove(&focused_window);
1512 1510
1513 if let Some(last) = self.last_layout { 1511 if let Some(last) = self.last_layout {
1514 if let Ok(layout) = layout_from_str(last) { 1512 if let Ok(layout) = layout_from_str(last) {