I am trying to enchance event handling loop. Right now with a standard (text book) loop the problem is that on any ConfigureNotify or Expose event I had to run drawing function which takes too long to complete. As a result, e.g., when I resize the window it will draw one by one all the intermediate sizes up to the final one. (Again since the draw function is slow it may take up to several seconds) Can I somehow discard all the intermediate ConfigureNotify and Expose events and process only the final one? I am trying to do that but so far wthout success.
I had a similar problem when writing my own app, and here's some solutions I came up with:
1) Expose events have a count member; ignore all Expose events with a count higher than 0. (This was my temporary solution)
2) Expose events have members to specify the region of the window that needs to be redrawn; redraw only this part. (This is part of the solution I used)
3) Draw to back buffers (like Pixmaps or in my case, Imlib_Images) whenever needed (for me it was when the root pixmap changed) and render the buffer onto the window when needed (Expose event)