X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/904a68b6f648fc7802b41a8d176c78394252a4b7..5c235ea098366cc737f5bc5ea6c67b4fa33981ee:/src/gtk1/utilsgtk.cpp diff --git a/src/gtk1/utilsgtk.cpp b/src/gtk1/utilsgtk.cpp index 6d27531b26..1bc1106f93 100644 --- a/src/gtk1/utilsgtk.cpp +++ b/src/gtk1/utilsgtk.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: utils.cpp +// Name: src/gtk/utilsgtk.cpp // Purpose: // Author: Robert Roebling // Id: $Id$ @@ -21,6 +21,7 @@ #include #include #include +#include // for WNOHANG #include #include "glib.h" @@ -36,9 +37,9 @@ * field named "explicit" - which is, of course, an error for a C++ * compiler. To be on the safe side, just redefine it everywhere. */ #define explicit __wx_explicit - + #include "X11/XKBlib.h" - + #undef explicit #endif // HAVE_X11_XKBLIB_H @@ -46,7 +47,7 @@ // data //----------------------------------------------------------------------------- -extern GtkWidget *wxRootWindow; +extern GtkWidget *wxGetRootWindow(); //---------------------------------------------------------------------------- // misc. @@ -94,6 +95,17 @@ void wxDisplaySizeMM( int *width, int *height ) if (height) *height = gdk_screen_height_mm(); } +void wxClientDisplayRect(int *x, int *y, int *width, int *height) +{ + // This is supposed to return desktop dimensions minus any window + // manager panels, menus, taskbars, etc. If there is a way to do that + // for this platform please fix this function, otherwise it defaults + // to the entire desktop. + if (x) *x = 0; + if (y) *y = 0; + wxDisplaySize(width, height); +} + void wxGetMousePosition( int* x, int* y ) { gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL ); @@ -106,7 +118,7 @@ bool wxColourDisplay() int wxDisplayDepth() { - return gdk_window_get_visual( wxRootWindow->window )->depth; + return gdk_window_get_visual( wxGetRootWindow()->window )->depth; } int wxGetOsVersion(int *majorVsn, int *minorVsn) @@ -127,16 +139,35 @@ wxWindow* wxFindWindowAtPoint(const wxPoint& pt) // subprocess routines // ---------------------------------------------------------------------------- -static void GTK_EndProcessDetector(gpointer data, gint source, - GdkInputCondition WXUNUSED(condition) ) +extern "C" +void GTK_EndProcessDetector(gpointer data, gint source, + GdkInputCondition WXUNUSED(condition) ) { wxEndProcessData *proc_data = (wxEndProcessData *)data; + + // has the process really terminated? unfortunately GDK (or GLib) seem to + // generate G_IO_HUP notification even when it simply tries to read from a + // closed fd and hasn't terminated at all + int pid = (proc_data->pid > 0) ? proc_data->pid : -(proc_data->pid); + int status = 0; + int rc = waitpid(pid, &status, WNOHANG); + + if ( rc == 0 ) + { + // no, it didn't exit yet, continue waiting + return; + } + + // set exit code to -1 if something bad happened + proc_data->exitcode = rc != -1 && WIFEXITED(status) ? WEXITSTATUS(status) + : -1; + + // child exited, end waiting close(source); + + // don't call us again! gdk_input_remove(proc_data->tag); - // This has to come after gdk_input_remove() or we will - // occasionally receive multiple callbacks with corrupt data - // pointers. (KB) wxHandleProcessTermination(proc_data); }