X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/71317c5b3086a27e6f3b041e8ec02a1c5ad2ab32..e487524e492809638b7e335937c41fd432458a54:/src/gtk1/utilsgtk.cpp diff --git a/src/gtk1/utilsgtk.cpp b/src/gtk1/utilsgtk.cpp index 07ca4f5658..20ad8bc2a2 100644 --- a/src/gtk1/utilsgtk.cpp +++ b/src/gtk1/utilsgtk.cpp @@ -30,6 +30,11 @@ #include #include +#include +#include +#include + +#include "gdk/gdkx.h" // GDK_DISPLAY #ifdef __SVR4__ #include @@ -37,7 +42,11 @@ #ifdef __SOLARIS__ // somehow missing from sys/wait.h but in the system's docs -pid_t wait4(pid_t pid, int *statusp, int options, struct rusage *rusage); +extern "C" +{ + pid_t wait4(pid_t pid, int *statusp, int options, struct rusage + *rusage); +} #endif //------------------------------------------------------------------------ @@ -46,42 +55,45 @@ pid_t wait4(pid_t pid, int *statusp, int options, struct rusage *rusage); void wxBell(void) { - gdk_beep(); -}; + gdk_beep(); +} void wxSleep(int nSecs) { - sleep(nSecs); -}; + sleep(nSecs); +} int wxKill(long pid, int sig) { - return kill(pid, sig); -}; + return kill(pid, sig); +} void wxDisplaySize( int *width, int *height ) { - if (width) *width = gdk_screen_width(); - if (height) *height = gdk_screen_height(); + if (width) *width = gdk_screen_width(); + if (height) *height = gdk_screen_height(); } void wxGetMousePosition( int* x, int* y ) { - wxFAIL_MSG( "GetMousePosition not yet implemented" ); - if (x) *x = 0; - if (y) *y = 0; -}; + Window dumw; + int dumi; + unsigned int dumu; + + XQueryPointer( GDK_DISPLAY(),GDK_ROOT_WINDOW(), + &dumw,&dumw,x,y,&dumi,&dumi,&dumu ); +} bool wxColourDisplay(void) { - wxFAIL_MSG( "wxColourDisplay always returns TRUE" ); - return TRUE; + wxFAIL_MSG( "wxColourDisplay always returns TRUE" ); + return TRUE; } int wxDisplayDepth(void) { - wxFAIL_MSG( "wxDisplayDepth always returns 8" ); - return 8; + wxFAIL_MSG( "wxDisplayDepth always returns 8" ); + return 8; } //------------------------------------------------------------------------ @@ -90,34 +102,40 @@ int wxDisplayDepth(void) const char* wxGetHomeDir( wxString *home ) { - *home = wxGetUserHome( wxString() ); - if (home->IsNull()) *home = "/"; - return *home; -}; + *home = wxGetUserHome( wxString() ); + if (home->IsNull()) *home = "/"; + return *home; +} char *wxGetUserHome( const wxString &user ) { - struct passwd *who = (struct passwd *) NULL; + struct passwd *who = (struct passwd *) NULL; - if (user.IsNull() || (user== "")) - { + if (user.IsNull() || (user== "")) + { register char *ptr; if ((ptr = getenv("HOME")) != NULL) + { return ptr; - if ((ptr = getenv("USER")) != NULL - || (ptr = getenv("LOGNAME")) != NULL) { + } + if ((ptr = getenv("USER")) != NULL || (ptr = getenv("LOGNAME")) != NULL) + { who = getpwnam(ptr); } // We now make sure the the user exists! if (who == NULL) + { who = getpwuid(getuid()); - } - else - who = getpwnam (user); + } + } + else + { + who = getpwnam (user); + } - return who ? who->pw_dir : (char*)NULL; -}; + return who ? who->pw_dir : (char*)NULL; +} //------------------------------------------------------------------------ // id routines @@ -143,15 +161,15 @@ bool wxGetHostName(char *buf, int sz) // strncpy(buf, (h=gethostbyname(name))!=NULL ? h->h_name : name, sz-1); if((unsigned)sz > strlen(name)+strlen(domain)+1) { - strcpy(buf, name); - if(strcmp(domain,"(none)") == 0) // standalone machine - { - strcat(buf,"."); - strcat(buf,domain); - } + strcpy(buf, name); + if(strcmp(domain,"(none)") == 0) // standalone machine + { + strcat(buf,"."); + strcat(buf,domain); + } } else - return FALSE; + return FALSE; return TRUE; #endif } @@ -219,10 +237,10 @@ void wxFatalError( const wxString &msg, const wxString &title ) bool wxDirExists( const wxString& dir ) { - char buf[500]; - strcpy( buf, WXSTRINGCAST(dir) ); - struct stat sbuf; - return ((stat(buf, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE); + char buf[500]; + strcpy( buf, WXSTRINGCAST(dir) ); + struct stat sbuf; + return ((stat(buf, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE); }; //------------------------------------------------------------------------