From 93c547f7499105d69f2bef41699b76937a2559c8 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Tue, 6 Feb 2024 19:47:36 +0400 Subject: Move focus ring into Tile For now, will make the open animation better. --- src/layout/tile.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/layout/tile.rs') diff --git a/src/layout/tile.rs b/src/layout/tile.rs index 8932b494..a691e2e0 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -21,6 +21,12 @@ pub struct Tile { /// The border around the window. border: FocusRing, + /// The focus ring around the window. + /// + /// It's supposed to be on the Workspace, but for the sake of a nicer open animation it's + /// currently here. + focus_ring: FocusRing, + /// Whether this tile is fullscreen. /// /// This will update only when the `window` actually goes fullscreen, rather than right away, @@ -49,6 +55,7 @@ impl Tile { Self { window, border: FocusRing::new(options.border), + focus_ring: FocusRing::new(options.focus_ring), is_fullscreen: false, // FIXME: up-to-date fullscreen right away, but we need size. fullscreen_backdrop: SolidColorBuffer::new((0, 0), [0., 0., 0., 1.]), fullscreen_size: Default::default(), @@ -58,6 +65,7 @@ impl Tile { pub fn update_config(&mut self, options: Rc) { self.border.update_config(options.border); + self.focus_ring.update_config(options.focus_ring); self.options = options; } @@ -76,6 +84,10 @@ impl Tile { self.window.has_ssd(), ); self.border.set_active(is_active); + + self.focus_ring + .update((0, 0).into(), self.tile_size(), self.has_ssd()); + self.focus_ring.set_active(is_active); } pub fn window(&self) -> &W { @@ -244,6 +256,7 @@ impl Tile { renderer: &mut R, location: Point, scale: Scale, + focus_ring: bool, ) -> impl Iterator> { let window_pos = location + self.window_loc(); let rv = self @@ -264,6 +277,18 @@ impl Tile { }); let rv = rv.chain(elem.into_iter().flatten()); + let elem = focus_ring.then(|| { + self.focus_ring.render(scale).map(move |elem| { + RelocateRenderElement::from_element( + elem, + location.to_physical_precise_round(scale), + Relocate::Relative, + ) + .into() + }) + }); + let rv = rv.chain(elem.into_iter().flatten()); + let elem = self.is_fullscreen.then(|| { let elem = SolidColorRenderElement::from_buffer( &self.fullscreen_backdrop, -- cgit