]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/utilsgtk.cpp
Attempt to add primary selection support, but doesn't work.
[wxWidgets.git] / src / gtk1 / 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 <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 HAVE_X11_XKBLIB_H
40 #ifdef __HPUX__
41 /* under HP-UX XKBlib.h defines structures with field named "explicit" -
42 * which is, of course, an error for a C++ compiler */
43 #define explicit __wx_explicit
44 #endif
45
46 #include "X11/XKBlib.h"
47
48 #ifdef __HPUX__
49 #undef explicit
50 #endif // __HPUX__
51#endif // HAVE_X11_XKBLIB_H
52
53// ----------------------------------------------------------------------------
54// misc.
55// ----------------------------------------------------------------------------
56
57void wxBell()
58{
59 gdk_beep();
60}
61
62/* Don't synthesize KeyUp events holding down a key and producing
63 KeyDown events with autorepeat. */
64#ifdef HAVE_X11_XKBLIB_H
65bool wxSetDetectableAutoRepeat( bool flag )
66{
67 Bool result;
68 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result );
69 return result; /* TRUE if keyboard hardware supports this mode */
70}
71#else
72bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
73{
74 return FALSE;
75}
76#endif
77
78// ----------------------------------------------------------------------------
79// display characterstics
80// ----------------------------------------------------------------------------
81
82void wxDisplaySize( int *width, int *height )
83{
84 if (width) *width = gdk_screen_width();
85 if (height) *height = gdk_screen_height();
86}
87
88void wxGetMousePosition( int* x, int* y )
89{
90 gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
91}
92
93bool wxColourDisplay()
94{
95 return TRUE;
96}
97
98int wxDisplayDepth()
99{
100 return gdk_window_get_visual( (GdkWindow*) &gdk_root_parent )->depth;
101}
102
103int wxGetOsVersion(int *majorVsn, int *minorVsn)
104{
105 if (majorVsn) *majorVsn = GTK_MAJOR_VERSION;
106 if (minorVsn) *minorVsn = GTK_MINOR_VERSION;
107
108 return wxGTK;
109}
110
111// ----------------------------------------------------------------------------
112// subprocess routines
113// ----------------------------------------------------------------------------
114
115static void GTK_EndProcessDetector(gpointer data, gint source,
116 GdkInputCondition WXUNUSED(condition) )
117{
118 wxEndProcessData *proc_data = (wxEndProcessData *)data;
119
120 wxHandleProcessTermination(proc_data);
121
122 close(source);
123 gdk_input_remove(proc_data->tag);
124}
125
126int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
127{
128 int tag = gdk_input_add(fd,
129 GDK_INPUT_READ,
130 GTK_EndProcessDetector,
131 (gpointer)proc_data);
132
133 return tag;
134}
135