]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/utilsgtk.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/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
35 #include "gtk/gtkfeatures.h"
39 #ifdef HAVE_X11_XKBLIB_H
40 /* under HP-UX and Solaris 2.6, at least, XKBlib.h defines structures with
41 * field named "explicit" - which is, of course, an error for a C++
42 * compiler. To be on the safe side, just redefine it everywhere. */
43 #define explicit __wx_explicit
45 #include "X11/XKBlib.h"
48 #endif // HAVE_X11_XKBLIB_H
50 //-----------------------------------------------------------------------------
52 //-----------------------------------------------------------------------------
54 extern GtkWidget
*wxGetRootWindow();
56 //----------------------------------------------------------------------------
58 //----------------------------------------------------------------------------
60 // on OS/2, we use the wxBell from wxBase library
68 /* Don't synthesize KeyUp events holding down a key and producing
69 KeyDown events with autorepeat. */
70 #ifdef HAVE_X11_XKBLIB_H
71 bool wxSetDetectableAutoRepeat( bool flag
)
74 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag
, &result
);
75 return result
; /* TRUE if keyboard hardware supports this mode */
78 bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag
) )
84 // ----------------------------------------------------------------------------
85 // display characterstics
86 // ----------------------------------------------------------------------------
93 void wxDisplaySize( int *width
, int *height
)
95 if (width
) *width
= gdk_screen_width();
96 if (height
) *height
= gdk_screen_height();
99 void wxDisplaySizeMM( int *width
, int *height
)
101 if (width
) *width
= gdk_screen_width_mm();
102 if (height
) *height
= gdk_screen_height_mm();
105 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
107 // This is supposed to return desktop dimensions minus any window
108 // manager panels, menus, taskbars, etc. If there is a way to do that
109 // for this platform please fix this function, otherwise it defaults
110 // to the entire desktop.
113 wxDisplaySize(width
, height
);
116 void wxGetMousePosition( int* x
, int* y
)
118 gdk_window_get_pointer( (GdkWindow
*) NULL
, x
, y
, (GdkModifierType
*) NULL
);
121 bool wxColourDisplay()
128 return gdk_window_get_visual( wxGetRootWindow()->window
)->depth
;
131 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
133 static wxToolkitInfo info
;
135 info
.shortName
= _T("gtk2");
137 info
.shortName
= _T("gtk");
139 info
.name
= _T("wxGTK");
140 #ifdef __WXUNIVERSAL__
141 info
.shortName
<< _T("univ");
142 info
.name
<< _T("/wxUniversal");
144 info
.versionMajor
= gtk_major_version
;
145 info
.versionMinor
= gtk_minor_version
;
150 wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
)
152 return wxGenericFindWindowAtPoint(pt
);
156 // ----------------------------------------------------------------------------
157 // subprocess routines
158 // ----------------------------------------------------------------------------
161 void GTK_EndProcessDetector(gpointer data
, gint source
,
162 GdkInputCondition
WXUNUSED(condition
) )
164 wxEndProcessData
*proc_data
= (wxEndProcessData
*)data
;
166 // has the process really terminated? unfortunately GDK (or GLib) seem to
167 // generate G_IO_HUP notification even when it simply tries to read from a
168 // closed fd and hasn't terminated at all
169 int pid
= (proc_data
->pid
> 0) ? proc_data
->pid
: -(proc_data
->pid
);
171 int rc
= waitpid(pid
, &status
, WNOHANG
);
175 // no, it didn't exit yet, continue waiting
179 // set exit code to -1 if something bad happened
180 proc_data
->exitcode
= rc
!= -1 && WIFEXITED(status
) ? WEXITSTATUS(status
)
183 // child exited, end waiting
186 // don't call us again!
187 gdk_input_remove(proc_data
->tag
);
189 wxHandleProcessTermination(proc_data
);
192 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
194 int tag
= gdk_input_add(fd
,
196 GTK_EndProcessDetector
,
197 (gpointer
)proc_data
);