Remove remaining Window-specific functions
Browse files at this commitbbb4caeb8ccba52949799e7a229ee710ffa23564Parent: d421e1f3 changed files +48 -15
- niri-visual-tests/src/test_window.rs +8 -0
- src/layout/mod.rs +38 -3
- src/layout/workspace.rs +2 -12
niri-visual-tests/src/test_window.rsmodified+8 -0
| @@ -202,6 +202,12 @@ impl LayoutElement for TestWindow { | |||
| 202 | 202 | ||
| 203 | fn set_offscreen_element_id(&self, _id: Option<Id>) {} | 203 | fn set_offscreen_element_id(&self, _id: Option<Id>) {} |
| 204 | 204 | ||
| 205 | + fn set_activated(&self, _active: bool) {} | ||
| 206 | + | ||
| 207 | + fn set_bounds(&self, _bounds: Size<i32, Logical>) {} | ||
| 208 | + | ||
| 209 | + fn send_pending_configure(&self) {} | ||
| 210 | + | ||
| 205 | fn is_fullscreen(&self) -> bool { | 211 | fn is_fullscreen(&self) -> bool { |
| 206 | false | 212 | false |
| 207 | } | 213 | } |
| @@ -209,4 +215,6 @@ impl LayoutElement for TestWindow { | |||
| 209 | fn is_pending_fullscreen(&self) -> bool { | 215 | fn is_pending_fullscreen(&self) -> bool { |
| 210 | self.inner.borrow().pending_fullscreen | 216 | self.inner.borrow().pending_fullscreen |
| 211 | } | 217 | } |
| 218 | + | ||
| 219 | + fn refresh(&self) {} | ||
| 212 | } | 220 | } |
src/layout/mod.rsmodified+38 -3
| @@ -113,6 +113,10 @@ pub trait LayoutElement { | |||
| 113 | fn output_enter(&self, output: &Output); | 113 | fn output_enter(&self, output: &Output); |
| 114 | fn output_leave(&self, output: &Output); | 114 | fn output_leave(&self, output: &Output); |
| 115 | fn set_offscreen_element_id(&self, id: Option<Id>); | 115 | fn set_offscreen_element_id(&self, id: Option<Id>); |
| 116 | + fn set_activated(&self, active: bool); | ||
| 117 | + fn set_bounds(&self, bounds: Size<i32, Logical>); | ||
| 118 | + | ||
| 119 | + fn send_pending_configure(&self); | ||
| 116 | 120 | ||
| 117 | /// Whether the element is currently fullscreen. | 121 | /// Whether the element is currently fullscreen. |
| 118 | /// | 122 | /// |
| @@ -123,6 +127,9 @@ pub trait LayoutElement { | |||
| 123 | /// | 127 | /// |
| 124 | /// This *will* switch immediately after a [`LayoutElement::request_fullscreen()`] call. | 128 | /// This *will* switch immediately after a [`LayoutElement::request_fullscreen()`] call. |
| 125 | fn is_pending_fullscreen(&self) -> bool; | 129 | fn is_pending_fullscreen(&self) -> bool; |
| 130 | + | ||
| 131 | + /// Runs periodic clean-up tasks. | ||
| 132 | + fn refresh(&self); | ||
| 126 | } | 133 | } |
| 127 | 134 | ||
| 128 | #[derive(Debug)] | 135 | #[derive(Debug)] |
| @@ -327,6 +334,24 @@ impl LayoutElement for Window { | |||
| 327 | data.0.replace(id); | 334 | data.0.replace(id); |
| 328 | } | 335 | } |
| 329 | 336 | ||
| 337 | + fn set_activated(&self, active: bool) { | ||
| 338 | + Window::set_activated(self, active); | ||
| 339 | + } | ||
| 340 | + | ||
| 341 | + fn set_bounds(&self, bounds: Size<i32, Logical>) { | ||
| 342 | + self.toplevel() | ||
| 343 | + .expect("no x11 support") | ||
| 344 | + .with_pending_state(|state| { | ||
| 345 | + state.bounds = Some(bounds); | ||
| 346 | + }); | ||
| 347 | + } | ||
| 348 | + | ||
| 349 | + fn send_pending_configure(&self) { | ||
| 350 | + self.toplevel() | ||
| 351 | + .expect("no x11 support") | ||
| 352 | + .send_pending_configure(); | ||
| 353 | + } | ||
| 354 | + | ||
| 330 | fn is_fullscreen(&self) -> bool { | 355 | fn is_fullscreen(&self) -> bool { |
| 331 | self.toplevel() | 356 | self.toplevel() |
| 332 | .expect("no x11 support") | 357 | .expect("no x11 support") |
| @@ -340,6 +365,10 @@ impl LayoutElement for Window { | |||
| 340 | .expect("no x11 support") | 365 | .expect("no x11 support") |
| 341 | .with_pending_state(|state| state.states.contains(xdg_toplevel::State::Fullscreen)) | 366 | .with_pending_state(|state| state.states.contains(xdg_toplevel::State::Fullscreen)) |
| 342 | } | 367 | } |
| 368 | + | ||
| 369 | + fn refresh(&self) { | ||
| 370 | + SpaceElement::refresh(self) | ||
| 371 | + } | ||
| 343 | } | 372 | } |
| 344 | 373 | ||
| 345 | impl<W: LayoutElement> Layout<W> { | 374 | impl<W: LayoutElement> Layout<W> { |
| @@ -1792,11 +1821,9 @@ impl<W: LayoutElement> Layout<W> { | |||
| 1792 | } | 1821 | } |
| 1793 | } | 1822 | } |
| 1794 | } | 1823 | } |
| 1795 | -} | ||
| 1796 | 1824 | ||
| 1797 | -impl Layout<Window> { | ||
| 1798 | pub fn refresh(&mut self) { | 1825 | pub fn refresh(&mut self) { |
| 1799 | - let _span = tracy_client::span!("MonitorSet::refresh"); | 1826 | + let _span = tracy_client::span!("Layout::refresh"); |
| 1800 | 1827 | ||
| 1801 | match &mut self.monitor_set { | 1828 | match &mut self.monitor_set { |
| 1802 | MonitorSet::Normal { | 1829 | MonitorSet::Normal { |
| @@ -1964,6 +1991,12 @@ mod tests { | |||
| 1964 | 1991 | ||
| 1965 | fn set_offscreen_element_id(&self, _id: Option<Id>) {} | 1992 | fn set_offscreen_element_id(&self, _id: Option<Id>) {} |
| 1966 | 1993 | ||
| 1994 | + fn set_activated(&self, _active: bool) {} | ||
| 1995 | + | ||
| 1996 | + fn set_bounds(&self, _bounds: Size<i32, Logical>) {} | ||
| 1997 | + | ||
| 1998 | + fn send_pending_configure(&self) {} | ||
| 1999 | + | ||
| 1967 | fn is_fullscreen(&self) -> bool { | 2000 | fn is_fullscreen(&self) -> bool { |
| 1968 | false | 2001 | false |
| 1969 | } | 2002 | } |
| @@ -1971,6 +2004,8 @@ mod tests { | |||
| 1971 | fn is_pending_fullscreen(&self) -> bool { | 2004 | fn is_pending_fullscreen(&self) -> bool { |
| 1972 | self.0.pending_fullscreen.get() | 2005 | self.0.pending_fullscreen.get() |
| 1973 | } | 2006 | } |
| 2007 | + | ||
| 2008 | + fn refresh(&self) {} | ||
| 1974 | } | 2009 | } |
| 1975 | 2010 | ||
| 1976 | fn arbitrary_bbox() -> impl Strategy<Value = Rectangle<i32, Logical>> { | 2011 | fn arbitrary_bbox() -> impl Strategy<Value = Rectangle<i32, Logical>> { |
src/layout/workspace.rsmodified+2 -12
| @@ -5,7 +5,6 @@ use std::time::Duration; | |||
| 5 | 5 | ||
| 6 | use niri_config::{CenterFocusedColumn, PresetWidth, Struts}; | 6 | use niri_config::{CenterFocusedColumn, PresetWidth, Struts}; |
| 7 | use niri_ipc::SizeChange; | 7 | use niri_ipc::SizeChange; |
| 8 | -use smithay::desktop::space::SpaceElement; | ||
| 9 | use smithay::desktop::{layer_map_for_output, Window}; | 8 | use smithay::desktop::{layer_map_for_output, Window}; |
| 10 | use smithay::output::Output; | 9 | use smithay::output::Output; |
| 11 | use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; | 10 | use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; |
| @@ -1534,9 +1533,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1534 | 1533 | ||
| 1535 | true | 1534 | true |
| 1536 | } | 1535 | } |
| 1537 | -} | ||
| 1538 | 1536 | ||
| 1539 | -impl Workspace<Window> { | ||
| 1540 | pub fn refresh(&self, is_active: bool) { | 1537 | pub fn refresh(&self, is_active: bool) { |
| 1541 | let bounds = self.toplevel_bounds(); | 1538 | let bounds = self.toplevel_bounds(); |
| 1542 | 1539 | ||
| @@ -1548,15 +1545,8 @@ impl Workspace<Window> { | |||
| 1548 | && col.active_tile_idx == tile_idx; | 1545 | && col.active_tile_idx == tile_idx; |
| 1549 | win.set_activated(active); | 1546 | win.set_activated(active); |
| 1550 | 1547 | ||
| 1551 | - win.toplevel() | 1548 | + win.set_bounds(bounds); |
| 1552 | - .expect("no x11 support") | 1549 | + win.send_pending_configure(); |
| 1553 | - .with_pending_state(|state| { | ||
| 1554 | - state.bounds = Some(bounds); | ||
| 1555 | - }); | ||
| 1556 | - | ||
| 1557 | - win.toplevel() | ||
| 1558 | - .expect("no x11 support") | ||
| 1559 | - .send_pending_configure(); | ||
| 1560 | win.refresh(); | 1550 | win.refresh(); |
| 1561 | } | 1551 | } |
| 1562 | } | 1552 | } |