]>
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"
13 #include "wx/apptrait.h"
17 #include "wx/process.h"
19 #include "wx/unix/execute.h"
24 #include <sys/types.h>
25 #include <sys/wait.h> // for WNOHANG
32 #include "gtk/gtkfeatures.h"
36 #ifdef HAVE_X11_XKBLIB_H
37 /* under HP-UX and Solaris 2.6, at least, XKBlib.h defines structures with
38 * field named "explicit" - which is, of course, an error for a C++
39 * compiler. To be on the safe side, just redefine it everywhere. */
40 #define explicit __wx_explicit
42 #include "X11/XKBlib.h"
45 #endif // HAVE_X11_XKBLIB_H
47 //-----------------------------------------------------------------------------
49 //-----------------------------------------------------------------------------
51 extern GtkWidget
*wxGetRootWindow();
53 //----------------------------------------------------------------------------
55 //----------------------------------------------------------------------------
62 /* Don't synthesize KeyUp events holding down a key and producing
63 KeyDown events with autorepeat. */
64 #ifdef HAVE_X11_XKBLIB_H
65 bool wxSetDetectableAutoRepeat( bool flag
)
68 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag
, &result
);
69 return result
; /* TRUE if keyboard hardware supports this mode */
72 bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag
) )
78 // ----------------------------------------------------------------------------
79 // display characterstics
80 // ----------------------------------------------------------------------------
87 void wxDisplaySize( int *width
, int *height
)
89 if (width
) *width
= gdk_screen_width();
90 if (height
) *height
= gdk_screen_height();
93 void wxDisplaySizeMM( int *width
, int *height
)
95 if (width
) *width
= gdk_screen_width_mm();
96 if (height
) *height
= gdk_screen_height_mm();
99 void wxClientDisplayRect(int *x
, int *y
, int *width
, int *height
)
101 // This is supposed to return desktop dimensions minus any window
102 // manager panels, menus, taskbars, etc. If there is a way to do that
103 // for this platform please fix this function, otherwise it defaults
104 // to the entire desktop.
107 wxDisplaySize(width
, height
);
110 void wxGetMousePosition( int* x
, int* y
)
112 gdk_window_get_pointer( (GdkWindow
*) NULL
, x
, y
, (GdkModifierType
*) NULL
);
115 bool wxColourDisplay()
122 return gdk_window_get_visual( wxGetRootWindow()->window
)->depth
;
125 wxToolkitInfo
& wxGUIAppTraits::GetToolkitInfo()
127 static wxToolkitInfo info
;
129 info
.shortName
= _T("gtk2");
131 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 // ----------------------------------------------------------------------------
155 void GTK_EndProcessDetector(gpointer data
, gint source
,
156 GdkInputCondition
WXUNUSED(condition
) )
158 wxEndProcessData
*proc_data
= (wxEndProcessData
*)data
;
160 // has the process really terminated? unfortunately GDK (or GLib) seem to
161 // generate G_IO_HUP notification even when it simply tries to read from a
162 // closed fd and hasn't terminated at all
163 int pid
= (proc_data
->pid
> 0) ? proc_data
->pid
: -(proc_data
->pid
);
165 int rc
= waitpid(pid
, &status
, WNOHANG
);
169 // no, it didn't exit yet, continue waiting
173 // set exit code to -1 if something bad happened
174 proc_data
->exitcode
= rc
!= -1 && WIFEXITED(status
) ? WEXITSTATUS(status
)
177 // child exited, end waiting
180 // don't call us again!
181 gdk_input_remove(proc_data
->tag
);
183 wxHandleProcessTermination(proc_data
);
186 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
188 int tag
= gdk_input_add(fd
,
190 GTK_EndProcessDetector
,
191 (gpointer
)proc_data
);