forge
Explore
Log in

Don't you dare go Hollow

Accept location in FocusRing

Browse files at this commit

646e3d89951e576a2e89ac121c521b4a7c3fced8Ivan MolodetskikhParent: d1fe693
Makes it work more like other elements.
src/layout/focus_ring.rsmodified+13 -14
@@ -39,26 +39,21 @@ impl FocusRing {
3939 self.inactive_color = config.inactive_color;
4040 }
4141
42- pub fn update(
43- &mut self,
44- win_pos: Point<i32, Logical>,
45- win_size: Size<i32, Logical>,
46- is_border: bool,
47- ) {
42+ pub fn update(&mut self, win_size: Size<i32, Logical>, is_border: bool) {
4843 if is_border {
4944 self.buffers[0].resize((win_size.w + self.width * 2, self.width));
5045 self.buffers[1].resize((win_size.w + self.width * 2, self.width));
5146 self.buffers[2].resize((self.width, win_size.h));
5247 self.buffers[3].resize((self.width, win_size.h));
5348
54- self.locations[0] = win_pos + Point::from((-self.width, -self.width));
55- self.locations[1] = win_pos + Point::from((-self.width, win_size.h));
56- self.locations[2] = win_pos + Point::from((-self.width, 0));
57- self.locations[3] = win_pos + Point::from((win_size.w, 0));
49+ self.locations[0] = Point::from((-self.width, -self.width));
50+ self.locations[1] = Point::from((-self.width, win_size.h));
51+ self.locations[2] = Point::from((-self.width, 0));
52+ self.locations[3] = Point::from((win_size.w, 0));
5853 } else {
5954 let size = win_size + Size::from((self.width * 2, self.width * 2));
6055 self.buffers[0].resize(size);
61- self.locations[0] = win_pos - Point::from((self.width, self.width));
56+ self.locations[0] = Point::from((-self.width, -self.width));
6257 }
6358
6459 self.is_border = is_border;
@@ -76,7 +71,11 @@ impl FocusRing {
7671 }
7772 }
7873
79- pub fn render(&self, scale: Scale<f64>) -> impl Iterator<Item = FocusRingRenderElement> {
74+ pub fn render(
75+ &self,
76+ location: Point<i32, Logical>,
77+ scale: Scale<f64>,
78+ ) -> impl Iterator<Item = FocusRingRenderElement> {
8079 let mut rv = ArrayVec::<_, 4>::new();
8180
8281 if self.is_off {
@@ -96,10 +95,10 @@ impl FocusRing {
9695
9796 if self.is_border {
9897 for (buf, loc) in zip(&self.buffers, self.locations) {
99- push(buf, loc);
98+ push(buf, location + loc);
10099 }
101100 } else {
102- push(&self.buffers[0], self.locations[0]);
101+ push(&self.buffers[0], location + self.locations[0]);
103102 }
104103
105104 rv.into_iter()
src/layout/tile.rsmodified+13 -34
@@ -3,9 +3,7 @@ use std::rc::Rc;
33 use std::time::Duration;
44
55 use smithay::backend::renderer::element::solid::{SolidColorBuffer, SolidColorRenderElement};
6-use smithay::backend::renderer::element::utils::{
7- Relocate, RelocateRenderElement, RescaleRenderElement,
8-};
6+use smithay::backend::renderer::element::utils::RescaleRenderElement;
97 use smithay::backend::renderer::element::{Element, Kind};
108 use smithay::utils::{Logical, Point, Rectangle, Scale, Size};
119
@@ -53,7 +51,7 @@ pub struct Tile<W: LayoutElement> {
5351 niri_render_elements! {
5452 TileRenderElement<R> => {
5553 LayoutElement = LayoutElementRenderElement<R>,
56- SolidColor = RelocateRenderElement<SolidColorRenderElement>,
54+ SolidColor = SolidColorRenderElement,
5755 Offscreen = RescaleRenderElement<OffscreenRenderElement>,
5856 }
5957 }
@@ -86,16 +84,11 @@ impl<W: LayoutElement> Tile<W> {
8684 }
8785
8886 pub fn advance_animations(&mut self, current_time: Duration, is_active: bool) {
89- let width = self.border.width();
90- self.border.update(
91- (width, width).into(),
92- self.window.size(),
93- self.window.has_ssd(),
94- );
87+ self.border
88+ .update(self.window.size(), self.window.has_ssd());
9589 self.border.set_active(is_active);
9690
97- self.focus_ring
98- .update((0, 0).into(), self.tile_size(), self.has_ssd());
91+ self.focus_ring.update(self.tile_size(), self.has_ssd());
9992 self.focus_ring.set_active(is_active);
10093
10194 match &mut self.open_animation {
@@ -312,39 +305,25 @@ impl<W: LayoutElement> Tile<W> {
312305 .into_iter()
313306 .map(Into::into);
314307
315- let elem = self.effective_border_width().map(|_| {
316- self.border.render(scale).map(move |elem| {
317- RelocateRenderElement::from_element(
318- elem,
319- location.to_physical_precise_round(scale),
320- Relocate::Relative,
321- )
322- .into()
323- })
308+ let elem = self.effective_border_width().map(|width| {
309+ self.border
310+ .render(location + Point::from((width, width)), scale)
311+ .map(Into::into)
324312 });
325313 let rv = rv.chain(elem.into_iter().flatten());
326314
327- let elem = focus_ring.then(|| {
328- self.focus_ring.render(scale).map(move |elem| {
329- RelocateRenderElement::from_element(
330- elem,
331- location.to_physical_precise_round(scale),
332- Relocate::Relative,
333- )
334- .into()
335- })
336- });
315+ let elem = focus_ring.then(|| self.focus_ring.render(location, scale).map(Into::into));
337316 let rv = rv.chain(elem.into_iter().flatten());
338317
339318 let elem = self.is_fullscreen.then(|| {
340- let elem = SolidColorRenderElement::from_buffer(
319+ SolidColorRenderElement::from_buffer(
341320 &self.fullscreen_backdrop,
342321 location.to_physical_precise_round(scale),
343322 scale,
344323 1.,
345324 Kind::Unspecified,
346- );
347- RelocateRenderElement::from_element(elem, (0, 0), Relocate::Relative).into()
325+ )
326+ .into()
348327 });
349328 rv.chain(elem)
350329 }