Reminder: your window animations belong to KWin

Martin Graesslin mgraesslin at kde.org
Wed Nov 25 14:13:28 UTC 2015


Hi Plasma devs,

a small reminder: if you want to animate windows use KWin. You should not 
animate your windows yourself. Why you might ask?

X11 sucks. If you animate using X11 you are moving the window. With each 
animation step you perform a configure event on the X server. This is then 
sent to all listening applications (e.g. KWin, Plasma, many more) which are 
woken up, process, etc.

You cannot in no reasonable way know when the frame gets rendered. So if you 
animate yourself you pick a "frame rate" which might be anywhere from 
stuttering to too fast. You just cannot know, because you have no 
introspection into X. If you send too many events, you just block everything 
due to too many wakeups and you get stuttering and in worst case even tearing. 
Oh and you increase the CPU usage significantly. Which again slows down your 
animation.

How does this change when you use KWin? Well KWin for starters doesn't need to 
move the window. All it needs to do is move a window texture around. For that 
it uses OpenGL and there is one thing OpenGL is really good at: that's texture  
mapping.

So with KWin you don't have to send configure requests, you don't wake up 
completely uninterested applications. The animation is controlled (KWin knows 
its framerate and how long it took to render the last frame), it never renders 
more frames than the screen could show. It cannot stall due to too many frames 
rendered.

If you have a problem where you want to animate windows and do so by moving 
the window position: talk to me. But please, pretty please never animate 
windows yourself. X sucks for that and Wayland makes it impossible. So please 
don't do it. Talk to me.

The same goes for opacity btw. Don't change the window opacity with Qt's 
mechanism, but use KWin. It's pretty much the same: QWindow's opacity goes 
through an X property, you have no control when it goes on the screen. KWin 
can animate opacity without going through X. That's how our fade effect works.

So if you want to animate any aspect of the window: talk to me. If you have 
code which animates: get rid of it.

Cheers
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20151125/f54bba51/attachment.sig>


More information about the Plasma-devel mailing list