]>
Commit | Line | Data |
---|---|---|
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> | |
f0492f7d | 38 | #include "X11/XKBlib.h" |
dfcb1ae0 | 39 | |
518b5d2f | 40 | // ---------------------------------------------------------------------------- |
c801d85f | 41 | // misc. |
518b5d2f | 42 | // ---------------------------------------------------------------------------- |
c801d85f | 43 | |
518b5d2f | 44 | void wxBell() |
c801d85f | 45 | { |
e52f60e6 RR |
46 | gdk_beep(); |
47 | } | |
c801d85f | 48 | |
f0492f7d RR |
49 | // Synthesize KeyUp events holding down a key and producing |
50 | // KeyDown events with autorepeat. | |
51 | bool wxSetDetectableAutoRepeat( bool flag ) | |
52 | { | |
53 | Bool result; | |
54 | XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result ); | |
55 | return result; // true if keyboard hardware supports this mode | |
56 | } | |
57 | ||
518b5d2f VZ |
58 | // ---------------------------------------------------------------------------- |
59 | // display characterstics | |
60 | // ---------------------------------------------------------------------------- | |
82052aff | 61 | |
c0392997 RR |
62 | void wxDisplaySize( int *width, int *height ) |
63 | { | |
e52f60e6 RR |
64 | if (width) *width = gdk_screen_width(); |
65 | if (height) *height = gdk_screen_height(); | |
c0392997 RR |
66 | } |
67 | ||
6de97a3b RR |
68 | void wxGetMousePosition( int* x, int* y ) |
69 | { | |
bbe0af5b | 70 | gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL ); |
e52f60e6 | 71 | } |
6de97a3b | 72 | |
518b5d2f | 73 | bool wxColourDisplay() |
6de97a3b | 74 | { |
e52f60e6 | 75 | return TRUE; |
6de97a3b RR |
76 | } |
77 | ||
518b5d2f | 78 | int wxDisplayDepth() |
6de97a3b | 79 | { |
2d17d68f | 80 | return gdk_window_get_visual( (GdkWindow*) &gdk_root_parent )->depth; |
6de97a3b RR |
81 | } |
82 | ||
bbe0af5b RR |
83 | int wxGetOsVersion(int *majorVsn, int *minorVsn) |
84 | { | |
85 | if (majorVsn) *majorVsn = GTK_MAJOR_VERSION; | |
86 | if (minorVsn) *minorVsn = GTK_MINOR_VERSION; | |
7e84f02d | 87 | |
bbe0af5b RR |
88 | return wxGTK; |
89 | } | |
90 | ||
518b5d2f | 91 | // ---------------------------------------------------------------------------- |
c801d85f | 92 | // subprocess routines |
518b5d2f | 93 | // ---------------------------------------------------------------------------- |
cf447356 GL |
94 | |
95 | static void GTK_EndProcessDetector(gpointer data, gint source, | |
e3e65dac | 96 | GdkInputCondition WXUNUSED(condition) ) |
cf447356 | 97 | { |
bbe0af5b | 98 | wxEndProcessData *proc_data = (wxEndProcessData *)data; |
cf447356 | 99 | |
518b5d2f | 100 | wxHandleProcessTermination(proc_data); |
cf447356 | 101 | |
bbe0af5b RR |
102 | close(source); |
103 | gdk_input_remove(proc_data->tag); | |
3069ac4e | 104 | } |
cf447356 | 105 | |
518b5d2f | 106 | int wxAddProcessCallback(wxEndProcessData *proc_data, int fd) |
c801d85f | 107 | { |
518b5d2f VZ |
108 | int tag = gdk_input_add(fd, |
109 | GDK_INPUT_READ, | |
110 | GTK_EndProcessDetector, | |
111 | (gpointer)proc_data); | |
c801d85f | 112 | |
518b5d2f | 113 | return tag; |
3069ac4e | 114 | } |
c801d85f | 115 |