yshui / picom

A lightweight compositor for X11 with animation support
https://picom.app/
Other
4.1k stars 585 forks source link

wm: split geometry trigger into geometry and position #1335

Open Monsterovich opened 3 weeks ago

Monsterovich commented 3 weeks ago
Monsterovich commented 2 weeks ago

@yshui

even just considering resizing with user interaction, this doesn't work. if you resize from the top-left corner, both (x, y) and (width, height) will change, which will only trigger position change in your code.

What? It works as it's supposed to, I don't use the position trigger because of the bad behavior, it will probably be more useful in tiling WMs.

https://github.com/user-attachments/assets/22a1e977-753a-4355-a869-cc74fccf9c94

    { match = "class_g !?= 'xfce4-panel' && class_g !?= 'Xfce4-notifyd'"; animations = (
        {
            triggers = ["geometry"];
            scale-x = {
                curve = "cubic-bezier(0.07, 0.65, 0, 1)";
                duration = "placeholder0";
                start = "window-width-before / window-width";
                end = 1;
            };
            scale-y = {
                curve = "cubic-bezier(0.07, 0.65, 0, 1)";
                duration = "placeholder0";
                start = "window-height-before / window-height";
                end = 1;
            };
            shadow-scale-x = "scale-x";
            shadow-scale-y = "scale-y";
            offset-x = {
                curve = "cubic-bezier(0.07, 0.65, 0, 1)";
                duration = "placeholder0";
                start = "window-x-before - window-x";
                end = 0;
            };
            offset-y = {
                curve = "cubic-bezier(0.07, 0.65, 0, 1)";
                duration = "placeholder0";
                start = "window-y-before - window-y";
                end = 0;
            };
            shadow-offset-x = "offset-x";
            shadow-offset-y = "offset-y";
            placeholder0 = 0.2;
        },
    ) },

I made it so that there is either a change in window dimensions or position, if you need both, then you just need to specify.

triggers = ["geometry", "position"];

yshui commented 2 weeks ago

if you don't even use the position trigger yourself, how do you know if it's working correctly? what is this "bad behavior" you are referring to?

Monsterovich commented 2 weeks ago

@yshui

if you don't even use the position trigger yourself, how do you know if it's working correctly? what is this "bad behavior" you are referring to?

I tested it, it works. The only bad behavior is moving a window from one workspace to another when the window is basically teleported, and I also don't like the animation of moving popups and would like them to appear immediately in the right place.

Like I said, position trigger is rarely needed and is most likely to be useful in very specific cases, like tiling WMs.

yshui commented 2 weeks ago

@Monsterovich the problem is resizing the window from the top-left corner triggers position change, but it should trigger geometry.

Monsterovich commented 2 weeks ago

@Monsterovich the problem is resizing the window from the top-left corner triggers position change, but it should trigger geometry.

@yshui How did you get this behavior, maybe it's the behavior of a particular application? I can't reproduce this on a regular window (e.g. thunar).

https://github.com/user-attachments/assets/7f5127b6-af4c-458b-a8cd-9757da546ffe

yshui commented 2 weeks ago

@Monsterovich ah... sorry, i did misread your code.

but there's the other problem: animation interruption doesn't work nicely with this: if you are in the middle of a resize animation, and the position changed, the resize animation will stop and the size jumps to the final size. which isn't very nice.

right now, with geometry trigger, you will notice if the window geometry changes when it's animating, it will still transition smoothly. i think that would be difficult to implement if we split the trigger.

Monsterovich commented 2 weeks ago

but there's the other problem: animation interruption doesn't work nicely with this: if you are in the middle of a resize animation, and the position changed, the resize animation will stop and the size jumps to the final size. which isn't very nice.

@yshui This is not true, the transition between animations works just fine.

https://github.com/user-attachments/assets/3c7c78e0-e675-4d93-a127-c71ef1863fa8

yshui commented 2 weeks ago

@Monsterovich of course it's going to work when you have the same animation for both geometry and position.

didn't you say you don't want animation when you move the window? if so, remove the position trigger, and see how it behaves.

Monsterovich commented 2 weeks ago

@Monsterovich of course it's going to work when you have the same animation for both geometry and position.

didn't you say you don't want animation when you move the window? if so, remove the position trigger, and see how it behaves.

@yshui I deleted it, so what? You can't physically interrupt an animation that lasts 0.1-0.2 seconds, I just wanted to show that the behavior when both triggers are specified is the same as before this PR that's why I set the length to 10s.

Additionally, I can now just specify the position in a separate match with another settings if I need to, in order to try to eliminate the bad behavior of the position trigger that I have. However, in general, it's fine for me to use only geometry without position, I have my use-cases, others have theirs.

Monsterovich commented 2 weeks ago

@yshui In theory, you could add a setting that waits for the previous animation to finish playing, e.g. for those willing to watch the window slowly change for 10 seconds, but is it necessary?

Monsterovich commented 2 weeks ago

@yshui I played around with the config some more, maybe that's what you wanted?

https://www.youtube.com/watch?v=_quxT7xsTO0

That's how I achieved this:

...
            triggers = ["geometry"];
            suppressions = ["position"];
...
yshui commented 2 weeks ago

suppressions = ["position"];

hurmmm, IIUC this means windows will just not react at all if you try to move them when they are in geometry animation? it doesn't feel like the right thing to do.

Monsterovich commented 2 weeks ago

suppressions = ["position"];

hurmmm, IIUC this means windows will just not react at all if you try to move them when they are in geometry animation? it doesn't feel like the right thing to do.

In my opinion, this is the only solution when you don't need a position trigger.

yshui commented 2 weeks ago

ok, might not be a bad idea after all :thinking: