Fixed sockets under X11.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17845 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1231,6 +1231,10 @@ bool wxApp::Yield(bool onlyIfNeeded)
|
|||||||
wxEventLoop::SetActive(newEventLoop);
|
wxEventLoop::SetActive(newEventLoop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call dispatch at least once so that sockets
|
||||||
|
// can be tested
|
||||||
|
wxTheApp->Dispatch();
|
||||||
|
|
||||||
while (wxTheApp && wxTheApp->Pending())
|
while (wxTheApp && wxTheApp->Pending())
|
||||||
wxTheApp->Dispatch();
|
wxTheApp->Dispatch();
|
||||||
|
|
||||||
|
@@ -387,7 +387,7 @@ int wxEventLoop::Run()
|
|||||||
#endif
|
#endif
|
||||||
if (!m_impl->SendIdleEvent())
|
if (!m_impl->SendIdleEvent())
|
||||||
{
|
{
|
||||||
#if wxUSE_THREADS
|
#if 0 // wxUSE_THREADS
|
||||||
// leave the main loop to give other threads a chance to
|
// leave the main loop to give other threads a chance to
|
||||||
// perform their GUI work
|
// perform their GUI work
|
||||||
wxMutexGuiLeave();
|
wxMutexGuiLeave();
|
||||||
@@ -430,8 +430,8 @@ void wxEventLoop::Exit(int rc)
|
|||||||
|
|
||||||
bool wxEventLoop::Pending() const
|
bool wxEventLoop::Pending() const
|
||||||
{
|
{
|
||||||
XFlush((Display*) wxGetDisplay());
|
XFlush( wxGlobalDisplay() );
|
||||||
return (XPending((Display*) wxGetDisplay()) > 0);
|
return (XPending( wxGlobalDisplay() ) > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxEventLoop::Dispatch()
|
bool wxEventLoop::Dispatch()
|
||||||
@@ -447,7 +447,7 @@ bool wxEventLoop::Dispatch()
|
|||||||
// often, so we should probably limit idle processing to
|
// often, so we should probably limit idle processing to
|
||||||
// not be repeated more than every N milliseconds.
|
// not be repeated more than every N milliseconds.
|
||||||
|
|
||||||
if (XPending((Display*) wxGetDisplay()) == 0)
|
if (XPending( wxGlobalDisplay() ) == 0)
|
||||||
{
|
{
|
||||||
#if wxUSE_NANOX
|
#if wxUSE_NANOX
|
||||||
GR_TIMEOUT timeout = 10; // Milliseconds
|
GR_TIMEOUT timeout = 10; // Milliseconds
|
||||||
@@ -462,7 +462,8 @@ bool wxEventLoop::Dispatch()
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
tv.tv_sec=0;
|
tv.tv_sec=0;
|
||||||
tv.tv_usec=10000; // TODO make this configurable
|
tv.tv_usec=10000; // TODO make this configurable
|
||||||
int fd = ConnectionNumber((Display*) wxGetDisplay());
|
int fd = ConnectionNumber( wxGlobalDisplay() );
|
||||||
|
|
||||||
fd_set readset;
|
fd_set readset;
|
||||||
fd_set writeset;
|
fd_set writeset;
|
||||||
int highest = fd;
|
int highest = fd;
|
||||||
@@ -473,10 +474,10 @@ bool wxEventLoop::Dispatch()
|
|||||||
|
|
||||||
#if wxUSE_SOCKETS
|
#if wxUSE_SOCKETS
|
||||||
if (wxTheSocketTable)
|
if (wxTheSocketTable)
|
||||||
wxTheSocketTable->FillSets(& readset, & writeset, & highest);
|
wxTheSocketTable->FillSets( &readset, &writeset, &highest );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (select(highest+1, &readset, &writeset, NULL, & tv) == 0)
|
if (select( highest+1, &readset, &writeset, NULL, &tv ) == 0)
|
||||||
{
|
{
|
||||||
// Timed out, so no event to process
|
// Timed out, so no event to process
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -484,23 +485,25 @@ bool wxEventLoop::Dispatch()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// An X11 event was pending, so get it
|
// An X11 event was pending, so get it
|
||||||
if (FD_ISSET(fd, & readset))
|
if (FD_ISSET( fd, &readset ))
|
||||||
XNextEvent((Display*) wxGetDisplay(), & event);
|
XNextEvent( wxGlobalDisplay(), &event );
|
||||||
|
|
||||||
#if wxUSE_SOCKETS
|
#if wxUSE_SOCKETS
|
||||||
// Check if any socket events were pending,
|
// Check if any socket events were pending,
|
||||||
// and if so, call their callbacks
|
// and if so, call their callbacks
|
||||||
if (wxTheSocketTable)
|
if (wxTheSocketTable)
|
||||||
wxTheSocketTable->ProcessEvents(& readset, & writeset);
|
wxTheSocketTable->ProcessEvents( &readset, &writeset );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
XNextEvent((Display*) wxGetDisplay(), & event);
|
XNextEvent( wxGlobalDisplay(), &event );
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) m_impl->ProcessEvent(& event);
|
|
||||||
|
(void) m_impl->ProcessEvent( &event );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user