]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/utilsgtk.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/utilsgtk.cpp
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #include "wx/string.h"
16 #include "wx/process.h"
18 #include "wx/unix/execute.h"
23 #include <sys/types.h>
24 #include <sys/wait.h> // for WNOHANG
31 #include "gtk/gtkfeatures.h"
35 #ifdef HAVE_X11_XKBLIB_H
36 /* under HP-UX and Solaris 2.6, at least, XKBlib.h defines structures with
37 * field named "explicit" - which is, of course, an error for a C++
38 * compiler. To be on the safe side, just redefine it everywhere. */
39 #define explicit __wx_explicit
41 #include "X11/XKBlib.h"
44 #endif // HAVE_X11_XKBLIB_H
46 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
50 extern GtkWidget
*wxGetRootWindow();
52 //----------------------------------------------------------------------------
54 //----------------------------------------------------------------------------
61 /* Don't synthesize KeyUp events holding down a key and producing
62 KeyDown events with autorepeat. */
63 #ifdef HAVE_X11_XKBLIB_H
64 bool wxSetDetectableAutoRepeat( bool flag
)
67 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag
, &result
);
68 return result
; /* TRUE if keyboard hardware supports this mode */
71 bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag
) )
77 // ----------------------------------------------------------------------------
78 // display characterstics
79 // ----------------------------------------------------------------------------
86 void wxDisplaySize( int *width
, int *height
)
88 if (width
) *width
= gdk_screen_width();
89 if (height
) *height
= gdk_screen_height();
92 void wxDisplaySizeMM( int *width
, int *height
)
94 if (width
) *width
= gdk_screen_width_mm();
95 if (height
) *height
= gdk_screen_height_mm();
98 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
100 // This is supposed to return desktop dimensions minus any window
101 // manager panels, menus, taskbars, etc. If there is a way to do that
102 // for this platform please fix this function, otherwise it defaults
103 // to the entire desktop.
106 wxDisplaySize(width
, height
);
109 void wxGetMousePosition( int* x
, int* y
)
111 gdk_window_get_pointer( (GdkWindow
*) NULL
, x
, y
, (GdkModifierType
*) NULL
);
114 bool wxColourDisplay()
121 return gdk_window_get_visual( wxGetRootWindow()->window
)->depth
;
124 int wxGetOsVersion(int *majorVsn
, int *minorVsn
)
126 if (majorVsn
) *majorVsn
= GTK_MAJOR_VERSION
;
127 if (minorVsn
) *minorVsn
= GTK_MINOR_VERSION
;
132 wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
)
134 return wxGenericFindWindowAtPoint(pt
);
138 // ----------------------------------------------------------------------------
139 // subprocess routines
140 // ----------------------------------------------------------------------------
143 void GTK_EndProcessDetector(gpointer data
, gint source
,
144 GdkInputCondition
WXUNUSED(condition
) )
146 wxEndProcessData
*proc_data
= (wxEndProcessData
*)data
;
148 // has the process really terminated? unfortunately GDK (or GLib) seem to
149 // generate G_IO_HUP notification even when it simply tries to read from a
150 // closed fd and hasn't terminated at all
151 int pid
= (proc_data
->pid
> 0) ? proc_data
->pid
: -(proc_data
->pid
);
153 int rc
= waitpid(pid
, &status
, WNOHANG
);
157 // no, it didn't exit yet, continue waiting
161 // set exit code to -1 if something bad happened
162 proc_data
->exitcode
= rc
!= -1 && WIFEXITED(status
) ? WEXITSTATUS(status
)
165 // child exited, end waiting
168 // don't call us again!
169 gdk_input_remove(proc_data
->tag
);
171 wxHandleProcessTermination(proc_data
);
174 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
176 int tag
= gdk_input_add(fd
,
178 GTK_EndProcessDetector
,
179 (gpointer
)proc_data
);