]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/gtk1/utilsgtk.cpp
fixed bug in mouse handling
[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 <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#ifndef __WXGTK20__
30#include "gtk/gtkfeatures.h"
31#endif
32#include "gdk/gdkx.h"
33
34#ifdef HAVE_X11_XKBLIB_H
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. */
38 #define explicit __wx_explicit
39
40 #include "X11/XKBlib.h"
41
42 #undef explicit
43#endif // HAVE_X11_XKBLIB_H
44
45//-----------------------------------------------------------------------------
46// data
47//-----------------------------------------------------------------------------
48
49extern GtkWidget *wxRootWindow;
50
51//----------------------------------------------------------------------------
52// misc.
53//----------------------------------------------------------------------------
54
55void wxBell()
56{
57 gdk_beep();
58}
59
60/* Don't synthesize KeyUp events holding down a key and producing
61 KeyDown events with autorepeat. */
62#ifdef HAVE_X11_XKBLIB_H
63bool wxSetDetectableAutoRepeat( bool flag )
64{
65 Bool result;
66 XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result );
67 return result; /* TRUE if keyboard hardware supports this mode */
68}
69#else
70bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) )
71{
72 return FALSE;
73}
74#endif
75
76// ----------------------------------------------------------------------------
77// display characterstics
78// ----------------------------------------------------------------------------
79
80void *wxGetDisplay()
81{
82 return GDK_DISPLAY();
83}
84
85void wxDisplaySize( int *width, int *height )
86{
87 if (width) *width = gdk_screen_width();
88 if (height) *height = gdk_screen_height();
89}
90
91void wxGetMousePosition( int* x, int* y )
92{
93 gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL );
94}
95
96bool wxColourDisplay()
97{
98 return TRUE;
99}
100
101int wxDisplayDepth()
102{
103 return gdk_window_get_visual( wxRootWindow->window )->depth;
104}
105
106int wxGetOsVersion(int *majorVsn, int *minorVsn)
107{
108 if (majorVsn) *majorVsn = GTK_MAJOR_VERSION;
109 if (minorVsn) *minorVsn = GTK_MINOR_VERSION;
110
111 return wxGTK;
112}
113
114wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
115{
116 return wxGenericFindWindowAtPoint(pt);
117}
118
119
120// ----------------------------------------------------------------------------
121// subprocess routines
122// ----------------------------------------------------------------------------
123
124static void GTK_EndProcessDetector(gpointer data, gint source,
125 GdkInputCondition WXUNUSED(condition) )
126{
127 wxEndProcessData *proc_data = (wxEndProcessData *)data;
128 close(source);
129 gdk_input_remove(proc_data->tag);
130
131 // This has to come after gdk_input_remove() or we will
132 // occasionally receive multiple callbacks with corrupt data
133 // pointers. (KB)
134 wxHandleProcessTermination(proc_data);
135}
136
137int wxAddProcessCallback(wxEndProcessData *proc_data, int fd)
138{
139 int tag = gdk_input_add(fd,
140 GDK_INPUT_READ,
141 GTK_EndProcessDetector,
142 (gpointer)proc_data);
143
144 return tag;
145}
146