-#ifdef HAVE_SYS_EPOLL_H
- m_dispatcher = wxEpollDispatcher::Get();
- if ( !m_dispatcher )
-#endif // HAVE_SYS_EPOLL_H
- {
- m_dispatcher = wxSelectDispatcher::Get();
+ wxLogTrace(wxTRACE_EVT_SOURCE,
+ "Adding event loop source for fd=%d", fd);
+
+ // we need a bridge to wxFDIODispatcher
+ //
+ // TODO: refactor the code so that only wxEventLoopSourceHandler is used
+ wxScopedPtr<wxFDIOHandler>
+ fdioHandler(new wxFDIOEventLoopSourceHandler(handler));
+
+ if ( !wxFDIODispatcher::Get()->RegisterFD(fd, fdioHandler.get(), flags) )
+ return NULL;
+
+ return new wxUnixEventLoopSource(wxFDIODispatcher::Get(), fdioHandler.release(),
+ fd, handler, flags);