- // Indicate that we are now in idle mode and event handlers
- // will have to reinstall the idle handler again.
- g_isIdle = true;
- wxTheApp->m_idleTag = 0;
-
- wxAddEmissionHook();
- }
-
- // Return FALSE if no more idle events are to be sent
- return moreIdles;
-}
-
-#if wxUSE_THREADS
-
-#ifdef HAVE_POLL
- #define wxPoll poll
- #define wxPollFd pollfd
-#else // !HAVE_POLL
-
-typedef GPollFD wxPollFd;
-
-int wxPoll(wxPollFd *ufds, unsigned int nfds, int timeout)
-{
- // convert timeout from ms to struct timeval (s/us)
- timeval tv_timeout;
- tv_timeout.tv_sec = timeout/1000;
- tv_timeout.tv_usec = (timeout%1000)*1000;
-
- // remember the highest fd used here
- int fdMax = -1;
-
- // and fill the sets for select()
- fd_set readfds;
- fd_set writefds;
- fd_set exceptfds;
- wxFD_ZERO(&readfds);
- wxFD_ZERO(&writefds);
- wxFD_ZERO(&exceptfds);
-
- unsigned int i;
- for ( i = 0; i < nfds; i++ )
- {
- wxASSERT_MSG( ufds[i].fd < wxFD_SETSIZE, _T("fd out of range") );
-
- if ( ufds[i].events & G_IO_IN )
- wxFD_SET(ufds[i].fd, &readfds);
-
- if ( ufds[i].events & G_IO_PRI )
- wxFD_SET(ufds[i].fd, &exceptfds);
-
- if ( ufds[i].events & G_IO_OUT )
- wxFD_SET(ufds[i].fd, &writefds);
-
- if ( ufds[i].fd > fdMax )
- fdMax = ufds[i].fd;
- }
-
- fdMax++;
- int res = select(fdMax, &readfds, &writefds, &exceptfds, &tv_timeout);
-
- // translate the results back
- for ( i = 0; i < nfds; i++ )
- {
- ufds[i].revents = 0;
-
- if ( wxFD_ISSET(ufds[i].fd, &readfds ) )
- ufds[i].revents |= G_IO_IN;
-
- if ( wxFD_ISSET(ufds[i].fd, &exceptfds ) )
- ufds[i].revents |= G_IO_PRI;
-
- if ( wxFD_ISSET(ufds[i].fd, &writefds ) )
- ufds[i].revents |= G_IO_OUT;