]>
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"
14 #include "wx/string.h"
16 #include "wx/apptrait.h"
20 #include "wx/process.h"
22 #include "wx/unix/execute.h"
27 #include <sys/types.h>
28 #include <sys/wait.h> // for WNOHANG
34 #include "gtk/gtkfeatures.h"
37 #ifdef HAVE_X11_XKBLIB_H
38 /* under HP-UX and Solaris 2.6, at least, XKBlib.h defines structures with
39 * field named "explicit" - which is, of course, an error for a C++
40 * compiler. To be on the safe side, just redefine it everywhere. */
41 #define explicit __wx_explicit
43 #include "X11/XKBlib.h"
46 #endif // HAVE_X11_XKBLIB_H
48 //-----------------------------------------------------------------------------
50 //-----------------------------------------------------------------------------
52 extern GtkWidget
*wxGetRootWindow();
54 //----------------------------------------------------------------------------
56 //----------------------------------------------------------------------------
58 // on OS/2, we use the wxBell from wxBase library
66 /* Don't synthesize KeyUp events holding down a key and producing
67 KeyDown events with autorepeat. */
68 #ifdef HAVE_X11_XKBLIB_H
69 bool wxSetDetectableAutoRepeat( bool flag
)
72 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag
, &result
);
73 return result
; /* TRUE if keyboard hardware supports this mode */
76 bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag
) )
82 // ----------------------------------------------------------------------------
83 // display characterstics
84 // ----------------------------------------------------------------------------
91 void wxDisplaySize( int *width
, int *height
)
93 if (width
) *width
= gdk_screen_width();
94 if (height
) *height
= gdk_screen_height();
97 void wxDisplaySizeMM( int *width
, int *height
)
99 if (width
) *width
= gdk_screen_width_mm();
100 if (height
) *height
= gdk_screen_height_mm();
103 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
105 // This is supposed to return desktop dimensions minus any window
106 // manager panels, menus, taskbars, etc. If there is a way to do that
107 // for this platform please fix this function, otherwise it defaults
108 // to the entire desktop.
111 wxDisplaySize(width
, height
);
114 void wxGetMousePosition( int* x
, int* y
)
116 gdk_window_get_pointer( (GdkWindow
*) NULL
, x
, y
, (GdkModifierType
*) NULL
);
119 bool wxColourDisplay()
126 return gdk_window_get_visual( wxGetRootWindow()->window
)->depth
;
129 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
131 static wxToolkitInfo info
;
132 info
.shortName
= _T("gtk");
133 info
.name
= _T("wxGTK");
134 #ifdef __WXUNIVERSAL__
135 info
.shortName
<< _T("univ");
136 info
.name
<< _T("/wxUniversal");
138 info
.versionMajor
= gtk_major_version
;
139 info
.versionMinor
= gtk_minor_version
;
144 wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
)
146 return wxGenericFindWindowAtPoint(pt
);
150 // ----------------------------------------------------------------------------
151 // subprocess routines
152 // ----------------------------------------------------------------------------
156 void GTK_EndProcessDetector(gpointer data
, gint source
,
157 GdkInputCondition
WXUNUSED(condition
) )
159 wxEndProcessData
*proc_data
= (wxEndProcessData
*)data
;
161 // has the process really terminated? unfortunately GDK (or GLib) seem to
162 // generate G_IO_HUP notification even when it simply tries to read from a
163 // closed fd and hasn't terminated at all
164 int pid
= (proc_data
->pid
> 0) ? proc_data
->pid
: -(proc_data
->pid
);
166 int rc
= waitpid(pid
, &status
, WNOHANG
);
170 // no, it didn't exit yet, continue waiting
174 // set exit code to -1 if something bad happened
175 proc_data
->exitcode
= rc
!= -1 && WIFEXITED(status
) ? WEXITSTATUS(status
)
178 // child exited, end waiting
181 // don't call us again!
182 gdk_input_remove(proc_data
->tag
);
184 wxHandleProcessTermination(proc_data
);
188 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
190 int tag
= gdk_input_add(fd
,
192 GTK_EndProcessDetector
,
193 (gpointer
)proc_data
);