]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/utilsgtk.cpp
c8837d8f2e7524477c0f69533fd023d6a361576b
[wxWidgets.git] / src / gtk / utilsgtk.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: utils.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #include "wx/utils.h"
11 #include "wx/string.h"
12
13 #include "wx/intl.h"
14 #include "wx/log.h"
15
16 #include "wx/process.h"
17
18 #include "wx/unix/execute.h"
19
20 #include <stdarg.h>
21 #include <dirent.h>
22 #include <string.h>
23 #include <sys/stat.h>
24 #include <sys/types.h>
25 #include <unistd.h>
26 #include <sys/wait.h>
27 #include <pwd.h>
28 #include <errno.h>
29 #include <netdb.h>
30 #include <signal.h>
31 #include <fcntl.h> // for O_WRONLY and friends
32
33 #include <glib.h>
34 #include <gdk/gdk.h>
35 #include <gtk/gtk.h>
36 #include <gtk/gtkfeatures.h>
37 #include <gdk/gdkx.h>
38
39 #ifdef __HPUX__
40 // under HP-UX XKBlib.h defines structures with field named "explicit" -
41 // which is, of course, an error for a C++ compiler
42 #define explicit __wx_explicit
43 #include "X11/XKBlib.h"
44 #undef explicit
45 #endif // __HPUX__
46
47 // ----------------------------------------------------------------------------
48 // misc.
49 // ----------------------------------------------------------------------------
50
51 void wxBell()
52 {
53 gdk_beep();
54 }
55
56 // Synthesize KeyUp events holding down a key and producing
57 // KeyDown events with autorepeat.
58 bool wxSetDetectableAutoRepeat( bool flag )
59 {
60 Bool result;
61 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result );
62 return result; // true if keyboard hardware supports this mode
63 }
64
65 // ----------------------------------------------------------------------------
66 // display characterstics
67 // ----------------------------------------------------------------------------
68
69 void wxDisplaySize( int *width, int *height )
70 {
71 if (width) *width = gdk_screen_width();
72 if (height) *height = gdk_screen_height();
73 }
74
75 void wxGetMousePosition( int* x, int* y )
76 {
77 gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
78 }
79
80 bool wxColourDisplay()
81 {
82 return TRUE;
83 }
84
85 int wxDisplayDepth()
86 {
87 return gdk_window_get_visual( (GdkWindow*) &gdk_root_parent )->depth;
88 }
89
90 int wxGetOsVersion(int *majorVsn, int *minorVsn)
91 {
92 if (majorVsn) *majorVsn = GTK_MAJOR_VERSION;
93 if (minorVsn) *minorVsn = GTK_MINOR_VERSION;
94
95 return wxGTK;
96 }
97
98 // ----------------------------------------------------------------------------
99 // subprocess routines
100 // ----------------------------------------------------------------------------
101
102 static void GTK_EndProcessDetector(gpointer data, gint source,
103 GdkInputCondition WXUNUSED(condition) )
104 {
105 wxEndProcessData *proc_data = (wxEndProcessData *)data;
106
107 wxHandleProcessTermination(proc_data);
108
109 close(source);
110 gdk_input_remove(proc_data->tag);
111 }
112
113 int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
114 {
115 int tag = gdk_input_add(fd,
116 GDK_INPUT_READ,
117 GTK_EndProcessDetector,
118 (gpointer)proc_data);
119
120 return tag;
121 }
122