]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/utilsgtk.cpp
compilation fixes
[wxWidgets.git] / src / gtk / utilsgtk.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: utils.cpp
3// Purpose:
4// Author: Robert Roebling
dfcb1ae0 5// Id: $Id$
c801d85f 6// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
518b5d2f 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
c801d85f
KB
10#include "wx/utils.h"
11#include "wx/string.h"
12
02847e59
VZ
13#include "wx/intl.h"
14#include "wx/log.h"
15
5336ece4
VZ
16#include "wx/process.h"
17
518b5d2f
VZ
18#include "wx/unix/execute.h"
19
c801d85f
KB
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>
82052aff 30#include <signal.h>
4e13eb84 31#include <fcntl.h> // for O_WRONLY and friends
c801d85f 32
afb74891
VZ
33#include <glib.h>
34#include <gdk/gdk.h>
35#include <gtk/gtk.h>
36#include <gtk/gtkfeatures.h>
37#include <gdk/gdkx.h>
88ac883a
VZ
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__
dfcb1ae0 46
518b5d2f 47// ----------------------------------------------------------------------------
c801d85f 48// misc.
518b5d2f 49// ----------------------------------------------------------------------------
c801d85f 50
518b5d2f 51void wxBell()
c801d85f 52{
e52f60e6
RR
53 gdk_beep();
54}
c801d85f 55
f0492f7d
RR
56// Synthesize KeyUp events holding down a key and producing
57// KeyDown events with autorepeat.
58bool 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
518b5d2f
VZ
65// ----------------------------------------------------------------------------
66// display characterstics
67// ----------------------------------------------------------------------------
82052aff 68
c0392997
RR
69void wxDisplaySize( int *width, int *height )
70{
e52f60e6
RR
71 if (width) *width = gdk_screen_width();
72 if (height) *height = gdk_screen_height();
c0392997
RR
73}
74
6de97a3b
RR
75void wxGetMousePosition( int* x, int* y )
76{
bbe0af5b 77 gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
e52f60e6 78}
6de97a3b 79
518b5d2f 80bool wxColourDisplay()
6de97a3b 81{
e52f60e6 82 return TRUE;
6de97a3b
RR
83}
84
518b5d2f 85int wxDisplayDepth()
6de97a3b 86{
2d17d68f 87 return gdk_window_get_visual( (GdkWindow*) &gdk_root_parent )->depth;
6de97a3b
RR
88}
89
bbe0af5b
RR
90int wxGetOsVersion(int *majorVsn, int *minorVsn)
91{
92 if (majorVsn) *majorVsn = GTK_MAJOR_VERSION;
93 if (minorVsn) *minorVsn = GTK_MINOR_VERSION;
7e84f02d 94
bbe0af5b
RR
95 return wxGTK;
96}
97
518b5d2f 98// ----------------------------------------------------------------------------
c801d85f 99// subprocess routines
518b5d2f 100// ----------------------------------------------------------------------------
cf447356
GL
101
102static void GTK_EndProcessDetector(gpointer data, gint source,
e3e65dac 103 GdkInputCondition WXUNUSED(condition) )
cf447356 104{
bbe0af5b 105 wxEndProcessData *proc_data = (wxEndProcessData *)data;
cf447356 106
518b5d2f 107 wxHandleProcessTermination(proc_data);
cf447356 108
bbe0af5b
RR
109 close(source);
110 gdk_input_remove(proc_data->tag);
3069ac4e 111}
cf447356 112
518b5d2f 113int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
c801d85f 114{
518b5d2f
VZ
115 int tag = gdk_input_add(fd,
116 GDK_INPUT_READ,
117 GTK_EndProcessDetector,
118 (gpointer)proc_data);
c801d85f 119
518b5d2f 120 return tag;
3069ac4e 121}
c801d85f 122