jpayne@69
|
1 /*
|
jpayne@69
|
2 * tkMacOSXPort.h --
|
jpayne@69
|
3 *
|
jpayne@69
|
4 * This file is included by all of the Tk C files. It contains
|
jpayne@69
|
5 * information that may be configuration-dependent, such as
|
jpayne@69
|
6 * #includes for system include files and a few other things.
|
jpayne@69
|
7 *
|
jpayne@69
|
8 * Copyright (c) 1994-1996 Sun Microsystems, Inc.
|
jpayne@69
|
9 * Copyright 2001-2009, Apple Inc.
|
jpayne@69
|
10 * Copyright (c) 2005-2009 Daniel A. Steffen <das@users.sourceforge.net>
|
jpayne@69
|
11 *
|
jpayne@69
|
12 * See the file "license.terms" for information on usage and redistribution
|
jpayne@69
|
13 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
jpayne@69
|
14 */
|
jpayne@69
|
15
|
jpayne@69
|
16 #ifndef _TKMACPORT
|
jpayne@69
|
17 #define _TKMACPORT
|
jpayne@69
|
18
|
jpayne@69
|
19 #include <stdio.h>
|
jpayne@69
|
20 #include <pwd.h>
|
jpayne@69
|
21 #include <assert.h>
|
jpayne@69
|
22 #include <errno.h>
|
jpayne@69
|
23 #include <fcntl.h>
|
jpayne@69
|
24 #include <ctype.h>
|
jpayne@69
|
25 #include <math.h>
|
jpayne@69
|
26 #include <string.h>
|
jpayne@69
|
27 #include <limits.h>
|
jpayne@69
|
28 #include <stdlib.h>
|
jpayne@69
|
29 #include <sys/types.h>
|
jpayne@69
|
30 #include <sys/file.h>
|
jpayne@69
|
31 #ifdef HAVE_SYS_SELECT_H
|
jpayne@69
|
32 # include <sys/select.h>
|
jpayne@69
|
33 #endif
|
jpayne@69
|
34 #include <sys/stat.h>
|
jpayne@69
|
35 #ifndef _TCL
|
jpayne@69
|
36 # include <tcl.h>
|
jpayne@69
|
37 #endif
|
jpayne@69
|
38 #ifdef HAVE_SYS_TIME_H
|
jpayne@69
|
39 # include <sys/time.h>
|
jpayne@69
|
40 #endif
|
jpayne@69
|
41 #include <time.h>
|
jpayne@69
|
42 #ifdef HAVE_INTTYPES_H
|
jpayne@69
|
43 # include <inttypes.h>
|
jpayne@69
|
44 #endif
|
jpayne@69
|
45 #include <unistd.h>
|
jpayne@69
|
46 #if defined(__GNUC__) && !defined(__cplusplus)
|
jpayne@69
|
47 # pragma GCC diagnostic ignored "-Wc++-compat"
|
jpayne@69
|
48 #endif
|
jpayne@69
|
49 #include <X11/Xlib.h>
|
jpayne@69
|
50 #include <X11/cursorfont.h>
|
jpayne@69
|
51 #include <X11/keysym.h>
|
jpayne@69
|
52 #include <X11/Xatom.h>
|
jpayne@69
|
53 #include <X11/Xfuncproto.h>
|
jpayne@69
|
54 #include <X11/Xutil.h>
|
jpayne@69
|
55
|
jpayne@69
|
56 /*
|
jpayne@69
|
57 * The following macro defines the type of the mask arguments to
|
jpayne@69
|
58 * select:
|
jpayne@69
|
59 */
|
jpayne@69
|
60
|
jpayne@69
|
61 #ifndef NO_FD_SET
|
jpayne@69
|
62 # define SELECT_MASK fd_set
|
jpayne@69
|
63 #else
|
jpayne@69
|
64 # ifndef _AIX
|
jpayne@69
|
65 typedef long fd_mask;
|
jpayne@69
|
66 # endif
|
jpayne@69
|
67 # if defined(_IBMR2)
|
jpayne@69
|
68 # define SELECT_MASK void
|
jpayne@69
|
69 # else
|
jpayne@69
|
70 # define SELECT_MASK int
|
jpayne@69
|
71 # endif
|
jpayne@69
|
72 #endif
|
jpayne@69
|
73
|
jpayne@69
|
74 /*
|
jpayne@69
|
75 * Used to tag functions that are only to be visible within the module being
|
jpayne@69
|
76 * built and not outside it (where this is supported by the linker).
|
jpayne@69
|
77 */
|
jpayne@69
|
78
|
jpayne@69
|
79 #ifndef MODULE_SCOPE
|
jpayne@69
|
80 # ifdef __cplusplus
|
jpayne@69
|
81 # define MODULE_SCOPE extern "C"
|
jpayne@69
|
82 # else
|
jpayne@69
|
83 # define MODULE_SCOPE extern
|
jpayne@69
|
84 # endif
|
jpayne@69
|
85 #endif
|
jpayne@69
|
86
|
jpayne@69
|
87 /*
|
jpayne@69
|
88 * The following macro defines the number of fd_masks in an fd_set:
|
jpayne@69
|
89 */
|
jpayne@69
|
90
|
jpayne@69
|
91 #ifndef FD_SETSIZE
|
jpayne@69
|
92 # ifdef OPEN_MAX
|
jpayne@69
|
93 # define FD_SETSIZE OPEN_MAX
|
jpayne@69
|
94 # else
|
jpayne@69
|
95 # define FD_SETSIZE 256
|
jpayne@69
|
96 # endif
|
jpayne@69
|
97 #endif
|
jpayne@69
|
98 #if !defined(howmany)
|
jpayne@69
|
99 # define howmany(x, y) (((x)+((y)-1))/(y))
|
jpayne@69
|
100 #endif
|
jpayne@69
|
101 #ifndef NFDBITS
|
jpayne@69
|
102 # define NFDBITS NBBY*sizeof(fd_mask)
|
jpayne@69
|
103 #endif
|
jpayne@69
|
104 #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
|
jpayne@69
|
105
|
jpayne@69
|
106 /*
|
jpayne@69
|
107 * Define "NBBY" (number of bits per byte) if it's not already defined.
|
jpayne@69
|
108 */
|
jpayne@69
|
109
|
jpayne@69
|
110 #ifndef NBBY
|
jpayne@69
|
111 # define NBBY 8
|
jpayne@69
|
112 #endif
|
jpayne@69
|
113
|
jpayne@69
|
114 /*
|
jpayne@69
|
115 * The following define causes Tk to use its internal keysym hash table
|
jpayne@69
|
116 */
|
jpayne@69
|
117
|
jpayne@69
|
118 #define REDO_KEYSYM_LOOKUP
|
jpayne@69
|
119
|
jpayne@69
|
120 /*
|
jpayne@69
|
121 * Defines for X functions that are used by Tk but are treated as
|
jpayne@69
|
122 * no-op functions on the Macintosh.
|
jpayne@69
|
123 */
|
jpayne@69
|
124
|
jpayne@69
|
125 #undef XFlush
|
jpayne@69
|
126 #define XFlush(display) (0)
|
jpayne@69
|
127 #undef XFree
|
jpayne@69
|
128 #define XFree(data) (((data) != NULL) ? (ckfree(data),0) : 0)
|
jpayne@69
|
129 #undef XGrabServer
|
jpayne@69
|
130 #define XGrabServer(display) (0)
|
jpayne@69
|
131 #undef XNoOp
|
jpayne@69
|
132 #define XNoOp(display) (display->request++,0)
|
jpayne@69
|
133 #undef XUngrabServer
|
jpayne@69
|
134 #define XUngrabServer(display) (0)
|
jpayne@69
|
135 #undef XSynchronize
|
jpayne@69
|
136 #define XSynchronize(display, onoff) (display->request++,NULL)
|
jpayne@69
|
137 #undef XVisualIDFromVisual
|
jpayne@69
|
138 #define XVisualIDFromVisual(visual) (visual->visualid)
|
jpayne@69
|
139
|
jpayne@69
|
140 /*
|
jpayne@69
|
141 * The following functions are not used on the Mac, so we stub them out.
|
jpayne@69
|
142 */
|
jpayne@69
|
143
|
jpayne@69
|
144 #define TkpCmapStressed(tkwin,colormap) (0)
|
jpayne@69
|
145 #define TkpFreeColor(tkColPtr)
|
jpayne@69
|
146 #define TkSetPixmapColormap(p,c) {}
|
jpayne@69
|
147 #define TkpSync(display)
|
jpayne@69
|
148
|
jpayne@69
|
149 /*
|
jpayne@69
|
150 * TkMacOSXGetCapture is a legacy function used on the Mac. When fixing
|
jpayne@69
|
151 * [943d5ebe51], TkpGetCapture was added to the Windows port. Both
|
jpayne@69
|
152 * are actually the same feature and should bear the same name. However,
|
jpayne@69
|
153 * in order to avoid potential backwards incompatibilities, renaming
|
jpayne@69
|
154 * TkMacOSXGetCapture into TkpGetCapture in *PlatDecls.h shall not be
|
jpayne@69
|
155 * done in a patch release, therefore use a define here.
|
jpayne@69
|
156 */
|
jpayne@69
|
157
|
jpayne@69
|
158 #define TkpGetCapture TkMacOSXGetCapture
|
jpayne@69
|
159
|
jpayne@69
|
160 /*
|
jpayne@69
|
161 * This macro stores a representation of the window handle in a string.
|
jpayne@69
|
162 */
|
jpayne@69
|
163
|
jpayne@69
|
164 #define TkpPrintWindowId(buf,w) \
|
jpayne@69
|
165 sprintf((buf), "0x%lx", (unsigned long) (w))
|
jpayne@69
|
166
|
jpayne@69
|
167 /*
|
jpayne@69
|
168 * Turn off Tk double-buffering as Aqua windows are already double-buffered.
|
jpayne@69
|
169 */
|
jpayne@69
|
170
|
jpayne@69
|
171 #define TK_NO_DOUBLE_BUFFERING 1
|
jpayne@69
|
172 #define TK_HAS_DYNAMIC_COLORS 1
|
jpayne@69
|
173 #define TK_DYNAMIC_COLORMAP 0x0fffffff
|
jpayne@69
|
174
|
jpayne@69
|
175 /*
|
jpayne@69
|
176 * Inform tkImgPhInstance.c that we implement TkpPutRGBAImage to render RGBA
|
jpayne@69
|
177 * images directly into a window.
|
jpayne@69
|
178 */
|
jpayne@69
|
179
|
jpayne@69
|
180 #define TK_CAN_RENDER_RGBA
|
jpayne@69
|
181
|
jpayne@69
|
182 MODULE_SCOPE int TkpPutRGBAImage(
|
jpayne@69
|
183 Display* display, Drawable drawable, GC gc,XImage* image,
|
jpayne@69
|
184 int src_x, int src_y, int dest_x, int dest_y,
|
jpayne@69
|
185 unsigned int width, unsigned int height);
|
jpayne@69
|
186
|
jpayne@69
|
187 /*
|
jpayne@69
|
188 * Used by xcolor.c
|
jpayne@69
|
189 */
|
jpayne@69
|
190
|
jpayne@69
|
191 MODULE_SCOPE unsigned long TkMacOSXRGBPixel(unsigned long red, unsigned long green,
|
jpayne@69
|
192 unsigned long blue);
|
jpayne@69
|
193 #define TkpGetPixel(p) (TkMacOSXRGBPixel(p->red >> 8, p->green >> 8, p->blue >> 8))
|
jpayne@69
|
194
|
jpayne@69
|
195 /*
|
jpayne@69
|
196 * Used by tkAppInit
|
jpayne@69
|
197 */
|
jpayne@69
|
198
|
jpayne@69
|
199 #define USE_CUSTOM_EXIT_PROC
|
jpayne@69
|
200 EXTERN int TkpWantsExitProc(void);
|
jpayne@69
|
201 EXTERN TCL_NORETURN void TkpExitProc(void *);
|
jpayne@69
|
202
|
jpayne@69
|
203 #endif /* _TKMACPORT */
|