gala icon indicating copy to clipboard operation
gala copied to clipboard

Add style transition API

Open donadigo opened this issue 6 years ago • 10 comments

Adds a new method to the DBus API called transition_from_snapshot for apps (and primarily the switchboard plug) to be able to create a smooth stylesheet transition. The transition will not happen when animations are disabled but the snapshot will still be created and added (that is it will stay for 200ms and hide without any animations).

The code should be quite optimized for the task, I previously used a simple Cogl.Texture.get_data for creating a static texture but it turned out to be quite long to execute: transferring pixel data from GPU to CPU took ~15ms on my machine which is little bit above 60FPS but there were longer runs that caused visible lag when creating textures for maximized windows. We now copy the texture directly on the GPU which takes about ~2ms.

Update: the code has been updated to Cogl2 and to automatically transition when the style changes, however there still seems to be the problem of some elements flickering while transitioning. I think this is a matter of timing things correctly.

donadigo avatar May 18 '19 00:05 donadigo

I guess an obvious question is, what about Wayland? Do we get window IDs like this once we move away from X?

I think we should also think about the abuse perspective. I'm not sure it's a good idea to have the API endpoint be the same for an app to request the transition of any window it can guess the ID of and for the whole desktop to be affected when no argument is supplied. An App should probably only be able to effect itself

danirabbit avatar May 18 '19 00:05 danirabbit

  1. No one knows. See https://github.com/elementary/gala/issues/68. I'm not sure if mutter will do anything about this but it seems like there's no standard for those things either. I also don't know how mutter on wayland handles window ID's.

  2. We can optionally move part of the current method and get the PID of who's calling it and create the effect for windows based on PID.

donadigo avatar May 18 '19 01:05 donadigo

@danrabbit updated.

donadigo avatar May 19 '19 02:05 donadigo

Does this need to be an external API at all? Can't Gala just listen to the setting and do this transition automatically? Edit: I guess the use of an API is that each app could request this whenever, i.e. Code could request it when changing its style?

cassidyjames avatar Jan 24 '20 17:01 cassidyjames

@cassidyjames yeah that and if gala listened to that setting you have to account for the fact that the signal could fire later than the theme change, causing a jarring flick before the actual transition. That's why it's safer to have the app call before actually changing the setting. If we had a Gtk fork / patch then perhaps that would be possible to do automatically.

donadigo avatar Jan 24 '20 18:01 donadigo

Branch updated to use the newest Cogl2 API and updated to master.

donadigo avatar Nov 19 '20 01:11 donadigo

Ready for review again.

donadigo avatar Nov 21 '20 23:11 donadigo

Hm, I can't really see that this smooths anything out for me. Is there something I need to do other than install this branch and restart my session?

danirabbit avatar Nov 24 '20 23:11 danirabbit

@danrabbit hm, that's weird. Installing the branch & restarting should be enough. Is the transition like instant, or do you see at least some trace of the animation?

donadigo avatar Dec 03 '20 11:12 donadigo

~@donadigo would it be possible to resolve conflicts here?~ I'm not sure why we weren't seeing it work in the past, but now that we have all the other dark style bits merged in, it's working for me. This would be an incredibly nice effect.

cassidyjames avatar Jul 17 '21 05:07 cassidyjames