+ if (XPending( wxGlobalDisplay() ) == 0)
+ {
+#if wxUSE_NANOX
+ GR_TIMEOUT timeout = 10; // Milliseconds
+ // Wait for next event, or timeout
+ GrGetNextEventTimeout(& event, timeout);
+
+ // Fall through to ProcessEvent.
+ // we'll assume that ProcessEvent will just ignore
+ // the event if there was a timeout and no event.
+
+#else
+ struct timeval tv;
+ tv.tv_sec=0;
+ tv.tv_usec=10000; // TODO make this configurable
+ int fd = ConnectionNumber( wxGlobalDisplay() );
+
+ fd_set readset;
+ fd_set writeset;
+ wxFD_ZERO(&readset);
+ wxFD_ZERO(&writeset);
+ wxFD_SET(fd, &readset);
+
+ if (select( fd+1, &readset, &writeset, NULL, &tv ) != 0)
+ {
+ // An X11 event was pending, get it
+ if (wxFD_ISSET( fd, &readset ))
+ XNextEvent( wxGlobalDisplay(), &event );
+ }
+#endif
+ }
+ else
+ {
+ XNextEvent( wxGlobalDisplay(), &event );
+ }
+
+#if wxUSE_SOCKETS
+ // handle any pending socket events:
+ wxFDIODispatcher::DispatchPending();
+#endif
+
+ (void) m_impl->ProcessEvent( &event );
+ return true;
+}