Hook up are_transitions_ongoing() for floating and tiles

Don't spoil it
This commit is contained in:
Ivan Molodetskikh
2025-02-11 15:35:06 +03:00
parent d94fbe9895
commit fd8140e091
6 changed files with 53 additions and 3 deletions
+2
View File
@@ -1189,6 +1189,8 @@ pub struct WindowRule {
#[knuffel(child, unwrap(argument))]
pub clip_to_geometry: Option<bool>,
#[knuffel(child, unwrap(argument))]
pub baba_is_float: Option<bool>,
#[knuffel(child, unwrap(argument))]
pub block_out_from: Option<BlockOutFrom>,
#[knuffel(child, unwrap(argument))]
pub variable_refresh_rate: Option<bool>,
+4
View File
@@ -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() {
+7 -1
View File
@@ -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() {
+32 -1
View File
@@ -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();
+1 -1
View File
@@ -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) {
+7
View File
@@ -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);
}