From bbb4caeb8ccba52949799e7a229ee710ffa23564 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Tue, 19 Mar 2024 13:52:08 +0400 Subject: Remove remaining Window-specific functions --- src/layout/mod.rs | 41 ++++++++++++++++++++++++++++++++++++++--- src/layout/workspace.rs | 14 ++------------ 2 files changed, 40 insertions(+), 15 deletions(-) (limited to 'src/layout') diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 09c8abed..24720435 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -113,6 +113,10 @@ pub trait LayoutElement { fn output_enter(&self, output: &Output); fn output_leave(&self, output: &Output); fn set_offscreen_element_id(&self, id: Option); + fn set_activated(&self, active: bool); + fn set_bounds(&self, bounds: Size); + + fn send_pending_configure(&self); /// Whether the element is currently fullscreen. /// @@ -123,6 +127,9 @@ pub trait LayoutElement { /// /// This *will* switch immediately after a [`LayoutElement::request_fullscreen()`] call. fn is_pending_fullscreen(&self) -> bool; + + /// Runs periodic clean-up tasks. + fn refresh(&self); } #[derive(Debug)] @@ -327,6 +334,24 @@ impl LayoutElement for Window { data.0.replace(id); } + fn set_activated(&self, active: bool) { + Window::set_activated(self, active); + } + + fn set_bounds(&self, bounds: Size) { + self.toplevel() + .expect("no x11 support") + .with_pending_state(|state| { + state.bounds = Some(bounds); + }); + } + + fn send_pending_configure(&self) { + self.toplevel() + .expect("no x11 support") + .send_pending_configure(); + } + fn is_fullscreen(&self) -> bool { self.toplevel() .expect("no x11 support") @@ -340,6 +365,10 @@ impl LayoutElement for Window { .expect("no x11 support") .with_pending_state(|state| state.states.contains(xdg_toplevel::State::Fullscreen)) } + + fn refresh(&self) { + SpaceElement::refresh(self) + } } impl Layout { @@ -1792,11 +1821,9 @@ impl Layout { } } } -} -impl Layout { pub fn refresh(&mut self) { - let _span = tracy_client::span!("MonitorSet::refresh"); + let _span = tracy_client::span!("Layout::refresh"); match &mut self.monitor_set { MonitorSet::Normal { @@ -1964,6 +1991,12 @@ mod tests { fn set_offscreen_element_id(&self, _id: Option) {} + fn set_activated(&self, _active: bool) {} + + fn set_bounds(&self, _bounds: Size) {} + + fn send_pending_configure(&self) {} + fn is_fullscreen(&self) -> bool { false } @@ -1971,6 +2004,8 @@ mod tests { fn is_pending_fullscreen(&self) -> bool { self.0.pending_fullscreen.get() } + + fn refresh(&self) {} } fn arbitrary_bbox() -> impl Strategy> { diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index b5d1b220..9a0f10e5 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -5,7 +5,6 @@ use std::time::Duration; use niri_config::{CenterFocusedColumn, PresetWidth, Struts}; use niri_ipc::SizeChange; -use smithay::desktop::space::SpaceElement; use smithay::desktop::{layer_map_for_output, Window}; use smithay::output::Output; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; @@ -1534,9 +1533,7 @@ impl Workspace { true } -} -impl Workspace { pub fn refresh(&self, is_active: bool) { let bounds = self.toplevel_bounds(); @@ -1548,15 +1545,8 @@ impl Workspace { && col.active_tile_idx == tile_idx; win.set_activated(active); - win.toplevel() - .expect("no x11 support") - .with_pending_state(|state| { - state.bounds = Some(bounds); - }); - - win.toplevel() - .expect("no x11 support") - .send_pending_configure(); + win.set_bounds(bounds); + win.send_pending_configure(); win.refresh(); } } -- cgit