code: func mainEventLoop(xu *xgbutil.XUtil,
  	pingBefore, pingAfter, pingQuit chan struct{}) {
  	for {
  		if Quitting(xu) {
  			if pingQuit != nil {
  				pingQuit <- struct{}{}
  			}
  			break
  		}
  
  		// Gobble up as many events as possible (into the queue).
  		// If there are no events, we block.
  		Read(xu, true)
  
  		// Now process every event/error in the queue.
  		processEventQueue(xu, pingBefore, pingAfter)
  	}
  }
docs: // mainEventLoop runs the main event loop with an optional ping channel.