Verify that pending fullscreen matches column
Browse files at this commit05613eed1efc724277a08f763e19e218b1d697ffParent: b23dd4b2 changed files +45 -1
- src/layout/mod.rs +41 -1
- src/layout/workspace.rs +4 -0
src/layout/mod.rsmodified+41 -1
| @@ -104,6 +104,11 @@ pub trait LayoutElement: PartialEq { | |||
| 104 | /// | 104 | /// |
| 105 | /// This will *not* switch immediately after a [`LayoutElement::request_fullscreen()`] call. | 105 | /// This will *not* switch immediately after a [`LayoutElement::request_fullscreen()`] call. |
| 106 | fn is_fullscreen(&self) -> bool; | 106 | fn is_fullscreen(&self) -> bool; |
| 107 | + | ||
| 108 | + /// Whether we're requesting the element to be fullscreen. | ||
| 109 | + /// | ||
| 110 | + /// This *will* switch immediately after a [`LayoutElement::request_fullscreen()`] call. | ||
| 111 | + fn is_pending_fullscreen(&self) -> bool; | ||
| 107 | } | 112 | } |
| 108 | 113 | ||
| 109 | #[derive(Debug)] | 114 | #[derive(Debug)] |
| @@ -290,6 +295,11 @@ impl LayoutElement for Window { | |||
| 290 | .states | 295 | .states |
| 291 | .contains(xdg_toplevel::State::Fullscreen) | 296 | .contains(xdg_toplevel::State::Fullscreen) |
| 292 | } | 297 | } |
| 298 | + | ||
| 299 | + fn is_pending_fullscreen(&self) -> bool { | ||
| 300 | + self.toplevel() | ||
| 301 | + .with_pending_state(|state| state.states.contains(xdg_toplevel::State::Fullscreen)) | ||
| 302 | + } | ||
| 293 | } | 303 | } |
| 294 | 304 | ||
| 295 | impl<W: LayoutElement> Layout<W> { | 305 | impl<W: LayoutElement> Layout<W> { |
| @@ -1586,6 +1596,7 @@ mod tests { | |||
| 1586 | requested_size: Cell<Option<Size<i32, Logical>>>, | 1596 | requested_size: Cell<Option<Size<i32, Logical>>>, |
| 1587 | min_size: Size<i32, Logical>, | 1597 | min_size: Size<i32, Logical>, |
| 1588 | max_size: Size<i32, Logical>, | 1598 | max_size: Size<i32, Logical>, |
| 1599 | + pending_fullscreen: Cell<bool>, | ||
| 1589 | } | 1600 | } |
| 1590 | 1601 | ||
| 1591 | #[derive(Debug, Clone)] | 1602 | #[derive(Debug, Clone)] |
| @@ -1605,6 +1616,7 @@ mod tests { | |||
| 1605 | requested_size: Cell::new(None), | 1616 | requested_size: Cell::new(None), |
| 1606 | min_size, | 1617 | min_size, |
| 1607 | max_size, | 1618 | max_size, |
| 1619 | + pending_fullscreen: Cell::new(false), | ||
| 1608 | })) | 1620 | })) |
| 1609 | } | 1621 | } |
| 1610 | 1622 | ||
| @@ -1661,9 +1673,12 @@ mod tests { | |||
| 1661 | 1673 | ||
| 1662 | fn request_size(&self, size: Size<i32, Logical>) { | 1674 | fn request_size(&self, size: Size<i32, Logical>) { |
| 1663 | self.0.requested_size.set(Some(size)); | 1675 | self.0.requested_size.set(Some(size)); |
| 1676 | + self.0.pending_fullscreen.set(false); | ||
| 1664 | } | 1677 | } |
| 1665 | 1678 | ||
| 1666 | - fn request_fullscreen(&self, _size: Size<i32, Logical>) {} | 1679 | + fn request_fullscreen(&self, _size: Size<i32, Logical>) { |
| 1680 | + self.0.pending_fullscreen.set(true); | ||
| 1681 | + } | ||
| 1667 | 1682 | ||
| 1668 | fn min_size(&self) -> Size<i32, Logical> { | 1683 | fn min_size(&self) -> Size<i32, Logical> { |
| 1669 | self.0.min_size | 1684 | self.0.min_size |
| @@ -1690,6 +1705,10 @@ mod tests { | |||
| 1690 | fn is_fullscreen(&self) -> bool { | 1705 | fn is_fullscreen(&self) -> bool { |
| 1691 | false | 1706 | false |
| 1692 | } | 1707 | } |
| 1708 | + | ||
| 1709 | + fn is_pending_fullscreen(&self) -> bool { | ||
| 1710 | + self.0.pending_fullscreen.get() | ||
| 1711 | + } | ||
| 1693 | } | 1712 | } |
| 1694 | 1713 | ||
| 1695 | fn arbitrary_bbox() -> impl Strategy<Value = Rectangle<i32, Logical>> { | 1714 | fn arbitrary_bbox() -> impl Strategy<Value = Rectangle<i32, Logical>> { |
| @@ -2017,6 +2036,9 @@ mod tests { | |||
| 2017 | Op::CloseWindow(0), | 2036 | Op::CloseWindow(0), |
| 2018 | Op::CloseWindow(1), | 2037 | Op::CloseWindow(1), |
| 2019 | Op::CloseWindow(2), | 2038 | Op::CloseWindow(2), |
| 2039 | + Op::FullscreenWindow(1), | ||
| 2040 | + Op::FullscreenWindow(2), | ||
| 2041 | + Op::FullscreenWindow(3), | ||
| 2020 | Op::FocusColumnLeft, | 2042 | Op::FocusColumnLeft, |
| 2021 | Op::FocusColumnRight, | 2043 | Op::FocusColumnRight, |
| 2022 | Op::FocusWindowUp, | 2044 | Op::FocusWindowUp, |
| @@ -2145,6 +2167,9 @@ mod tests { | |||
| 2145 | Op::CloseWindow(0), | 2167 | Op::CloseWindow(0), |
| 2146 | Op::CloseWindow(1), | 2168 | Op::CloseWindow(1), |
| 2147 | Op::CloseWindow(2), | 2169 | Op::CloseWindow(2), |
| 2170 | + Op::FullscreenWindow(1), | ||
| 2171 | + Op::FullscreenWindow(2), | ||
| 2172 | + Op::FullscreenWindow(3), | ||
| 2148 | Op::FocusColumnLeft, | 2173 | Op::FocusColumnLeft, |
| 2149 | Op::FocusColumnRight, | 2174 | Op::FocusColumnRight, |
| 2150 | Op::FocusWindowUp, | 2175 | Op::FocusWindowUp, |
| @@ -2498,6 +2523,21 @@ mod tests { | |||
| 2498 | assert!(monitors[1].workspaces[0].has_windows()); | 2523 | assert!(monitors[1].workspaces[0].has_windows()); |
| 2499 | } | 2524 | } |
| 2500 | 2525 | ||
| 2526 | + #[test] | ||
| 2527 | + fn fullscreen() { | ||
| 2528 | + let ops = [ | ||
| 2529 | + Op::AddOutput(1), | ||
| 2530 | + Op::AddWindow { | ||
| 2531 | + id: 1, | ||
| 2532 | + bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), | ||
| 2533 | + min_max_size: (Size::from((0, 0)), Size::from((i32::MAX, i32::MAX))), | ||
| 2534 | + }, | ||
| 2535 | + Op::FullscreenWindow(1), | ||
| 2536 | + ]; | ||
| 2537 | + | ||
| 2538 | + check_ops(&ops); | ||
| 2539 | + } | ||
| 2540 | + | ||
| 2501 | fn arbitrary_spacing() -> impl Strategy<Value = u16> { | 2541 | fn arbitrary_spacing() -> impl Strategy<Value = u16> { |
| 2502 | // Give equal weight to: | 2542 | // Give equal weight to: |
| 2503 | // - 0: the element is disabled | 2543 | // - 0: the element is disabled |
src/layout/workspace.rsmodified+4 -0
| @@ -1441,6 +1441,10 @@ impl<W: LayoutElement> Column<W> { | |||
| 1441 | if self.is_fullscreen { | 1441 | if self.is_fullscreen { |
| 1442 | assert_eq!(self.tiles.len(), 1); | 1442 | assert_eq!(self.tiles.len(), 1); |
| 1443 | } | 1443 | } |
| 1444 | + | ||
| 1445 | + for tile in &self.tiles { | ||
| 1446 | + assert_eq!(self.is_fullscreen, tile.window().is_pending_fullscreen()); | ||
| 1447 | + } | ||
| 1444 | } | 1448 | } |
| 1445 | 1449 | ||
| 1446 | fn toggle_width(&mut self) { | 1450 | fn toggle_width(&mut self) { |