Conversation
13420bf to
c42db0f
Compare
YaLTeR
left a comment
There was a problem hiding this comment.
Haven't looked through in detail
src/handlers/layer_shell.rs
Outdated
| if let Some((_, mut mapped)) = self.niri.closing_layers.remove(layer) { | ||
| mapped.clear_close_animation(); | ||
| mapped.start_open_animation(&config.animations); |
There was a problem hiding this comment.
I think it would make more sense for it to work like closing windows work where they are not tied in any way to a Mapped. It would remove this sort of juggling.
| use crate::render_helpers::{render_to_encompassing_texture, RenderTarget}; | ||
|
|
||
| #[derive(Debug)] | ||
| pub struct ClosingLayer { |
There was a problem hiding this comment.
This is pretty much exactly the same as ClosingWindow, maybe they could be somehow combined together?
There was a problem hiding this comment.
Yeah, this and opening_layer.rs, I directly copied from window stuff. Combining them together would be more architectural change, and I didn't think it appropriate for this PR.
src/layer/mapped.rs
Outdated
| pub closing_layer: Option<ClosingLayer>, | ||
|
|
||
| /// Cached render elements for close animation (captured on last commit before close). | ||
| cached_close_elements: Option<CachedCloseElements>, |
There was a problem hiding this comment.
This is called "unmap snapshot" for windows, let's keep the terminology
| let buf_pos = location; | ||
|
|
||
| let surface = self.surface.wl_surface(); | ||
|
|
src/handlers/layer_shell.rs
Outdated
| push_elements_from_surface_tree( | ||
| renderer, | ||
| surface, | ||
| Point::from((0., 0.)).to_physical_precise_round(scale), | ||
| scale, | ||
| alpha, | ||
| Kind::ScanoutCandidate, | ||
| &mut |elem| contents.push(elem), | ||
| ); | ||
|
|
||
| let mut blocked_out_contents = Vec::new(); | ||
| push_elements_from_surface_tree( | ||
| renderer, | ||
| surface, | ||
| Point::from((0., 0.)).to_physical_precise_round(scale), | ||
| scale, | ||
| alpha, | ||
| Kind::ScanoutCandidate, | ||
| &mut |elem| blocked_out_contents.push(elem), | ||
| ); |
There was a problem hiding this comment.
This stuff duplicated in 2 places likely needs to go into a separate function called store_unmap_snapshot() (see how window Mapped does it)
There was a problem hiding this comment.
Already done in a local commit.
src/layer/mapped.rs
Outdated
| // Blocked out layers fall back to normal rendering | ||
| if target.should_block_out(self.rules.block_out_from) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Why? Blocked-out tiles get rendered with anims, layers should too
There was a problem hiding this comment.
I think I got the wrong idea from render_popups(). I also don't use screensharing+block-out-from much so I didn't notice.
src/handlers/layer_shell.rs
Outdated
| Kind::ScanoutCandidate, | ||
| &mut |elem| contents.push(elem), | ||
| ); | ||
|
|
There was a problem hiding this comment.
So the logic here is to store a snapshot of contents at first commit to use if the surface is destroyed without unmapping? That's kinda weird tbh, those contents are way out of date by then. And anyhow this shouldn't be a problem I think if you store unmap snapshot in CompositorHandler::destroyed() just like regular windows do
src/handlers/layer_shell.rs
Outdated
| // The surface is unmapped. Capture elements now (while surface still has content) | ||
| // and add to closing_layers for animation rendering. |
There was a problem hiding this comment.
And this needs to be in pre-commit hook I believe (just like normal windows unmap snapshot)
c42db0f to
b94f028
Compare
b94f028 to
1affc8e
Compare
|
Alright everything seems to work. 260224_11h17m05s_recording.mp4 |
|
Looks like the SwayNC panel has a faint overlay during close animation. |
|
That's just how SwayNC does it. I tested it on Hyprland, and it's there as well. |
|
Test config for anyone looking to review this and new config design: animations {
layer-open {
duration-ms 700
curve "cubic-bezier" 0.05 0.7 0.1 1 // CSS cubic-bezier curve
// fade in, no movement
custom-shader r"
vec4 open_color(vec3 coords_geo, vec3 size_geo) {
vec3 coords_tex = niri_geo_to_tex * coords_geo;
vec4 color = texture2D(niri_tex, coords_tex.st);
color *= niri_clamped_progress;
return color;
}
"
}
layer-close {
// base fallback close (wallpaper, and any bucket without overrides)
duration-ms 900
curve "cubic-bezier" 0.05 0.7 0.1 1
// fade out, no movement
custom-shader r"
vec4 close_color(vec3 coords_geo, vec3 size_geo) {
// Geometry-space y coordinate of output bottom edge.
float bottom_geo = (niri_input_to_geo * vec3(0.0, 1.0, 1.0)).y;
vec3 coords = coords_geo;
coords.y -= niri_clamped_progress * bottom_geo;
vec3 coords_tex = niri_geo_to_tex * coords;
vec4 color = texture2D(niri_tex, coords_tex.st);
if (coords_tex.x < 0.0 || coords_tex.x > 1.0 ||
coords_tex.y < 0.0 || coords_tex.y > 1.0) {
color = vec4(0.0);
}
return color;
}
"
}
layer-launcher-open {
// distinct long launcher open
duration-ms 2400
curve "cubic-bezier" 0.05 0.7 0.1 1
// slide in from left with fade
custom-shader r"
vec4 open_color(vec3 coords_geo, vec3 size_geo) {
// Geometry-space x coordinate of output left edge.
float left_geo = (niri_input_to_geo * vec3(1.0, 0.0, 1.0)).x;
vec3 coords = coords_geo;
coords.x += (1.0 - niri_clamped_progress) * left_geo;
vec3 coords_tex = niri_geo_to_tex * coords;
vec4 color = texture2D(niri_tex, coords_tex.st);
if (coords_tex.x < 0.0 || coords_tex.x > 1.0 ||
coords_tex.y < 0.0 || coords_tex.y > 1.0) {
color = vec4(0.0);
}
color *= niri_clamped_progress;
return color;
}
"
}
layer-launcher-close {
// distinct long launcher close
duration-ms 2600
curve "cubic-bezier" 0.05 0.7 0.1 1
// slide out to right with fade
custom-shader r"
vec4 close_color(vec3 coords_geo, vec3 size_geo) {
// Geometry-space x coordinate of output right edge.
float right_geo = (niri_input_to_geo * vec3(1.0, 0.0, 1.0)).x;
vec3 coords = coords_geo;
coords.x -= niri_clamped_progress * right_geo;
vec3 coords_tex = niri_geo_to_tex * coords;
vec4 color = texture2D(niri_tex, coords_tex.st);
if (coords_tex.x < 0.0 || coords_tex.x > 1.0 ||
coords_tex.y < 0.0 || coords_tex.y > 1.0) {
color = vec4(0.0);
}
color *= (1.0 - niri_clamped_progress);
return color;
}
"
}
layer-bar-open {
// bar open distinct but shorter than launcher
duration-ms 1800
curve "cubic-bezier" 0.05 0.7 0.1 1
// slide in from left
custom-shader r"
vec4 open_color(vec3 coords_geo, vec3 size_geo) {
// Geometry-space x coordinate of output right edge.
float right_geo = (niri_input_to_geo * vec3(1.0, 0.0, 1.0)).x;
vec3 coords = coords_geo;
coords.x -= (1.0 - niri_clamped_progress) * right_geo;
vec3 coords_tex = niri_geo_to_tex * coords;
vec4 color = texture2D(niri_tex, coords_tex.st);
if (coords_tex.x < 0.0 || coords_tex.x > 1.0 ||
coords_tex.y < 0.0 || coords_tex.y > 1.0) {
color = vec4(0.0);
}
return color;
}
"
}
layer-bar-close {
duration-ms 3200
curve "cubic-bezier" 0.05 0.7 0.1 1
// slide out to right
custom-shader r"
vec4 close_color(vec3 coords_geo, vec3 size_geo) {
float right_geo = (niri_input_to_geo * vec3(1.0, 0.0, 1.0)).x;
vec3 coords = coords_geo;
coords.x += niri_clamped_progress * right_geo;
vec3 coords_tex = niri_geo_to_tex * coords;
vec4 color = texture2D(niri_tex, coords_tex.st);
if (coords_tex.x < 0.0 || coords_tex.x > 1.0 ||
coords_tex.y < 0.0 || coords_tex.y > 1.0) {
color = vec4(0.0);
}
return color;
}
"
}
layer-wallpaper-open {
duration-ms 2000
curve "cubic-bezier" 0.05 0.7 0.1 1
// slide in from left
custom-shader r"
vec4 open_color(vec3 coords_geo, vec3 size_geo) {
// Geometry-space x coordinate of output right edge.
float right_geo = (niri_input_to_geo * vec3(1.0, 0.0, 1.0)).x;
vec3 coords = coords_geo;
coords.x -= (1.0 - niri_clamped_progress) * right_geo;
vec3 coords_tex = niri_geo_to_tex * coords;
vec4 color = texture2D(niri_tex, coords_tex.st);
if (coords_tex.x < 0.0 || coords_tex.x > 1.0 ||
coords_tex.y < 0.0 || coords_tex.y > 1.0) {
color = vec4(0.0);
}
return color;
}
"
}
layer-wallpaper-close {
duration-ms 2000
curve "cubic-bezier" 0.05 0.7 0.1 1
// slide out to right
custom-shader r"
vec4 close_color(vec3 coords_geo, vec3 size_geo) {
float right_geo = (niri_input_to_geo * vec3(1.0, 0.0, 1.0)).x;
vec3 coords = coords_geo;
coords.x += niri_clamped_progress * right_geo;
vec3 coords_tex = niri_geo_to_tex * coords;
vec4 color = texture2D(niri_tex, coords_tex.st);
if (coords_tex.x < 0.0 || coords_tex.x > 1.0 ||
coords_tex.y < 0.0 || coords_tex.y > 1.0) {
color = vec4(0.0);
}
return color;
}
"
}
} |
9abd9ae to
8091e58
Compare
8091e58 to
4499c6c
Compare
|
I'm not sure if I like the I would prefer if it just use the usual |
Neither do I. But Yalter mentioned wanting to see if such a design, with it's backing heuristic, was possible to do relatively painlessly over on matrix. It is not as painless as desired. We'll see which parts we can keep and which to throw out.
That'll have to wait for animations block support in window-rules. |
|
|
I already replied to that thread but it was me doing something AI suggested, to make the open anim work. |
|
I was just linking the rationale |
Implements layer animations.
There is surprisingly no open issue for this. Just a couple discussions.
260220_23h27m11s_recording.mp4