projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix typo (missing closing brackets); add some comments to wxKeyCode; no real change
[wxWidgets.git]
/
src
/
unix
/
evtloopunix.cpp
diff --git
a/src/unix/evtloopunix.cpp
b/src/unix/evtloopunix.cpp
index fc1f469ae427e6f626902b971c2377d0a119836d..b439c4d4664b4f871973739e7187fdd2bf5d0699 100644
(file)
--- a/
src/unix/evtloopunix.cpp
+++ b/
src/unix/evtloopunix.cpp
@@
-85,14
+85,14
@@
void wxConsoleEventLoop::PipeIOHandler::WakeUp()
void wxConsoleEventLoop::PipeIOHandler::OnReadWaiting()
{
// got wakeup from child thread: read all data available in pipe just to
void wxConsoleEventLoop::PipeIOHandler::OnReadWaiting()
{
// got wakeup from child thread: read all data available in pipe just to
- // make it empty (eve
v
n though we write one byte at a time from WakeUp(),
+ // make it empty (even though we write one byte at a time from WakeUp(),
// it could have been called several times)
char buf[4];
for ( ;; )
{
const int size = read(GetReadFd(), buf, WXSIZEOF(buf));
// it could have been called several times)
char buf[4];
for ( ;; )
{
const int size = read(GetReadFd(), buf, WXSIZEOF(buf));
- if ( size == 0 || (size == -1 &&
errno == EAGAIN
) )
+ if ( size == 0 || (size == -1 &&
(errno == EAGAIN || errno == EINTR)
) )
{
// nothing left in the pipe (EAGAIN is expected for an FD with
// O_NONBLOCK)
{
// nothing left in the pipe (EAGAIN is expected for an FD with
// O_NONBLOCK)
@@
-107,7
+107,9
@@
void wxConsoleEventLoop::PipeIOHandler::OnReadWaiting()
}
}
}
}
- wxTheApp->ProcessPendingEvents();
+ // writing to the wake up pipe will make wxConsoleEventLoop return from
+ // wxFDIODispatcher::Dispatch() it might be currently blocking in, nothing
+ // else needs to be done
}
// ===========================================================================
}
// ===========================================================================
@@
-144,35
+146,47
@@
wxConsoleEventLoop::wxConsoleEventLoop()
bool wxConsoleEventLoop::Pending() const
{
bool wxConsoleEventLoop::Pending() const
{
- return wxTheApp->HasPendingEvents();
+ if ( m_dispatcher->HasPending() )
+ return true;
+
+#if wxUSE_TIMER
+ wxUsecClock_t nextTimer;
+ if ( wxTimerScheduler::Get().GetNext(&nextTimer) &&
+ !wxMilliClockToLong(nextTimer) )
+ return true;
+#endif // wxUSE_TIMER
+
+ return false;
}
bool wxConsoleEventLoop::Dispatch()
{
}
bool wxConsoleEventLoop::Dispatch()
{
- // calculate the timeout until the next timer expiration
- int timeout;
+ DispatchTimeout(wxFDIODispatcher::TIMEOUT_INFINITE);
+
+ return true;
+}
+int wxConsoleEventLoop::DispatchTimeout(unsigned long timeout)
+{
#if wxUSE_TIMER
#if wxUSE_TIMER
+ // check if we need to decrease the timeout to account for a timer
wxUsecClock_t nextTimer;
if ( wxTimerScheduler::Get().GetNext(&nextTimer) )
{
wxUsecClock_t nextTimer;
if ( wxTimerScheduler::Get().GetNext(&nextTimer) )
{
- // timeout is in ms
- timeout = (nextTimer / 1000).ToLong();
+ unsigned long timeUntilNextTimer = wxMilliClockToLong(nextTimer / 1000);
+ if ( timeUntilNextTimer < timeout )
+ timeout = timeUntilNextTimer;
}
}
- else // no timers, we can block forever
#endif // wxUSE_TIMER
#endif // wxUSE_TIMER
- {
- timeout = wxFDIODispatcher::TIMEOUT_INFINITE;
- }
-
m_dispatcher->Dispatch(timeout)
;
+
bool hadEvent = m_dispatcher->Dispatch(timeout) > 0
;
#if wxUSE_TIMER
#if wxUSE_TIMER
- wxTimerScheduler::Get().NotifyExpired();
-#endif
+ if ( wxTimerScheduler::Get().NotifyExpired() )
+ hadEvent = true;
+#endif // wxUSE_TIMER
- wxTheApp->ProcessPendingEvents();
- return true;
+ return hadEvent ? 1 : -1;
}
void wxConsoleEventLoop::WakeUp()
}
void wxConsoleEventLoop::WakeUp()