yshui / picom

A lightweight compositor for X11
Other
3.92k stars 576 forks source link

Added Desktop Switch Triggers for different animations #1262

Closed pijulius closed 1 month ago

pijulius commented 1 month ago

This adds support for desktop switching animations by keeping track of _NET_CURRENT_DESKTOP atom on the root window.

As far as I understand this atom is set by window managers and so if it changes we can know that it's a desktop switch happening. Unfortunately window manager may need to set this BEFORE hiding/showing windows so we can animate correctly, me personally using FluxBox and this quick change https://github.com/pijulius/fluxbox/commit/83ee4dbee67a68fe38b0f96431473719e165bf1e makes it work just fine.

It adds the following animation triggers:

Unfortunately had to add inverse variables too as you may navigate to the next workspace from for e.g. 1st to 2nd but you may also go to 2nd from 1st and in that case the animations have to be totally different.

Here is a config example for switching workspace:

animations = ({ triggers = ["workspace-out"]; offset-y = { timing = "0.2s cubic-bezier(0.21, 0.02, 0.76, 0.36)"; start = "0"; end = "-window-height"; }; shadow-offset-y = "offset-y"; opacity = { timing = "0.2s linear"; start = "window-raw-opacity-before"; end = "window-raw-opacity"; }; blur-opacity = "opacity"; shadow-opacity = "opacity"; }, { triggers = ["workspace-out-inverse"]; offset-y = { timing = "0.2s cubic-bezier(0.21, 0.02, 0.76, 0.36)"; start = "0"; end = "window-height + window-y"; }; shadow-offset-y = "offset-y"; opacity = { timing = "0.2s linear"; start = "window-raw-opacity-before"; end = "window-raw-opacity"; }; blur-opacity = "opacity"; shadow-opacity = "opacity"; }, { triggers = ["workspace-in"]; offset-y = { timing = "0.2s cubic-bezier(0.24, 0.64, 0.79, 0.98)"; start = "window-height + window-y"; end = "0"; }; shadow-offset-y = "offset-y"; opacity = { timing = "0.2s linear"; start = "0"; end = "window-raw-opacity"; }; blur-opacity = "opacity"; shadow-opacity = "opacity"; }, { triggers = ["workspace-in-inverse"]; offset-y = { timing = "0.2s cubic-bezier(0.24, 0.64, 0.79, 0.98)"; start = "-window-height"; end = "0"; }; shadow-offset-y = "offset-y"; opacity = { timing = "0.2s linear"; start = "0"; end = "window-raw-opacity"; }; blur-opacity = "opacity"; shadow-opacity = "opacity"; })

yshui commented 1 month ago

Unfortunately window manager may need to set this BEFORE hiding/showing windows so we can animate correctly

Yeah, that's the problem I was thinking when I said this is impossible. Because the order of changes is not defined by any specification. So unless we can somehow convince all window managers to change, I don't think we can rely on this. If we do what we get will be endless streams of bug reports from people using a window manager that behaves differently...

And beyond that, your implementation also requires that the _NET_CURRENT_DESKTOP change happens in the same frame as the maps/unmaps, which isn't guaranteed either.

pijulius commented 1 month ago

Yep, got it, nw, thanks for the inputs!

Unfortunately atm don't know any other way to implement this, it worked out just fine for myself in the last years so will keep it and let it here till there is a better solution.

yshui commented 1 month ago

My plan is to add a dbus interface and custom animation triggers. so you can, for example, run a dbus-send in your switch workspace key binding to start a workspace animation.

pijulius commented 1 month ago

Hmm, that sounds great, so could use dbus to sign picom that workspace switching is happening, just not sure if the dbus event is picked up sooner than the windows start to hide/show but do like the idea a lot!