Remove remaining Window-specific functions

This commit is contained in:
Ivan Molodetskikh
2024-03-19 13:52:08 +04:00
parent d421e1fbf8
commit bbb4caeb8c
3 changed files with 48 additions and 15 deletions
+8
View File
@@ -202,6 +202,12 @@ impl LayoutElement for TestWindow {
fn set_offscreen_element_id(&self, _id: Option<Id>) {} fn set_offscreen_element_id(&self, _id: Option<Id>) {}
fn set_activated(&self, _active: bool) {}
fn set_bounds(&self, _bounds: Size<i32, Logical>) {}
fn send_pending_configure(&self) {}
fn is_fullscreen(&self) -> bool { fn is_fullscreen(&self) -> bool {
false false
} }
@@ -209,4 +215,6 @@ impl LayoutElement for TestWindow {
fn is_pending_fullscreen(&self) -> bool { fn is_pending_fullscreen(&self) -> bool {
self.inner.borrow().pending_fullscreen self.inner.borrow().pending_fullscreen
} }
fn refresh(&self) {}
} }
+38 -3
View File
@@ -113,6 +113,10 @@ pub trait LayoutElement {
fn output_enter(&self, output: &Output); fn output_enter(&self, output: &Output);
fn output_leave(&self, output: &Output); fn output_leave(&self, output: &Output);
fn set_offscreen_element_id(&self, id: Option<Id>); fn set_offscreen_element_id(&self, id: Option<Id>);
fn set_activated(&self, active: bool);
fn set_bounds(&self, bounds: Size<i32, Logical>);
fn send_pending_configure(&self);
/// Whether the element is currently fullscreen. /// Whether the element is currently fullscreen.
/// ///
@@ -123,6 +127,9 @@ pub trait LayoutElement {
/// ///
/// This *will* switch immediately after a [`LayoutElement::request_fullscreen()`] call. /// This *will* switch immediately after a [`LayoutElement::request_fullscreen()`] call.
fn is_pending_fullscreen(&self) -> bool; fn is_pending_fullscreen(&self) -> bool;
/// Runs periodic clean-up tasks.
fn refresh(&self);
} }
#[derive(Debug)] #[derive(Debug)]
@@ -327,6 +334,24 @@ impl LayoutElement for Window {
data.0.replace(id); data.0.replace(id);
} }
fn set_activated(&self, active: bool) {
Window::set_activated(self, active);
}
fn set_bounds(&self, bounds: Size<i32, Logical>) {
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 { fn is_fullscreen(&self) -> bool {
self.toplevel() self.toplevel()
.expect("no x11 support") .expect("no x11 support")
@@ -340,6 +365,10 @@ impl LayoutElement for Window {
.expect("no x11 support") .expect("no x11 support")
.with_pending_state(|state| state.states.contains(xdg_toplevel::State::Fullscreen)) .with_pending_state(|state| state.states.contains(xdg_toplevel::State::Fullscreen))
} }
fn refresh(&self) {
SpaceElement::refresh(self)
}
} }
impl<W: LayoutElement> Layout<W> { impl<W: LayoutElement> Layout<W> {
@@ -1792,11 +1821,9 @@ impl<W: LayoutElement> Layout<W> {
} }
} }
} }
}
impl Layout<Window> {
pub fn refresh(&mut self) { pub fn refresh(&mut self) {
let _span = tracy_client::span!("MonitorSet::refresh"); let _span = tracy_client::span!("Layout::refresh");
match &mut self.monitor_set { match &mut self.monitor_set {
MonitorSet::Normal { MonitorSet::Normal {
@@ -1964,6 +1991,12 @@ mod tests {
fn set_offscreen_element_id(&self, _id: Option<Id>) {} fn set_offscreen_element_id(&self, _id: Option<Id>) {}
fn set_activated(&self, _active: bool) {}
fn set_bounds(&self, _bounds: Size<i32, Logical>) {}
fn send_pending_configure(&self) {}
fn is_fullscreen(&self) -> bool { fn is_fullscreen(&self) -> bool {
false false
} }
@@ -1971,6 +2004,8 @@ mod tests {
fn is_pending_fullscreen(&self) -> bool { fn is_pending_fullscreen(&self) -> bool {
self.0.pending_fullscreen.get() self.0.pending_fullscreen.get()
} }
fn refresh(&self) {}
} }
fn arbitrary_bbox() -> impl Strategy<Value = Rectangle<i32, Logical>> { fn arbitrary_bbox() -> impl Strategy<Value = Rectangle<i32, Logical>> {
+2 -12
View File
@@ -5,7 +5,6 @@ use std::time::Duration;
use niri_config::{CenterFocusedColumn, PresetWidth, Struts}; use niri_config::{CenterFocusedColumn, PresetWidth, Struts};
use niri_ipc::SizeChange; use niri_ipc::SizeChange;
use smithay::desktop::space::SpaceElement;
use smithay::desktop::{layer_map_for_output, Window}; use smithay::desktop::{layer_map_for_output, Window};
use smithay::output::Output; use smithay::output::Output;
use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel; use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
@@ -1534,9 +1533,7 @@ impl<W: LayoutElement> Workspace<W> {
true true
} }
}
impl Workspace<Window> {
pub fn refresh(&self, is_active: bool) { pub fn refresh(&self, is_active: bool) {
let bounds = self.toplevel_bounds(); let bounds = self.toplevel_bounds();
@@ -1548,15 +1545,8 @@ impl Workspace<Window> {
&& col.active_tile_idx == tile_idx; && col.active_tile_idx == tile_idx;
win.set_activated(active); win.set_activated(active);
win.toplevel() win.set_bounds(bounds);
.expect("no x11 support") win.send_pending_configure();
.with_pending_state(|state| {
state.bounds = Some(bounds);
});
win.toplevel()
.expect("no x11 support")
.send_pending_configure();
win.refresh(); win.refresh();
} }
} }