]>
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 /////////////////////////////////////////////////////////////////////////////
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 int wxGUIAppTraits::GetOSVersion(int *majorVsn
, int *minorVsn
)
128 *majorVsn
= GTK_MAJOR_VERSION
;
130 *minorVsn
= GTK_MINOR_VERSION
;
135 wxWindow
* wxFindWindowAtPoint(const wxPoint
& pt
)
137 return wxGenericFindWindowAtPoint(pt
);
141 // ----------------------------------------------------------------------------
142 // subprocess routines
143 // ----------------------------------------------------------------------------
146 void GTK_EndProcessDetector(gpointer data
, gint source
,
147 GdkInputCondition
WXUNUSED(condition
) )
149 wxEndProcessData
*proc_data
= (wxEndProcessData
*)data
;
151 // has the process really terminated? unfortunately GDK (or GLib) seem to
152 // generate G_IO_HUP notification even when it simply tries to read from a
153 // closed fd and hasn't terminated at all
154 int pid
= (proc_data
->pid
> 0) ? proc_data
->pid
: -(proc_data
->pid
);
156 int rc
= waitpid(pid
, &status
, WNOHANG
);
160 // no, it didn't exit yet, continue waiting
164 // set exit code to -1 if something bad happened
165 proc_data
->exitcode
= rc
!= -1 && WIFEXITED(status
) ? WEXITSTATUS(status
)
168 // child exited, end waiting
171 // don't call us again!
172 gdk_input_remove(proc_data
->tag
);
174 wxHandleProcessTermination(proc_data
);
177 int wxAddProcessCallback(wxEndProcessData
*proc_data
, int fd
)
179 int tag
= gdk_input_add(fd
,
181 GTK_EndProcessDetector
,
182 (gpointer
)proc_data
);