X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/521bf4ff3ef47059265beff5d53c9e1162beb122..b9d880d6382e24156cdce4ae0390c843cc6208d9:/src/x11/utils.cpp diff --git a/src/x11/utils.cpp b/src/x11/utils.cpp index 501b9fcaeb..6c8fa963cb 100644 --- a/src/x11/utils.cpp +++ b/src/x11/utils.cpp @@ -13,7 +13,7 @@ #include "wx/wxprec.h" #if defined(__BORLANDC__) -#pragma hdrstop + #pragma hdrstop #endif // ============================================================================ @@ -25,11 +25,15 @@ // ---------------------------------------------------------------------------- #include "wx/utils.h" -#include "wx/app.h" + +#ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/window.h" // for wxTopLevelWindows + #include "wx/cursor.h" + #include "wx/msgdlg.h" +#endif + #include "wx/apptrait.h" -#include "wx/msgdlg.h" -#include "wx/cursor.h" -#include "wx/window.h" // for wxTopLevelWindows #include #include @@ -79,18 +83,60 @@ void wxFlushEvents() bool wxCheckForInterrupt(wxWindow *wnd) { - wxASSERT_MSG(FALSE, wxT("wxCheckForInterrupt not yet implemented.")); - return FALSE; + wxFAIL_MSG(wxT("wxCheckForInterrupt not yet implemented.")); + return false; } // ---------------------------------------------------------------------------- // wxExecute stuff // ---------------------------------------------------------------------------- +WX_DECLARE_HASH_MAP( int, wxEndProcessData*, wxIntegerHash, wxIntegerEqual, wxProcMap ); + +static wxProcMap *gs_procmap; + int wxAddProcessCallback(wxEndProcessData *proc_data, int fd) { - // TODO - return 0; + if (!gs_procmap) gs_procmap = new wxProcMap(); + (*gs_procmap)[fd] = proc_data; + return 1; +} + +void wxCheckForFinishedChildren() +{ + wxProcMap::iterator it; + if (!gs_procmap) return; + if (gs_procmap->size() == 0) { + // Map empty, delete it. + delete gs_procmap; + gs_procmap = NULL; + } + for (it = gs_procmap->begin();it != gs_procmap->end(); ++it) + { + wxEndProcessData *proc_data = it->second; + int pid = (proc_data->pid > 0) ? proc_data->pid : -(proc_data->pid); + int status = 0; + // has the process really terminated? + int rc = waitpid(pid, &status, WNOHANG); + if (rc == 0) + continue; // no, it didn't exit yet, continue waiting + + // set exit code to -1 if something bad happened + proc_data->exitcode = rc != -1 && WIFEXITED(status) ? + WEXITSTATUS(status) : -1; + + // child exited, end waiting + close(it->first); + + // don't call us again! + gs_procmap->erase(it->first); + + wxHandleProcessTermination(proc_data); + + // Iterator is invalid. Handle any further children in subsequent + // calls. + break; + } } // ---------------------------------------------------------------------------- @@ -107,17 +153,22 @@ void wxBell() } #endif -wxToolkitInfo& wxGUIAppTraits::GetToolkitInfo() +wxPortId wxGUIAppTraits::GetToolkitVersion(int *verMaj, int *verMin) const { - static wxToolkitInfo info; - info.shortName = _T("x11univ"); - info.name = _T("wxX11"); - info.versionMajor = 0; - info.versionMinor = 0; - info.os = wxX11; - return info; + // get X protocol version + Display *display = wxGlobalDisplay(); + if (display) + { + if ( verMaj ) + *verMaj = ProtocolVersion (display); + if ( verMin ) + *verMin = ProtocolRevision (display); + } + + return wxPORT_X11; } + // ---------------------------------------------------------------------------- // display info // ---------------------------------------------------------------------------- @@ -142,7 +193,7 @@ void wxGetMousePosition( int* x, int* y ) #endif }; -// Return TRUE if we have a colour display +// Return true if we have a colour display bool wxColourDisplay() { return wxDisplayDepth() > 1; @@ -220,7 +271,7 @@ bool wxSetDisplay(const wxString& display_name) return true; } else - return FALSE; + return false; } }