The X server sends a ConfigureNotify event to indicate a window resize. Handling the event generally requires changing the viewport of OpenGL windows. The sample program calls glViewport specifying the window's new width and height. A resize also necessitates a screen redraw so the code ``falls through'' to the expose code which sets the needRedraw flag.
When you resize the window, the aspect ratio of the window may change (unless you have negotiated a fixed aspect ratio with the window manager as the -keepaspect option does). If you want the aspect ratio of your final image to remain constant, you might need to respecify the projection matrix with an aspect ratio to compensate for the window's changed aspect ratio. The example does not do this.