Hook up are_transitions_ongoing() for floating and tiles
Browse files at this commitfd8140e091df24e02de279b287d42b087eab19e2Parent: d94fbe96 changed files +53 -3
- niri-config/src/lib.rs +2 -0
- src/layout/floating.rs +4 -0
- src/layout/scrolling.rs +7 -1
- src/layout/tile.rs +32 -1
- src/layout/workspace.rs +1 -1
- src/window/mod.rs +7 -0
niri-config/src/lib.rsmodified+2 -0
| @@ -1189,6 +1189,8 @@ pub struct WindowRule { | |||
| 1189 | #[knuffel(child, unwrap(argument))] | 1189 | #[knuffel(child, unwrap(argument))] |
| 1190 | pub clip_to_geometry: Option<bool>, | 1190 | pub clip_to_geometry: Option<bool>, |
| 1191 | #[knuffel(child, unwrap(argument))] | 1191 | #[knuffel(child, unwrap(argument))] |
| 1192 | + pub baba_is_float: Option<bool>, | ||
| 1193 | + #[knuffel(child, unwrap(argument))] | ||
| 1192 | pub block_out_from: Option<BlockOutFrom>, | 1194 | pub block_out_from: Option<BlockOutFrom>, |
| 1193 | #[knuffel(child, unwrap(argument))] | 1195 | #[knuffel(child, unwrap(argument))] |
| 1194 | pub variable_refresh_rate: Option<bool>, | 1196 | pub variable_refresh_rate: Option<bool>, |
src/layout/floating.rsmodified+4 -0
| @@ -259,6 +259,10 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 259 | self.tiles.iter().any(Tile::are_animations_ongoing) || !self.closing_windows.is_empty() | 259 | self.tiles.iter().any(Tile::are_animations_ongoing) || !self.closing_windows.is_empty() |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | + pub fn are_transitions_ongoing(&self) -> bool { | ||
| 263 | + self.tiles.iter().any(Tile::are_transitions_ongoing) || !self.closing_windows.is_empty() | ||
| 264 | + } | ||
| 265 | + | ||
| 262 | pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) { | 266 | pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) { |
| 263 | let active = self.active_window_id.clone(); | 267 | let active = self.active_window_id.clone(); |
| 264 | for (tile, offset) in self.tiles_with_offsets_mut() { | 268 | for (tile, offset) in self.tiles_with_offsets_mut() { |
src/layout/scrolling.rsmodified+7 -1
| @@ -342,7 +342,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 342 | 342 | ||
| 343 | pub fn are_transitions_ongoing(&self) -> bool { | 343 | pub fn are_transitions_ongoing(&self) -> bool { |
| 344 | !self.view_offset.is_static() | 344 | !self.view_offset.is_static() |
| 345 | - || self.columns.iter().any(Column::are_animations_ongoing) | 345 | + || self.columns.iter().any(Column::are_transitions_ongoing) |
| 346 | || !self.closing_windows.is_empty() | 346 | || !self.closing_windows.is_empty() |
| 347 | } | 347 | } |
| 348 | 348 | ||
| @@ -3526,6 +3526,12 @@ impl<W: LayoutElement> Column<W> { | |||
| 3526 | || self.tiles.iter().any(Tile::are_animations_ongoing) | 3526 | || self.tiles.iter().any(Tile::are_animations_ongoing) |
| 3527 | } | 3527 | } |
| 3528 | 3528 | ||
| 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 | + | ||
| 3529 | pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) { | 3535 | pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) { |
| 3530 | let active_idx = self.active_tile_idx; | 3536 | let active_idx = self.active_tile_idx; |
| 3531 | for (tile_idx, (tile, tile_off)) in self.tiles_mut().enumerate() { | 3537 | 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; | ||
| 1 | use std::rc::Rc; | 2 | use std::rc::Rc; |
| 2 | 3 | ||
| 3 | use niri_config::{Color, CornerRadius, GradientInterpolation}; | 4 | use niri_config::{Color, CornerRadius, GradientInterpolation}; |
| @@ -24,6 +25,7 @@ use crate::render_helpers::shadow::ShadowRenderElement; | |||
| 24 | use crate::render_helpers::snapshot::RenderSnapshot; | 25 | use crate::render_helpers::snapshot::RenderSnapshot; |
| 25 | use crate::render_helpers::solid_color::{SolidColorBuffer, SolidColorRenderElement}; | 26 | use crate::render_helpers::solid_color::{SolidColorBuffer, SolidColorRenderElement}; |
| 26 | use crate::render_helpers::{render_to_encompassing_texture, RenderTarget}; | 27 | use crate::render_helpers::{render_to_encompassing_texture, RenderTarget}; |
| 28 | +use crate::utils::round_logical_in_physical; | ||
| 27 | use crate::utils::transaction::Transaction; | 29 | use crate::utils::transaction::Transaction; |
| 28 | 30 | ||
| 29 | /// Toplevel window with decorations. | 31 | /// Toplevel window with decorations. |
| @@ -314,6 +316,10 @@ impl<W: LayoutElement> Tile<W> { | |||
| 314 | } | 316 | } |
| 315 | 317 | ||
| 316 | pub fn are_animations_ongoing(&self) -> bool { | 318 | 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 { | ||
| 317 | self.open_animation.is_some() | 323 | self.open_animation.is_some() |
| 318 | || self.resize_animation.is_some() | 324 | || self.resize_animation.is_some() |
| 319 | || self.move_x_animation.is_some() | 325 | || self.move_x_animation.is_some() |
| @@ -654,8 +660,11 @@ impl<W: LayoutElement> Tile<W> { | |||
| 654 | } | 660 | } |
| 655 | 661 | ||
| 656 | pub fn hit(&self, point: Point<f64, Logical>) -> Option<HitType> { | 662 | pub fn hit(&self, point: Point<f64, Logical>) -> Option<HitType> { |
| 663 | + let offset = self.bob_offset(); | ||
| 664 | + let point = point - offset; | ||
| 665 | + | ||
| 657 | if self.is_in_input_region(point) { | 666 | if self.is_in_input_region(point) { |
| 658 | - let win_pos = self.buf_loc(); | 667 | + let win_pos = self.buf_loc() + offset; |
| 659 | Some(HitType::Input { win_pos }) | 668 | Some(HitType::Input { win_pos }) |
| 660 | } else if self.is_in_activation_region(point) { | 669 | } else if self.is_in_activation_region(point) { |
| 661 | Some(HitType::Activate { | 670 | Some(HitType::Activate { |
| @@ -752,6 +761,18 @@ impl<W: LayoutElement> Tile<W> { | |||
| 752 | size | 761 | size |
| 753 | } | 762 | } |
| 754 | 763 | ||
| 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 | + | ||
| 755 | pub fn draw_border_with_background(&self) -> bool { | 776 | pub fn draw_border_with_background(&self) -> bool { |
| 756 | if self.effective_border_width().is_some() { | 777 | if self.effective_border_width().is_some() { |
| 757 | return false; | 778 | return false; |
| @@ -782,6 +803,16 @@ impl<W: LayoutElement> Tile<W> { | |||
| 782 | let tile_alpha = self.tile_alpha(); | 803 | let tile_alpha = self.tile_alpha(); |
| 783 | let win_alpha = win_alpha * tile_alpha; | 804 | let win_alpha = win_alpha * tile_alpha; |
| 784 | 805 | ||
| 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 | + | ||
| 785 | let window_loc = self.window_loc(); | 816 | let window_loc = self.window_loc(); |
| 786 | let window_size = self.window_size().to_f64(); | 817 | let window_size = self.window_size().to_f64(); |
| 787 | let animated_window_size = self.animated_window_size(); | 818 | let animated_window_size = self.animated_window_size(); |
src/layout/workspace.rsmodified+1 -1
| @@ -333,7 +333,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | pub fn are_transitions_ongoing(&self) -> bool { | 335 | 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() |
| 337 | } | 337 | } |
| 338 | 338 | ||
| 339 | pub fn update_render_elements(&mut self, is_active: bool) { | 339 | pub fn update_render_elements(&mut self, is_active: bool) { |
src/window/mod.rsmodified+7 -0
| @@ -100,6 +100,9 @@ pub struct ResolvedWindowRules { | |||
| 100 | /// Whether to clip this window to its geometry, including the corner radius. | 100 | /// Whether to clip this window to its geometry, including the corner radius. |
| 101 | pub clip_to_geometry: Option<bool>, | 101 | pub clip_to_geometry: Option<bool>, |
| 102 | 102 | ||
| 103 | + /// Whether bob this window up and down. | ||
| 104 | + pub baba_is_float: Option<bool>, | ||
| 105 | + | ||
| 103 | /// Whether to block out this window from certain render targets. | 106 | /// Whether to block out this window from certain render targets. |
| 104 | pub block_out_from: Option<BlockOutFrom>, | 107 | pub block_out_from: Option<BlockOutFrom>, |
| 105 | 108 | ||
| @@ -210,6 +213,7 @@ impl ResolvedWindowRules { | |||
| 210 | opacity: None, | 213 | opacity: None, |
| 211 | geometry_corner_radius: None, | 214 | geometry_corner_radius: None, |
| 212 | clip_to_geometry: None, | 215 | clip_to_geometry: None, |
| 216 | + baba_is_float: None, | ||
| 213 | block_out_from: None, | 217 | block_out_from: None, |
| 214 | variable_refresh_rate: None, | 218 | variable_refresh_rate: None, |
| 215 | scroll_factor: None, | 219 | scroll_factor: None, |
| @@ -319,6 +323,9 @@ impl ResolvedWindowRules { | |||
| 319 | if let Some(x) = rule.clip_to_geometry { | 323 | if let Some(x) = rule.clip_to_geometry { |
| 320 | resolved.clip_to_geometry = Some(x); | 324 | resolved.clip_to_geometry = Some(x); |
| 321 | } | 325 | } |
| 326 | + if let Some(x) = rule.baba_is_float { | ||
| 327 | + resolved.baba_is_float = Some(x); | ||
| 328 | + } | ||
| 322 | if let Some(x) = rule.block_out_from { | 329 | if let Some(x) = rule.block_out_from { |
| 323 | resolved.block_out_from = Some(x); | 330 | resolved.block_out_from = Some(x); |
| 324 | } | 331 | } |