'Old xlib programs hang the Linux GUI on window resize. Why?

I have noticed, that with the older X programs, when the user start to resize window by dragging its edges, the whole GUI of the OS freezes.

I am testing with glxgears - the gears stop rotating. The same happens with the content update of all other programs - such as the task manager, terminal windows and so on.

After stopping moving the mouse, all activity starts again.

Resizing newer program windows (I mean using GTK or Qt) does not freeze anything.

In the same time, the GUI of the older programs is much more responsive than the new. Only the dragging resize is the problem.

The older programs all use the standard documented way of handling the message queue. Something like the following (more complex, of course):

while (1) {
      XNextEvent(d, &e);
      if (e.type == Expose) {
         XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
         XDrawString(d, w, DefaultGC(d, s), 10, 50, msg, strlen(msg));
      }
}

I have tried to eliminate the whole message processing by setting XSetWindowAttributes.event_mask = 0 on main window creation. The events stop flowing at all, but on resizing the empty window, all GUI still freezes.

So, the problem is not (only) on the client side. Although, it can be in the way the client and the server interact. For example it can be because the client does not do something.

So, what the newer toolkits do differently? What to change in the older programs in order to avoid such freezes.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source