Fixed panic caused by double .unwrap() in the event that no windows are opened, but fullscreen is sent.
Browse files
+10 −4 src/window_manager.rs
| @@ -1420,11 +1420,14 @@ impl WindowManager { | |||
| 1420 | .copied() | 1420 | .copied() |
| 1421 | .collect(); | 1421 | .collect(); |
| 1422 | 1422 | ||
| 1423 | - let focused = self | 1423 | + let focused = match self |
| 1424 | .monitors | 1424 | .monitors |
| 1425 | .get(self.selected_monitor) | 1425 | .get(self.selected_monitor) |
| 1426 | .and_then(|m| m.selected_client) | 1426 | .and_then(|m| m.selected_client) |
| 1427 | - .unwrap(); | 1427 | + { |
| 1428 | + Some(window) => window, | ||
| 1429 | + None => return Ok(()), | ||
| 1430 | + }; | ||
| 1428 | 1431 | ||
| 1429 | self.fullscreen_windows.insert(focused); | 1432 | self.fullscreen_windows.insert(focused); |
| 1430 | 1433 | ||
| @@ -1496,11 +1499,14 @@ impl WindowManager { | |||
| 1496 | } | 1499 | } |
| 1497 | self.connection.flush()?; | 1500 | self.connection.flush()?; |
| 1498 | } else { | 1501 | } else { |
| 1499 | - let focused = self | 1502 | + let focused = match self |
| 1500 | .monitors | 1503 | .monitors |
| 1501 | .get(self.selected_monitor) | 1504 | .get(self.selected_monitor) |
| 1502 | .and_then(|m| m.selected_client) | 1505 | .and_then(|m| m.selected_client) |
| 1503 | - .unwrap(); | 1506 | + { |
| 1507 | + Some(window) => window, | ||
| 1508 | + None => return Ok(()), | ||
| 1509 | + }; | ||
| 1504 | 1510 | ||
| 1505 | self.fullscreen_windows.remove(&focused); | 1511 | self.fullscreen_windows.remove(&focused); |
| 1506 | 1512 | ||