-static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
-{
- gtk_timeout_remove( wxTheApp->m_wakeUpTimerTag );
- wxTheApp->m_wakeUpTimerTag = 0;
-
-#if (GTK_MINOR_VERSION > 0)
- /* when getting called from GDK's time-out handler
- we are no longer within GDK's grab on the GUI
- thread so we must lock it here ourselves */
- GDK_THREADS_ENTER ();
-#endif
-
- /* unblock other threads wishing to do some GUI things */
+
+#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;
+ FD_ZERO(&readfds);
+ FD_ZERO(&writefds);
+ FD_ZERO(&exceptfds);
+
+ unsigned int i;
+ for ( i = 0; i < nfds; i++ )
+ {
+ wxASSERT_MSG( ufds[i].fd < FD_SETSIZE, _T("fd out of range") );
+
+ if ( ufds[i].events & G_IO_IN )
+ FD_SET(ufds[i].fd, &readfds);
+
+ if ( ufds[i].events & G_IO_PRI )
+ FD_SET(ufds[i].fd, &exceptfds);
+
+ if ( ufds[i].events & G_IO_OUT )
+ FD_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 ( FD_ISSET(ufds[i].fd, &readfds ) )
+ ufds[i].revents |= G_IO_IN;
+
+ if ( FD_ISSET(ufds[i].fd, &exceptfds ) )
+ ufds[i].revents |= G_IO_PRI;
+
+ if ( FD_ISSET(ufds[i].fd, &writefds ) )
+ ufds[i].revents |= G_IO_OUT;
+ }
+
+ return res;
+}
+
+#endif // HAVE_POLL/!HAVE_POLL
+
+static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout )
+{
+ gdk_threads_enter();
+