Smooth and solid resizing on X11

Because of the asynchronous nature of X11, it has traditionally been hard to make sure that the contents of a window synchronizes well with the window border while resizing. To solve this, a window manager protocol was developed that allowed the application to inform the window manager about when it had finished dealing with the resize event. This is known as the _NET_WM_SYNC_REQUEST protocol.

Until now, Qt has not officially supported this protocol, although there was a patch that adds support for it in the KDE copy of Qt 3. What bugged me about this was mainly that it caused resizing to be unnecessarily slow on the GNOME desktop, since Metacity will only send resize events at a fixed slow interval for applications that do not support this protocol, no matter how simple your dialog. I never did any X11 programming before, so I joined forces with Matthias and Denis and together we worked towards this patch, which adds support for the _NET_WM_SYNC_REQUEST to Qt 4.6.

Demonstrating resizing got smoother on GNOME

As a bonus, this fixed the disturbing resize behaviour when running with Compiz (visual effects). As became clear, Compiz relies heavily on this protocol to provide perfect synchronization between the application and the window border.

Demonstrating smooth and solid resizing on Compiz

Finally, I will note that waiting on the application does of course not come without drawbacks. For complex applications like for example Qt Creator, we have noticed that the resizing can also feel slower. This is because the window frame is waiting on the application to catch up, which increases the desynchronization with the mouse cursor. We're not sure what is better in this case. I know I personally would prefer my frame to resize as fast as possible, without taking into account the application at all. But that should in my opinion be a window manager option.

For those who would like to try it out live but don't want to go through the trouble of compiling Qt themselves, I've built two static 32-bit binaries; one that has the patch and one that doesn't. Even though they are built statically against Qt, they will still need some other libraries available on your system, just see if it works for you (tested on Ubuntu Jaunty).

Blog Topics: