aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/layout/floating.rs4
-rw-r--r--src/layout/scrolling.rs8
-rw-r--r--src/layout/tile.rs33
-rw-r--r--src/layout/workspace.rs2
-rw-r--r--src/window/mod.rs7
5 files changed, 51 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) {
diff --git a/src/window/mod.rs b/src/window/mod.rs
index 41f2182b..c99d10d2 100644
--- a/src/window/mod.rs
+++ b/src/window/mod.rs
@@ -100,6 +100,9 @@ pub struct ResolvedWindowRules {
/// Whether to clip this window to its geometry, including the corner radius.
pub clip_to_geometry: Option<bool>,
+ /// Whether bob this window up and down.
+ pub baba_is_float: Option<bool>,
+
/// Whether to block out this window from certain render targets.
pub block_out_from: Option<BlockOutFrom>,
@@ -210,6 +213,7 @@ impl ResolvedWindowRules {
opacity: None,
geometry_corner_radius: None,
clip_to_geometry: None,
+ baba_is_float: None,
block_out_from: None,
variable_refresh_rate: None,
scroll_factor: None,
@@ -319,6 +323,9 @@ impl ResolvedWindowRules {
if let Some(x) = rule.clip_to_geometry {
resolved.clip_to_geometry = Some(x);
}
+ if let Some(x) = rule.baba_is_float {
+ resolved.baba_is_float = Some(x);
+ }
if let Some(x) = rule.block_out_from {
resolved.block_out_from = Some(x);
}