Skip to content

Squeezemize looks bad if minimize area is too narrow #2720

Closed

Description

@dkondor

If setting a minimize area (by set_rectangle) with a very small width, the animation looks "bad": the view being minimized is squeezed too much too early, becoming a thin line.

Image

Simple test case: https://github.com/dkondor/minimize_test

Real-world use case: under some conditions, Cairo-Dock will try to set a rectangle with width = height = 1 (see here and here) This is easy to fix, but I thought to raise this here as a general issue.

I'll look into the squeezimize plugin and suggest an improvement if I can.

Activity

  1. soreau commented on Jul 12, 2025

    @soreau
    Member

    If setting a minimize area (by set_rectangle) with a very small width, the animation looks "bad": the view being minimized is squeezed too much too early, becoming a thin line.

    I'm not sure this should be considered as a bug. This is the way squeezimize animation works, and the algorithm is baked into the fragment shader.

    I'll look into the squeezimize plugin and suggest an improvement if I can.

    Good luck! 😀

  2. soreau commented on Jul 12, 2025

    @soreau
    Member

    That said, I tinkered around with the shader a bit and came up with this. Does it make the animation more in line with what you're expecting?

    -    float sigmoid = 1.0 / (1.0 + pow(2.718, -((y * inv_h) * 7.0 - 3.5)));
    +    float sigmoid = 1.0 / (1.0 + pow(2.718, -((y * inv_h) * 15.0 - 15.0)));
    
  3. dkondor commented on Jul 12, 2025

    @dkondor
    ContributorAuthor

    That said, I tinkered around with the shader a bit and came up with this. Does it make the animation more in line with what you're expecting?

    -    float sigmoid = 1.0 / (1.0 + pow(2.718, -((y * inv_h) * 7.0 - 3.5)));
    +    float sigmoid = 1.0 / (1.0 + pow(2.718, -((y * inv_h) * 15.0 - 15.0)));
    

    Thanks, this already looks better! But I also started tinkering, and feel that I cannot rest until I figure out how the shader works :D I'll report back if I find anything...

  4. soreau commented on Jul 12, 2025

    @soreau
    Member

    I wrote it from scratch, but I'm not completely sure how it works even still. 😆

    If you have any questions, feel free to ask. 👍

  5. soreau commented on Jul 12, 2025

    @soreau
    Member

    @dkondor Here is what I've found to be an improvement. It should solve the problem of being too slender too quickly, and smooth out the animation so it's less jarring overall. Let me know what you think. If it's good, I can submit a PR.

    @@ -76,7 +76,7 @@ void main()
         vec2 uv_squeeze;
         float inv_w = 1.0 / (src_box.z - src_box.x);
         float inv_h = 1.0 / (src_box.w - src_box.y);
    -    float progress_pt_one = clamp(progress, 0.0, 0.5) * 2.0;
    +    float progress_pt_one = pow(clamp(progress, 0.0, 0.5) * 2.0, 3.0);
         float progress_pt_two = (clamp(progress, 0.5, 1.0) - 0.5) * 2.0;
     
         uv_squeeze.x = (uv.x * inv_w) - (inv_w - 1.0);
    @@ -94,7 +94,7 @@ void main()
             uv_squeeze.y -= -progress_pt_two * (inv_h - target_box.y + target_box.w);
         }
     
    -    float sigmoid = 1.0 / (1.0 + pow(2.718, -((y * inv_h) * 7.0 - 3.5)));
    +    float sigmoid = 1.0 / (1.0 + pow(2.718, -((y * inv_h) * 15.0 - 12.0)));
    
  6. soreau commented on Jul 12, 2025

    @soreau
    Member

    Here's another variation that might be even better:

    @@ -76,8 +76,8 @@ void main()
         vec2 uv_squeeze;
         float inv_w = 1.0 / (src_box.z - src_box.x);
         float inv_h = 1.0 / (src_box.w - src_box.y);
    -    float progress_pt_one = clamp(progress, 0.0, 0.5) * 2.0;
    -    float progress_pt_two = (clamp(progress, 0.5, 1.0) - 0.5) * 2.0;
    +    float progress_pt_one = pow(clamp(progress, 0.0, 0.25) * 4.0, 3.0);
    +    float progress_pt_two = pow(progress, 2.0);
     
         uv_squeeze.x = (uv.x * inv_w) - (inv_w - 1.0);
         uv_squeeze.x += inv_w - inv_w * src_box.z;
    @@ -94,7 +94,7 @@ void main()
             uv_squeeze.y -= -progress_pt_two * (inv_h - target_box.y + target_box.w);
         }
     
    -    float sigmoid = 1.0 / (1.0 + pow(2.718, -((y * inv_h) * 7.0 - 3.5)));
    +    float sigmoid = 1.0 / (1.0 + pow(2.718, -(y * (1.0 / (src_box.w - target_box.w)) * 15.0 - 10.0)));
    
  7. added a commit that references this issue on Jul 13, 2025
    88bf949
  8. dkondor commented on Jul 13, 2025

    @dkondor
    ContributorAuthor

    I've just checked #2721 it works nicely. Thanks for looking into this so quickly!

  9. added a commit that references this issue on Jul 13, 2025
    a1032fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions