]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/utilsgtk.cpp
   1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/gtk1/utilsgtk.cpp 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  10 // For compilers that support precompilation, includes "wx.h". 
  11 #include "wx/wxprec.h" 
  16     #include "wx/string.h" 
  21 #include "wx/apptrait.h" 
  23 #include "wx/process.h" 
  25 #include "wx/unix/execute.h" 
  30 #include <sys/types.h> 
  31 #include <sys/wait.h>   // for WNOHANG 
  37 #include "gtk/gtkfeatures.h" 
  40 #ifdef HAVE_X11_XKBLIB_H 
  41     /* under HP-UX and Solaris 2.6, at least, XKBlib.h defines structures with 
  42      * field named "explicit" - which is, of course, an error for a C++ 
  43      * compiler. To be on the safe side, just redefine it everywhere. */ 
  44     #define explicit __wx_explicit 
  46     #include "X11/XKBlib.h" 
  49 #endif // HAVE_X11_XKBLIB_H 
  51 //----------------------------------------------------------------------------- 
  53 //----------------------------------------------------------------------------- 
  55 extern GtkWidget 
*wxGetRootWindow(); 
  57 //---------------------------------------------------------------------------- 
  59 //---------------------------------------------------------------------------- 
  61 // on OS/2, we use the wxBell from wxBase library 
  69 /* Don't synthesize KeyUp events holding down a key and producing 
  70    KeyDown events with autorepeat. */ 
  71 #ifdef HAVE_X11_XKBLIB_H 
  72 bool wxSetDetectableAutoRepeat( bool flag 
) 
  75     XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag
, &result 
); 
  76     return result
;       /* true if keyboard hardware supports this mode */ 
  79 bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag
) ) 
  85 // ---------------------------------------------------------------------------- 
  86 // display characterstics 
  87 // ---------------------------------------------------------------------------- 
  94 void wxDisplaySize( int *width
, int *height 
) 
  96     if (width
) *width 
= gdk_screen_width(); 
  97     if (height
) *height 
= gdk_screen_height(); 
 100 void wxDisplaySizeMM( int *width
, int *height 
) 
 102     if (width
) *width 
= gdk_screen_width_mm(); 
 103     if (height
) *height 
= gdk_screen_height_mm(); 
 106 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
) 
 108     // This is supposed to return desktop dimensions minus any window 
 109     // manager panels, menus, taskbars, etc.  If there is a way to do that 
 110     // for this platform please fix this function, otherwise it defaults 
 111     // to the entire desktop. 
 114     wxDisplaySize(width
, height
); 
 117 void wxGetMousePosition( int* x
, int* y 
) 
 119     gdk_window_get_pointer( (GdkWindow
*) NULL
, x
, y
, (GdkModifierType
*) NULL 
); 
 122 bool wxColourDisplay() 
 129     return gdk_window_get_visual( wxGetRootWindow()->window 
)->depth
; 
 132 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo() 
 134     static wxToolkitInfo info
; 
 135     info
.shortName 
= _T("gtk"); 
 136     info
.name 
= _T("wxGTK"); 
 137 #ifdef __WXUNIVERSAL__ 
 138     info
.shortName 
<< _T("univ"); 
 139     info
.name 
<< _T("/wxUniversal"); 
 141     info
.versionMajor 
= gtk_major_version
; 
 142     info
.versionMinor 
= gtk_minor_version
; 
 147 wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
) 
 149     return wxGenericFindWindowAtPoint(pt
); 
 153 // ---------------------------------------------------------------------------- 
 154 // subprocess routines 
 155 // ---------------------------------------------------------------------------- 
 159 void GTK_EndProcessDetector(gpointer data
, gint source
, 
 160                             GdkInputCondition 
WXUNUSED(condition
) ) 
 162    wxEndProcessData 
*proc_data 
= (wxEndProcessData 
*)data
; 
 164    // has the process really terminated? unfortunately GDK (or GLib) seem to 
 165    // generate G_IO_HUP notification even when it simply tries to read from a 
 166    // closed fd and hasn't terminated at all 
 167    int pid 
= (proc_data
->pid 
> 0) ? proc_data
->pid 
: -(proc_data
->pid
); 
 169    int rc 
= waitpid(pid
, &status
, WNOHANG
); 
 173        // no, it didn't exit yet, continue waiting 
 177    // set exit code to -1 if something bad happened 
 178    proc_data
->exitcode 
= rc 
!= -1 && WIFEXITED(status
) ? WEXITSTATUS(status
) 
 181    // child exited, end waiting 
 184    // don't call us again! 
 185    gdk_input_remove(proc_data
->tag
); 
 187    wxHandleProcessTermination(proc_data
); 
 191 int wxAddProcessCallback(wxEndProcessData 
*proc_data
, int fd
) 
 193     int tag 
= gdk_input_add(fd
, 
 195                             GTK_EndProcessDetector
, 
 196                             (gpointer
)proc_data
);