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