forge
Explore
Log in

Don't you dare go Hollow

Move focus ring into Tile

Browse files at this commit

93c547f7499105d69f2bef41699b76937a2559c8Ivan MolodetskikhParent: e2b91c0
For now, will make the open animation better.
niri-visual-tests/src/cases/tile.rsmodified+1 -1
@@ -76,7 +76,7 @@ impl TestCase for JustTile {
76 let location = Point::from(((size.w - tile_size.w) / 2, (size.h - tile_size.h) / 2));76 let location = Point::from(((size.w - tile_size.w) / 2, (size.h - tile_size.h) / 2));
77 77
78 self.tile78 self.tile
79- .render(renderer, location, Scale::from(1.))79+ .render(renderer, location, Scale::from(1.), true)
80 .map(|elem| Box::new(elem) as _)80 .map(|elem| Box::new(elem) as _)
81 .collect()81 .collect()
82 }82 }
src/layout/tile.rsmodified+25 -0
@@ -21,6 +21,12 @@ pub struct Tile<W: LayoutElement> {
21 /// The border around the window.21 /// The border around the window.
22 border: FocusRing,22 border: FocusRing,
23 23
24+ /// The focus ring around the window.
25+ ///
26+ /// It's supposed to be on the Workspace, but for the sake of a nicer open animation it's
27+ /// currently here.
28+ focus_ring: FocusRing,
29+
24 /// Whether this tile is fullscreen.30 /// Whether this tile is fullscreen.
25 ///31 ///
26 /// This will update only when the `window` actually goes fullscreen, rather than right away,32 /// This will update only when the `window` actually goes fullscreen, rather than right away,
@@ -49,6 +55,7 @@ impl<W: LayoutElement> Tile<W> {
49 Self {55 Self {
50 window,56 window,
51 border: FocusRing::new(options.border),57 border: FocusRing::new(options.border),
58+ focus_ring: FocusRing::new(options.focus_ring),
52 is_fullscreen: false, // FIXME: up-to-date fullscreen right away, but we need size.59 is_fullscreen: false, // FIXME: up-to-date fullscreen right away, but we need size.
53 fullscreen_backdrop: SolidColorBuffer::new((0, 0), [0., 0., 0., 1.]),60 fullscreen_backdrop: SolidColorBuffer::new((0, 0), [0., 0., 0., 1.]),
54 fullscreen_size: Default::default(),61 fullscreen_size: Default::default(),
@@ -58,6 +65,7 @@ impl<W: LayoutElement> Tile<W> {
58 65
59 pub fn update_config(&mut self, options: Rc<Options>) {66 pub fn update_config(&mut self, options: Rc<Options>) {
60 self.border.update_config(options.border);67 self.border.update_config(options.border);
68+ self.focus_ring.update_config(options.focus_ring);
61 self.options = options;69 self.options = options;
62 }70 }
63 71
@@ -76,6 +84,10 @@ impl<W: LayoutElement> Tile<W> {
76 self.window.has_ssd(),84 self.window.has_ssd(),
77 );85 );
78 self.border.set_active(is_active);86 self.border.set_active(is_active);
87+
88+ self.focus_ring
89+ .update((0, 0).into(), self.tile_size(), self.has_ssd());
90+ self.focus_ring.set_active(is_active);
79 }91 }
80 92
81 pub fn window(&self) -> &W {93 pub fn window(&self) -> &W {
@@ -244,6 +256,7 @@ impl<W: LayoutElement> Tile<W> {
244 renderer: &mut R,256 renderer: &mut R,
245 location: Point<i32, Logical>,257 location: Point<i32, Logical>,
246 scale: Scale<f64>,258 scale: Scale<f64>,
259+ focus_ring: bool,
247 ) -> impl Iterator<Item = TileRenderElement<R>> {260 ) -> impl Iterator<Item = TileRenderElement<R>> {
248 let window_pos = location + self.window_loc();261 let window_pos = location + self.window_loc();
249 let rv = self262 let rv = self
@@ -264,6 +277,18 @@ impl<W: LayoutElement> Tile<W> {
264 });277 });
265 let rv = rv.chain(elem.into_iter().flatten());278 let rv = rv.chain(elem.into_iter().flatten());
266 279
280+ let elem = focus_ring.then(|| {
281+ self.focus_ring.render(scale).map(move |elem| {
282+ RelocateRenderElement::from_element(
283+ elem,
284+ location.to_physical_precise_round(scale),
285+ Relocate::Relative,
286+ )
287+ .into()
288+ })
289+ });
290+ let rv = rv.chain(elem.into_iter().flatten());
291+
267 let elem = self.is_fullscreen.then(|| {292 let elem = self.is_fullscreen.then(|| {
268 let elem = SolidColorRenderElement::from_buffer(293 let elem = SolidColorRenderElement::from_buffer(
269 &self.fullscreen_backdrop,294 &self.fullscreen_backdrop,
src/layout/workspace.rsmodified+5 -36
@@ -10,7 +10,6 @@ use smithay::output::Output;
10 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;10 use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
11 use smithay::utils::{Logical, Point, Rectangle, Scale, Size};11 use smithay::utils::{Logical, Point, Rectangle, Scale, Size};
12 12
13-use super::focus_ring::{FocusRing, FocusRingRenderElement};
14 use super::tile::{Tile, TileRenderElement};13 use super::tile::{Tile, TileRenderElement};
15 use super::{LayoutElement, Options};14 use super::{LayoutElement, Options};
16 use crate::animation::Animation;15 use crate::animation::Animation;
@@ -47,9 +46,6 @@ pub struct Workspace<W: LayoutElement> {
47 /// Index of the currently active column, if any.46 /// Index of the currently active column, if any.
48 pub active_column_idx: usize,47 pub active_column_idx: usize,
49 48
50- /// Focus ring buffer and parameters.
51- focus_ring: FocusRing,
52-
53 /// Offset of the view computed from the active column.49 /// Offset of the view computed from the active column.
54 ///50 ///
55 /// Any gaps, including left padding from work area left exclusive zone, is handled51 /// Any gaps, including left padding from work area left exclusive zone, is handled
@@ -80,7 +76,6 @@ pub struct OutputId(String);
80 niri_render_elements! {76 niri_render_elements! {
81 WorkspaceRenderElement => {77 WorkspaceRenderElement => {
82 Tile = TileRenderElement<R>,78 Tile = TileRenderElement<R>,
83- FocusRing = FocusRingRenderElement,
84 }79 }
85 }80 }
86 81
@@ -194,7 +189,6 @@ impl<W: LayoutElement> Workspace<W> {
194 output: Some(output),189 output: Some(output),
195 columns: vec![],190 columns: vec![],
196 active_column_idx: 0,191 active_column_idx: 0,
197- focus_ring: FocusRing::new(options.focus_ring),
198 view_offset: 0,192 view_offset: 0,
199 view_offset_anim: None,193 view_offset_anim: None,
200 activate_prev_column_on_removal: false,194 activate_prev_column_on_removal: false,
@@ -210,7 +204,6 @@ impl<W: LayoutElement> Workspace<W> {
210 working_area: Rectangle::from_loc_and_size((0, 0), (1280, 720)),204 working_area: Rectangle::from_loc_and_size((0, 0), (1280, 720)),
211 columns: vec![],205 columns: vec![],
212 active_column_idx: 0,206 active_column_idx: 0,
213- focus_ring: FocusRing::new(options.focus_ring),
214 view_offset: 0,207 view_offset: 0,
215 view_offset_anim: None,208 view_offset_anim: None,
216 activate_prev_column_on_removal: false,209 activate_prev_column_on_removal: false,
@@ -230,8 +223,6 @@ impl<W: LayoutElement> Workspace<W> {
230 None => (),223 None => (),
231 }224 }
232 225
233- let view_pos = self.view_pos();
234-
235 for (col_idx, col) in self.columns.iter_mut().enumerate() {226 for (col_idx, col) in self.columns.iter_mut().enumerate() {
236 for (tile_idx, tile) in col.tiles.iter_mut().enumerate() {227 for (tile_idx, tile) in col.tiles.iter_mut().enumerate() {
237 let is_active = is_active228 let is_active = is_active
@@ -240,22 +231,6 @@ impl<W: LayoutElement> Workspace<W> {
240 tile.advance_animations(current_time, is_active);231 tile.advance_animations(current_time, is_active);
241 }232 }
242 }233 }
243-
244- // This shall one day become a proper animation.
245- if !self.columns.is_empty() {
246- let col = &self.columns[self.active_column_idx];
247- let active_tile = &col.tiles[col.active_tile_idx];
248- let size = active_tile.tile_size();
249- let has_ssd = active_tile.has_ssd();
250-
251- let tile_pos = Point::from((
252- self.column_x(self.active_column_idx) - view_pos,
253- col.tile_y(col.active_tile_idx),
254- ));
255-
256- self.focus_ring.update(tile_pos, size, has_ssd);
257- self.focus_ring.set_active(is_active);
258- }
259 }234 }
260 235
261 pub fn are_animations_ongoing(&self) -> bool {236 pub fn are_animations_ongoing(&self) -> bool {
@@ -263,9 +238,6 @@ impl<W: LayoutElement> Workspace<W> {
263 }238 }
264 239
265 pub fn update_config(&mut self, options: Rc<Options>) {240 pub fn update_config(&mut self, options: Rc<Options>) {
266- self.focus_ring.update_config(options.focus_ring);
267- // The focus ring buffer will be updated in a subsequent update_animations call.
268-
269 for column in &mut self.columns {241 for column in &mut self.columns {
270 column.update_config(options.clone());242 column.update_config(options.clone());
271 }243 }
@@ -1152,17 +1124,14 @@ impl<W: LayoutElement> Workspace<W> {
1152 let mut first = true;1124 let mut first = true;
1153 1125
1154 for (tile, tile_pos) in self.tiles_in_render_order() {1126 for (tile, tile_pos) in self.tiles_in_render_order() {
1155- // Draw the window itself.1127+ // For the active tile (which comes first), draw the focus ring.
1128+ let focus_ring = first;
1129+ first = false;
1130+
1156 rv.extend(1131 rv.extend(
1157- tile.render(renderer, tile_pos, output_scale)1132+ tile.render(renderer, tile_pos, output_scale, focus_ring)
1158 .map(Into::into),1133 .map(Into::into),
1159 );1134 );
1160-
1161- // For the active tile (which comes first), draw the focus ring.
1162- if first {
1163- rv.extend(self.focus_ring.render(output_scale).map(Into::into));
1164- first = false;
1165- }
1166 }1135 }
1167 1136
1168 rv1137 rv