]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/utilsgtk.cpp
some more (apparently harmless) changes from Klass Holwerda
[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 20#include <stdarg.h>
c801d85f
KB
21#include <string.h>
22#include <sys/stat.h>
23#include <sys/types.h>
24#include <unistd.h>
91b8de8d
RR
25
26#include "glib.h"
27#include "gdk/gdk.h"
28#include "gtk/gtk.h"
29#include "gtk/gtkfeatures.h"
30#include "gdk/gdkx.h"
88ac883a 31
27933891 32#ifdef HAVE_X11_XKBLIB_H
154c4aa1
VZ
33 /* under HP-UX and Solaris 2.6, at least, XKBlib.h defines structures with
34 * field named "explicit" - which is, of course, an error for a C++
35 * compiler. To be on the safe side, just redefine it everywhere. */
88ac883a 36 #define explicit __wx_explicit
27933891 37
154c4aa1 38 #include "X11/XKBlib.h"
27933891 39
88ac883a 40 #undef explicit
27933891 41#endif // HAVE_X11_XKBLIB_H
dfcb1ae0 42
d76fe38b
RR
43//-----------------------------------------------------------------------------
44// data
45//-----------------------------------------------------------------------------
46
47extern GtkWidget *wxRootWindow;
48
49//----------------------------------------------------------------------------
c801d85f 50// misc.
d76fe38b 51//----------------------------------------------------------------------------
c801d85f 52
518b5d2f 53void wxBell()
c801d85f 54{
e52f60e6
RR
55 gdk_beep();
56}
c801d85f 57
27933891
RR
58/* Don't synthesize KeyUp events holding down a key and producing
59 KeyDown events with autorepeat. */
60#ifdef HAVE_X11_XKBLIB_H
f0492f7d
RR
61bool wxSetDetectableAutoRepeat( bool flag )
62{
63 Bool result;
64 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result );
27933891
RR
65 return result; /* TRUE if keyboard hardware supports this mode */
66}
67#else
68bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
69{
70 return FALSE;
f0492f7d 71}
27933891 72#endif
f0492f7d 73
518b5d2f
VZ
74// ----------------------------------------------------------------------------
75// display characterstics
76// ----------------------------------------------------------------------------
82052aff 77
d111a89a
VZ
78void *wxGetDisplay()
79{
27df579a 80 return GDK_DISPLAY();
d111a89a
VZ
81}
82
c0392997
RR
83void wxDisplaySize( int *width, int *height )
84{
e52f60e6
RR
85 if (width) *width = gdk_screen_width();
86 if (height) *height = gdk_screen_height();
c0392997
RR
87}
88
6de97a3b
RR
89void wxGetMousePosition( int* x, int* y )
90{
bbe0af5b 91 gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
e52f60e6 92}
6de97a3b 93
518b5d2f 94bool wxColourDisplay()
6de97a3b 95{
e52f60e6 96 return TRUE;
6de97a3b
RR
97}
98
518b5d2f 99int wxDisplayDepth()
6de97a3b 100{
d76fe38b 101 return gdk_window_get_visual( wxRootWindow->window )->depth;
6de97a3b
RR
102}
103
bbe0af5b
RR
104int wxGetOsVersion(int *majorVsn, int *minorVsn)
105{
106 if (majorVsn) *majorVsn = GTK_MAJOR_VERSION;
107 if (minorVsn) *minorVsn = GTK_MINOR_VERSION;
7e84f02d 108
bbe0af5b
RR
109 return wxGTK;
110}
111
518b5d2f 112// ----------------------------------------------------------------------------
c801d85f 113// subprocess routines
518b5d2f 114// ----------------------------------------------------------------------------
cf447356
GL
115
116static void GTK_EndProcessDetector(gpointer data, gint source,
e3e65dac 117 GdkInputCondition WXUNUSED(condition) )
cf447356 118{
ab857a4e
KB
119 wxEndProcessData *proc_data = (wxEndProcessData *)data;
120 close(source);
121 gdk_input_remove(proc_data->tag);
122
123 // This has to come after gdk_input_remove() or we will
124 // occasionally receive multiple callbacks with corrupt data
125 // pointers. (KB)
126 wxHandleProcessTermination(proc_data);
3069ac4e 127}
cf447356 128
518b5d2f 129int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
c801d85f 130{
518b5d2f
VZ
131 int tag = gdk_input_add(fd,
132 GDK_INPUT_READ,
133 GTK_EndProcessDetector,
134 (gpointer)proc_data);
c801d85f 135
518b5d2f 136 return tag;
3069ac4e 137}
c801d85f 138