]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk/utilsgtk.cpp
some != NULL checks
[wxWidgets.git] / src / gtk / utilsgtk.cpp
... / ...
CommitLineData
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 <string.h>
22#include <sys/stat.h>
23#include <sys/types.h>
24#include <unistd.h>
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"
31
32#ifdef HAVE_X11_XKBLIB_H
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. */
36 #define explicit __wx_explicit
37
38 #include "X11/XKBlib.h"
39
40 #undef explicit
41#endif // HAVE_X11_XKBLIB_H
42
43//-----------------------------------------------------------------------------
44// data
45//-----------------------------------------------------------------------------
46
47extern GtkWidget *wxRootWindow;
48
49//----------------------------------------------------------------------------
50// misc.
51//----------------------------------------------------------------------------
52
53void wxBell()
54{
55 gdk_beep();
56}
57
58/* Don't synthesize KeyUp events holding down a key and producing
59 KeyDown events with autorepeat. */
60#ifdef HAVE_X11_XKBLIB_H
61bool wxSetDetectableAutoRepeat( bool flag )
62{
63 Bool result;
64 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result );
65 return result; /* TRUE if keyboard hardware supports this mode */
66}
67#else
68bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
69{
70 return FALSE;
71}
72#endif
73
74// ----------------------------------------------------------------------------
75// display characterstics
76// ----------------------------------------------------------------------------
77
78void *wxGetDisplay()
79{
80 return gdk_display;
81}
82
83void wxDisplaySize( int *width, int *height )
84{
85 if (width) *width = gdk_screen_width();
86 if (height) *height = gdk_screen_height();
87}
88
89void wxGetMousePosition( int* x, int* y )
90{
91 gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
92}
93
94bool wxColourDisplay()
95{
96 return TRUE;
97}
98
99int wxDisplayDepth()
100{
101 return gdk_window_get_visual( wxRootWindow->window )->depth;
102}
103
104int wxGetOsVersion(int *majorVsn, int *minorVsn)
105{
106 if (majorVsn) *majorVsn = GTK_MAJOR_VERSION;
107 if (minorVsn) *minorVsn = GTK_MINOR_VERSION;
108
109 return wxGTK;
110}
111
112// ----------------------------------------------------------------------------
113// subprocess routines
114// ----------------------------------------------------------------------------
115
116static void GTK_EndProcessDetector(gpointer data, gint source,
117 GdkInputCondition WXUNUSED(condition) )
118{
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);
127}
128
129int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
130{
131 int tag = gdk_input_add(fd,
132 GDK_INPUT_READ,
133 GTK_EndProcessDetector,
134 (gpointer)proc_data);
135
136 return tag;
137}
138