]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/utilsgtk.cpp
added dependency handling to Makefiles
[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"
df530a26 29#ifndef __WXGTK20__
91b8de8d 30#include "gtk/gtkfeatures.h"
df530a26 31#endif
91b8de8d 32#include "gdk/gdkx.h"
88ac883a 33
27933891 34#ifdef HAVE_X11_XKBLIB_H
154c4aa1
VZ
35 /* under HP-UX and Solaris 2.6, at least, XKBlib.h defines structures with
36 * field named "explicit" - which is, of course, an error for a C++
37 * compiler. To be on the safe side, just redefine it everywhere. */
88ac883a 38 #define explicit __wx_explicit
ec5d7799 39
154c4aa1 40 #include "X11/XKBlib.h"
ec5d7799 41
88ac883a 42 #undef explicit
27933891 43#endif // HAVE_X11_XKBLIB_H
dfcb1ae0 44
d76fe38b
RR
45//-----------------------------------------------------------------------------
46// data
47//-----------------------------------------------------------------------------
48
c2fa61e8 49extern GtkWidget *wxGetRootWindow();
d76fe38b
RR
50
51//----------------------------------------------------------------------------
c801d85f 52// misc.
d76fe38b 53//----------------------------------------------------------------------------
c801d85f 54
518b5d2f 55void wxBell()
c801d85f 56{
e52f60e6
RR
57 gdk_beep();
58}
c801d85f 59
27933891
RR
60/* Don't synthesize KeyUp events holding down a key and producing
61 KeyDown events with autorepeat. */
62#ifdef HAVE_X11_XKBLIB_H
f0492f7d
RR
63bool wxSetDetectableAutoRepeat( bool flag )
64{
65 Bool result;
66 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result );
27933891
RR
67 return result; /* TRUE if keyboard hardware supports this mode */
68}
69#else
70bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
71{
72 return FALSE;
f0492f7d 73}
27933891 74#endif
f0492f7d 75
518b5d2f
VZ
76// ----------------------------------------------------------------------------
77// display characterstics
78// ----------------------------------------------------------------------------
82052aff 79
d111a89a
VZ
80void *wxGetDisplay()
81{
27df579a 82 return GDK_DISPLAY();
d111a89a
VZ
83}
84
c0392997
RR
85void wxDisplaySize( int *width, int *height )
86{
e52f60e6
RR
87 if (width) *width = gdk_screen_width();
88 if (height) *height = gdk_screen_height();
c0392997
RR
89}
90
904a68b6
RL
91void wxDisplaySizeMM( int *width, int *height )
92{
93 if (width) *width = gdk_screen_width_mm();
94 if (height) *height = gdk_screen_height_mm();
95}
96
ec5d7799
RD
97void wxClientDisplayRect(int *x, int *y, int *width, int *height)
98{
99 // This is supposed to return desktop dimensions minus any window
100 // manager panels, menus, taskbars, etc. If there is a way to do that
101 // for this platform please fix this function, otherwise it defaults
102 // to the entire desktop.
103 if (x) *x = 0;
104 if (y) *y = 0;
105 wxDisplaySize(width, height);
106}
107
6de97a3b
RR
108void wxGetMousePosition( int* x, int* y )
109{
bbe0af5b 110 gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
e52f60e6 111}
6de97a3b 112
518b5d2f 113bool wxColourDisplay()
6de97a3b 114{
e52f60e6 115 return TRUE;
6de97a3b
RR
116}
117
518b5d2f 118int wxDisplayDepth()
6de97a3b 119{
c2fa61e8 120 return gdk_window_get_visual( wxGetRootWindow()->window )->depth;
6de97a3b
RR
121}
122
bbe0af5b
RR
123int wxGetOsVersion(int *majorVsn, int *minorVsn)
124{
125 if (majorVsn) *majorVsn = GTK_MAJOR_VERSION;
126 if (minorVsn) *minorVsn = GTK_MINOR_VERSION;
7e84f02d 127
bbe0af5b
RR
128 return wxGTK;
129}
130
57591e0e
JS
131wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
132{
133 return wxGenericFindWindowAtPoint(pt);
134}
135
136
518b5d2f 137// ----------------------------------------------------------------------------
c801d85f 138// subprocess routines
518b5d2f 139// ----------------------------------------------------------------------------
cf447356
GL
140
141static void GTK_EndProcessDetector(gpointer data, gint source,
e3e65dac 142 GdkInputCondition WXUNUSED(condition) )
cf447356 143{
ab857a4e
KB
144 wxEndProcessData *proc_data = (wxEndProcessData *)data;
145 close(source);
146 gdk_input_remove(proc_data->tag);
147
148 // This has to come after gdk_input_remove() or we will
149 // occasionally receive multiple callbacks with corrupt data
ec5d7799 150 // pointers. (KB)
ab857a4e 151 wxHandleProcessTermination(proc_data);
3069ac4e 152}
cf447356 153
518b5d2f 154int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
c801d85f 155{
518b5d2f
VZ
156 int tag = gdk_input_add(fd,
157 GDK_INPUT_READ,
158 GTK_EndProcessDetector,
159 (gpointer)proc_data);
c801d85f 160
518b5d2f 161 return tag;
3069ac4e 162}
c801d85f 163