diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-11 15:35:06 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-02-15 13:28:57 +0300 |
| commit | fd8140e091df24e02de279b287d42b087eab19e2 (patch) | |
| tree | 94dc2b6970416f0f5349a84ab7159246ea8b07be /src/layout | |
| parent | d94fbe98952af12b639489f8bba70a4532a18a7b (diff) | |
| download | niri-fd8140e091df24e02de279b287d42b087eab19e2.tar.gz niri-fd8140e091df24e02de279b287d42b087eab19e2.tar.bz2 niri-fd8140e091df24e02de279b287d42b087eab19e2.zip | |
Hook up are_transitions_ongoing() for floating and tiles
Don't spoil it
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/floating.rs | 4 | ||||
| -rw-r--r-- | src/layout/scrolling.rs | 8 | ||||
| -rw-r--r-- | src/layout/tile.rs | 33 | ||||
| -rw-r--r-- | src/layout/workspace.rs | 2 |
4 files changed, 44 insertions, 3 deletions
diff --git a/src/layout/floating.rs b/src/layout/floating.rs index fef92309..2a4054bd 100644 --- a/src/layout/floating.rs +++ b/src/layout/floating.rs @@ -259,6 +259,10 @@ impl<W: LayoutElement> FloatingSpace<W> { self.tiles.iter().any(Tile::are_animations_ongoing) || !self.closing_windows.is_empty() } + pub fn are_transitions_ongoing(&self) -> bool { + self.tiles.iter().any(Tile::are_transitions_ongoing) || !self.closing_windows.is_empty() + } + pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) { let active = self.active_window_id.clone(); for (tile, offset) in self.tiles_with_offsets_mut() { diff --git a/src/layout/scrolling.rs b/src/layout/scrolling.rs index 865663b8..81f01559 100644 --- a/src/layout/scrolling.rs +++ b/src/layout/scrolling.rs @@ -342,7 +342,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { pub fn are_transitions_ongoing(&self) -> bool { !self.view_offset.is_static() - || self.columns.iter().any(Column::are_animations_ongoing) + || self.columns.iter().any(Column::are_transitions_ongoing) || !self.closing_windows.is_empty() } @@ -3526,6 +3526,12 @@ impl<W: LayoutElement> Column<W> { || self.tiles.iter().any(Tile::are_animations_ongoing) } + pub fn are_transitions_ongoing(&self) -> bool { + self.move_animation.is_some() + || self.tab_indicator.are_animations_ongoing() + || self.tiles.iter().any(Tile::are_transitions_ongoing) + } + pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) { let active_idx = self.active_tile_idx; for (tile_idx, (tile, tile_off)) in self.tiles_mut().enumerate() { diff --git a/src/layout/tile.rs b/src/layout/tile.rs index e3c1cce7..f8a5f68e 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -1,3 +1,4 @@ +use core::f64; use std::rc::Rc; use niri_config::{Color, CornerRadius, GradientInterpolation}; @@ -24,6 +25,7 @@ use crate::render_helpers::shadow::ShadowRenderElement; use crate::render_helpers::snapshot::RenderSnapshot; use crate::render_helpers::solid_color::{SolidColorBuffer, SolidColorRenderElement}; use crate::render_helpers::{render_to_encompassing_texture, RenderTarget}; +use crate::utils::round_logical_in_physical; use crate::utils::transaction::Transaction; /// Toplevel window with decorations. @@ -314,6 +316,10 @@ impl<W: LayoutElement> Tile<W> { } pub fn are_animations_ongoing(&self) -> bool { + self.are_transitions_ongoing() || self.window.rules().baba_is_float == Some(true) + } + + pub fn are_transitions_ongoing(&self) -> bool { self.open_animation.is_some() || self.resize_animation.is_some() || self.move_x_animation.is_some() @@ -654,8 +660,11 @@ impl<W: LayoutElement> Tile<W> { } pub fn hit(&self, point: Point<f64, Logical>) -> Option<HitType> { + let offset = self.bob_offset(); + let point = point - offset; + if self.is_in_input_region(point) { - let win_pos = self.buf_loc(); + let win_pos = self.buf_loc() + offset; Some(HitType::Input { win_pos }) } else if self.is_in_activation_region(point) { Some(HitType::Activate { @@ -752,6 +761,18 @@ impl<W: LayoutElement> Tile<W> { size } + pub fn bob_offset(&self) -> Point<f64, Logical> { + if self.window.rules().baba_is_float != Some(true) { + return Point::from((0., 0.)); + } + + let now = self.clock.now().as_secs_f64(); + let amplitude = self.view_size.h / 96.; + let y = amplitude * ((f64::consts::TAU * now / 3.6).sin() - 1.); + let y = round_logical_in_physical(self.scale, y); + Point::from((0., y)) + } + pub fn draw_border_with_background(&self) -> bool { if self.effective_border_width().is_some() { return false; @@ -782,6 +803,16 @@ impl<W: LayoutElement> Tile<W> { let tile_alpha = self.tile_alpha(); let win_alpha = win_alpha * tile_alpha; + // This is here rather than in render_offset() because render_offset() is currently assumed + // by the code to be temporary. So, for example, interactive move will try to "grab" the + // tile at its current render offset and reset the render offset to zero by cancelling the + // tile move animations. On the other hand, bob_offset() is not resettable, so adding it in + // render_offset() would cause obvious animation glitches. + // + // This isn't to say that adding it here is perfect; indeed, it kind of breaks view_rect + // passed to update_render_elements(). But, it works well enough for what it is. + let location = location + self.bob_offset(); + let window_loc = self.window_loc(); let window_size = self.window_size().to_f64(); let animated_window_size = self.animated_window_size(); diff --git a/src/layout/workspace.rs b/src/layout/workspace.rs index a402ad44..fa2c906a 100644 --- a/src/layout/workspace.rs +++ b/src/layout/workspace.rs @@ -333,7 +333,7 @@ impl<W: LayoutElement> Workspace<W> { } pub fn are_transitions_ongoing(&self) -> bool { - self.scrolling.are_transitions_ongoing() || self.floating.are_animations_ongoing() + self.scrolling.are_transitions_ongoing() || self.floating.are_transitions_ongoing() } pub fn update_render_elements(&mut self, is_active: bool) { |
