In my program I am using similar code to the one shown below. The problem is that redrawing is a kind of slow (I have many object on the screen) and when I resize the window graphics is updated for all intermediate window sizes which takes forever. How can I kill all the intermediate "resize" event and process only the last one?

/* Get events, use first to display text and graphics */
while (1)
/* Get any type of event on any window; this gets
* events on every window for which we have selected
* events (three in this case) */
XNextEvent(display, &report);
switch (report.type) {
case Expose:
printf("got an Expose event\n");
/* Redraw contents of windows; note that we can't
* use switch because window IDs are not constant */
if (report.xexpose.window == window1)
/* Redraw window 1 */;
else if (report.xexpose.window == window2)
/* Redraw window 2 */;
else (report.xexpose.window == window3)
/* Redraw window 3 */;
case ButtonPress:
printf("got a ButtonPress event\n");
/* Respond to buttonpress, probably depending on
* which window is reported in report.xbutton.window */
case ConfigureNotify:
printf("got a ConfigureNotify event\n");
/* Window was resized, moved, or restacked or border
* width was changed; reset application variables
* so Expose branch will scale graphics properly */

Thank you!