forge
Explore
Log in

Don't you dare go Hollow

Hook up are_transitions_ongoing() for floating and tiles

Browse files at this commit

fd8140e091df24e02de279b287d42b087eab19e2Ivan MolodetskikhParent: d94fbe9
Don't spoil it
niri-config/src/lib.rsmodified+2 -0
@@ -1189,6 +1189,8 @@ pub struct WindowRule {
11891189 #[knuffel(child, unwrap(argument))]
11901190 pub clip_to_geometry: Option<bool>,
11911191 #[knuffel(child, unwrap(argument))]
1192+ pub baba_is_float: Option<bool>,
1193+ #[knuffel(child, unwrap(argument))]
11921194 pub block_out_from: Option<BlockOutFrom>,
11931195 #[knuffel(child, unwrap(argument))]
11941196 pub variable_refresh_rate: Option<bool>,
src/layout/floating.rsmodified+4 -0
@@ -259,6 +259,10 @@ impl<W: LayoutElement> FloatingSpace<W> {
259259 self.tiles.iter().any(Tile::are_animations_ongoing) || !self.closing_windows.is_empty()
260260 }
261261
262+ pub fn are_transitions_ongoing(&self) -> bool {
263+ self.tiles.iter().any(Tile::are_transitions_ongoing) || !self.closing_windows.is_empty()
264+ }
265+
262266 pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) {
263267 let active = self.active_window_id.clone();
264268 for (tile, offset) in self.tiles_with_offsets_mut() {
src/layout/scrolling.rsmodified+7 -1
@@ -342,7 +342,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
342342
343343 pub fn are_transitions_ongoing(&self) -> bool {
344344 !self.view_offset.is_static()
345- || self.columns.iter().any(Column::are_animations_ongoing)
345+ || self.columns.iter().any(Column::are_transitions_ongoing)
346346 || !self.closing_windows.is_empty()
347347 }
348348
@@ -3526,6 +3526,12 @@ impl<W: LayoutElement> Column<W> {
35263526 || self.tiles.iter().any(Tile::are_animations_ongoing)
35273527 }
35283528
3529+ pub fn are_transitions_ongoing(&self) -> bool {
3530+ self.move_animation.is_some()
3531+ || self.tab_indicator.are_animations_ongoing()
3532+ || self.tiles.iter().any(Tile::are_transitions_ongoing)
3533+ }
3534+
35293535 pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) {
35303536 let active_idx = self.active_tile_idx;
35313537 for (tile_idx, (tile, tile_off)) in self.tiles_mut().enumerate() {
src/layout/tile.rsmodified+32 -1
@@ -1,3 +1,4 @@
1+use core::f64;
12 use std::rc::Rc;
23
34 use niri_config::{Color, CornerRadius, GradientInterpolation};
@@ -24,6 +25,7 @@ use crate::render_helpers::shadow::ShadowRenderElement;
2425 use crate::render_helpers::snapshot::RenderSnapshot;
2526 use crate::render_helpers::solid_color::{SolidColorBuffer, SolidColorRenderElement};
2627 use crate::render_helpers::{render_to_encompassing_texture, RenderTarget};
28+use crate::utils::round_logical_in_physical;
2729 use crate::utils::transaction::Transaction;
2830
2931 /// Toplevel window with decorations.
@@ -314,6 +316,10 @@ impl<W: LayoutElement> Tile<W> {
314316 }
315317
316318 pub fn are_animations_ongoing(&self) -> bool {
319+ self.are_transitions_ongoing() || self.window.rules().baba_is_float == Some(true)
320+ }
321+
322+ pub fn are_transitions_ongoing(&self) -> bool {
317323 self.open_animation.is_some()
318324 || self.resize_animation.is_some()
319325 || self.move_x_animation.is_some()
@@ -654,8 +660,11 @@ impl<W: LayoutElement> Tile<W> {
654660 }
655661
656662 pub fn hit(&self, point: Point<f64, Logical>) -> Option<HitType> {
663+ let offset = self.bob_offset();
664+ let point = point - offset;
665+
657666 if self.is_in_input_region(point) {
658- let win_pos = self.buf_loc();
667+ let win_pos = self.buf_loc() + offset;
659668 Some(HitType::Input { win_pos })
660669 } else if self.is_in_activation_region(point) {
661670 Some(HitType::Activate {
@@ -752,6 +761,18 @@ impl<W: LayoutElement> Tile<W> {
752761 size
753762 }
754763
764+ pub fn bob_offset(&self) -> Point<f64, Logical> {
765+ if self.window.rules().baba_is_float != Some(true) {
766+ return Point::from((0., 0.));
767+ }
768+
769+ let now = self.clock.now().as_secs_f64();
770+ let amplitude = self.view_size.h / 96.;
771+ let y = amplitude * ((f64::consts::TAU * now / 3.6).sin() - 1.);
772+ let y = round_logical_in_physical(self.scale, y);
773+ Point::from((0., y))
774+ }
775+
755776 pub fn draw_border_with_background(&self) -> bool {
756777 if self.effective_border_width().is_some() {
757778 return false;
@@ -782,6 +803,16 @@ impl<W: LayoutElement> Tile<W> {
782803 let tile_alpha = self.tile_alpha();
783804 let win_alpha = win_alpha * tile_alpha;
784805
806+ // This is here rather than in render_offset() because render_offset() is currently assumed
807+ // by the code to be temporary. So, for example, interactive move will try to "grab" the
808+ // tile at its current render offset and reset the render offset to zero by cancelling the
809+ // tile move animations. On the other hand, bob_offset() is not resettable, so adding it in
810+ // render_offset() would cause obvious animation glitches.
811+ //
812+ // This isn't to say that adding it here is perfect; indeed, it kind of breaks view_rect
813+ // passed to update_render_elements(). But, it works well enough for what it is.
814+ let location = location + self.bob_offset();
815+
785816 let window_loc = self.window_loc();
786817 let window_size = self.window_size().to_f64();
787818 let animated_window_size = self.animated_window_size();
src/layout/workspace.rsmodified+1 -1
@@ -333,7 +333,7 @@ impl<W: LayoutElement> Workspace<W> {
333333 }
334334
335335 pub fn are_transitions_ongoing(&self) -> bool {
336- self.scrolling.are_transitions_ongoing() || self.floating.are_animations_ongoing()
336+ self.scrolling.are_transitions_ongoing() || self.floating.are_transitions_ongoing()
337337 }
338338
339339 pub fn update_render_elements(&mut self, is_active: bool) {
src/window/mod.rsmodified+7 -0
@@ -100,6 +100,9 @@ pub struct ResolvedWindowRules {
100100 /// Whether to clip this window to its geometry, including the corner radius.
101101 pub clip_to_geometry: Option<bool>,
102102
103+ /// Whether bob this window up and down.
104+ pub baba_is_float: Option<bool>,
105+
103106 /// Whether to block out this window from certain render targets.
104107 pub block_out_from: Option<BlockOutFrom>,
105108
@@ -210,6 +213,7 @@ impl ResolvedWindowRules {
210213 opacity: None,
211214 geometry_corner_radius: None,
212215 clip_to_geometry: None,
216+ baba_is_float: None,
213217 block_out_from: None,
214218 variable_refresh_rate: None,
215219 scroll_factor: None,
@@ -319,6 +323,9 @@ impl ResolvedWindowRules {
319323 if let Some(x) = rule.clip_to_geometry {
320324 resolved.clip_to_geometry = Some(x);
321325 }
326+ if let Some(x) = rule.baba_is_float {
327+ resolved.baba_is_float = Some(x);
328+ }
322329 if let Some(x) = rule.block_out_from {
323330 resolved.block_out_from = Some(x);
324331 }