diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-03-01 09:45:57 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-03-10 07:59:14 +0300 |
| commit | 88614c08fe0a7833cbb749a6ecf3e703eb373c6e (patch) | |
| tree | f8dfa7b6b1802a355eb42fb7abc0f46a224928c1 /src/layout/tile.rs | |
| parent | 4f5c8e745bec6395105138c83468bccb4ab27ea9 (diff) | |
| download | niri-88614c08fe0a7833cbb749a6ecf3e703eb373c6e.tar.gz niri-88614c08fe0a7833cbb749a6ecf3e703eb373c6e.tar.bz2 niri-88614c08fe0a7833cbb749a6ecf3e703eb373c6e.zip | |
Make interactively moved window semitransparent
Diffstat (limited to 'src/layout/tile.rs')
| -rw-r--r-- | src/layout/tile.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/layout/tile.rs b/src/layout/tile.rs index 71aa33a1..a93e4a6f 100644 --- a/src/layout/tile.rs +++ b/src/layout/tile.rs @@ -148,6 +148,12 @@ struct MoveAnimation { #[derive(Debug)] pub(super) struct AlphaAnimation { pub(super) anim: Animation, + /// Whether the animation should persist after it's done. + /// + /// This is used by things like interactive move which need to animate alpha to + /// semitransparent, then hold it at semitransparent for a while, until the operation + /// completes. + pub(super) hold_after_done: bool, offscreen: OffscreenBuffer, } @@ -319,7 +325,7 @@ impl<W: LayoutElement> Tile<W> { } if let Some(alpha) = &mut self.alpha_animation { - if alpha.anim.is_done() { + if !alpha.hold_after_done && alpha.anim.is_done() { self.alpha_animation = None; } } @@ -334,7 +340,10 @@ impl<W: LayoutElement> Tile<W> { || self.resize_animation.is_some() || self.move_x_animation.is_some() || self.move_y_animation.is_some() - || self.alpha_animation.is_some() + || self + .alpha_animation + .as_ref() + .is_some_and(|alpha| !alpha.anim.is_done()) } pub fn update_render_elements(&mut self, is_active: bool, view_rect: Rectangle<f64, Logical>) { @@ -491,6 +500,7 @@ impl<W: LayoutElement> Tile<W> { self.alpha_animation = Some(AlphaAnimation { anim: Animation::new(self.clock.clone(), current, to, 0., config), + hold_after_done: false, offscreen, }); } @@ -505,6 +515,12 @@ impl<W: LayoutElement> Tile<W> { } } + pub fn hold_alpha_animation_after_done(&mut self) { + if let Some(alpha) = &mut self.alpha_animation { + alpha.hold_after_done = true; + } + } + pub fn window(&self) -> &W { &self.window } |
