Merge from emacs--rel--22
[bpt/emacs.git] / src / macfns.c
1 /* Graphical user interface functions for Mac OS.
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
3 2008 Free Software Foundation, Inc.
4
5 This file is part of GNU Emacs.
6
7 GNU Emacs is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 GNU Emacs is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* Contributed by Andrew Choi (akochoi@mac.com). */
21
22 #include <config.h>
23 #include <stdio.h>
24 #include <math.h>
25
26 #include "lisp.h"
27 #include "macterm.h"
28 #include "frame.h"
29 #include "window.h"
30 #include "buffer.h"
31 #include "intervals.h"
32 #include "dispextern.h"
33 #include "keyboard.h"
34 #include "blockinput.h"
35 #include <epaths.h>
36 #include "charset.h"
37 #include "coding.h"
38 #include "fontset.h"
39 #include "systime.h"
40 #include "termhooks.h"
41 #include "atimer.h"
42
43 #include <ctype.h>
44 #include <sys/types.h>
45 #include <sys/stat.h>
46 #include <limits.h>
47 #include <errno.h>
48 #include <sys/param.h>
49
50 extern void free_frame_menubar ();
51
52 #if TARGET_API_MAC_CARBON
53
54 /* Carbon version info */
55
56 static Lisp_Object Vmac_carbon_version_string;
57
58 #endif /* TARGET_API_MAC_CARBON */
59
60 /* The background and shape of the mouse pointer, and shape when not
61 over text or in the modeline. */
62
63 Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
64 Lisp_Object Vx_hourglass_pointer_shape;
65
66 /* The shape when over mouse-sensitive text. */
67
68 Lisp_Object Vx_sensitive_text_pointer_shape;
69
70 /* If non-nil, the pointer shape to indicate that windows can be
71 dragged horizontally. */
72
73 Lisp_Object Vx_window_horizontal_drag_shape;
74
75 /* Color of chars displayed in cursor box. */
76
77 Lisp_Object Vx_cursor_fore_pixel;
78
79 /* Nonzero if using Windows. */
80
81 static int mac_in_use;
82
83 /* Non nil if no window manager is in use. */
84
85 Lisp_Object Vx_no_window_manager;
86
87 /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. */
88
89 Lisp_Object Vx_pixel_size_width_font_regexp;
90
91 Lisp_Object Qnone;
92 Lisp_Object Qsuppress_icon;
93 Lisp_Object Qundefined_color;
94 Lisp_Object Qcancel_timer;
95
96 /* In dispnew.c */
97
98 extern Lisp_Object Vwindow_system_version;
99
100 #if GLYPH_DEBUG
101 int image_cache_refcount, dpyinfo_refcount;
102 #endif
103
104 #if 0 /* Use xstrcasecmp instead. */
105 /* compare two strings ignoring case */
106
107 static int
108 stricmp (const char *s, const char *t)
109 {
110 for ( ; tolower (*s) == tolower (*t); s++, t++)
111 if (*s == '\0')
112 return 0;
113 return tolower (*s) - tolower (*t);
114 }
115 #endif
116
117 /* compare two strings up to n characters, ignoring case */
118
119 static int
120 strnicmp (const char *s, const char *t, unsigned int n)
121 {
122 for ( ; n > 0 && tolower (*s) == tolower (*t); n--, s++, t++)
123 if (*s == '\0')
124 return 0;
125 return n == 0 ? 0 : tolower (*s) - tolower (*t);
126 }
127
128 \f
129 /* Error if we are not running on Mac OS. */
130
131 void
132 check_mac ()
133 {
134 if (! mac_in_use)
135 error ("Mac native windows not in use or not initialized");
136 }
137
138 /* Nonzero if we can use mouse menus.
139 You should not call this unless HAVE_MENUS is defined. */
140
141 int
142 have_menus_p ()
143 {
144 return mac_in_use;
145 }
146
147 /* Extract a frame as a FRAME_PTR, defaulting to the selected frame
148 and checking validity for Mac. */
149
150 FRAME_PTR
151 check_x_frame (frame)
152 Lisp_Object frame;
153 {
154 FRAME_PTR f;
155
156 if (NILP (frame))
157 frame = selected_frame;
158 CHECK_LIVE_FRAME (frame);
159 f = XFRAME (frame);
160 if (! FRAME_MAC_P (f))
161 error ("Non-Mac frame used");
162 return f;
163 }
164
165 /* Let the user specify a display with a frame.
166 nil stands for the selected frame--or, if that is not a mac frame,
167 the first display on the list. */
168
169 struct mac_display_info *
170 check_x_display_info (frame)
171 Lisp_Object frame;
172 {
173 struct mac_display_info *dpyinfo = NULL;
174
175 if (NILP (frame))
176 {
177 struct frame *sf = XFRAME (selected_frame);
178
179 if (FRAME_MAC_P (sf) && FRAME_LIVE_P (sf))
180 dpyinfo = FRAME_MAC_DISPLAY_INFO (sf);
181 else if (x_display_list != 0)
182 dpyinfo = x_display_list;
183 else
184 error ("Mac native windows are not in use or not initialized");
185 }
186 else if (STRINGP (frame))
187 dpyinfo = x_display_info_for_name (frame);
188 else
189 {
190 FRAME_PTR f = check_x_frame (frame);
191 dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
192 }
193
194 return dpyinfo;
195 }
196
197 \f
198
199 static Lisp_Object unwind_create_frame P_ ((Lisp_Object));
200 static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object));
201
202 void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
203 void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
204 void x_set_mouse_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
205 void x_set_cursor_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
206 void x_set_border_color P_ ((struct frame *, Lisp_Object, Lisp_Object));
207 void x_set_cursor_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
208 void x_set_icon_type P_ ((struct frame *, Lisp_Object, Lisp_Object));
209 void x_set_icon_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
210 void x_explicitly_set_name P_ ((struct frame *, Lisp_Object, Lisp_Object));
211 void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
212 void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object));
213 void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
214 \f
215
216 /* Store the screen positions of frame F into XPTR and YPTR.
217 These are the positions of the containing window manager window,
218 not Emacs's own window. */
219
220 void
221 x_real_positions (f, xptr, yptr)
222 FRAME_PTR f;
223 int *xptr, *yptr;
224 {
225 Rect inner, outer;
226
227 mac_get_window_bounds (f, &inner, &outer);
228
229 f->x_pixels_diff = inner.left - outer.left;
230 f->y_pixels_diff = inner.top - outer.top;
231
232 *xptr = outer.left;
233 *yptr = outer.top;
234 }
235
236 \f
237 /* The default colors for the Mac color map */
238 typedef struct colormap_t
239 {
240 unsigned long color;
241 char *name;
242 } colormap_t;
243
244 static const colormap_t mac_color_map[] =
245 {
246 { RGB_TO_ULONG(255, 250, 250), "snow" },
247 { RGB_TO_ULONG(248, 248, 255), "ghost white" },
248 { RGB_TO_ULONG(248, 248, 255), "GhostWhite" },
249 { RGB_TO_ULONG(245, 245, 245), "white smoke" },
250 { RGB_TO_ULONG(245, 245, 245), "WhiteSmoke" },
251 { RGB_TO_ULONG(220, 220, 220), "gainsboro" },
252 { RGB_TO_ULONG(255, 250, 240), "floral white" },
253 { RGB_TO_ULONG(255, 250, 240), "FloralWhite" },
254 { RGB_TO_ULONG(253, 245, 230), "old lace" },
255 { RGB_TO_ULONG(253, 245, 230), "OldLace" },
256 { RGB_TO_ULONG(250, 240, 230), "linen" },
257 { RGB_TO_ULONG(250, 235, 215), "antique white" },
258 { RGB_TO_ULONG(250, 235, 215), "AntiqueWhite" },
259 { RGB_TO_ULONG(255, 239, 213), "papaya whip" },
260 { RGB_TO_ULONG(255, 239, 213), "PapayaWhip" },
261 { RGB_TO_ULONG(255, 235, 205), "blanched almond" },
262 { RGB_TO_ULONG(255, 235, 205), "BlanchedAlmond" },
263 { RGB_TO_ULONG(255, 228, 196), "bisque" },
264 { RGB_TO_ULONG(255, 218, 185), "peach puff" },
265 { RGB_TO_ULONG(255, 218, 185), "PeachPuff" },
266 { RGB_TO_ULONG(255, 222, 173), "navajo white" },
267 { RGB_TO_ULONG(255, 222, 173), "NavajoWhite" },
268 { RGB_TO_ULONG(255, 228, 181), "moccasin" },
269 { RGB_TO_ULONG(255, 248, 220), "cornsilk" },
270 { RGB_TO_ULONG(255, 255, 240), "ivory" },
271 { RGB_TO_ULONG(255, 250, 205), "lemon chiffon" },
272 { RGB_TO_ULONG(255, 250, 205), "LemonChiffon" },
273 { RGB_TO_ULONG(255, 245, 238), "seashell" },
274 { RGB_TO_ULONG(240, 255, 240), "honeydew" },
275 { RGB_TO_ULONG(245, 255, 250), "mint cream" },
276 { RGB_TO_ULONG(245, 255, 250), "MintCream" },
277 { RGB_TO_ULONG(240, 255, 255), "azure" },
278 { RGB_TO_ULONG(240, 248, 255), "alice blue" },
279 { RGB_TO_ULONG(240, 248, 255), "AliceBlue" },
280 { RGB_TO_ULONG(230, 230, 250), "lavender" },
281 { RGB_TO_ULONG(255, 240, 245), "lavender blush" },
282 { RGB_TO_ULONG(255, 240, 245), "LavenderBlush" },
283 { RGB_TO_ULONG(255, 228, 225), "misty rose" },
284 { RGB_TO_ULONG(255, 228, 225), "MistyRose" },
285 { RGB_TO_ULONG(255, 255, 255), "white" },
286 { RGB_TO_ULONG(0 , 0 , 0 ), "black" },
287 { RGB_TO_ULONG(47 , 79 , 79 ), "dark slate gray" },
288 { RGB_TO_ULONG(47 , 79 , 79 ), "DarkSlateGray" },
289 { RGB_TO_ULONG(47 , 79 , 79 ), "dark slate grey" },
290 { RGB_TO_ULONG(47 , 79 , 79 ), "DarkSlateGrey" },
291 { RGB_TO_ULONG(105, 105, 105), "dim gray" },
292 { RGB_TO_ULONG(105, 105, 105), "DimGray" },
293 { RGB_TO_ULONG(105, 105, 105), "dim grey" },
294 { RGB_TO_ULONG(105, 105, 105), "DimGrey" },
295 { RGB_TO_ULONG(112, 128, 144), "slate gray" },
296 { RGB_TO_ULONG(112, 128, 144), "SlateGray" },
297 { RGB_TO_ULONG(112, 128, 144), "slate grey" },
298 { RGB_TO_ULONG(112, 128, 144), "SlateGrey" },
299 { RGB_TO_ULONG(119, 136, 153), "light slate gray" },
300 { RGB_TO_ULONG(119, 136, 153), "LightSlateGray" },
301 { RGB_TO_ULONG(119, 136, 153), "light slate grey" },
302 { RGB_TO_ULONG(119, 136, 153), "LightSlateGrey" },
303 { RGB_TO_ULONG(190, 190, 190), "gray" },
304 { RGB_TO_ULONG(190, 190, 190), "grey" },
305 { RGB_TO_ULONG(211, 211, 211), "light grey" },
306 { RGB_TO_ULONG(211, 211, 211), "LightGrey" },
307 { RGB_TO_ULONG(211, 211, 211), "light gray" },
308 { RGB_TO_ULONG(211, 211, 211), "LightGray" },
309 { RGB_TO_ULONG(25 , 25 , 112), "midnight blue" },
310 { RGB_TO_ULONG(25 , 25 , 112), "MidnightBlue" },
311 { RGB_TO_ULONG(0 , 0 , 128), "navy" },
312 { RGB_TO_ULONG(0 , 0 , 128), "navy blue" },
313 { RGB_TO_ULONG(0 , 0 , 128), "NavyBlue" },
314 { RGB_TO_ULONG(100, 149, 237), "cornflower blue" },
315 { RGB_TO_ULONG(100, 149, 237), "CornflowerBlue" },
316 { RGB_TO_ULONG(72 , 61 , 139), "dark slate blue" },
317 { RGB_TO_ULONG(72 , 61 , 139), "DarkSlateBlue" },
318 { RGB_TO_ULONG(106, 90 , 205), "slate blue" },
319 { RGB_TO_ULONG(106, 90 , 205), "SlateBlue" },
320 { RGB_TO_ULONG(123, 104, 238), "medium slate blue" },
321 { RGB_TO_ULONG(123, 104, 238), "MediumSlateBlue" },
322 { RGB_TO_ULONG(132, 112, 255), "light slate blue" },
323 { RGB_TO_ULONG(132, 112, 255), "LightSlateBlue" },
324 { RGB_TO_ULONG(0 , 0 , 205), "medium blue" },
325 { RGB_TO_ULONG(0 , 0 , 205), "MediumBlue" },
326 { RGB_TO_ULONG(65 , 105, 225), "royal blue" },
327 { RGB_TO_ULONG(65 , 105, 225), "RoyalBlue" },
328 { RGB_TO_ULONG(0 , 0 , 255), "blue" },
329 { RGB_TO_ULONG(30 , 144, 255), "dodger blue" },
330 { RGB_TO_ULONG(30 , 144, 255), "DodgerBlue" },
331 { RGB_TO_ULONG(0 , 191, 255), "deep sky blue" },
332 { RGB_TO_ULONG(0 , 191, 255), "DeepSkyBlue" },
333 { RGB_TO_ULONG(135, 206, 235), "sky blue" },
334 { RGB_TO_ULONG(135, 206, 235), "SkyBlue" },
335 { RGB_TO_ULONG(135, 206, 250), "light sky blue" },
336 { RGB_TO_ULONG(135, 206, 250), "LightSkyBlue" },
337 { RGB_TO_ULONG(70 , 130, 180), "steel blue" },
338 { RGB_TO_ULONG(70 , 130, 180), "SteelBlue" },
339 { RGB_TO_ULONG(176, 196, 222), "light steel blue" },
340 { RGB_TO_ULONG(176, 196, 222), "LightSteelBlue" },
341 { RGB_TO_ULONG(173, 216, 230), "light blue" },
342 { RGB_TO_ULONG(173, 216, 230), "LightBlue" },
343 { RGB_TO_ULONG(176, 224, 230), "powder blue" },
344 { RGB_TO_ULONG(176, 224, 230), "PowderBlue" },
345 { RGB_TO_ULONG(175, 238, 238), "pale turquoise" },
346 { RGB_TO_ULONG(175, 238, 238), "PaleTurquoise" },
347 { RGB_TO_ULONG(0 , 206, 209), "dark turquoise" },
348 { RGB_TO_ULONG(0 , 206, 209), "DarkTurquoise" },
349 { RGB_TO_ULONG(72 , 209, 204), "medium turquoise" },
350 { RGB_TO_ULONG(72 , 209, 204), "MediumTurquoise" },
351 { RGB_TO_ULONG(64 , 224, 208), "turquoise" },
352 { RGB_TO_ULONG(0 , 255, 255), "cyan" },
353 { RGB_TO_ULONG(224, 255, 255), "light cyan" },
354 { RGB_TO_ULONG(224, 255, 255), "LightCyan" },
355 { RGB_TO_ULONG(95 , 158, 160), "cadet blue" },
356 { RGB_TO_ULONG(95 , 158, 160), "CadetBlue" },
357 { RGB_TO_ULONG(102, 205, 170), "medium aquamarine" },
358 { RGB_TO_ULONG(102, 205, 170), "MediumAquamarine" },
359 { RGB_TO_ULONG(127, 255, 212), "aquamarine" },
360 { RGB_TO_ULONG(0 , 100, 0 ), "dark green" },
361 { RGB_TO_ULONG(0 , 100, 0 ), "DarkGreen" },
362 { RGB_TO_ULONG(85 , 107, 47 ), "dark olive green" },
363 { RGB_TO_ULONG(85 , 107, 47 ), "DarkOliveGreen" },
364 { RGB_TO_ULONG(143, 188, 143), "dark sea green" },
365 { RGB_TO_ULONG(143, 188, 143), "DarkSeaGreen" },
366 { RGB_TO_ULONG(46 , 139, 87 ), "sea green" },
367 { RGB_TO_ULONG(46 , 139, 87 ), "SeaGreen" },
368 { RGB_TO_ULONG(60 , 179, 113), "medium sea green" },
369 { RGB_TO_ULONG(60 , 179, 113), "MediumSeaGreen" },
370 { RGB_TO_ULONG(32 , 178, 170), "light sea green" },
371 { RGB_TO_ULONG(32 , 178, 170), "LightSeaGreen" },
372 { RGB_TO_ULONG(152, 251, 152), "pale green" },
373 { RGB_TO_ULONG(152, 251, 152), "PaleGreen" },
374 { RGB_TO_ULONG(0 , 255, 127), "spring green" },
375 { RGB_TO_ULONG(0 , 255, 127), "SpringGreen" },
376 { RGB_TO_ULONG(124, 252, 0 ), "lawn green" },
377 { RGB_TO_ULONG(124, 252, 0 ), "LawnGreen" },
378 { RGB_TO_ULONG(0 , 255, 0 ), "green" },
379 { RGB_TO_ULONG(127, 255, 0 ), "chartreuse" },
380 { RGB_TO_ULONG(0 , 250, 154), "medium spring green" },
381 { RGB_TO_ULONG(0 , 250, 154), "MediumSpringGreen" },
382 { RGB_TO_ULONG(173, 255, 47 ), "green yellow" },
383 { RGB_TO_ULONG(173, 255, 47 ), "GreenYellow" },
384 { RGB_TO_ULONG(50 , 205, 50 ), "lime green" },
385 { RGB_TO_ULONG(50 , 205, 50 ), "LimeGreen" },
386 { RGB_TO_ULONG(154, 205, 50 ), "yellow green" },
387 { RGB_TO_ULONG(154, 205, 50 ), "YellowGreen" },
388 { RGB_TO_ULONG(34 , 139, 34 ), "forest green" },
389 { RGB_TO_ULONG(34 , 139, 34 ), "ForestGreen" },
390 { RGB_TO_ULONG(107, 142, 35 ), "olive drab" },
391 { RGB_TO_ULONG(107, 142, 35 ), "OliveDrab" },
392 { RGB_TO_ULONG(189, 183, 107), "dark khaki" },
393 { RGB_TO_ULONG(189, 183, 107), "DarkKhaki" },
394 { RGB_TO_ULONG(240, 230, 140), "khaki" },
395 { RGB_TO_ULONG(238, 232, 170), "pale goldenrod" },
396 { RGB_TO_ULONG(238, 232, 170), "PaleGoldenrod" },
397 { RGB_TO_ULONG(250, 250, 210), "light goldenrod yellow" },
398 { RGB_TO_ULONG(250, 250, 210), "LightGoldenrodYellow" },
399 { RGB_TO_ULONG(255, 255, 224), "light yellow" },
400 { RGB_TO_ULONG(255, 255, 224), "LightYellow" },
401 { RGB_TO_ULONG(255, 255, 0 ), "yellow" },
402 { RGB_TO_ULONG(255, 215, 0 ), "gold" },
403 { RGB_TO_ULONG(238, 221, 130), "light goldenrod" },
404 { RGB_TO_ULONG(238, 221, 130), "LightGoldenrod" },
405 { RGB_TO_ULONG(218, 165, 32 ), "goldenrod" },
406 { RGB_TO_ULONG(184, 134, 11 ), "dark goldenrod" },
407 { RGB_TO_ULONG(184, 134, 11 ), "DarkGoldenrod" },
408 { RGB_TO_ULONG(188, 143, 143), "rosy brown" },
409 { RGB_TO_ULONG(188, 143, 143), "RosyBrown" },
410 { RGB_TO_ULONG(205, 92 , 92 ), "indian red" },
411 { RGB_TO_ULONG(205, 92 , 92 ), "IndianRed" },
412 { RGB_TO_ULONG(139, 69 , 19 ), "saddle brown" },
413 { RGB_TO_ULONG(139, 69 , 19 ), "SaddleBrown" },
414 { RGB_TO_ULONG(160, 82 , 45 ), "sienna" },
415 { RGB_TO_ULONG(205, 133, 63 ), "peru" },
416 { RGB_TO_ULONG(222, 184, 135), "burlywood" },
417 { RGB_TO_ULONG(245, 245, 220), "beige" },
418 { RGB_TO_ULONG(245, 222, 179), "wheat" },
419 { RGB_TO_ULONG(244, 164, 96 ), "sandy brown" },
420 { RGB_TO_ULONG(244, 164, 96 ), "SandyBrown" },
421 { RGB_TO_ULONG(210, 180, 140), "tan" },
422 { RGB_TO_ULONG(210, 105, 30 ), "chocolate" },
423 { RGB_TO_ULONG(178, 34 , 34 ), "firebrick" },
424 { RGB_TO_ULONG(165, 42 , 42 ), "brown" },
425 { RGB_TO_ULONG(233, 150, 122), "dark salmon" },
426 { RGB_TO_ULONG(233, 150, 122), "DarkSalmon" },
427 { RGB_TO_ULONG(250, 128, 114), "salmon" },
428 { RGB_TO_ULONG(255, 160, 122), "light salmon" },
429 { RGB_TO_ULONG(255, 160, 122), "LightSalmon" },
430 { RGB_TO_ULONG(255, 165, 0 ), "orange" },
431 { RGB_TO_ULONG(255, 140, 0 ), "dark orange" },
432 { RGB_TO_ULONG(255, 140, 0 ), "DarkOrange" },
433 { RGB_TO_ULONG(255, 127, 80 ), "coral" },
434 { RGB_TO_ULONG(240, 128, 128), "light coral" },
435 { RGB_TO_ULONG(240, 128, 128), "LightCoral" },
436 { RGB_TO_ULONG(255, 99 , 71 ), "tomato" },
437 { RGB_TO_ULONG(255, 69 , 0 ), "orange red" },
438 { RGB_TO_ULONG(255, 69 , 0 ), "OrangeRed" },
439 { RGB_TO_ULONG(255, 0 , 0 ), "red" },
440 { RGB_TO_ULONG(255, 105, 180), "hot pink" },
441 { RGB_TO_ULONG(255, 105, 180), "HotPink" },
442 { RGB_TO_ULONG(255, 20 , 147), "deep pink" },
443 { RGB_TO_ULONG(255, 20 , 147), "DeepPink" },
444 { RGB_TO_ULONG(255, 192, 203), "pink" },
445 { RGB_TO_ULONG(255, 182, 193), "light pink" },
446 { RGB_TO_ULONG(255, 182, 193), "LightPink" },
447 { RGB_TO_ULONG(219, 112, 147), "pale violet red" },
448 { RGB_TO_ULONG(219, 112, 147), "PaleVioletRed" },
449 { RGB_TO_ULONG(176, 48 , 96 ), "maroon" },
450 { RGB_TO_ULONG(199, 21 , 133), "medium violet red" },
451 { RGB_TO_ULONG(199, 21 , 133), "MediumVioletRed" },
452 { RGB_TO_ULONG(208, 32 , 144), "violet red" },
453 { RGB_TO_ULONG(208, 32 , 144), "VioletRed" },
454 { RGB_TO_ULONG(255, 0 , 255), "magenta" },
455 { RGB_TO_ULONG(238, 130, 238), "violet" },
456 { RGB_TO_ULONG(221, 160, 221), "plum" },
457 { RGB_TO_ULONG(218, 112, 214), "orchid" },
458 { RGB_TO_ULONG(186, 85 , 211), "medium orchid" },
459 { RGB_TO_ULONG(186, 85 , 211), "MediumOrchid" },
460 { RGB_TO_ULONG(153, 50 , 204), "dark orchid" },
461 { RGB_TO_ULONG(153, 50 , 204), "DarkOrchid" },
462 { RGB_TO_ULONG(148, 0 , 211), "dark violet" },
463 { RGB_TO_ULONG(148, 0 , 211), "DarkViolet" },
464 { RGB_TO_ULONG(138, 43 , 226), "blue violet" },
465 { RGB_TO_ULONG(138, 43 , 226), "BlueViolet" },
466 { RGB_TO_ULONG(160, 32 , 240), "purple" },
467 { RGB_TO_ULONG(147, 112, 219), "medium purple" },
468 { RGB_TO_ULONG(147, 112, 219), "MediumPurple" },
469 { RGB_TO_ULONG(216, 191, 216), "thistle" },
470 { RGB_TO_ULONG(255, 250, 250), "snow1" },
471 { RGB_TO_ULONG(238, 233, 233), "snow2" },
472 { RGB_TO_ULONG(205, 201, 201), "snow3" },
473 { RGB_TO_ULONG(139, 137, 137), "snow4" },
474 { RGB_TO_ULONG(255, 245, 238), "seashell1" },
475 { RGB_TO_ULONG(238, 229, 222), "seashell2" },
476 { RGB_TO_ULONG(205, 197, 191), "seashell3" },
477 { RGB_TO_ULONG(139, 134, 130), "seashell4" },
478 { RGB_TO_ULONG(255, 239, 219), "AntiqueWhite1" },
479 { RGB_TO_ULONG(238, 223, 204), "AntiqueWhite2" },
480 { RGB_TO_ULONG(205, 192, 176), "AntiqueWhite3" },
481 { RGB_TO_ULONG(139, 131, 120), "AntiqueWhite4" },
482 { RGB_TO_ULONG(255, 228, 196), "bisque1" },
483 { RGB_TO_ULONG(238, 213, 183), "bisque2" },
484 { RGB_TO_ULONG(205, 183, 158), "bisque3" },
485 { RGB_TO_ULONG(139, 125, 107), "bisque4" },
486 { RGB_TO_ULONG(255, 218, 185), "PeachPuff1" },
487 { RGB_TO_ULONG(238, 203, 173), "PeachPuff2" },
488 { RGB_TO_ULONG(205, 175, 149), "PeachPuff3" },
489 { RGB_TO_ULONG(139, 119, 101), "PeachPuff4" },
490 { RGB_TO_ULONG(255, 222, 173), "NavajoWhite1" },
491 { RGB_TO_ULONG(238, 207, 161), "NavajoWhite2" },
492 { RGB_TO_ULONG(205, 179, 139), "NavajoWhite3" },
493 { RGB_TO_ULONG(139, 121, 94), "NavajoWhite4" },
494 { RGB_TO_ULONG(255, 250, 205), "LemonChiffon1" },
495 { RGB_TO_ULONG(238, 233, 191), "LemonChiffon2" },
496 { RGB_TO_ULONG(205, 201, 165), "LemonChiffon3" },
497 { RGB_TO_ULONG(139, 137, 112), "LemonChiffon4" },
498 { RGB_TO_ULONG(255, 248, 220), "cornsilk1" },
499 { RGB_TO_ULONG(238, 232, 205), "cornsilk2" },
500 { RGB_TO_ULONG(205, 200, 177), "cornsilk3" },
501 { RGB_TO_ULONG(139, 136, 120), "cornsilk4" },
502 { RGB_TO_ULONG(255, 255, 240), "ivory1" },
503 { RGB_TO_ULONG(238, 238, 224), "ivory2" },
504 { RGB_TO_ULONG(205, 205, 193), "ivory3" },
505 { RGB_TO_ULONG(139, 139, 131), "ivory4" },
506 { RGB_TO_ULONG(240, 255, 240), "honeydew1" },
507 { RGB_TO_ULONG(224, 238, 224), "honeydew2" },
508 { RGB_TO_ULONG(193, 205, 193), "honeydew3" },
509 { RGB_TO_ULONG(131, 139, 131), "honeydew4" },
510 { RGB_TO_ULONG(255, 240, 245), "LavenderBlush1" },
511 { RGB_TO_ULONG(238, 224, 229), "LavenderBlush2" },
512 { RGB_TO_ULONG(205, 193, 197), "LavenderBlush3" },
513 { RGB_TO_ULONG(139, 131, 134), "LavenderBlush4" },
514 { RGB_TO_ULONG(255, 228, 225), "MistyRose1" },
515 { RGB_TO_ULONG(238, 213, 210), "MistyRose2" },
516 { RGB_TO_ULONG(205, 183, 181), "MistyRose3" },
517 { RGB_TO_ULONG(139, 125, 123), "MistyRose4" },
518 { RGB_TO_ULONG(240, 255, 255), "azure1" },
519 { RGB_TO_ULONG(224, 238, 238), "azure2" },
520 { RGB_TO_ULONG(193, 205, 205), "azure3" },
521 { RGB_TO_ULONG(131, 139, 139), "azure4" },
522 { RGB_TO_ULONG(131, 111, 255), "SlateBlue1" },
523 { RGB_TO_ULONG(122, 103, 238), "SlateBlue2" },
524 { RGB_TO_ULONG(105, 89 , 205), "SlateBlue3" },
525 { RGB_TO_ULONG(71 , 60 , 139), "SlateBlue4" },
526 { RGB_TO_ULONG(72 , 118, 255), "RoyalBlue1" },
527 { RGB_TO_ULONG(67 , 110, 238), "RoyalBlue2" },
528 { RGB_TO_ULONG(58 , 95 , 205), "RoyalBlue3" },
529 { RGB_TO_ULONG(39 , 64 , 139), "RoyalBlue4" },
530 { RGB_TO_ULONG(0 , 0 , 255), "blue1" },
531 { RGB_TO_ULONG(0 , 0 , 238), "blue2" },
532 { RGB_TO_ULONG(0 , 0 , 205), "blue3" },
533 { RGB_TO_ULONG(0 , 0 , 139), "blue4" },
534 { RGB_TO_ULONG(30 , 144, 255), "DodgerBlue1" },
535 { RGB_TO_ULONG(28 , 134, 238), "DodgerBlue2" },
536 { RGB_TO_ULONG(24 , 116, 205), "DodgerBlue3" },
537 { RGB_TO_ULONG(16 , 78 , 139), "DodgerBlue4" },
538 { RGB_TO_ULONG(99 , 184, 255), "SteelBlue1" },
539 { RGB_TO_ULONG(92 , 172, 238), "SteelBlue2" },
540 { RGB_TO_ULONG(79 , 148, 205), "SteelBlue3" },
541 { RGB_TO_ULONG(54 , 100, 139), "SteelBlue4" },
542 { RGB_TO_ULONG(0 , 191, 255), "DeepSkyBlue1" },
543 { RGB_TO_ULONG(0 , 178, 238), "DeepSkyBlue2" },
544 { RGB_TO_ULONG(0 , 154, 205), "DeepSkyBlue3" },
545 { RGB_TO_ULONG(0 , 104, 139), "DeepSkyBlue4" },
546 { RGB_TO_ULONG(135, 206, 255), "SkyBlue1" },
547 { RGB_TO_ULONG(126, 192, 238), "SkyBlue2" },
548 { RGB_TO_ULONG(108, 166, 205), "SkyBlue3" },
549 { RGB_TO_ULONG(74 , 112, 139), "SkyBlue4" },
550 { RGB_TO_ULONG(176, 226, 255), "LightSkyBlue1" },
551 { RGB_TO_ULONG(164, 211, 238), "LightSkyBlue2" },
552 { RGB_TO_ULONG(141, 182, 205), "LightSkyBlue3" },
553 { RGB_TO_ULONG(96 , 123, 139), "LightSkyBlue4" },
554 { RGB_TO_ULONG(198, 226, 255), "SlateGray1" },
555 { RGB_TO_ULONG(185, 211, 238), "SlateGray2" },
556 { RGB_TO_ULONG(159, 182, 205), "SlateGray3" },
557 { RGB_TO_ULONG(108, 123, 139), "SlateGray4" },
558 { RGB_TO_ULONG(202, 225, 255), "LightSteelBlue1" },
559 { RGB_TO_ULONG(188, 210, 238), "LightSteelBlue2" },
560 { RGB_TO_ULONG(162, 181, 205), "LightSteelBlue3" },
561 { RGB_TO_ULONG(110, 123, 139), "LightSteelBlue4" },
562 { RGB_TO_ULONG(191, 239, 255), "LightBlue1" },
563 { RGB_TO_ULONG(178, 223, 238), "LightBlue2" },
564 { RGB_TO_ULONG(154, 192, 205), "LightBlue3" },
565 { RGB_TO_ULONG(104, 131, 139), "LightBlue4" },
566 { RGB_TO_ULONG(224, 255, 255), "LightCyan1" },
567 { RGB_TO_ULONG(209, 238, 238), "LightCyan2" },
568 { RGB_TO_ULONG(180, 205, 205), "LightCyan3" },
569 { RGB_TO_ULONG(122, 139, 139), "LightCyan4" },
570 { RGB_TO_ULONG(187, 255, 255), "PaleTurquoise1" },
571 { RGB_TO_ULONG(174, 238, 238), "PaleTurquoise2" },
572 { RGB_TO_ULONG(150, 205, 205), "PaleTurquoise3" },
573 { RGB_TO_ULONG(102, 139, 139), "PaleTurquoise4" },
574 { RGB_TO_ULONG(152, 245, 255), "CadetBlue1" },
575 { RGB_TO_ULONG(142, 229, 238), "CadetBlue2" },
576 { RGB_TO_ULONG(122, 197, 205), "CadetBlue3" },
577 { RGB_TO_ULONG(83 , 134, 139), "CadetBlue4" },
578 { RGB_TO_ULONG(0 , 245, 255), "turquoise1" },
579 { RGB_TO_ULONG(0 , 229, 238), "turquoise2" },
580 { RGB_TO_ULONG(0 , 197, 205), "turquoise3" },
581 { RGB_TO_ULONG(0 , 134, 139), "turquoise4" },
582 { RGB_TO_ULONG(0 , 255, 255), "cyan1" },
583 { RGB_TO_ULONG(0 , 238, 238), "cyan2" },
584 { RGB_TO_ULONG(0 , 205, 205), "cyan3" },
585 { RGB_TO_ULONG(0 , 139, 139), "cyan4" },
586 { RGB_TO_ULONG(151, 255, 255), "DarkSlateGray1" },
587 { RGB_TO_ULONG(141, 238, 238), "DarkSlateGray2" },
588 { RGB_TO_ULONG(121, 205, 205), "DarkSlateGray3" },
589 { RGB_TO_ULONG(82 , 139, 139), "DarkSlateGray4" },
590 { RGB_TO_ULONG(127, 255, 212), "aquamarine1" },
591 { RGB_TO_ULONG(118, 238, 198), "aquamarine2" },
592 { RGB_TO_ULONG(102, 205, 170), "aquamarine3" },
593 { RGB_TO_ULONG(69 , 139, 116), "aquamarine4" },
594 { RGB_TO_ULONG(193, 255, 193), "DarkSeaGreen1" },
595 { RGB_TO_ULONG(180, 238, 180), "DarkSeaGreen2" },
596 { RGB_TO_ULONG(155, 205, 155), "DarkSeaGreen3" },
597 { RGB_TO_ULONG(105, 139, 105), "DarkSeaGreen4" },
598 { RGB_TO_ULONG(84 , 255, 159), "SeaGreen1" },
599 { RGB_TO_ULONG(78 , 238, 148), "SeaGreen2" },
600 { RGB_TO_ULONG(67 , 205, 128), "SeaGreen3" },
601 { RGB_TO_ULONG(46 , 139, 87 ), "SeaGreen4" },
602 { RGB_TO_ULONG(154, 255, 154), "PaleGreen1" },
603 { RGB_TO_ULONG(144, 238, 144), "PaleGreen2" },
604 { RGB_TO_ULONG(124, 205, 124), "PaleGreen3" },
605 { RGB_TO_ULONG(84 , 139, 84 ), "PaleGreen4" },
606 { RGB_TO_ULONG(0 , 255, 127), "SpringGreen1" },
607 { RGB_TO_ULONG(0 , 238, 118), "SpringGreen2" },
608 { RGB_TO_ULONG(0 , 205, 102), "SpringGreen3" },
609 { RGB_TO_ULONG(0 , 139, 69 ), "SpringGreen4" },
610 { RGB_TO_ULONG(0 , 255, 0 ), "green1" },
611 { RGB_TO_ULONG(0 , 238, 0 ), "green2" },
612 { RGB_TO_ULONG(0 , 205, 0 ), "green3" },
613 { RGB_TO_ULONG(0 , 139, 0 ), "green4" },
614 { RGB_TO_ULONG(127, 255, 0 ), "chartreuse1" },
615 { RGB_TO_ULONG(118, 238, 0 ), "chartreuse2" },
616 { RGB_TO_ULONG(102, 205, 0 ), "chartreuse3" },
617 { RGB_TO_ULONG(69 , 139, 0 ), "chartreuse4" },
618 { RGB_TO_ULONG(192, 255, 62 ), "OliveDrab1" },
619 { RGB_TO_ULONG(179, 238, 58 ), "OliveDrab2" },
620 { RGB_TO_ULONG(154, 205, 50 ), "OliveDrab3" },
621 { RGB_TO_ULONG(105, 139, 34 ), "OliveDrab4" },
622 { RGB_TO_ULONG(202, 255, 112), "DarkOliveGreen1" },
623 { RGB_TO_ULONG(188, 238, 104), "DarkOliveGreen2" },
624 { RGB_TO_ULONG(162, 205, 90 ), "DarkOliveGreen3" },
625 { RGB_TO_ULONG(110, 139, 61 ), "DarkOliveGreen4" },
626 { RGB_TO_ULONG(255, 246, 143), "khaki1" },
627 { RGB_TO_ULONG(238, 230, 133), "khaki2" },
628 { RGB_TO_ULONG(205, 198, 115), "khaki3" },
629 { RGB_TO_ULONG(139, 134, 78 ), "khaki4" },
630 { RGB_TO_ULONG(255, 236, 139), "LightGoldenrod1" },
631 { RGB_TO_ULONG(238, 220, 130), "LightGoldenrod2" },
632 { RGB_TO_ULONG(205, 190, 112), "LightGoldenrod3" },
633 { RGB_TO_ULONG(139, 129, 76 ), "LightGoldenrod4" },
634 { RGB_TO_ULONG(255, 255, 224), "LightYellow1" },
635 { RGB_TO_ULONG(238, 238, 209), "LightYellow2" },
636 { RGB_TO_ULONG(205, 205, 180), "LightYellow3" },
637 { RGB_TO_ULONG(139, 139, 122), "LightYellow4" },
638 { RGB_TO_ULONG(255, 255, 0 ), "yellow1" },
639 { RGB_TO_ULONG(238, 238, 0 ), "yellow2" },
640 { RGB_TO_ULONG(205, 205, 0 ), "yellow3" },
641 { RGB_TO_ULONG(139, 139, 0 ), "yellow4" },
642 { RGB_TO_ULONG(255, 215, 0 ), "gold1" },
643 { RGB_TO_ULONG(238, 201, 0 ), "gold2" },
644 { RGB_TO_ULONG(205, 173, 0 ), "gold3" },
645 { RGB_TO_ULONG(139, 117, 0 ), "gold4" },
646 { RGB_TO_ULONG(255, 193, 37 ), "goldenrod1" },
647 { RGB_TO_ULONG(238, 180, 34 ), "goldenrod2" },
648 { RGB_TO_ULONG(205, 155, 29 ), "goldenrod3" },
649 { RGB_TO_ULONG(139, 105, 20 ), "goldenrod4" },
650 { RGB_TO_ULONG(255, 185, 15 ), "DarkGoldenrod1" },
651 { RGB_TO_ULONG(238, 173, 14 ), "DarkGoldenrod2" },
652 { RGB_TO_ULONG(205, 149, 12 ), "DarkGoldenrod3" },
653 { RGB_TO_ULONG(139, 101, 8 ), "DarkGoldenrod4" },
654 { RGB_TO_ULONG(255, 193, 193), "RosyBrown1" },
655 { RGB_TO_ULONG(238, 180, 180), "RosyBrown2" },
656 { RGB_TO_ULONG(205, 155, 155), "RosyBrown3" },
657 { RGB_TO_ULONG(139, 105, 105), "RosyBrown4" },
658 { RGB_TO_ULONG(255, 106, 106), "IndianRed1" },
659 { RGB_TO_ULONG(238, 99 , 99 ), "IndianRed2" },
660 { RGB_TO_ULONG(205, 85 , 85 ), "IndianRed3" },
661 { RGB_TO_ULONG(139, 58 , 58 ), "IndianRed4" },
662 { RGB_TO_ULONG(255, 130, 71 ), "sienna1" },
663 { RGB_TO_ULONG(238, 121, 66 ), "sienna2" },
664 { RGB_TO_ULONG(205, 104, 57 ), "sienna3" },
665 { RGB_TO_ULONG(139, 71 , 38 ), "sienna4" },
666 { RGB_TO_ULONG(255, 211, 155), "burlywood1" },
667 { RGB_TO_ULONG(238, 197, 145), "burlywood2" },
668 { RGB_TO_ULONG(205, 170, 125), "burlywood3" },
669 { RGB_TO_ULONG(139, 115, 85 ), "burlywood4" },
670 { RGB_TO_ULONG(255, 231, 186), "wheat1" },
671 { RGB_TO_ULONG(238, 216, 174), "wheat2" },
672 { RGB_TO_ULONG(205, 186, 150), "wheat3" },
673 { RGB_TO_ULONG(139, 126, 102), "wheat4" },
674 { RGB_TO_ULONG(255, 165, 79 ), "tan1" },
675 { RGB_TO_ULONG(238, 154, 73 ), "tan2" },
676 { RGB_TO_ULONG(205, 133, 63 ), "tan3" },
677 { RGB_TO_ULONG(139, 90 , 43 ), "tan4" },
678 { RGB_TO_ULONG(255, 127, 36 ), "chocolate1" },
679 { RGB_TO_ULONG(238, 118, 33 ), "chocolate2" },
680 { RGB_TO_ULONG(205, 102, 29 ), "chocolate3" },
681 { RGB_TO_ULONG(139, 69 , 19 ), "chocolate4" },
682 { RGB_TO_ULONG(255, 48 , 48 ), "firebrick1" },
683 { RGB_TO_ULONG(238, 44 , 44 ), "firebrick2" },
684 { RGB_TO_ULONG(205, 38 , 38 ), "firebrick3" },
685 { RGB_TO_ULONG(139, 26 , 26 ), "firebrick4" },
686 { RGB_TO_ULONG(255, 64 , 64 ), "brown1" },
687 { RGB_TO_ULONG(238, 59 , 59 ), "brown2" },
688 { RGB_TO_ULONG(205, 51 , 51 ), "brown3" },
689 { RGB_TO_ULONG(139, 35 , 35 ), "brown4" },
690 { RGB_TO_ULONG(255, 140, 105), "salmon1" },
691 { RGB_TO_ULONG(238, 130, 98 ), "salmon2" },
692 { RGB_TO_ULONG(205, 112, 84 ), "salmon3" },
693 { RGB_TO_ULONG(139, 76 , 57 ), "salmon4" },
694 { RGB_TO_ULONG(255, 160, 122), "LightSalmon1" },
695 { RGB_TO_ULONG(238, 149, 114), "LightSalmon2" },
696 { RGB_TO_ULONG(205, 129, 98 ), "LightSalmon3" },
697 { RGB_TO_ULONG(139, 87 , 66 ), "LightSalmon4" },
698 { RGB_TO_ULONG(255, 165, 0 ), "orange1" },
699 { RGB_TO_ULONG(238, 154, 0 ), "orange2" },
700 { RGB_TO_ULONG(205, 133, 0 ), "orange3" },
701 { RGB_TO_ULONG(139, 90 , 0 ), "orange4" },
702 { RGB_TO_ULONG(255, 127, 0 ), "DarkOrange1" },
703 { RGB_TO_ULONG(238, 118, 0 ), "DarkOrange2" },
704 { RGB_TO_ULONG(205, 102, 0 ), "DarkOrange3" },
705 { RGB_TO_ULONG(139, 69 , 0 ), "DarkOrange4" },
706 { RGB_TO_ULONG(255, 114, 86 ), "coral1" },
707 { RGB_TO_ULONG(238, 106, 80 ), "coral2" },
708 { RGB_TO_ULONG(205, 91 , 69 ), "coral3" },
709 { RGB_TO_ULONG(139, 62 , 47 ), "coral4" },
710 { RGB_TO_ULONG(255, 99 , 71 ), "tomato1" },
711 { RGB_TO_ULONG(238, 92 , 66 ), "tomato2" },
712 { RGB_TO_ULONG(205, 79 , 57 ), "tomato3" },
713 { RGB_TO_ULONG(139, 54 , 38 ), "tomato4" },
714 { RGB_TO_ULONG(255, 69 , 0 ), "OrangeRed1" },
715 { RGB_TO_ULONG(238, 64 , 0 ), "OrangeRed2" },
716 { RGB_TO_ULONG(205, 55 , 0 ), "OrangeRed3" },
717 { RGB_TO_ULONG(139, 37 , 0 ), "OrangeRed4" },
718 { RGB_TO_ULONG(255, 0 , 0 ), "red1" },
719 { RGB_TO_ULONG(238, 0 , 0 ), "red2" },
720 { RGB_TO_ULONG(205, 0 , 0 ), "red3" },
721 { RGB_TO_ULONG(139, 0 , 0 ), "red4" },
722 { RGB_TO_ULONG(255, 20 , 147), "DeepPink1" },
723 { RGB_TO_ULONG(238, 18 , 137), "DeepPink2" },
724 { RGB_TO_ULONG(205, 16 , 118), "DeepPink3" },
725 { RGB_TO_ULONG(139, 10 , 80 ), "DeepPink4" },
726 { RGB_TO_ULONG(255, 110, 180), "HotPink1" },
727 { RGB_TO_ULONG(238, 106, 167), "HotPink2" },
728 { RGB_TO_ULONG(205, 96 , 144), "HotPink3" },
729 { RGB_TO_ULONG(139, 58 , 98 ), "HotPink4" },
730 { RGB_TO_ULONG(255, 181, 197), "pink1" },
731 { RGB_TO_ULONG(238, 169, 184), "pink2" },
732 { RGB_TO_ULONG(205, 145, 158), "pink3" },
733 { RGB_TO_ULONG(139, 99 , 108), "pink4" },
734 { RGB_TO_ULONG(255, 174, 185), "LightPink1" },
735 { RGB_TO_ULONG(238, 162, 173), "LightPink2" },
736 { RGB_TO_ULONG(205, 140, 149), "LightPink3" },
737 { RGB_TO_ULONG(139, 95 , 101), "LightPink4" },
738 { RGB_TO_ULONG(255, 130, 171), "PaleVioletRed1" },
739 { RGB_TO_ULONG(238, 121, 159), "PaleVioletRed2" },
740 { RGB_TO_ULONG(205, 104, 137), "PaleVioletRed3" },
741 { RGB_TO_ULONG(139, 71 , 93 ), "PaleVioletRed4" },
742 { RGB_TO_ULONG(255, 52 , 179), "maroon1" },
743 { RGB_TO_ULONG(238, 48 , 167), "maroon2" },
744 { RGB_TO_ULONG(205, 41 , 144), "maroon3" },
745 { RGB_TO_ULONG(139, 28 , 98 ), "maroon4" },
746 { RGB_TO_ULONG(255, 62 , 150), "VioletRed1" },
747 { RGB_TO_ULONG(238, 58 , 140), "VioletRed2" },
748 { RGB_TO_ULONG(205, 50 , 120), "VioletRed3" },
749 { RGB_TO_ULONG(139, 34 , 82 ), "VioletRed4" },
750 { RGB_TO_ULONG(255, 0 , 255), "magenta1" },
751 { RGB_TO_ULONG(238, 0 , 238), "magenta2" },
752 { RGB_TO_ULONG(205, 0 , 205), "magenta3" },
753 { RGB_TO_ULONG(139, 0 , 139), "magenta4" },
754 { RGB_TO_ULONG(255, 131, 250), "orchid1" },
755 { RGB_TO_ULONG(238, 122, 233), "orchid2" },
756 { RGB_TO_ULONG(205, 105, 201), "orchid3" },
757 { RGB_TO_ULONG(139, 71 , 137), "orchid4" },
758 { RGB_TO_ULONG(255, 187, 255), "plum1" },
759 { RGB_TO_ULONG(238, 174, 238), "plum2" },
760 { RGB_TO_ULONG(205, 150, 205), "plum3" },
761 { RGB_TO_ULONG(139, 102, 139), "plum4" },
762 { RGB_TO_ULONG(224, 102, 255), "MediumOrchid1" },
763 { RGB_TO_ULONG(209, 95 , 238), "MediumOrchid2" },
764 { RGB_TO_ULONG(180, 82 , 205), "MediumOrchid3" },
765 { RGB_TO_ULONG(122, 55 , 139), "MediumOrchid4" },
766 { RGB_TO_ULONG(191, 62 , 255), "DarkOrchid1" },
767 { RGB_TO_ULONG(178, 58 , 238), "DarkOrchid2" },
768 { RGB_TO_ULONG(154, 50 , 205), "DarkOrchid3" },
769 { RGB_TO_ULONG(104, 34 , 139), "DarkOrchid4" },
770 { RGB_TO_ULONG(155, 48 , 255), "purple1" },
771 { RGB_TO_ULONG(145, 44 , 238), "purple2" },
772 { RGB_TO_ULONG(125, 38 , 205), "purple3" },
773 { RGB_TO_ULONG(85 , 26 , 139), "purple4" },
774 { RGB_TO_ULONG(171, 130, 255), "MediumPurple1" },
775 { RGB_TO_ULONG(159, 121, 238), "MediumPurple2" },
776 { RGB_TO_ULONG(137, 104, 205), "MediumPurple3" },
777 { RGB_TO_ULONG(93 , 71 , 139), "MediumPurple4" },
778 { RGB_TO_ULONG(255, 225, 255), "thistle1" },
779 { RGB_TO_ULONG(238, 210, 238), "thistle2" },
780 { RGB_TO_ULONG(205, 181, 205), "thistle3" },
781 { RGB_TO_ULONG(139, 123, 139), "thistle4" },
782 { RGB_TO_ULONG(0 , 0 , 0 ), "gray0" },
783 { RGB_TO_ULONG(0 , 0 , 0 ), "grey0" },
784 { RGB_TO_ULONG(3 , 3 , 3 ), "gray1" },
785 { RGB_TO_ULONG(3 , 3 , 3 ), "grey1" },
786 { RGB_TO_ULONG(5 , 5 , 5 ), "gray2" },
787 { RGB_TO_ULONG(5 , 5 , 5 ), "grey2" },
788 { RGB_TO_ULONG(8 , 8 , 8 ), "gray3" },
789 { RGB_TO_ULONG(8 , 8 , 8 ), "grey3" },
790 { RGB_TO_ULONG(10 , 10 , 10 ), "gray4" },
791 { RGB_TO_ULONG(10 , 10 , 10 ), "grey4" },
792 { RGB_TO_ULONG(13 , 13 , 13 ), "gray5" },
793 { RGB_TO_ULONG(13 , 13 , 13 ), "grey5" },
794 { RGB_TO_ULONG(15 , 15 , 15 ), "gray6" },
795 { RGB_TO_ULONG(15 , 15 , 15 ), "grey6" },
796 { RGB_TO_ULONG(18 , 18 , 18 ), "gray7" },
797 { RGB_TO_ULONG(18 , 18 , 18 ), "grey7" },
798 { RGB_TO_ULONG(20 , 20 , 20 ), "gray8" },
799 { RGB_TO_ULONG(20 , 20 , 20 ), "grey8" },
800 { RGB_TO_ULONG(23 , 23 , 23 ), "gray9" },
801 { RGB_TO_ULONG(23 , 23 , 23 ), "grey9" },
802 { RGB_TO_ULONG(26 , 26 , 26 ), "gray10" },
803 { RGB_TO_ULONG(26 , 26 , 26 ), "grey10" },
804 { RGB_TO_ULONG(28 , 28 , 28 ), "gray11" },
805 { RGB_TO_ULONG(28 , 28 , 28 ), "grey11" },
806 { RGB_TO_ULONG(31 , 31 , 31 ), "gray12" },
807 { RGB_TO_ULONG(31 , 31 , 31 ), "grey12" },
808 { RGB_TO_ULONG(33 , 33 , 33 ), "gray13" },
809 { RGB_TO_ULONG(33 , 33 , 33 ), "grey13" },
810 { RGB_TO_ULONG(36 , 36 , 36 ), "gray14" },
811 { RGB_TO_ULONG(36 , 36 , 36 ), "grey14" },
812 { RGB_TO_ULONG(38 , 38 , 38 ), "gray15" },
813 { RGB_TO_ULONG(38 , 38 , 38 ), "grey15" },
814 { RGB_TO_ULONG(41 , 41 , 41 ), "gray16" },
815 { RGB_TO_ULONG(41 , 41 , 41 ), "grey16" },
816 { RGB_TO_ULONG(43 , 43 , 43 ), "gray17" },
817 { RGB_TO_ULONG(43 , 43 , 43 ), "grey17" },
818 { RGB_TO_ULONG(46 , 46 , 46 ), "gray18" },
819 { RGB_TO_ULONG(46 , 46 , 46 ), "grey18" },
820 { RGB_TO_ULONG(48 , 48 , 48 ), "gray19" },
821 { RGB_TO_ULONG(48 , 48 , 48 ), "grey19" },
822 { RGB_TO_ULONG(51 , 51 , 51 ), "gray20" },
823 { RGB_TO_ULONG(51 , 51 , 51 ), "grey20" },
824 { RGB_TO_ULONG(54 , 54 , 54 ), "gray21" },
825 { RGB_TO_ULONG(54 , 54 , 54 ), "grey21" },
826 { RGB_TO_ULONG(56 , 56 , 56 ), "gray22" },
827 { RGB_TO_ULONG(56 , 56 , 56 ), "grey22" },
828 { RGB_TO_ULONG(59 , 59 , 59 ), "gray23" },
829 { RGB_TO_ULONG(59 , 59 , 59 ), "grey23" },
830 { RGB_TO_ULONG(61 , 61 , 61 ), "gray24" },
831 { RGB_TO_ULONG(61 , 61 , 61 ), "grey24" },
832 { RGB_TO_ULONG(64 , 64 , 64 ), "gray25" },
833 { RGB_TO_ULONG(64 , 64 , 64 ), "grey25" },
834 { RGB_TO_ULONG(66 , 66 , 66 ), "gray26" },
835 { RGB_TO_ULONG(66 , 66 , 66 ), "grey26" },
836 { RGB_TO_ULONG(69 , 69 , 69 ), "gray27" },
837 { RGB_TO_ULONG(69 , 69 , 69 ), "grey27" },
838 { RGB_TO_ULONG(71 , 71 , 71 ), "gray28" },
839 { RGB_TO_ULONG(71 , 71 , 71 ), "grey28" },
840 { RGB_TO_ULONG(74 , 74 , 74 ), "gray29" },
841 { RGB_TO_ULONG(74 , 74 , 74 ), "grey29" },
842 { RGB_TO_ULONG(77 , 77 , 77 ), "gray30" },
843 { RGB_TO_ULONG(77 , 77 , 77 ), "grey30" },
844 { RGB_TO_ULONG(79 , 79 , 79 ), "gray31" },
845 { RGB_TO_ULONG(79 , 79 , 79 ), "grey31" },
846 { RGB_TO_ULONG(82 , 82 , 82 ), "gray32" },
847 { RGB_TO_ULONG(82 , 82 , 82 ), "grey32" },
848 { RGB_TO_ULONG(84 , 84 , 84 ), "gray33" },
849 { RGB_TO_ULONG(84 , 84 , 84 ), "grey33" },
850 { RGB_TO_ULONG(87 , 87 , 87 ), "gray34" },
851 { RGB_TO_ULONG(87 , 87 , 87 ), "grey34" },
852 { RGB_TO_ULONG(89 , 89 , 89 ), "gray35" },
853 { RGB_TO_ULONG(89 , 89 , 89 ), "grey35" },
854 { RGB_TO_ULONG(92 , 92 , 92 ), "gray36" },
855 { RGB_TO_ULONG(92 , 92 , 92 ), "grey36" },
856 { RGB_TO_ULONG(94 , 94 , 94 ), "gray37" },
857 { RGB_TO_ULONG(94 , 94 , 94 ), "grey37" },
858 { RGB_TO_ULONG(97 , 97 , 97 ), "gray38" },
859 { RGB_TO_ULONG(97 , 97 , 97 ), "grey38" },
860 { RGB_TO_ULONG(99 , 99 , 99 ), "gray39" },
861 { RGB_TO_ULONG(99 , 99 , 99 ), "grey39" },
862 { RGB_TO_ULONG(102, 102, 102), "gray40" },
863 { RGB_TO_ULONG(102, 102, 102), "grey40" },
864 { RGB_TO_ULONG(105, 105, 105), "gray41" },
865 { RGB_TO_ULONG(105, 105, 105), "grey41" },
866 { RGB_TO_ULONG(107, 107, 107), "gray42" },
867 { RGB_TO_ULONG(107, 107, 107), "grey42" },
868 { RGB_TO_ULONG(110, 110, 110), "gray43" },
869 { RGB_TO_ULONG(110, 110, 110), "grey43" },
870 { RGB_TO_ULONG(112, 112, 112), "gray44" },
871 { RGB_TO_ULONG(112, 112, 112), "grey44" },
872 { RGB_TO_ULONG(115, 115, 115), "gray45" },
873 { RGB_TO_ULONG(115, 115, 115), "grey45" },
874 { RGB_TO_ULONG(117, 117, 117), "gray46" },
875 { RGB_TO_ULONG(117, 117, 117), "grey46" },
876 { RGB_TO_ULONG(120, 120, 120), "gray47" },
877 { RGB_TO_ULONG(120, 120, 120), "grey47" },
878 { RGB_TO_ULONG(122, 122, 122), "gray48" },
879 { RGB_TO_ULONG(122, 122, 122), "grey48" },
880 { RGB_TO_ULONG(125, 125, 125), "gray49" },
881 { RGB_TO_ULONG(125, 125, 125), "grey49" },
882 { RGB_TO_ULONG(127, 127, 127), "gray50" },
883 { RGB_TO_ULONG(127, 127, 127), "grey50" },
884 { RGB_TO_ULONG(130, 130, 130), "gray51" },
885 { RGB_TO_ULONG(130, 130, 130), "grey51" },
886 { RGB_TO_ULONG(133, 133, 133), "gray52" },
887 { RGB_TO_ULONG(133, 133, 133), "grey52" },
888 { RGB_TO_ULONG(135, 135, 135), "gray53" },
889 { RGB_TO_ULONG(135, 135, 135), "grey53" },
890 { RGB_TO_ULONG(138, 138, 138), "gray54" },
891 { RGB_TO_ULONG(138, 138, 138), "grey54" },
892 { RGB_TO_ULONG(140, 140, 140), "gray55" },
893 { RGB_TO_ULONG(140, 140, 140), "grey55" },
894 { RGB_TO_ULONG(143, 143, 143), "gray56" },
895 { RGB_TO_ULONG(143, 143, 143), "grey56" },
896 { RGB_TO_ULONG(145, 145, 145), "gray57" },
897 { RGB_TO_ULONG(145, 145, 145), "grey57" },
898 { RGB_TO_ULONG(148, 148, 148), "gray58" },
899 { RGB_TO_ULONG(148, 148, 148), "grey58" },
900 { RGB_TO_ULONG(150, 150, 150), "gray59" },
901 { RGB_TO_ULONG(150, 150, 150), "grey59" },
902 { RGB_TO_ULONG(153, 153, 153), "gray60" },
903 { RGB_TO_ULONG(153, 153, 153), "grey60" },
904 { RGB_TO_ULONG(156, 156, 156), "gray61" },
905 { RGB_TO_ULONG(156, 156, 156), "grey61" },
906 { RGB_TO_ULONG(158, 158, 158), "gray62" },
907 { RGB_TO_ULONG(158, 158, 158), "grey62" },
908 { RGB_TO_ULONG(161, 161, 161), "gray63" },
909 { RGB_TO_ULONG(161, 161, 161), "grey63" },
910 { RGB_TO_ULONG(163, 163, 163), "gray64" },
911 { RGB_TO_ULONG(163, 163, 163), "grey64" },
912 { RGB_TO_ULONG(166, 166, 166), "gray65" },
913 { RGB_TO_ULONG(166, 166, 166), "grey65" },
914 { RGB_TO_ULONG(168, 168, 168), "gray66" },
915 { RGB_TO_ULONG(168, 168, 168), "grey66" },
916 { RGB_TO_ULONG(171, 171, 171), "gray67" },
917 { RGB_TO_ULONG(171, 171, 171), "grey67" },
918 { RGB_TO_ULONG(173, 173, 173), "gray68" },
919 { RGB_TO_ULONG(173, 173, 173), "grey68" },
920 { RGB_TO_ULONG(176, 176, 176), "gray69" },
921 { RGB_TO_ULONG(176, 176, 176), "grey69" },
922 { RGB_TO_ULONG(179, 179, 179), "gray70" },
923 { RGB_TO_ULONG(179, 179, 179), "grey70" },
924 { RGB_TO_ULONG(181, 181, 181), "gray71" },
925 { RGB_TO_ULONG(181, 181, 181), "grey71" },
926 { RGB_TO_ULONG(184, 184, 184), "gray72" },
927 { RGB_TO_ULONG(184, 184, 184), "grey72" },
928 { RGB_TO_ULONG(186, 186, 186), "gray73" },
929 { RGB_TO_ULONG(186, 186, 186), "grey73" },
930 { RGB_TO_ULONG(189, 189, 189), "gray74" },
931 { RGB_TO_ULONG(189, 189, 189), "grey74" },
932 { RGB_TO_ULONG(191, 191, 191), "gray75" },
933 { RGB_TO_ULONG(191, 191, 191), "grey75" },
934 { RGB_TO_ULONG(194, 194, 194), "gray76" },
935 { RGB_TO_ULONG(194, 194, 194), "grey76" },
936 { RGB_TO_ULONG(196, 196, 196), "gray77" },
937 { RGB_TO_ULONG(196, 196, 196), "grey77" },
938 { RGB_TO_ULONG(199, 199, 199), "gray78" },
939 { RGB_TO_ULONG(199, 199, 199), "grey78" },
940 { RGB_TO_ULONG(201, 201, 201), "gray79" },
941 { RGB_TO_ULONG(201, 201, 201), "grey79" },
942 { RGB_TO_ULONG(204, 204, 204), "gray80" },
943 { RGB_TO_ULONG(204, 204, 204), "grey80" },
944 { RGB_TO_ULONG(207, 207, 207), "gray81" },
945 { RGB_TO_ULONG(207, 207, 207), "grey81" },
946 { RGB_TO_ULONG(209, 209, 209), "gray82" },
947 { RGB_TO_ULONG(209, 209, 209), "grey82" },
948 { RGB_TO_ULONG(212, 212, 212), "gray83" },
949 { RGB_TO_ULONG(212, 212, 212), "grey83" },
950 { RGB_TO_ULONG(214, 214, 214), "gray84" },
951 { RGB_TO_ULONG(214, 214, 214), "grey84" },
952 { RGB_TO_ULONG(217, 217, 217), "gray85" },
953 { RGB_TO_ULONG(217, 217, 217), "grey85" },
954 { RGB_TO_ULONG(219, 219, 219), "gray86" },
955 { RGB_TO_ULONG(219, 219, 219), "grey86" },
956 { RGB_TO_ULONG(222, 222, 222), "gray87" },
957 { RGB_TO_ULONG(222, 222, 222), "grey87" },
958 { RGB_TO_ULONG(224, 224, 224), "gray88" },
959 { RGB_TO_ULONG(224, 224, 224), "grey88" },
960 { RGB_TO_ULONG(227, 227, 227), "gray89" },
961 { RGB_TO_ULONG(227, 227, 227), "grey89" },
962 { RGB_TO_ULONG(229, 229, 229), "gray90" },
963 { RGB_TO_ULONG(229, 229, 229), "grey90" },
964 { RGB_TO_ULONG(232, 232, 232), "gray91" },
965 { RGB_TO_ULONG(232, 232, 232), "grey91" },
966 { RGB_TO_ULONG(235, 235, 235), "gray92" },
967 { RGB_TO_ULONG(235, 235, 235), "grey92" },
968 { RGB_TO_ULONG(237, 237, 237), "gray93" },
969 { RGB_TO_ULONG(237, 237, 237), "grey93" },
970 { RGB_TO_ULONG(240, 240, 240), "gray94" },
971 { RGB_TO_ULONG(240, 240, 240), "grey94" },
972 { RGB_TO_ULONG(242, 242, 242), "gray95" },
973 { RGB_TO_ULONG(242, 242, 242), "grey95" },
974 { RGB_TO_ULONG(245, 245, 245), "gray96" },
975 { RGB_TO_ULONG(245, 245, 245), "grey96" },
976 { RGB_TO_ULONG(247, 247, 247), "gray97" },
977 { RGB_TO_ULONG(247, 247, 247), "grey97" },
978 { RGB_TO_ULONG(250, 250, 250), "gray98" },
979 { RGB_TO_ULONG(250, 250, 250), "grey98" },
980 { RGB_TO_ULONG(252, 252, 252), "gray99" },
981 { RGB_TO_ULONG(252, 252, 252), "grey99" },
982 { RGB_TO_ULONG(255, 255, 255), "gray100" },
983 { RGB_TO_ULONG(255, 255, 255), "grey100" },
984 { RGB_TO_ULONG(169, 169, 169), "dark grey" },
985 { RGB_TO_ULONG(169, 169, 169), "DarkGrey" },
986 { RGB_TO_ULONG(169, 169, 169), "dark gray" },
987 { RGB_TO_ULONG(169, 169, 169), "DarkGray" },
988 { RGB_TO_ULONG(0 , 0 , 139), "dark blue" },
989 { RGB_TO_ULONG(0 , 0 , 139), "DarkBlue" },
990 { RGB_TO_ULONG(0 , 139, 139), "dark cyan" },
991 { RGB_TO_ULONG(0 , 139, 139), "DarkCyan" },
992 { RGB_TO_ULONG(139, 0 , 139), "dark magenta" },
993 { RGB_TO_ULONG(139, 0 , 139), "DarkMagenta" },
994 { RGB_TO_ULONG(139, 0 , 0 ), "dark red" },
995 { RGB_TO_ULONG(139, 0 , 0 ), "DarkRed" },
996 { RGB_TO_ULONG(144, 238, 144), "light green" },
997 { RGB_TO_ULONG(144, 238, 144), "LightGreen" }
998 };
999
1000 Lisp_Object
1001 mac_color_map_lookup (colorname)
1002 const char *colorname;
1003 {
1004 Lisp_Object ret = Qnil;
1005 int i;
1006
1007 BLOCK_INPUT;
1008
1009 for (i = 0; i < sizeof (mac_color_map) / sizeof (mac_color_map[0]); i++)
1010 if (xstrcasecmp (colorname, mac_color_map[i].name) == 0)
1011 {
1012 ret = make_number (mac_color_map[i].color);
1013 break;
1014 }
1015
1016 UNBLOCK_INPUT;
1017
1018 return ret;
1019 }
1020
1021 Lisp_Object
1022 x_to_mac_color (colorname)
1023 char * colorname;
1024 {
1025 register Lisp_Object ret = Qnil;
1026
1027 BLOCK_INPUT;
1028
1029 if (colorname[0] == '#')
1030 {
1031 /* Could be an old-style RGB Device specification. */
1032 char *color;
1033 int size;
1034 color = colorname + 1;
1035
1036 size = strlen(color);
1037 if (size == 3 || size == 6 || size == 9 || size == 12)
1038 {
1039 unsigned long colorval;
1040 int i, pos;
1041 pos = 16;
1042 size /= 3;
1043 colorval = 0;
1044
1045 for (i = 0; i < 3; i++)
1046 {
1047 char *end;
1048 char t;
1049 unsigned long value;
1050
1051 /* The check for 'x' in the following conditional takes into
1052 account the fact that strtol allows a "0x" in front of
1053 our numbers, and we don't. */
1054 if (!isxdigit(color[0]) || color[1] == 'x')
1055 break;
1056 t = color[size];
1057 color[size] = '\0';
1058 value = strtoul(color, &end, 16);
1059 color[size] = t;
1060 if (errno == ERANGE || end - color != size)
1061 break;
1062 switch (size)
1063 {
1064 case 1:
1065 value = value * 0x10;
1066 break;
1067 case 2:
1068 break;
1069 case 3:
1070 value /= 0x10;
1071 break;
1072 case 4:
1073 value /= 0x100;
1074 break;
1075 }
1076 colorval |= (value << pos);
1077 pos -= 8;
1078 if (i == 2)
1079 {
1080 UNBLOCK_INPUT;
1081 return make_number (colorval);
1082 }
1083 color = end;
1084 }
1085 }
1086 }
1087 else if (strnicmp(colorname, "rgb:", 4) == 0)
1088 {
1089 char *color;
1090 unsigned long colorval;
1091 int i, pos;
1092 pos = 16;
1093
1094 colorval = 0;
1095 color = colorname + 4;
1096 for (i = 0; i < 3; i++)
1097 {
1098 char *end;
1099 unsigned long value;
1100
1101 /* The check for 'x' in the following conditional takes into
1102 account the fact that strtol allows a "0x" in front of
1103 our numbers, and we don't. */
1104 if (!isxdigit(color[0]) || color[1] == 'x')
1105 break;
1106 value = strtoul(color, &end, 16);
1107 if (errno == ERANGE)
1108 break;
1109 switch (end - color)
1110 {
1111 case 1:
1112 value = value * 0x10 + value;
1113 break;
1114 case 2:
1115 break;
1116 case 3:
1117 value /= 0x10;
1118 break;
1119 case 4:
1120 value /= 0x100;
1121 break;
1122 default:
1123 value = ULONG_MAX;
1124 }
1125 if (value == ULONG_MAX)
1126 break;
1127 colorval |= (value << pos);
1128 pos -= 0x8;
1129 if (i == 2)
1130 {
1131 if (*end != '\0')
1132 break;
1133 UNBLOCK_INPUT;
1134 return make_number (colorval);
1135 }
1136 if (*end != '/')
1137 break;
1138 color = end + 1;
1139 }
1140 }
1141 else if (strnicmp(colorname, "rgbi:", 5) == 0)
1142 {
1143 /* This is an RGB Intensity specification. */
1144 char *color;
1145 unsigned long colorval;
1146 int i, pos;
1147 pos = 16;
1148
1149 colorval = 0;
1150 color = colorname + 5;
1151 for (i = 0; i < 3; i++)
1152 {
1153 char *end;
1154 double value;
1155 unsigned long val;
1156
1157 value = strtod(color, &end);
1158 if (errno == ERANGE)
1159 break;
1160 if (value < 0.0 || value > 1.0)
1161 break;
1162 val = (unsigned long)(0x100 * value);
1163 /* We used 0x100 instead of 0xFF to give a continuous
1164 range between 0.0 and 1.0 inclusive. The next statement
1165 fixes the 1.0 case. */
1166 if (val == 0x100)
1167 val = 0xFF;
1168 colorval |= (val << pos);
1169 pos -= 0x8;
1170 if (i == 2)
1171 {
1172 if (*end != '\0')
1173 break;
1174 UNBLOCK_INPUT;
1175 return make_number (colorval);
1176 }
1177 if (*end != '/')
1178 break;
1179 color = end + 1;
1180 }
1181 }
1182
1183 ret = mac_color_map_lookup (colorname);
1184
1185 UNBLOCK_INPUT;
1186 return ret;
1187 }
1188
1189 /* Gamma-correct COLOR on frame F. */
1190
1191 void
1192 gamma_correct (f, color)
1193 struct frame *f;
1194 unsigned long *color;
1195 {
1196 if (f->gamma)
1197 {
1198 unsigned long red, green, blue;
1199
1200 red = pow (RED_FROM_ULONG (*color) / 255.0, f->gamma) * 255.0 + 0.5;
1201 green = pow (GREEN_FROM_ULONG (*color) / 255.0, f->gamma) * 255.0 + 0.5;
1202 blue = pow (BLUE_FROM_ULONG (*color) / 255.0, f->gamma) * 255.0 + 0.5;
1203 *color = RGB_TO_ULONG (red, green, blue);
1204 }
1205 }
1206
1207 /* Decide if color named COLOR is valid for the display associated
1208 with the selected frame; if so, return the rgb values in COLOR_DEF.
1209 If ALLOC is nonzero, allocate a new colormap cell. */
1210
1211 int
1212 mac_defined_color (f, color, color_def, alloc)
1213 FRAME_PTR f;
1214 char *color;
1215 XColor *color_def;
1216 int alloc;
1217 {
1218 register Lisp_Object tem;
1219 unsigned long mac_color_ref;
1220
1221 tem = x_to_mac_color (color);
1222
1223 if (!NILP (tem))
1224 {
1225 if (f)
1226 {
1227 /* Apply gamma correction. */
1228 mac_color_ref = XUINT (tem);
1229 gamma_correct (f, &mac_color_ref);
1230 XSETINT (tem, mac_color_ref);
1231 }
1232
1233 color_def->pixel = mac_color_ref;
1234 color_def->red = RED16_FROM_ULONG (mac_color_ref);
1235 color_def->green = GREEN16_FROM_ULONG (mac_color_ref);
1236 color_def->blue = BLUE16_FROM_ULONG (mac_color_ref);
1237
1238 return 1;
1239 }
1240 else
1241 {
1242 return 0;
1243 }
1244 }
1245
1246 /* Given a string ARG naming a color, compute a pixel value from it
1247 suitable for screen F.
1248 If F is not a color screen, return DEF (default) regardless of what
1249 ARG says. */
1250
1251 int
1252 x_decode_color (f, arg, def)
1253 FRAME_PTR f;
1254 Lisp_Object arg;
1255 int def;
1256 {
1257 XColor cdef;
1258
1259 CHECK_STRING (arg);
1260
1261 if (strcmp (SDATA (arg), "black") == 0)
1262 return BLACK_PIX_DEFAULT (f);
1263 else if (strcmp (SDATA (arg), "white") == 0)
1264 return WHITE_PIX_DEFAULT (f);
1265
1266 #if 0
1267 if (FRAME_MAC_DISPLAY_INFO (f)->n_planes) == 1)
1268 return def;
1269 #endif
1270
1271 if (mac_defined_color (f, SDATA (arg), &cdef, 1))
1272 return cdef.pixel;
1273
1274 /* defined_color failed; return an ultimate default. */
1275 return def;
1276 }
1277 \f
1278 /* Functions called only from `x_set_frame_param'
1279 to set individual parameters.
1280
1281 If FRAME_MAC_WINDOW (f) is 0,
1282 the frame is being created and its window does not exist yet.
1283 In that case, just record the parameter's new value
1284 in the standard place; do not attempt to change the window. */
1285
1286 void
1287 x_set_foreground_color (f, arg, oldval)
1288 struct frame *f;
1289 Lisp_Object arg, oldval;
1290 {
1291 struct mac_output *mac = f->output_data.mac;
1292 unsigned long fg, old_fg;
1293
1294 fg = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1295 old_fg = FRAME_FOREGROUND_PIXEL (f);
1296 FRAME_FOREGROUND_PIXEL (f) = fg;
1297
1298 if (FRAME_MAC_WINDOW (f) != 0)
1299 {
1300 Display *dpy = FRAME_MAC_DISPLAY (f);
1301
1302 BLOCK_INPUT;
1303 XSetForeground (dpy, mac->normal_gc, fg);
1304 XSetBackground (dpy, mac->reverse_gc, fg);
1305
1306 if (mac->cursor_pixel == old_fg)
1307 {
1308 unload_color (f, mac->cursor_pixel);
1309 mac->cursor_pixel = fg;
1310 XSetBackground (dpy, mac->cursor_gc, mac->cursor_pixel);
1311 }
1312
1313 UNBLOCK_INPUT;
1314
1315 update_face_from_frame_parameter (f, Qforeground_color, arg);
1316
1317 if (FRAME_VISIBLE_P (f))
1318 redraw_frame (f);
1319 }
1320
1321 unload_color (f, old_fg);
1322 }
1323
1324 void
1325 x_set_background_color (f, arg, oldval)
1326 struct frame *f;
1327 Lisp_Object arg, oldval;
1328 {
1329 struct mac_output *mac = f->output_data.mac;
1330 unsigned long bg;
1331
1332 bg = x_decode_color (f, arg, WHITE_PIX_DEFAULT (f));
1333 unload_color (f, FRAME_BACKGROUND_PIXEL (f));
1334 FRAME_BACKGROUND_PIXEL (f) = bg;
1335
1336 if (FRAME_MAC_WINDOW (f) != 0)
1337 {
1338 Display *dpy = FRAME_MAC_DISPLAY (f);
1339
1340 BLOCK_INPUT;
1341 XSetBackground (dpy, mac->normal_gc, bg);
1342 XSetForeground (dpy, mac->reverse_gc, bg);
1343 mac_set_frame_window_background (f, bg);
1344 XSetForeground (dpy, mac->cursor_gc, bg);
1345
1346 UNBLOCK_INPUT;
1347 update_face_from_frame_parameter (f, Qbackground_color, arg);
1348
1349 if (FRAME_VISIBLE_P (f))
1350 redraw_frame (f);
1351 }
1352 }
1353
1354 void
1355 x_set_mouse_color (f, arg, oldval)
1356 struct frame *f;
1357 Lisp_Object arg, oldval;
1358 {
1359 struct x_output *x = f->output_data.x;
1360 Cursor cursor, nontext_cursor, mode_cursor, hand_cursor;
1361 Cursor hourglass_cursor, horizontal_drag_cursor;
1362 unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1363 unsigned long mask_color = FRAME_BACKGROUND_PIXEL (f);
1364
1365 /* Don't let pointers be invisible. */
1366 if (mask_color == pixel)
1367 pixel = FRAME_FOREGROUND_PIXEL (f);
1368
1369 f->output_data.mac->mouse_pixel = pixel;
1370
1371 if (!NILP (Vx_pointer_shape))
1372 {
1373 CHECK_NUMBER (Vx_pointer_shape);
1374 cursor = XINT (Vx_pointer_shape);
1375 }
1376 else
1377 cursor = kThemeIBeamCursor;
1378
1379 if (!NILP (Vx_nontext_pointer_shape))
1380 {
1381 CHECK_NUMBER (Vx_nontext_pointer_shape);
1382 nontext_cursor = XINT (Vx_nontext_pointer_shape);
1383 }
1384 else
1385 nontext_cursor = kThemeArrowCursor;
1386
1387 if (!NILP (Vx_hourglass_pointer_shape))
1388 {
1389 CHECK_NUMBER (Vx_hourglass_pointer_shape);
1390 hourglass_cursor = XINT (Vx_hourglass_pointer_shape);
1391 }
1392 else
1393 hourglass_cursor = kThemeWatchCursor;
1394
1395 if (!NILP (Vx_mode_pointer_shape))
1396 {
1397 CHECK_NUMBER (Vx_mode_pointer_shape);
1398 mode_cursor = XINT (Vx_mode_pointer_shape);
1399 }
1400 else
1401 mode_cursor = kThemeArrowCursor;
1402
1403 if (!NILP (Vx_sensitive_text_pointer_shape))
1404 {
1405 CHECK_NUMBER (Vx_sensitive_text_pointer_shape);
1406 hand_cursor = XINT (Vx_sensitive_text_pointer_shape);
1407 }
1408 else
1409 hand_cursor = kThemePointingHandCursor;
1410
1411 if (!NILP (Vx_window_horizontal_drag_shape))
1412 {
1413 CHECK_NUMBER (Vx_window_horizontal_drag_shape);
1414 horizontal_drag_cursor = XINT (Vx_window_horizontal_drag_shape);
1415 }
1416 else
1417 horizontal_drag_cursor = kThemeResizeLeftRightCursor;
1418
1419 #if 0 /* MAC_TODO: cursor color changes */
1420 {
1421 XColor fore_color, back_color;
1422
1423 fore_color.pixel = f->output_data.mac->mouse_pixel;
1424 x_query_color (f, &fore_color);
1425 back_color.pixel = mask_color;
1426 x_query_color (f, &back_color);
1427
1428 XRecolorCursor (dpy, cursor, &fore_color, &back_color);
1429 XRecolorCursor (dpy, nontext_cursor, &fore_color, &back_color);
1430 XRecolorCursor (dpy, mode_cursor, &fore_color, &back_color);
1431 XRecolorCursor (dpy, hand_cursor, &fore_color, &back_color);
1432 XRecolorCursor (dpy, hourglass_cursor, &fore_color, &back_color);
1433 XRecolorCursor (dpy, horizontal_drag_cursor, &fore_color, &back_color);
1434 }
1435 #endif
1436
1437 BLOCK_INPUT;
1438
1439 if (FRAME_MAC_WINDOW (f) != 0)
1440 FRAME_TERMINAL (f)->rif->define_frame_cursor (f, cursor);
1441
1442 f->output_data.mac->text_cursor = cursor;
1443 f->output_data.mac->nontext_cursor = nontext_cursor;
1444 f->output_data.mac->hourglass_cursor = hourglass_cursor;
1445 f->output_data.mac->modeline_cursor = mode_cursor;
1446 f->output_data.mac->hand_cursor = hand_cursor;
1447 f->output_data.mac->horizontal_drag_cursor = horizontal_drag_cursor;
1448
1449 UNBLOCK_INPUT;
1450
1451 update_face_from_frame_parameter (f, Qmouse_color, arg);
1452 }
1453
1454 void
1455 x_set_cursor_color (f, arg, oldval)
1456 struct frame *f;
1457 Lisp_Object arg, oldval;
1458 {
1459 unsigned long fore_pixel, pixel;
1460
1461 if (!NILP (Vx_cursor_fore_pixel))
1462 fore_pixel = x_decode_color (f, Vx_cursor_fore_pixel,
1463 WHITE_PIX_DEFAULT (f));
1464 else
1465 fore_pixel = FRAME_BACKGROUND_PIXEL (f);
1466
1467 pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1468
1469 /* Make sure that the cursor color differs from the background color. */
1470 if (pixel == FRAME_BACKGROUND_PIXEL (f))
1471 {
1472 pixel = f->output_data.mac->mouse_pixel;
1473 if (pixel == fore_pixel)
1474 fore_pixel = FRAME_BACKGROUND_PIXEL (f);
1475 }
1476
1477 f->output_data.mac->cursor_foreground_pixel = fore_pixel;
1478 f->output_data.mac->cursor_pixel = pixel;
1479
1480 if (FRAME_MAC_WINDOW (f) != 0)
1481 {
1482 BLOCK_INPUT;
1483 /* Update frame's cursor_gc. */
1484 XSetBackground (FRAME_MAC_DISPLAY (f),
1485 f->output_data.mac->cursor_gc, pixel);
1486 XSetForeground (FRAME_MAC_DISPLAY (f),
1487 f->output_data.mac->cursor_gc, fore_pixel);
1488 UNBLOCK_INPUT;
1489
1490 if (FRAME_VISIBLE_P (f))
1491 {
1492 x_update_cursor (f, 0);
1493 x_update_cursor (f, 1);
1494 }
1495 }
1496
1497 update_face_from_frame_parameter (f, Qcursor_color, arg);
1498 }
1499
1500 /* Set the border-color of frame F to pixel value PIX.
1501 Note that this does not fully take effect if done before
1502 F has a window. */
1503
1504 void
1505 x_set_border_pixel (f, pix)
1506 struct frame *f;
1507 int pix;
1508 {
1509
1510 f->output_data.mac->border_pixel = pix;
1511
1512 if (FRAME_MAC_WINDOW (f) != 0 && f->border_width > 0)
1513 {
1514 if (FRAME_VISIBLE_P (f))
1515 redraw_frame (f);
1516 }
1517 }
1518
1519 /* Set the border-color of frame F to value described by ARG.
1520 ARG can be a string naming a color.
1521 The border-color is used for the border that is drawn by the server.
1522 Note that this does not fully take effect if done before
1523 F has a window; it must be redone when the window is created. */
1524
1525 void
1526 x_set_border_color (f, arg, oldval)
1527 struct frame *f;
1528 Lisp_Object arg, oldval;
1529 {
1530 int pix;
1531
1532 CHECK_STRING (arg);
1533 pix = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f));
1534 x_set_border_pixel (f, pix);
1535 update_face_from_frame_parameter (f, Qborder_color, arg);
1536 }
1537
1538
1539 void
1540 x_set_cursor_type (f, arg, oldval)
1541 FRAME_PTR f;
1542 Lisp_Object arg, oldval;
1543 {
1544 set_frame_cursor_types (f, arg);
1545
1546 /* Make sure the cursor gets redrawn. */
1547 cursor_type_changed = 1;
1548 }
1549 \f
1550 #if 0 /* MAC_TODO: really no icon for Mac */
1551 void
1552 x_set_icon_type (f, arg, oldval)
1553 struct frame *f;
1554 Lisp_Object arg, oldval;
1555 {
1556 int result;
1557
1558 if (NILP (arg) && NILP (oldval))
1559 return;
1560
1561 if (STRINGP (arg) && STRINGP (oldval)
1562 && EQ (Fstring_equal (oldval, arg), Qt))
1563 return;
1564
1565 if (SYMBOLP (arg) && SYMBOLP (oldval) && EQ (arg, oldval))
1566 return;
1567
1568 BLOCK_INPUT;
1569
1570 result = x_bitmap_icon (f, arg);
1571 if (result)
1572 {
1573 UNBLOCK_INPUT;
1574 error ("No icon window available");
1575 }
1576
1577 UNBLOCK_INPUT;
1578 }
1579 #endif /* MAC_TODO */
1580
1581 void
1582 x_set_icon_name (f, arg, oldval)
1583 struct frame *f;
1584 Lisp_Object arg, oldval;
1585 {
1586 int result;
1587
1588 if (STRINGP (arg))
1589 {
1590 if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
1591 return;
1592 }
1593 else if (!NILP (arg) || NILP (oldval))
1594 return;
1595
1596 f->icon_name = arg;
1597
1598 #if 0 /* MAC_TODO */
1599 if (f->output_data.w32->icon_bitmap != 0)
1600 return;
1601
1602 BLOCK_INPUT;
1603
1604 result = x_text_icon (f,
1605 (char *) SDATA ((!NILP (f->icon_name)
1606 ? f->icon_name
1607 : !NILP (f->title)
1608 ? f->title
1609 : f->name)));
1610
1611 if (result)
1612 {
1613 UNBLOCK_INPUT;
1614 error ("No icon window available");
1615 }
1616
1617 /* If the window was unmapped (and its icon was mapped),
1618 the new icon is not mapped, so map the window in its stead. */
1619 if (FRAME_VISIBLE_P (f))
1620 {
1621 #ifdef USE_X_TOOLKIT
1622 XtPopup (f->output_data.w32->widget, XtGrabNone);
1623 #endif
1624 XMapWindow (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f));
1625 }
1626
1627 XFlush (FRAME_W32_DISPLAY (f));
1628 UNBLOCK_INPUT;
1629 #endif /* MAC_TODO */
1630 }
1631
1632 \f
1633 void
1634 x_set_menu_bar_lines (f, value, oldval)
1635 struct frame *f;
1636 Lisp_Object value, oldval;
1637 {
1638 /* Make sure we redisplay all windows in this frame. */
1639 windows_or_buffers_changed++;
1640
1641 FRAME_MENU_BAR_LINES (f) = 0;
1642 /* The menu bar is always shown. */
1643 FRAME_EXTERNAL_MENU_BAR (f) = 1;
1644 if (FRAME_MAC_P (f) && f->output_data.mac->menubar_widget == 0)
1645 /* Make sure next redisplay shows the menu bar. */
1646 XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
1647 adjust_glyphs (f);
1648 }
1649
1650
1651 /* Set the number of lines used for the tool bar of frame F to VALUE.
1652 VALUE not an integer, or < 0 means set the lines to zero. OLDVAL
1653 is the old number of tool bar lines. This function changes the
1654 height of all windows on frame F to match the new tool bar height.
1655 The frame's height doesn't change. */
1656
1657 void
1658 x_set_tool_bar_lines (f, value, oldval)
1659 struct frame *f;
1660 Lisp_Object value, oldval;
1661 {
1662 int delta, nlines, root_height;
1663 Lisp_Object root_window;
1664
1665 /* Treat tool bars like menu bars. */
1666 if (FRAME_MINIBUF_ONLY_P (f))
1667 return;
1668
1669 /* Use VALUE only if an integer >= 0. */
1670 if (INTEGERP (value) && XINT (value) >= 0)
1671 nlines = XFASTINT (value);
1672 else
1673 nlines = 0;
1674
1675 /* Make sure we redisplay all windows in this frame. */
1676 ++windows_or_buffers_changed;
1677
1678 #if USE_MAC_TOOLBAR
1679 FRAME_TOOL_BAR_LINES (f) = 0;
1680 if (nlines)
1681 {
1682 FRAME_EXTERNAL_TOOL_BAR (f) = 1;
1683 if (FRAME_MAC_P (f)
1684 && !mac_is_window_toolbar_visible (FRAME_MAC_WINDOW (f)))
1685 /* Make sure next redisplay shows the tool bar. */
1686 XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
1687 }
1688 else
1689 {
1690 if (FRAME_EXTERNAL_TOOL_BAR (f))
1691 free_frame_tool_bar (f);
1692 FRAME_EXTERNAL_TOOL_BAR (f) = 0;
1693 }
1694
1695 return;
1696 #endif
1697
1698 delta = nlines - FRAME_TOOL_BAR_LINES (f);
1699
1700 /* Don't resize the tool-bar to more than we have room for. */
1701 root_window = FRAME_ROOT_WINDOW (f);
1702 root_height = WINDOW_TOTAL_LINES (XWINDOW (root_window));
1703 if (root_height - delta < 1)
1704 {
1705 delta = root_height - 1;
1706 nlines = FRAME_TOOL_BAR_LINES (f) + delta;
1707 }
1708
1709 FRAME_TOOL_BAR_LINES (f) = nlines;
1710 change_window_heights (root_window, delta);
1711 adjust_glyphs (f);
1712
1713 /* We also have to make sure that the internal border at the top of
1714 the frame, below the menu bar or tool bar, is redrawn when the
1715 tool bar disappears. This is so because the internal border is
1716 below the tool bar if one is displayed, but is below the menu bar
1717 if there isn't a tool bar. The tool bar draws into the area
1718 below the menu bar. */
1719 if (FRAME_MAC_WINDOW (f) && FRAME_TOOL_BAR_LINES (f) == 0)
1720 {
1721 clear_frame (f);
1722 clear_current_matrices (f);
1723 }
1724
1725 /* If the tool bar gets smaller, the internal border below it
1726 has to be cleared. It was formerly part of the display
1727 of the larger tool bar, and updating windows won't clear it. */
1728 if (delta < 0)
1729 {
1730 int height = FRAME_INTERNAL_BORDER_WIDTH (f);
1731 int width = FRAME_PIXEL_WIDTH (f);
1732 int y = nlines * FRAME_LINE_HEIGHT (f);
1733
1734 BLOCK_INPUT;
1735 mac_clear_area (f, 0, y, width, height);
1736 UNBLOCK_INPUT;
1737
1738 if (WINDOWP (f->tool_bar_window))
1739 clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
1740 }
1741 }
1742
1743
1744 \f
1745 /* Set the Mac window title to NAME for frame F. */
1746
1747 static void
1748 x_set_name_internal (f, name)
1749 FRAME_PTR f;
1750 Lisp_Object name;
1751 {
1752 if (FRAME_MAC_WINDOW (f))
1753 {
1754 if (STRING_MULTIBYTE (name))
1755 #if TARGET_API_MAC_CARBON
1756 name = ENCODE_UTF_8 (name);
1757 #else
1758 name = ENCODE_SYSTEM (name);
1759 #endif
1760
1761 BLOCK_INPUT;
1762
1763 {
1764 #if TARGET_API_MAC_CARBON
1765 CFStringRef windowTitle =
1766 cfstring_create_with_utf8_cstring (SDATA (name));
1767
1768 mac_set_window_title (FRAME_MAC_WINDOW (f), windowTitle);
1769 CFRelease (windowTitle);
1770 #else
1771 Str255 windowTitle;
1772 if (strlen (SDATA (name)) < 255)
1773 {
1774 strcpy (windowTitle, SDATA (name));
1775 c2pstr (windowTitle);
1776 SetWTitle (FRAME_MAC_WINDOW (f), windowTitle);
1777 }
1778 #endif
1779 }
1780
1781 UNBLOCK_INPUT;
1782 }
1783 }
1784
1785 /* Change the name of frame F to NAME. If NAME is nil, set F's name to
1786 mac_id_name.
1787
1788 If EXPLICIT is non-zero, that indicates that lisp code is setting the
1789 name; if NAME is a string, set F's name to NAME and set
1790 F->explicit_name; if NAME is Qnil, then clear F->explicit_name.
1791
1792 If EXPLICIT is zero, that indicates that Emacs redisplay code is
1793 suggesting a new name, which lisp code should override; if
1794 F->explicit_name is set, ignore the new name; otherwise, set it. */
1795
1796 void
1797 x_set_name (f, name, explicit)
1798 struct frame *f;
1799 Lisp_Object name;
1800 int explicit;
1801 {
1802 /* Make sure that requests from lisp code override requests from
1803 Emacs redisplay code. */
1804 if (explicit)
1805 {
1806 /* If we're switching from explicit to implicit, we had better
1807 update the mode lines and thereby update the title. */
1808 if (f->explicit_name && NILP (name))
1809 update_mode_lines = 1;
1810
1811 f->explicit_name = ! NILP (name);
1812 }
1813 else if (f->explicit_name)
1814 return;
1815
1816 /* If NAME is nil, set the name to the mac_id_name. */
1817 if (NILP (name))
1818 {
1819 /* Check for no change needed in this very common case
1820 before we do any consing. */
1821 if (!strcmp (FRAME_MAC_DISPLAY_INFO (f)->mac_id_name,
1822 SDATA (f->name)))
1823 return;
1824 name = build_string (FRAME_MAC_DISPLAY_INFO (f)->mac_id_name);
1825 }
1826 else
1827 CHECK_STRING (name);
1828
1829 /* Don't change the name if it's already NAME. */
1830 if (! NILP (Fstring_equal (name, f->name)))
1831 return;
1832
1833 f->name = name;
1834
1835 /* For setting the frame title, the title parameter should override
1836 the name parameter. */
1837 if (! NILP (f->title))
1838 name = f->title;
1839
1840 x_set_name_internal (f, name);
1841 }
1842
1843 /* This function should be called when the user's lisp code has
1844 specified a name for the frame; the name will override any set by the
1845 redisplay code. */
1846 void
1847 x_explicitly_set_name (f, arg, oldval)
1848 FRAME_PTR f;
1849 Lisp_Object arg, oldval;
1850 {
1851 x_set_name (f, arg, 1);
1852 }
1853
1854 /* This function should be called by Emacs redisplay code to set the
1855 name; names set this way will never override names set by the user's
1856 lisp code. */
1857 void
1858 x_implicitly_set_name (f, arg, oldval)
1859 FRAME_PTR f;
1860 Lisp_Object arg, oldval;
1861 {
1862 x_set_name (f, arg, 0);
1863 }
1864 \f
1865 /* Change the title of frame F to NAME.
1866 If NAME is nil, use the frame name as the title. */
1867
1868 void
1869 x_set_title (f, name, old_name)
1870 struct frame *f;
1871 Lisp_Object name, old_name;
1872 {
1873 /* Don't change the title if it's already NAME. */
1874 if (EQ (name, f->title))
1875 return;
1876
1877 update_mode_lines = 1;
1878
1879 f->title = name;
1880
1881 if (NILP (name))
1882 name = f->name;
1883 else
1884 CHECK_STRING (name);
1885
1886 x_set_name_internal (f, name);
1887 }
1888
1889 void
1890 x_set_scroll_bar_default_width (f)
1891 struct frame *f;
1892 {
1893 /* Imitate X without X Toolkit */
1894
1895 int wid = FRAME_COLUMN_WIDTH (f);
1896
1897 #ifdef MAC_OSX
1898 FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = MAC_AQUA_VERTICAL_SCROLL_BAR_WIDTH;
1899 FRAME_CONFIG_SCROLL_BAR_COLS (f) = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) +
1900 wid - 1) / wid;
1901 #else /* not MAC_OSX */
1902 /* Make the actual width at least 14 pixels and a multiple of a
1903 character width. */
1904 FRAME_CONFIG_SCROLL_BAR_COLS (f) = (14 + wid - 1) / wid;
1905
1906 /* Use all of that space (aside from required margins) for the
1907 scroll bar. */
1908 FRAME_CONFIG_SCROLL_BAR_WIDTH (f) = 0;
1909 #endif /* not MAC_OSX */
1910 }
1911
1912 static void
1913 mac_set_font (f, arg, oldval)
1914 struct frame *f;
1915 Lisp_Object arg, oldval;
1916 {
1917 x_set_font (f, arg, oldval);
1918 #if USE_MAC_FONT_PANEL
1919 {
1920 Lisp_Object focus_frame = x_get_focus_frame (f);
1921
1922 if ((NILP (focus_frame) && f == SELECTED_FRAME ())
1923 || XFRAME (focus_frame) == f)
1924 {
1925 BLOCK_INPUT;
1926 mac_set_font_info_for_selection (f, DEFAULT_FACE_ID, 0);
1927 UNBLOCK_INPUT;
1928 }
1929 }
1930 #endif
1931 }
1932
1933 void
1934 mac_update_title_bar (f, save_match_data)
1935 struct frame *f;
1936 int save_match_data;
1937 {
1938 #if TARGET_API_MAC_CARBON
1939 struct window *w;
1940 int modified_p;
1941
1942 if (!FRAME_MAC_P (f))
1943 return;
1944
1945 w = XWINDOW (FRAME_SELECTED_WINDOW (f));
1946 modified_p = (BUF_SAVE_MODIFF (XBUFFER (w->buffer))
1947 < BUF_MODIFF (XBUFFER (w->buffer)));
1948 if (windows_or_buffers_changed
1949 /* Minibuffer modification status shown in the close button is
1950 confusing. */
1951 || (!MINI_WINDOW_P (w)
1952 && (modified_p != !NILP (w->last_had_star))))
1953 {
1954 BLOCK_INPUT;
1955 mac_set_window_modified (FRAME_MAC_WINDOW (f),
1956 !MINI_WINDOW_P (w) && modified_p);
1957 mac_update_proxy_icon (f);
1958 UNBLOCK_INPUT;
1959 }
1960 #endif
1961 }
1962
1963 \f
1964 /* Subroutines of creating a frame. */
1965
1966 /* Retrieve the string resource specified by NAME with CLASS from
1967 database RDB.
1968
1969 The return value points to the contents of a Lisp string. So it
1970 will not be valid after the next GC where string compaction will
1971 occur. */
1972
1973 char *
1974 x_get_string_resource (rdb, name, class)
1975 XrmDatabase rdb;
1976 char *name, *class;
1977 {
1978 Lisp_Object value = xrm_get_resource (rdb, name, class);
1979
1980 if (STRINGP (value))
1981 return SDATA (value);
1982 else
1983 return NULL;
1984 }
1985
1986 /* Return the value of parameter PARAM.
1987
1988 First search ALIST, then Vdefault_frame_alist, then the X defaults
1989 database, using ATTRIBUTE as the attribute name and CLASS as its class.
1990
1991 Convert the resource to the type specified by desired_type.
1992
1993 If no default is specified, return Qunbound. If you call
1994 mac_get_arg, make sure you deal with Qunbound in a reasonable way,
1995 and don't let it get stored in any Lisp-visible variables! */
1996
1997 static Lisp_Object
1998 mac_get_arg (alist, param, attribute, class, type)
1999 Lisp_Object alist, param;
2000 char *attribute;
2001 char *class;
2002 enum resource_types type;
2003 {
2004 return x_get_arg (check_x_display_info (Qnil),
2005 alist, param, attribute, class, type);
2006 }
2007
2008 \f
2009 /* XParseGeometry copied from w32xfns.c */
2010
2011 /*
2012 * XParseGeometry parses strings of the form
2013 * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
2014 * width, height, xoffset, and yoffset are unsigned integers.
2015 * Example: "=80x24+300-49"
2016 * The equal sign is optional.
2017 * It returns a bitmask that indicates which of the four values
2018 * were actually found in the string. For each value found,
2019 * the corresponding argument is updated; for each value
2020 * not found, the corresponding argument is left unchanged.
2021 */
2022
2023 static int
2024 read_integer (string, NextString)
2025 register char *string;
2026 char **NextString;
2027 {
2028 register int Result = 0;
2029 int Sign = 1;
2030
2031 if (*string == '+')
2032 string++;
2033 else if (*string == '-')
2034 {
2035 string++;
2036 Sign = -1;
2037 }
2038 for (; (*string >= '0') && (*string <= '9'); string++)
2039 {
2040 Result = (Result * 10) + (*string - '0');
2041 }
2042 *NextString = string;
2043 if (Sign >= 0)
2044 return (Result);
2045 else
2046 return (-Result);
2047 }
2048
2049 int
2050 XParseGeometry (string, x, y, width, height)
2051 char *string;
2052 int *x, *y;
2053 unsigned int *width, *height; /* RETURN */
2054 {
2055 int mask = NoValue;
2056 register char *strind;
2057 unsigned int tempWidth, tempHeight;
2058 int tempX, tempY;
2059 char *nextCharacter;
2060
2061 if ((string == NULL) || (*string == '\0')) return (mask);
2062 if (*string == '=')
2063 string++; /* ignore possible '=' at beg of geometry spec */
2064
2065 strind = (char *)string;
2066 if (*strind != '+' && *strind != '-' && *strind != 'x')
2067 {
2068 tempWidth = read_integer (strind, &nextCharacter);
2069 if (strind == nextCharacter)
2070 return (0);
2071 strind = nextCharacter;
2072 mask |= WidthValue;
2073 }
2074
2075 if (*strind == 'x' || *strind == 'X')
2076 {
2077 strind++;
2078 tempHeight = read_integer (strind, &nextCharacter);
2079 if (strind == nextCharacter)
2080 return (0);
2081 strind = nextCharacter;
2082 mask |= HeightValue;
2083 }
2084
2085 if ((*strind == '+') || (*strind == '-'))
2086 {
2087 if (*strind == '-')
2088 {
2089 strind++;
2090 tempX = -read_integer (strind, &nextCharacter);
2091 if (strind == nextCharacter)
2092 return (0);
2093 strind = nextCharacter;
2094 mask |= XNegative;
2095
2096 }
2097 else
2098 {
2099 strind++;
2100 tempX = read_integer (strind, &nextCharacter);
2101 if (strind == nextCharacter)
2102 return (0);
2103 strind = nextCharacter;
2104 }
2105 mask |= XValue;
2106 if ((*strind == '+') || (*strind == '-'))
2107 {
2108 if (*strind == '-')
2109 {
2110 strind++;
2111 tempY = -read_integer (strind, &nextCharacter);
2112 if (strind == nextCharacter)
2113 return (0);
2114 strind = nextCharacter;
2115 mask |= YNegative;
2116
2117 }
2118 else
2119 {
2120 strind++;
2121 tempY = read_integer (strind, &nextCharacter);
2122 if (strind == nextCharacter)
2123 return (0);
2124 strind = nextCharacter;
2125 }
2126 mask |= YValue;
2127 }
2128 }
2129
2130 /* If strind isn't at the end of the string the it's an invalid
2131 geometry specification. */
2132
2133 if (*strind != '\0') return (0);
2134
2135 if (mask & XValue)
2136 *x = tempX;
2137 if (mask & YValue)
2138 *y = tempY;
2139 if (mask & WidthValue)
2140 *width = tempWidth;
2141 if (mask & HeightValue)
2142 *height = tempHeight;
2143 return (mask);
2144 }
2145
2146 \f
2147 /* Create and set up the Mac window for frame F. */
2148
2149 static void
2150 mac_window (f)
2151 struct frame *f;
2152 {
2153 BLOCK_INPUT;
2154
2155 mac_create_frame_window (f, 0);
2156
2157 if (FRAME_MAC_WINDOW (f))
2158 mac_set_frame_window_background (f, FRAME_BACKGROUND_PIXEL (f));
2159
2160 #if USE_MAC_TOOLBAR
2161 /* At the moment, the size of the tool bar is not yet known. We
2162 record the gravity value of the newly created window and use it
2163 to adjust the position of the window (especially for a negative
2164 specification of its vertical position) when the tool bar is
2165 first redisplayed. */
2166 if (FRAME_EXTERNAL_TOOL_BAR (f))
2167 f->output_data.mac->toolbar_win_gravity = f->win_gravity;
2168 #endif
2169
2170 validate_x_resource_name ();
2171
2172 /* x_set_name normally ignores requests to set the name if the
2173 requested name is the same as the current name. This is the one
2174 place where that assumption isn't correct; f->name is set, but
2175 the server hasn't been told. */
2176 {
2177 Lisp_Object name;
2178 int explicit = f->explicit_name;
2179
2180 f->explicit_name = 0;
2181 name = f->name;
2182 f->name = Qnil;
2183 x_set_name (f, name, explicit);
2184 }
2185
2186 UNBLOCK_INPUT;
2187
2188 if (FRAME_MAC_WINDOW (f) == 0)
2189 error ("Unable to create window");
2190 }
2191
2192 /* Handle the icon stuff for this window. Perhaps later we might
2193 want an x_set_icon_position which can be called interactively as
2194 well. */
2195
2196 static void
2197 x_icon (f, parms)
2198 struct frame *f;
2199 Lisp_Object parms;
2200 {
2201 Lisp_Object icon_x, icon_y;
2202
2203 /* Set the position of the icon. Note that Windows 95 groups all
2204 icons in the tray. */
2205 icon_x = mac_get_arg (parms, Qicon_left, 0, 0, RES_TYPE_NUMBER);
2206 icon_y = mac_get_arg (parms, Qicon_top, 0, 0, RES_TYPE_NUMBER);
2207 if (!EQ (icon_x, Qunbound) && !EQ (icon_y, Qunbound))
2208 {
2209 CHECK_NUMBER (icon_x);
2210 CHECK_NUMBER (icon_y);
2211 }
2212 else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound))
2213 error ("Both left and top icon corners of icon must be specified");
2214
2215 BLOCK_INPUT;
2216
2217 if (! EQ (icon_x, Qunbound))
2218 x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y));
2219
2220 #if 0 /* TODO */
2221 /* Start up iconic or window? */
2222 x_wm_set_window_state
2223 (f, (EQ (w32_get_arg (parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL), Qicon)
2224 ? IconicState
2225 : NormalState));
2226
2227 x_text_icon (f, (char *) SDATA ((!NILP (f->icon_name)
2228 ? f->icon_name
2229 : f->name)));
2230 #endif
2231
2232 UNBLOCK_INPUT;
2233 }
2234
2235
2236 void
2237 x_make_gc (f)
2238 struct frame *f;
2239 {
2240 XGCValues gc_values;
2241
2242 BLOCK_INPUT;
2243
2244 /* Create the GCs of this frame.
2245 Note that many default values are used. */
2246
2247 /* Normal video */
2248 gc_values.font = FRAME_FONT (f);
2249 gc_values.foreground = FRAME_FOREGROUND_PIXEL (f);
2250 gc_values.background = FRAME_BACKGROUND_PIXEL (f);
2251 f->output_data.mac->normal_gc = XCreateGC (FRAME_MAC_DISPLAY (f),
2252 FRAME_MAC_WINDOW (f),
2253 GCFont | GCForeground | GCBackground,
2254 &gc_values);
2255
2256 /* Reverse video style. */
2257 gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
2258 gc_values.background = FRAME_FOREGROUND_PIXEL (f);
2259 f->output_data.mac->reverse_gc = XCreateGC (FRAME_MAC_DISPLAY (f),
2260 FRAME_MAC_WINDOW (f),
2261 GCFont | GCForeground | GCBackground,
2262 &gc_values);
2263
2264 /* Cursor has cursor-color background, background-color foreground. */
2265 gc_values.foreground = FRAME_BACKGROUND_PIXEL (f);
2266 gc_values.background = f->output_data.mac->cursor_pixel;
2267 f->output_data.mac->cursor_gc = XCreateGC (FRAME_MAC_DISPLAY (f),
2268 FRAME_MAC_WINDOW (f),
2269 GCFont | GCForeground | GCBackground,
2270 &gc_values);
2271
2272 /* Reliefs. */
2273 f->output_data.mac->white_relief.gc = 0;
2274 f->output_data.mac->black_relief.gc = 0;
2275
2276 #if 0
2277 /* Create the gray border tile used when the pointer is not in
2278 the frame. Since this depends on the frame's pixel values,
2279 this must be done on a per-frame basis. */
2280 f->output_data.x->border_tile
2281 = (XCreatePixmapFromBitmapData
2282 (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window,
2283 gray_bits, gray_width, gray_height,
2284 FRAME_FOREGROUND_PIXEL (f),
2285 FRAME_BACKGROUND_PIXEL (f),
2286 DefaultDepth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f))));
2287 #endif
2288
2289 UNBLOCK_INPUT;
2290 }
2291
2292
2293 /* Free what was was allocated in x_make_gc. */
2294
2295 void
2296 x_free_gcs (f)
2297 struct frame *f;
2298 {
2299 Display *dpy = FRAME_MAC_DISPLAY (f);
2300
2301 BLOCK_INPUT;
2302
2303 if (f->output_data.mac->normal_gc)
2304 {
2305 XFreeGC (dpy, f->output_data.mac->normal_gc);
2306 f->output_data.mac->normal_gc = 0;
2307 }
2308
2309 if (f->output_data.mac->reverse_gc)
2310 {
2311 XFreeGC (dpy, f->output_data.mac->reverse_gc);
2312 f->output_data.mac->reverse_gc = 0;
2313 }
2314
2315 if (f->output_data.mac->cursor_gc)
2316 {
2317 XFreeGC (dpy, f->output_data.mac->cursor_gc);
2318 f->output_data.mac->cursor_gc = 0;
2319 }
2320
2321 #if 0
2322 if (f->output_data.mac->border_tile)
2323 {
2324 XFreePixmap (dpy, f->output_data.mac->border_tile);
2325 f->output_data.mac->border_tile = 0;
2326 }
2327 #endif
2328
2329 if (f->output_data.mac->white_relief.gc)
2330 {
2331 XFreeGC (dpy, f->output_data.mac->white_relief.gc);
2332 f->output_data.mac->white_relief.gc = 0;
2333 }
2334
2335 if (f->output_data.mac->black_relief.gc)
2336 {
2337 XFreeGC (dpy, f->output_data.mac->black_relief.gc);
2338 f->output_data.mac->black_relief.gc = 0;
2339 }
2340
2341 UNBLOCK_INPUT;
2342 }
2343
2344
2345 /* Handler for signals raised during x_create_frame and
2346 x_create_top_frame. FRAME is the frame which is partially
2347 constructed. */
2348
2349 static Lisp_Object
2350 unwind_create_frame (frame)
2351 Lisp_Object frame;
2352 {
2353 struct frame *f = XFRAME (frame);
2354
2355 /* If frame is ``official'', nothing to do. */
2356 if (!CONSP (Vframe_list) || !EQ (XCAR (Vframe_list), frame))
2357 {
2358 #if GLYPH_DEBUG
2359 struct x_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
2360 #endif
2361
2362 x_free_frame_resources (f);
2363
2364 #if GLYPH_DEBUG
2365 /* Check that reference counts are indeed correct. */
2366 xassert (dpyinfo->reference_count == dpyinfo_refcount);
2367 xassert (dpyinfo->image_cache->refcount == image_cache_refcount);
2368 #endif
2369 return Qt;
2370 }
2371
2372 return Qnil;
2373 }
2374
2375
2376 DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
2377 1, 1, 0,
2378 doc: /* Make a new window, which is called a "frame" in Emacs terms.
2379 Return an Emacs frame object.
2380 PARAMETERS is an alist of frame parameters.
2381 If the parameters specify that the frame should not have a minibuffer,
2382 and do not specify a specific minibuffer window to use,
2383 then `default-minibuffer-frame' must be a frame whose minibuffer can
2384 be shared by the new frame.
2385
2386 This function is an internal primitive--use `make-frame' instead. */)
2387 (parameters)
2388 Lisp_Object parameters;
2389 {
2390 struct frame *f;
2391 Lisp_Object frame, tem;
2392 Lisp_Object name;
2393 int minibuffer_only = 0;
2394 long window_prompting = 0;
2395 int width, height;
2396 int count = SPECPDL_INDEX ();
2397 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
2398 Lisp_Object display;
2399 struct mac_display_info *dpyinfo = NULL;
2400 Lisp_Object parent;
2401 struct kboard *kb;
2402
2403 check_mac ();
2404
2405 parms = Fcopy_alist (parms);
2406
2407 /* Use this general default value to start with
2408 until we know if this frame has a specified name. */
2409 Vx_resource_name = Vinvocation_name;
2410
2411 display = mac_get_arg (parameters, Qdisplay, 0, 0, RES_TYPE_STRING);
2412 if (EQ (display, Qunbound))
2413 display = Qnil;
2414 dpyinfo = check_x_display_info (display);
2415 kb = dpyinfo->terminal->kboard;
2416
2417 name = mac_get_arg (parameters, Qname, "name", "Name", RES_TYPE_STRING);
2418 if (!STRINGP (name)
2419 && ! EQ (name, Qunbound)
2420 && ! NILP (name))
2421 error ("Invalid frame name--not a string or nil");
2422
2423 if (STRINGP (name))
2424 Vx_resource_name = name;
2425
2426 /* See if parent window is specified. */
2427 parent = mac_get_arg (parameters, Qparent_id, NULL, NULL, RES_TYPE_NUMBER);
2428 if (EQ (parent, Qunbound))
2429 parent = Qnil;
2430 if (! NILP (parent))
2431 CHECK_NUMBER (parent);
2432
2433 /* make_frame_without_minibuffer can run Lisp code and garbage collect. */
2434 /* No need to protect DISPLAY because that's not used after passing
2435 it to make_frame_without_minibuffer. */
2436 frame = Qnil;
2437 GCPRO4 (parameters, parent, name, frame);
2438 tem = mac_get_arg (parameters, Qminibuffer, "minibuffer", "Minibuffer",
2439 RES_TYPE_SYMBOL);
2440 if (EQ (tem, Qnone) || NILP (tem))
2441 f = make_frame_without_minibuffer (Qnil, kb, display);
2442 else if (EQ (tem, Qonly))
2443 {
2444 f = make_minibuffer_frame ();
2445 minibuffer_only = 1;
2446 }
2447 else if (WINDOWP (tem))
2448 f = make_frame_without_minibuffer (tem, kb, display);
2449 else
2450 f = make_frame (1);
2451
2452 XSETFRAME (frame, f);
2453
2454 /* Note that X Windows does support scroll bars. */
2455 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
2456
2457 f->terminal = dpyinfo->terminal;
2458 f->terminal->reference_count++;
2459
2460 f->output_method = output_mac;
2461 f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output));
2462 bzero (f->output_data.mac, sizeof (struct mac_output));
2463 FRAME_FONTSET (f) = -1;
2464 record_unwind_protect (unwind_create_frame, frame);
2465
2466 f->icon_name
2467 = mac_get_arg (parameters, Qicon_name, "iconName", "Title", RES_TYPE_STRING);
2468 if (! STRINGP (f->icon_name))
2469 f->icon_name = Qnil;
2470
2471 /* XXX Is this needed? */
2472 /*FRAME_MAC_DISPLAY_INFO (f) = dpyinfo;*/
2473
2474 /* With FRAME_MAC_DISPLAY_INFO set up, this unwind-protect is safe. */
2475 #if GLYPH_DEBUG
2476 image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
2477 dpyinfo_refcount = dpyinfo->reference_count;
2478 #endif /* GLYPH_DEBUG */
2479 FRAME_KBOARD (f) = kb;
2480
2481 /* Specify the parent under which to make this window. */
2482
2483 if (!NILP (parent))
2484 {
2485 f->output_data.mac->parent_desc = (Window) XFASTINT (parent);
2486 f->output_data.mac->explicit_parent = 1;
2487 }
2488 else
2489 {
2490 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
2491 f->output_data.mac->explicit_parent = 0;
2492 }
2493
2494 /* Set the name; the functions to which we pass f expect the name to
2495 be set. */
2496 if (EQ (name, Qunbound) || NILP (name))
2497 {
2498 f->name = build_string (dpyinfo->mac_id_name);
2499 f->explicit_name = 0;
2500 }
2501 else
2502 {
2503 f->name = name;
2504 f->explicit_name = 1;
2505 /* use the frame's title when getting resources for this frame. */
2506 specbind (Qx_resource_name, name);
2507 }
2508
2509 /* Extract the window parameters from the supplied values
2510 that are needed to determine window geometry. */
2511 {
2512 Lisp_Object font;
2513
2514 font = mac_get_arg (parameters, Qfont, "font", "Font", RES_TYPE_STRING);
2515
2516 BLOCK_INPUT;
2517 /* First, try whatever font the caller has specified. */
2518 if (STRINGP (font))
2519 {
2520 tem = Fquery_fontset (font, Qnil);
2521 if (STRINGP (tem))
2522 font = x_new_fontset (f, tem);
2523 else
2524 font = x_new_font (f, SDATA (font));
2525 }
2526 /* Try out a font which we hope has bold and italic variations. */
2527 #if USE_ATSUI
2528 if (! STRINGP (font))
2529 font = x_new_font (f, "-*-monaco-medium-r-normal--12-*-*-*-*-*-iso10646-1");
2530 #endif
2531 if (! STRINGP (font))
2532 font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
2533 /* If those didn't work, look for something which will at least work. */
2534 if (! STRINGP (font))
2535 font = x_new_fontset (f, build_string ("fontset-standard"));
2536 if (! STRINGP (font))
2537 font = x_new_font (f, "-*-monaco-*-12-*-mac-roman");
2538 if (! STRINGP (font))
2539 font = x_new_font (f, "-*-courier-*-10-*-mac-roman");
2540 if (! STRINGP (font))
2541 error ("Cannot find any usable font");
2542 UNBLOCK_INPUT;
2543
2544 x_default_parameter (f, parameters, Qfont, font,
2545 "font", "Font", RES_TYPE_STRING);
2546 }
2547
2548 /* XXX Shouldn't this be borderWidth, not borderwidth ?*/
2549 x_default_parameter (f, parameters, Qborder_width, make_number (0),
2550 "borderwidth", "BorderWidth", RES_TYPE_NUMBER);
2551 /* This defaults to 2 in order to match xterm. We recognize either
2552 internalBorderWidth or internalBorder (which is what xterm calls
2553 it). */
2554 if (NILP (Fassq (Qinternal_border_width, parameters)))
2555 {
2556 Lisp_Object value;
2557
2558 value = mac_get_arg (parameters, Qinternal_border_width,
2559 "internalBorder", "InternalBorder", RES_TYPE_NUMBER);
2560 if (! EQ (value, Qunbound))
2561 parameters = Fcons (Fcons (Qinternal_border_width, value),
2562 parameters);
2563 }
2564 /* Default internalBorderWidth to 0 on Windows to match other programs. */
2565 x_default_parameter (f, parameters, Qinternal_border_width, make_number (0),
2566 "internalBorderWidth", "InternalBorder", RES_TYPE_NUMBER);
2567 x_default_parameter (f, parameters, Qvertical_scroll_bars, Qright,
2568 "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL);
2569
2570 /* Also do the stuff which must be set before the window exists. */
2571 x_default_parameter (f, parameters, Qforeground_color, build_string ("black"),
2572 "foreground", "Foreground", RES_TYPE_STRING);
2573 x_default_parameter (f, parameters, Qbackground_color, build_string ("white"),
2574 "background", "Background", RES_TYPE_STRING);
2575 x_default_parameter (f, parameters, Qmouse_color, build_string ("black"),
2576 "pointerColor", "Foreground", RES_TYPE_STRING);
2577 x_default_parameter (f, parameters, Qcursor_color, build_string ("black"),
2578 "cursorColor", "Foreground", RES_TYPE_STRING);
2579 x_default_parameter (f, parameters, Qborder_color, build_string ("black"),
2580 "borderColor", "BorderColor", RES_TYPE_STRING);
2581 x_default_parameter (f, parameters, Qscreen_gamma, Qnil,
2582 "screenGamma", "ScreenGamma", RES_TYPE_FLOAT);
2583 x_default_parameter (f, parameters, Qline_spacing, Qnil,
2584 "lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
2585 x_default_parameter (f, parameters, Qleft_fringe, Qnil,
2586 "leftFringe", "LeftFringe", RES_TYPE_NUMBER);
2587 x_default_parameter (f, parameters, Qright_fringe, Qnil,
2588 "rightFringe", "RightFringe", RES_TYPE_NUMBER);
2589
2590
2591 /* Init faces before x_default_parameter is called for scroll-bar
2592 parameters because that function calls x_set_scroll_bar_width,
2593 which calls change_frame_size, which calls Fset_window_buffer,
2594 which runs hooks, which call Fvertical_motion. At the end, we
2595 end up in init_iterator with a null face cache, which should not
2596 happen. */
2597 init_frame_faces (f);
2598
2599 x_default_parameter (f, parameters, Qmenu_bar_lines, make_number (1),
2600 "menuBar", "MenuBar", RES_TYPE_NUMBER);
2601 x_default_parameter (f, parameters, Qtool_bar_lines, make_number (1),
2602 "toolBar", "ToolBar", RES_TYPE_NUMBER);
2603
2604 x_default_parameter (f, parameters, Qbuffer_predicate, Qnil,
2605 "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
2606 x_default_parameter (f, parameters, Qtitle, Qnil,
2607 "title", "Title", RES_TYPE_STRING);
2608 x_default_parameter (f, parameters, Qfullscreen, Qnil,
2609 "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
2610
2611 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
2612
2613 /* Compute the size of the window. */
2614 window_prompting = x_figure_window_size (f, parameters, 1);
2615
2616 tem = mac_get_arg (parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
2617 f->no_split = minibuffer_only || EQ (tem, Qt);
2618
2619 mac_window (f);
2620 x_icon (f, parameters);
2621
2622 x_make_gc (f);
2623
2624 /* Now consider the frame official. */
2625 FRAME_MAC_DISPLAY_INFO (f)->reference_count++;
2626 Vframe_list = Fcons (frame, Vframe_list);
2627
2628 /* We need to do this after creating the window, so that the
2629 icon-creation functions can say whose icon they're describing. */
2630 x_default_parameter (f, parameters, Qicon_type, Qnil,
2631 "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
2632
2633 x_default_parameter (f, parameters, Qauto_raise, Qnil,
2634 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
2635 x_default_parameter (f, parameters, Qauto_lower, Qnil,
2636 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
2637 x_default_parameter (f, parameters, Qcursor_type, Qbox,
2638 "cursorType", "CursorType", RES_TYPE_SYMBOL);
2639 x_default_parameter (f, parameters, Qscroll_bar_width, Qnil,
2640 "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER);
2641
2642 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
2643 Change will not be effected unless different from the current
2644 FRAME_LINES (f). */
2645 width = FRAME_COLS (f);
2646 height = FRAME_LINES (f);
2647
2648 FRAME_LINES (f) = 0;
2649 SET_FRAME_COLS (f, 0);
2650 change_frame_size (f, height, width, 1, 0, 0);
2651
2652 /* Tell the server what size and position, etc, we want, and how
2653 badly we want them. This should be done after we have the menu
2654 bar so that its size can be taken into account. */
2655 BLOCK_INPUT;
2656 x_wm_set_size_hint (f, window_prompting, 0);
2657 UNBLOCK_INPUT;
2658
2659 /* Make the window appear on the frame and enable display, unless
2660 the caller says not to. However, with explicit parent, Emacs
2661 cannot control visibility, so don't try. */
2662 if (! f->output_data.mac->explicit_parent)
2663 {
2664 Lisp_Object visibility;
2665
2666 visibility = mac_get_arg (parameters, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
2667 if (EQ (visibility, Qunbound))
2668 visibility = Qt;
2669
2670 if (EQ (visibility, Qicon))
2671 x_iconify_frame (f);
2672 else if (! NILP (visibility))
2673 x_make_frame_visible (f);
2674 else
2675 /* Must have been Qnil. */
2676 ;
2677 }
2678
2679 /* Initialize `default-minibuffer-frame' in case this is the first
2680 frame on this display device. */
2681 if (FRAME_HAS_MINIBUF_P (f)
2682 && (!FRAMEP (kb->Vdefault_minibuffer_frame)
2683 || !FRAME_LIVE_P (XFRAME (kb->Vdefault_minibuffer_frame))))
2684 kb->Vdefault_minibuffer_frame = frame;
2685
2686 /* All remaining specified parameters, which have not been "used"
2687 by x_get_arg and friends, now go in the misc. alist of the frame. */
2688 for (tem = parameters; CONSP (tem); tem = XCDR (tem))
2689 if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
2690 f->param_alist = Fcons (XCAR (tem), f->param_alist);
2691
2692 UNGCPRO;
2693
2694 /* Make sure windows on this frame appear in calls to next-window
2695 and similar functions. */
2696 Vwindow_list = Qnil;
2697
2698 return unbind_to (count, frame);
2699 }
2700
2701
2702 /* FRAME is used only to get a handle on the X display. We don't pass the
2703 display info directly because we're called from frame.c, which doesn't
2704 know about that structure. */
2705
2706 Lisp_Object
2707 x_get_focus_frame (frame)
2708 struct frame *frame;
2709 {
2710 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (frame);
2711 Lisp_Object xfocus;
2712 if (! dpyinfo->x_focus_frame)
2713 return Qnil;
2714
2715 XSETFRAME (xfocus, dpyinfo->x_focus_frame);
2716 return xfocus;
2717 }
2718
2719
2720 DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
2721 doc: /* Set the input focus to FRAME.
2722 FRAME nil means use the selected frame. */)
2723 (frame)
2724 Lisp_Object frame;
2725 {
2726 OSErr err;
2727 ProcessSerialNumber front_psn;
2728 static const ProcessSerialNumber current_psn = {0, kCurrentProcess};
2729 Boolean front_p;
2730 struct frame *f = check_x_frame (frame);
2731
2732 BLOCK_INPUT;
2733 /* Move the current process to the foreground if it is not. Don't
2734 call SetFrontProcess if the current process is already running in
2735 the foreground so as not to change the z-order of windows. */
2736 err = GetFrontProcess (&front_psn);
2737 if (err == noErr)
2738 err = SameProcess (&front_psn, &current_psn, &front_p);
2739 if (err == noErr)
2740 if (!front_p)
2741 {
2742 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
2743 if (mac_front_non_floating_window () == FRAME_MAC_WINDOW (f))
2744 SetFrontProcessWithOptions (&current_psn,
2745 kSetFrontProcessFrontWindowOnly);
2746 else
2747 #endif
2748 SetFrontProcess (&current_psn);
2749 }
2750
2751 #ifdef MAC_OSX
2752 mac_activate_window (mac_active_non_floating_window (), false);
2753 mac_activate_window (FRAME_MAC_WINDOW (f), true);
2754 #else
2755 #if !TARGET_API_MAC_CARBON
2756 /* SelectWindow (Non-Carbon) does not issue deactivate events if the
2757 possibly inactive window that is to be selected is already the
2758 frontmost one. */
2759 SendBehind (FRAME_MAC_WINDOW (f), NULL);
2760 #endif
2761 /* This brings the window to the front. */
2762 SelectWindow (FRAME_MAC_WINDOW (f));
2763 #endif
2764 UNBLOCK_INPUT;
2765
2766 return Qnil;
2767 }
2768
2769 \f
2770 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
2771 doc: /* Internal function called by `color-defined-p', which see. */)
2772 (color, frame)
2773 Lisp_Object color, frame;
2774 {
2775 XColor foo;
2776 FRAME_PTR f = check_x_frame (frame);
2777
2778 CHECK_STRING (color);
2779
2780 if (mac_defined_color (f, SDATA (color), &foo, 0))
2781 return Qt;
2782 else
2783 return Qnil;
2784 }
2785
2786 DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
2787 doc: /* Internal function called by `color-values', which see. */)
2788 (color, frame)
2789 Lisp_Object color, frame;
2790 {
2791 XColor foo;
2792 FRAME_PTR f = check_x_frame (frame);
2793
2794 CHECK_STRING (color);
2795
2796 if (mac_defined_color (f, SDATA (color), &foo, 0))
2797 return list3 (make_number (foo.red),
2798 make_number (foo.green),
2799 make_number (foo.blue));
2800 else
2801 return Qnil;
2802 }
2803
2804 DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
2805 doc: /* Internal function called by `display-color-p', which see. */)
2806 (display)
2807 Lisp_Object display;
2808 {
2809 struct mac_display_info *dpyinfo = check_x_display_info (display);
2810
2811 if (!dpyinfo->color_p)
2812 return Qnil;
2813
2814 return Qt;
2815 }
2816
2817 DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p,
2818 0, 1, 0,
2819 doc: /* Return t if DISPLAY supports shades of gray.
2820 Note that color displays do support shades of gray.
2821 The optional argument DISPLAY specifies which display to ask about.
2822 DISPLAY should be either a frame or a display name (a string).
2823 If omitted or nil, that stands for the selected frame's display. */)
2824 (display)
2825 Lisp_Object display;
2826 {
2827 struct mac_display_info *dpyinfo = check_x_display_info (display);
2828
2829 if (dpyinfo->n_planes <= 1)
2830 return Qnil;
2831
2832 return Qt;
2833 }
2834
2835 DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width,
2836 0, 1, 0,
2837 doc: /* Return the width in pixels of DISPLAY.
2838 The optional argument DISPLAY specifies which display to ask about.
2839 DISPLAY should be either a frame or a display name (a string).
2840 If omitted or nil, that stands for the selected frame's display. */)
2841 (display)
2842 Lisp_Object display;
2843 {
2844 struct mac_display_info *dpyinfo = check_x_display_info (display);
2845
2846 return make_number (dpyinfo->width);
2847 }
2848
2849 DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
2850 Sx_display_pixel_height, 0, 1, 0,
2851 doc: /* Return the height in pixels of DISPLAY.
2852 The optional argument DISPLAY specifies which display to ask about.
2853 DISPLAY should be either a frame or a display name (a string).
2854 If omitted or nil, that stands for the selected frame's display. */)
2855 (display)
2856 Lisp_Object display;
2857 {
2858 struct mac_display_info *dpyinfo = check_x_display_info (display);
2859
2860 return make_number (dpyinfo->height);
2861 }
2862
2863 DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
2864 0, 1, 0,
2865 doc: /* Return the number of bitplanes of DISPLAY.
2866 The optional argument DISPLAY specifies which display to ask about.
2867 DISPLAY should be either a frame or a display name (a string).
2868 If omitted or nil, that stands for the selected frame's display. */)
2869 (display)
2870 Lisp_Object display;
2871 {
2872 struct mac_display_info *dpyinfo = check_x_display_info (display);
2873
2874 return make_number (dpyinfo->n_planes);
2875 }
2876
2877 DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
2878 0, 1, 0,
2879 doc: /* Return the number of color cells of DISPLAY.
2880 The optional argument DISPLAY specifies which display to ask about.
2881 DISPLAY should be either a frame or a display name (a string).
2882 If omitted or nil, that stands for the selected frame's display. */)
2883 (display)
2884 Lisp_Object display;
2885 {
2886 struct mac_display_info *dpyinfo = check_x_display_info (display);
2887
2888 /* We force 24+ bit depths to 24-bit to prevent an overflow. */
2889 return make_number (1 << min (dpyinfo->n_planes, 24));
2890 }
2891
2892 DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
2893 Sx_server_max_request_size,
2894 0, 1, 0,
2895 doc: /* Return the maximum request size of the server of DISPLAY.
2896 The optional argument DISPLAY specifies which display to ask about.
2897 DISPLAY should be either a frame or a display name (a string).
2898 If omitted or nil, that stands for the selected frame's display. */)
2899 (display)
2900 Lisp_Object display;
2901 {
2902 struct mac_display_info *dpyinfo = check_x_display_info (display);
2903
2904 return make_number (1);
2905 }
2906
2907 DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
2908 doc: /* Return the "vendor ID" string of the Mac OS system (Apple).
2909 The optional argument DISPLAY specifies which display to ask about.
2910 DISPLAY should be either a frame or a display name (a string).
2911 If omitted or nil, that stands for the selected frame's display. */)
2912 (display)
2913 Lisp_Object display;
2914 {
2915 return build_string ("Apple Inc.");
2916 }
2917
2918 DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
2919 doc: /* Return the version numbers of the Mac OS system.
2920 The value is a list of three integers: the major and minor
2921 version numbers, and the vendor-specific release
2922 number. See also the function `x-server-vendor'.
2923
2924 The optional argument DISPLAY specifies which display to ask about.
2925 DISPLAY should be either a frame or a display name (a string).
2926 If omitted or nil, that stands for the selected frame's display. */)
2927 (display)
2928 Lisp_Object display;
2929 {
2930 UInt32 response, major, minor, bugfix;
2931 OSErr err;
2932
2933 BLOCK_INPUT;
2934 err = Gestalt (gestaltSystemVersion, &response);
2935 if (err == noErr)
2936 {
2937 if (response >= 0x00001040)
2938 {
2939 err = Gestalt ('sys1', &major);
2940 if (err == noErr)
2941 err = Gestalt ('sys2', &minor);
2942 if (err == noErr)
2943 err = Gestalt ('sys3', &bugfix);
2944 }
2945 else
2946 {
2947 bugfix = response & 0xf;
2948 response >>= 4;
2949 minor = response & 0xf;
2950 response >>= 4;
2951 /* convert BCD to int */
2952 major = response - (response >> 4) * 6;
2953 }
2954 }
2955 UNBLOCK_INPUT;
2956
2957 if (err != noErr)
2958 error ("Cannot get Mac OS version");
2959
2960 return Fcons (make_number (major),
2961 Fcons (make_number (minor),
2962 Fcons (make_number (bugfix),
2963 Qnil)));
2964 }
2965
2966 DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
2967 doc: /* Return the number of screens on the server of DISPLAY.
2968 The optional argument DISPLAY specifies which display to ask about.
2969 DISPLAY should be either a frame or a display name (a string).
2970 If omitted or nil, that stands for the selected frame's display. */)
2971 (display)
2972 Lisp_Object display;
2973 {
2974 return make_number (1);
2975 }
2976
2977 DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0,
2978 doc: /* Return the height in millimeters of DISPLAY.
2979 The optional argument DISPLAY specifies which display to ask about.
2980 DISPLAY should be either a frame or a display name (a string).
2981 If omitted or nil, that stands for the selected frame's display. */)
2982 (display)
2983 Lisp_Object display;
2984 {
2985 struct mac_display_info *dpyinfo = check_x_display_info (display);
2986 float mm_per_pixel;
2987
2988 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
2989 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
2990 if (CGDisplayScreenSize != NULL)
2991 #endif
2992 {
2993 CGSize size;
2994
2995 BLOCK_INPUT;
2996 size = CGDisplayScreenSize (kCGDirectMainDisplay);
2997 mm_per_pixel = size.height / CGDisplayPixelsHigh (kCGDirectMainDisplay);
2998 UNBLOCK_INPUT;
2999 }
3000 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
3001 else /* CGDisplayScreenSize == NULL */
3002 #endif
3003 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
3004 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 || MAC_OS_X_VERSION_MIN_REQUIRED == 1020
3005 {
3006 /* This is an approximation. */
3007 mm_per_pixel = 25.4f / dpyinfo->resy;
3008 }
3009 #endif
3010
3011 return make_number ((int) (dpyinfo->height * mm_per_pixel + 0.5f));
3012 }
3013
3014 DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
3015 doc: /* Return the width in millimeters of DISPLAY.
3016 The optional argument DISPLAY specifies which display to ask about.
3017 DISPLAY should be either a frame or a display name (a string).
3018 If omitted or nil, that stands for the selected frame's display. */)
3019 (display)
3020 Lisp_Object display;
3021 {
3022 struct mac_display_info *dpyinfo = check_x_display_info (display);
3023 float mm_per_pixel;
3024
3025 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
3026 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
3027 if (CGDisplayScreenSize != NULL)
3028 #endif
3029 {
3030 CGSize size;
3031
3032 BLOCK_INPUT;
3033 size = CGDisplayScreenSize (kCGDirectMainDisplay);
3034 mm_per_pixel = size.width / CGDisplayPixelsWide (kCGDirectMainDisplay);
3035 UNBLOCK_INPUT;
3036 }
3037 #if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
3038 else /* CGDisplayScreenSize == NULL */
3039 #endif
3040 #endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
3041 #if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 || MAC_OS_X_VERSION_MIN_REQUIRED == 1020
3042 {
3043 /* This is an approximation. */
3044 mm_per_pixel = 25.4f / dpyinfo->resx;
3045 }
3046 #endif
3047
3048 return make_number ((int) (dpyinfo->width * mm_per_pixel + 0.5f));
3049 }
3050
3051 DEFUN ("x-display-backing-store", Fx_display_backing_store,
3052 Sx_display_backing_store, 0, 1, 0,
3053 doc: /* Return an indication of whether DISPLAY does backing store.
3054 The value may be `always', `when-mapped', or `not-useful'.
3055 The optional argument DISPLAY specifies which display to ask about.
3056 DISPLAY should be either a frame or a display name (a string).
3057 If omitted or nil, that stands for the selected frame's display. */)
3058 (display)
3059 Lisp_Object display;
3060 {
3061 return intern ("not-useful");
3062 }
3063
3064 DEFUN ("x-display-visual-class", Fx_display_visual_class,
3065 Sx_display_visual_class, 0, 1, 0,
3066 doc: /* Return the visual class of DISPLAY.
3067 The value is one of the symbols `static-gray', `gray-scale',
3068 `static-color', `pseudo-color', `true-color', or `direct-color'.
3069
3070 The optional argument DISPLAY specifies which display to ask about.
3071 DISPLAY should be either a frame or a display name (a string).
3072 If omitted or nil, that stands for the selected frame's display. */)
3073 (display)
3074 Lisp_Object display;
3075 {
3076 struct mac_display_info *dpyinfo = check_x_display_info (display);
3077
3078 #if 0
3079 switch (dpyinfo->visual->class)
3080 {
3081 case StaticGray: return (intern ("static-gray"));
3082 case GrayScale: return (intern ("gray-scale"));
3083 case StaticColor: return (intern ("static-color"));
3084 case PseudoColor: return (intern ("pseudo-color"));
3085 case TrueColor: return (intern ("true-color"));
3086 case DirectColor: return (intern ("direct-color"));
3087 default:
3088 error ("Display has an unknown visual class");
3089 }
3090 #endif /* 0 */
3091
3092 return (intern ("true-color"));
3093 }
3094
3095 DEFUN ("x-display-save-under", Fx_display_save_under,
3096 Sx_display_save_under, 0, 1, 0,
3097 doc: /* Return t if DISPLAY supports the save-under feature.
3098 The optional argument DISPLAY specifies which display to ask about.
3099 DISPLAY should be either a frame or a display name (a string).
3100 If omitted or nil, that stands for the selected frame's display. */)
3101 (display)
3102 Lisp_Object display;
3103 {
3104 return Qnil;
3105 }
3106 \f
3107 int
3108 x_pixel_width (f)
3109 register struct frame *f;
3110 {
3111 return FRAME_PIXEL_WIDTH (f);
3112 }
3113
3114 int
3115 x_pixel_height (f)
3116 register struct frame *f;
3117 {
3118 return FRAME_PIXEL_HEIGHT (f);
3119 }
3120
3121 int
3122 x_char_width (f)
3123 register struct frame *f;
3124 {
3125 return FRAME_COLUMN_WIDTH (f);
3126 }
3127
3128 int
3129 x_char_height (f)
3130 register struct frame *f;
3131 {
3132 return FRAME_LINE_HEIGHT (f);
3133 }
3134
3135 int
3136 x_screen_planes (f)
3137 register struct frame *f;
3138 {
3139 return FRAME_MAC_DISPLAY_INFO (f)->n_planes;
3140 }
3141 \f
3142 /* Return the display structure for the display named NAME.
3143 Open a new connection if necessary. */
3144
3145 struct mac_display_info *
3146 x_display_info_for_name (name)
3147 Lisp_Object name;
3148 {
3149 Lisp_Object names;
3150 struct mac_display_info *dpyinfo;
3151
3152 CHECK_STRING (name);
3153
3154 for (dpyinfo = &one_mac_display_info, names = x_display_name_list;
3155 dpyinfo;
3156 dpyinfo = dpyinfo->next, names = XCDR (names))
3157 {
3158 Lisp_Object tem;
3159 tem = Fstring_equal (XCAR (XCAR (names)), name);
3160 if (!NILP (tem))
3161 return dpyinfo;
3162 }
3163
3164 /* Use this general default value to start with. */
3165 Vx_resource_name = Vinvocation_name;
3166
3167 validate_x_resource_name ();
3168
3169 dpyinfo = mac_term_init (name, (unsigned char *) 0,
3170 (char *) SDATA (Vx_resource_name));
3171
3172 if (dpyinfo == 0)
3173 error ("Cannot connect to server %s", SDATA (name));
3174
3175 mac_in_use = 1;
3176 XSETFASTINT (Vwindow_system_version, 3);
3177
3178 return dpyinfo;
3179 }
3180
3181 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
3182 1, 3, 0,
3183 doc: /* Open a connection to a server.
3184 DISPLAY is the name of the display to connect to.
3185 Optional second arg XRM-STRING is a string of resources in xrdb format.
3186 If the optional third arg MUST-SUCCEED is non-nil,
3187 terminate Emacs if we can't open the connection. */)
3188 (display, xrm_string, must_succeed)
3189 Lisp_Object display, xrm_string, must_succeed;
3190 {
3191 unsigned char *xrm_option;
3192 struct mac_display_info *dpyinfo;
3193
3194 CHECK_STRING (display);
3195 if (! NILP (xrm_string))
3196 CHECK_STRING (xrm_string);
3197
3198 if (! NILP (xrm_string))
3199 xrm_option = (unsigned char *) SDATA (xrm_string);
3200 else
3201 xrm_option = (unsigned char *) 0;
3202
3203 validate_x_resource_name ();
3204
3205 /* This is what opens the connection and sets x_current_display.
3206 This also initializes many symbols, such as those used for input. */
3207 dpyinfo = mac_term_init (display, xrm_option,
3208 (char *) SDATA (Vx_resource_name));
3209
3210 if (dpyinfo == 0)
3211 {
3212 if (!NILP (must_succeed))
3213 fatal ("Cannot connect to server %s.\n",
3214 SDATA (display));
3215 else
3216 error ("Cannot connect to server %s", SDATA (display));
3217 }
3218
3219 mac_in_use = 1;
3220
3221 XSETFASTINT (Vwindow_system_version, 3);
3222 return Qnil;
3223 }
3224
3225 DEFUN ("x-close-connection", Fx_close_connection,
3226 Sx_close_connection, 1, 1, 0,
3227 doc: /* Close the connection to DISPLAY's server.
3228 For DISPLAY, specify either a frame or a display name (a string).
3229 If DISPLAY is nil, that stands for the selected frame's display. */)
3230 (display)
3231 Lisp_Object display;
3232 {
3233 struct mac_display_info *dpyinfo = check_x_display_info (display);
3234 int i;
3235
3236 if (dpyinfo->reference_count > 0)
3237 error ("Display still has frames on it");
3238
3239 BLOCK_INPUT;
3240 /* Free the fonts in the font table. */
3241 for (i = 0; i < dpyinfo->n_fonts; i++)
3242 if (dpyinfo->font_table[i].name)
3243 {
3244 mac_unload_font (dpyinfo, dpyinfo->font_table[i].font);
3245 }
3246
3247 x_destroy_all_bitmaps (dpyinfo);
3248
3249 x_delete_display (dpyinfo);
3250 UNBLOCK_INPUT;
3251
3252 return Qnil;
3253 }
3254
3255 DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
3256 doc: /* Return the list of display names that Emacs has connections to. */)
3257 ()
3258 {
3259 Lisp_Object tail, result;
3260
3261 result = Qnil;
3262 for (tail = x_display_name_list; CONSP (tail); tail = XCDR (tail))
3263 result = Fcons (XCAR (XCAR (tail)), result);
3264
3265 return result;
3266 }
3267
3268 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0,
3269 doc: /* This is a noop on Mac OS systems. */)
3270 (on, display)
3271 Lisp_Object display, on;
3272 {
3273 return Qnil;
3274 }
3275
3276 /* x_sync is a no-op on Mac. */
3277
3278 void
3279 x_sync (f)
3280 FRAME_PTR f;
3281 {
3282 }
3283
3284 \f
3285 /***********************************************************************
3286 Window properties
3287 ***********************************************************************/
3288
3289 DEFUN ("x-change-window-property", Fx_change_window_property,
3290 Sx_change_window_property, 2, 6, 0,
3291 doc: /* Change window property PROP to VALUE on the X window of FRAME.
3292 VALUE may be a string or a list of conses, numbers and/or strings.
3293 If an element in the list is a string, it is converted to
3294 an Atom and the value of the Atom is used. If an element is a cons,
3295 it is converted to a 32 bit number where the car is the 16 top bits and the
3296 cdr is the lower 16 bits.
3297 FRAME nil or omitted means use the selected frame.
3298 If TYPE is given and non-nil, it is the name of the type of VALUE.
3299 If TYPE is not given or nil, the type is STRING.
3300 FORMAT gives the size in bits of each element if VALUE is a list.
3301 It must be one of 8, 16 or 32.
3302 If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
3303 If OUTER_P is non-nil, the property is changed for the outer X window of
3304 FRAME. Default is to change on the edit X window.
3305
3306 Value is VALUE. */)
3307 (prop, value, frame, type, format, outer_p)
3308 Lisp_Object prop, value, frame, type, format, outer_p;
3309 {
3310 #if 0 /* MAC_TODO : port window properties to Mac */
3311 struct frame *f = check_x_frame (frame);
3312 Atom prop_atom;
3313
3314 CHECK_STRING (prop);
3315 CHECK_STRING (value);
3316
3317 BLOCK_INPUT;
3318 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
3319 XChangeProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
3320 prop_atom, XA_STRING, 8, PropModeReplace,
3321 SDATA (value), SCHARS (value));
3322
3323 /* Make sure the property is set when we return. */
3324 XFlush (FRAME_W32_DISPLAY (f));
3325 UNBLOCK_INPUT;
3326
3327 #endif /* MAC_TODO */
3328
3329 return value;
3330 }
3331
3332
3333 DEFUN ("x-delete-window-property", Fx_delete_window_property,
3334 Sx_delete_window_property, 1, 2, 0,
3335 doc: /* Remove window property PROP from X window of FRAME.
3336 FRAME nil or omitted means use the selected frame. Value is PROP. */)
3337 (prop, frame)
3338 Lisp_Object prop, frame;
3339 {
3340 #if 0 /* MAC_TODO : port window properties to Mac */
3341
3342 struct frame *f = check_x_frame (frame);
3343 Atom prop_atom;
3344
3345 CHECK_STRING (prop);
3346 BLOCK_INPUT;
3347 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
3348 XDeleteProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), prop_atom);
3349
3350 /* Make sure the property is removed when we return. */
3351 XFlush (FRAME_W32_DISPLAY (f));
3352 UNBLOCK_INPUT;
3353 #endif /* MAC_TODO */
3354
3355 return prop;
3356 }
3357
3358
3359 DEFUN ("x-window-property", Fx_window_property, Sx_window_property,
3360 1, 2, 0,
3361 doc: /* Value is the value of window property PROP on FRAME.
3362 If FRAME is nil or omitted, use the selected frame. Value is nil
3363 if FRAME hasn't a property with name PROP or if PROP has no string
3364 value. */)
3365 (prop, frame)
3366 Lisp_Object prop, frame;
3367 {
3368 #if 0 /* MAC_TODO : port window properties to Mac */
3369
3370 struct frame *f = check_x_frame (frame);
3371 Atom prop_atom;
3372 int rc;
3373 Lisp_Object prop_value = Qnil;
3374 char *tmp_data = NULL;
3375 Atom actual_type;
3376 int actual_format;
3377 unsigned long actual_size, bytes_remaining;
3378
3379 CHECK_STRING (prop);
3380 BLOCK_INPUT;
3381 prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
3382 rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
3383 prop_atom, 0, 0, False, XA_STRING,
3384 &actual_type, &actual_format, &actual_size,
3385 &bytes_remaining, (unsigned char **) &tmp_data);
3386 if (rc == Success)
3387 {
3388 int size = bytes_remaining;
3389
3390 XFree (tmp_data);
3391 tmp_data = NULL;
3392
3393 rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
3394 prop_atom, 0, bytes_remaining,
3395 False, XA_STRING,
3396 &actual_type, &actual_format,
3397 &actual_size, &bytes_remaining,
3398 (unsigned char **) &tmp_data);
3399 if (rc == Success)
3400 prop_value = make_string (tmp_data, size);
3401
3402 XFree (tmp_data);
3403 }
3404
3405 UNBLOCK_INPUT;
3406
3407 return prop_value;
3408
3409 #endif /* MAC_TODO */
3410 return Qnil;
3411 }
3412
3413
3414 \f
3415 /***********************************************************************
3416 Busy cursor
3417 ***********************************************************************/
3418
3419 /* Timer function of hourglass_atimer. TIMER is equal to
3420 hourglass_atimer.
3421
3422 On Mac, busy status is shown by the progress indicator (chasing
3423 arrows) at the upper-right corner of each frame instead of the
3424 hourglass pointer. */
3425
3426 void
3427 show_hourglass (timer)
3428 struct atimer *timer;
3429 {
3430 #if TARGET_API_MAC_CARBON
3431 /* The timer implementation will cancel this timer automatically
3432 after this function has run. Set hourglass_atimer to null
3433 so that we know the timer doesn't have to be canceled. */
3434 hourglass_atimer = NULL;
3435
3436 if (!hourglass_shown_p)
3437 {
3438 Lisp_Object rest, frame;
3439
3440 BLOCK_INPUT;
3441
3442 FOR_EACH_FRAME (rest, frame)
3443 {
3444 struct frame *f = XFRAME (frame);
3445
3446 if (FRAME_LIVE_P (f) && FRAME_MAC_P (f)
3447 && FRAME_MAC_WINDOW (f) != tip_window)
3448 mac_show_hourglass (f);
3449 }
3450
3451 hourglass_shown_p = 1;
3452 UNBLOCK_INPUT;
3453 }
3454 #endif /* TARGET_API_MAC_CARBON */
3455 }
3456
3457
3458 /* Hide the progress indicators on all frames, if it is currently
3459 shown. */
3460
3461 void
3462 hide_hourglass ()
3463 {
3464 #if TARGET_API_MAC_CARBON
3465 if (hourglass_shown_p)
3466 {
3467 Lisp_Object rest, frame;
3468
3469 BLOCK_INPUT;
3470 FOR_EACH_FRAME (rest, frame)
3471 {
3472 struct frame *f = XFRAME (frame);
3473
3474 if (FRAME_MAC_P (f))
3475 mac_hide_hourglass (f);
3476 }
3477
3478 hourglass_shown_p = 0;
3479 UNBLOCK_INPUT;
3480 }
3481 #endif /* TARGET_API_MAC_CARBON */
3482 }
3483
3484
3485 \f
3486 /***********************************************************************
3487 Tool tips
3488 ***********************************************************************/
3489
3490 static Lisp_Object x_create_tip_frame P_ ((struct mac_display_info *,
3491 Lisp_Object, Lisp_Object));
3492 static void compute_tip_xy P_ ((struct frame *, Lisp_Object, Lisp_Object,
3493 Lisp_Object, int, int, int *, int *));
3494
3495 /* The frame of a currently visible tooltip. */
3496
3497 Lisp_Object tip_frame;
3498
3499 /* If non-nil, a timer started that hides the last tooltip when it
3500 fires. */
3501
3502 Lisp_Object tip_timer;
3503 Window tip_window;
3504
3505 /* If non-nil, a vector of 3 elements containing the last args
3506 with which x-show-tip was called. See there. */
3507
3508 Lisp_Object last_show_tip_args;
3509
3510 /* Maximum size for tooltips; a cons (COLUMNS . ROWS). */
3511
3512 Lisp_Object Vx_max_tooltip_size;
3513
3514
3515 static Lisp_Object
3516 unwind_create_tip_frame (frame)
3517 Lisp_Object frame;
3518 {
3519 Lisp_Object deleted;
3520
3521 deleted = unwind_create_frame (frame);
3522 if (EQ (deleted, Qt))
3523 {
3524 tip_window = NULL;
3525 tip_frame = Qnil;
3526 }
3527
3528 return deleted;
3529 }
3530
3531
3532 /* Create a frame for a tooltip on the display described by DPYINFO.
3533 PARMS is a list of frame parameters. TEXT is the string to
3534 display in the tip frame. Value is the frame.
3535
3536 Note that functions called here, esp. x_default_parameter can
3537 signal errors, for instance when a specified color name is
3538 undefined. We have to make sure that we're in a consistent state
3539 when this happens. */
3540
3541 static Lisp_Object
3542 x_create_tip_frame (dpyinfo, parms, text)
3543 struct mac_display_info *dpyinfo;
3544 Lisp_Object parms, text;
3545 {
3546 struct frame *f;
3547 Lisp_Object frame, tem;
3548 Lisp_Object name;
3549 long window_prompting = 0;
3550 int width, height;
3551 int count = SPECPDL_INDEX ();
3552 struct gcpro gcpro1, gcpro2, gcpro3;
3553 struct kboard *kb;
3554 int face_change_count_before = face_change_count;
3555 Lisp_Object buffer;
3556 struct buffer *old_buffer;
3557
3558 check_mac ();
3559
3560 parms = Fcopy_alist (parms);
3561
3562 kb = dpyinfo->terminal->kboard;
3563
3564 /* Get the name of the frame to use for resource lookup. */
3565 name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING);
3566 if (!STRINGP (name)
3567 && !EQ (name, Qunbound)
3568 && !NILP (name))
3569 error ("Invalid frame name--not a string or nil");
3570
3571 frame = Qnil;
3572 GCPRO3 (parms, name, frame);
3573 f = make_frame (1);
3574 XSETFRAME (frame, f);
3575
3576 buffer = Fget_buffer_create (build_string (" *tip*"));
3577 Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
3578 old_buffer = current_buffer;
3579 set_buffer_internal_1 (XBUFFER (buffer));
3580 current_buffer->truncate_lines = Qnil;
3581 specbind (Qinhibit_read_only, Qt);
3582 specbind (Qinhibit_modification_hooks, Qt);
3583 Ferase_buffer ();
3584 Finsert (1, &text);
3585 set_buffer_internal_1 (old_buffer);
3586
3587 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0;
3588 record_unwind_protect (unwind_create_tip_frame, frame);
3589
3590 /* By setting the output method, we're essentially saying that
3591 the frame is live, as per FRAME_LIVE_P. If we get a signal
3592 from this point on, x_destroy_window might screw up reference
3593 counts etc. */
3594 f->terminal = dpyinfo->terminal;
3595 f->terminal->reference_count++;
3596 f->output_method = output_mac;
3597 f->output_data.mac =
3598 (struct mac_output *) xmalloc (sizeof (struct mac_output));
3599 bzero (f->output_data.mac, sizeof (struct mac_output));
3600
3601 FRAME_FONTSET (f) = -1;
3602 f->icon_name = Qnil;
3603 /* FRAME_X_DISPLAY_INFO (f) = dpyinfo; */
3604 #if GLYPH_DEBUG
3605 image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount;
3606 dpyinfo_refcount = dpyinfo->reference_count;
3607 #endif /* GLYPH_DEBUG */
3608 FRAME_KBOARD (f) = kb;
3609 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
3610 f->output_data.mac->explicit_parent = 0;
3611
3612 /* Set the name; the functions to which we pass f expect the name to
3613 be set. */
3614 if (EQ (name, Qunbound) || NILP (name))
3615 {
3616 f->name = build_string (dpyinfo->mac_id_name);
3617 f->explicit_name = 0;
3618 }
3619 else
3620 {
3621 f->name = name;
3622 f->explicit_name = 1;
3623 /* use the frame's title when getting resources for this frame. */
3624 specbind (Qx_resource_name, name);
3625 }
3626
3627 /* Extract the window parameters from the supplied values that are
3628 needed to determine window geometry. */
3629 {
3630 Lisp_Object font;
3631
3632 font = mac_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING);
3633
3634 BLOCK_INPUT;
3635 /* First, try whatever font the caller has specified. */
3636 if (STRINGP (font))
3637 {
3638 tem = Fquery_fontset (font, Qnil);
3639 if (STRINGP (tem))
3640 font = x_new_fontset (f, tem);
3641 else
3642 font = x_new_font (f, SDATA (font));
3643 }
3644
3645 /* Try out a font which we hope has bold and italic variations. */
3646 #if USE_ATSUI
3647 if (! STRINGP (font))
3648 font = x_new_font (f, "-*-monaco-medium-r-normal--12-*-*-*-*-*-iso10646-1");
3649 #endif
3650 if (! STRINGP (font))
3651 font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1");
3652 /* If those didn't work, look for something which will at least work. */
3653 if (! STRINGP (font))
3654 font = x_new_fontset (f, build_string ("fontset-standard"));
3655 if (! STRINGP (font))
3656 font = x_new_font (f, "-*-monaco-*-12-*-mac-roman");
3657 if (! STRINGP (font))
3658 font = x_new_font (f, "-*-courier-*-10-*-mac-roman");
3659 UNBLOCK_INPUT;
3660 if (! STRINGP (font))
3661 error ("Cannot find any usable font");
3662
3663 x_default_parameter (f, parms, Qfont, font,
3664 "font", "Font", RES_TYPE_STRING);
3665 }
3666
3667 x_default_parameter (f, parms, Qborder_width, make_number (2),
3668 "borderWidth", "BorderWidth", RES_TYPE_NUMBER);
3669
3670 /* This defaults to 2 in order to match xterm. We recognize either
3671 internalBorderWidth or internalBorder (which is what xterm calls
3672 it). */
3673 if (NILP (Fassq (Qinternal_border_width, parms)))
3674 {
3675 Lisp_Object value;
3676
3677 value = mac_get_arg (parms, Qinternal_border_width,
3678 "internalBorder", "internalBorder", RES_TYPE_NUMBER);
3679 if (! EQ (value, Qunbound))
3680 parms = Fcons (Fcons (Qinternal_border_width, value),
3681 parms);
3682 }
3683
3684 x_default_parameter (f, parms, Qinternal_border_width, make_number (1),
3685 "internalBorderWidth", "internalBorderWidth",
3686 RES_TYPE_NUMBER);
3687
3688 /* Also do the stuff which must be set before the window exists. */
3689 x_default_parameter (f, parms, Qforeground_color, build_string ("black"),
3690 "foreground", "Foreground", RES_TYPE_STRING);
3691 x_default_parameter (f, parms, Qbackground_color, build_string ("white"),
3692 "background", "Background", RES_TYPE_STRING);
3693 x_default_parameter (f, parms, Qmouse_color, build_string ("black"),
3694 "pointerColor", "Foreground", RES_TYPE_STRING);
3695 x_default_parameter (f, parms, Qcursor_color, build_string ("black"),
3696 "cursorColor", "Foreground", RES_TYPE_STRING);
3697 x_default_parameter (f, parms, Qborder_color, build_string ("black"),
3698 "borderColor", "BorderColor", RES_TYPE_STRING);
3699
3700 /* Init faces before x_default_parameter is called for scroll-bar
3701 parameters because that function calls x_set_scroll_bar_width,
3702 which calls change_frame_size, which calls Fset_window_buffer,
3703 which runs hooks, which call Fvertical_motion. At the end, we
3704 end up in init_iterator with a null face cache, which should not
3705 happen. */
3706 init_frame_faces (f);
3707
3708 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
3709
3710 window_prompting = x_figure_window_size (f, parms, 0);
3711
3712 BLOCK_INPUT;
3713
3714 mac_create_frame_window (f, 1);
3715
3716 if (FRAME_MAC_WINDOW (f))
3717 {
3718 mac_set_frame_window_background (f, FRAME_BACKGROUND_PIXEL (f));
3719 tip_window = FRAME_MAC_WINDOW (f);
3720 }
3721
3722 UNBLOCK_INPUT;
3723
3724 x_make_gc (f);
3725
3726 x_default_parameter (f, parms, Qauto_raise, Qnil,
3727 "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
3728 x_default_parameter (f, parms, Qauto_lower, Qnil,
3729 "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN);
3730 x_default_parameter (f, parms, Qcursor_type, Qbox,
3731 "cursorType", "CursorType", RES_TYPE_SYMBOL);
3732
3733 /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size.
3734 Change will not be effected unless different from the current
3735 FRAME_LINES (f). */
3736 width = FRAME_COLS (f);
3737 height = FRAME_LINES (f);
3738 SET_FRAME_COLS (f, 0);
3739 FRAME_LINES (f) = 0;
3740 change_frame_size (f, height, width, 1, 0, 0);
3741
3742 /* Add `tooltip' frame parameter's default value. */
3743 if (NILP (Fframe_parameter (frame, intern ("tooltip"))))
3744 Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
3745 Qnil));
3746
3747 /* Set up faces after all frame parameters are known. This call
3748 also merges in face attributes specified for new frames.
3749
3750 Frame parameters may be changed if .Xdefaults contains
3751 specifications for the default font. For example, if there is an
3752 `Emacs.default.attributeBackground: pink', the `background-color'
3753 attribute of the frame get's set, which let's the internal border
3754 of the tooltip frame appear in pink. Prevent this. */
3755 {
3756 Lisp_Object bg = Fframe_parameter (frame, Qbackground_color);
3757
3758 /* Set tip_frame here, so that */
3759 tip_frame = frame;
3760 call2 (Qface_set_after_frame_default, frame, Qnil);
3761
3762 if (!EQ (bg, Fframe_parameter (frame, Qbackground_color)))
3763 Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg),
3764 Qnil));
3765 }
3766
3767 f->no_split = 1;
3768
3769 UNGCPRO;
3770
3771 /* It is now ok to make the frame official even if we get an error
3772 below. And the frame needs to be on Vframe_list or making it
3773 visible won't work. */
3774 Vframe_list = Fcons (frame, Vframe_list);
3775
3776 /* Now that the frame is official, it counts as a reference to
3777 its display. */
3778 FRAME_MAC_DISPLAY_INFO (f)->reference_count++;
3779
3780 /* Setting attributes of faces of the tooltip frame from resources
3781 and similar will increment face_change_count, which leads to the
3782 clearing of all current matrices. Since this isn't necessary
3783 here, avoid it by resetting face_change_count to the value it
3784 had before we created the tip frame. */
3785 face_change_count = face_change_count_before;
3786
3787 /* Discard the unwind_protect. */
3788 return unbind_to (count, frame);
3789 }
3790
3791
3792 /* Compute where to display tip frame F. PARMS is the list of frame
3793 parameters for F. DX and DY are specified offsets from the current
3794 location of the mouse. WIDTH and HEIGHT are the width and height
3795 of the tooltip. Return coordinates relative to the root window of
3796 the display in *ROOT_X, and *ROOT_Y. */
3797
3798 static void
3799 compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y)
3800 struct frame *f;
3801 Lisp_Object parms, dx, dy;
3802 int width, height;
3803 int *root_x, *root_y;
3804 {
3805 Lisp_Object left, top;
3806
3807 /* User-specified position? */
3808 left = Fcdr (Fassq (Qleft, parms));
3809 top = Fcdr (Fassq (Qtop, parms));
3810
3811 /* Move the tooltip window where the mouse pointer is. Resize and
3812 show it. */
3813 if (!INTEGERP (left) || !INTEGERP (top))
3814 {
3815 Point mouse_pos;
3816
3817 BLOCK_INPUT;
3818 #if TARGET_API_MAC_CARBON
3819 mac_get_global_mouse (&mouse_pos);
3820 #else
3821 GetMouse (&mouse_pos);
3822 LocalToGlobal (&mouse_pos);
3823 #endif
3824 *root_x = mouse_pos.h;
3825 *root_y = mouse_pos.v;
3826 UNBLOCK_INPUT;
3827 }
3828
3829 if (INTEGERP (top))
3830 *root_y = XINT (top);
3831 else if (*root_y + XINT (dy) <= 0)
3832 *root_y = 0; /* Can happen for negative dy */
3833 else if (*root_y + XINT (dy) + height <= FRAME_MAC_DISPLAY_INFO (f)->height)
3834 /* It fits below the pointer */
3835 *root_y += XINT (dy);
3836 else if (height + XINT (dy) <= *root_y)
3837 /* It fits above the pointer. */
3838 *root_y -= height + XINT (dy);
3839 else
3840 /* Put it on the top. */
3841 *root_y = 0;
3842
3843 if (INTEGERP (left))
3844 *root_x = XINT (left);
3845 else if (*root_x + XINT (dx) <= 0)
3846 *root_x = 0; /* Can happen for negative dx */
3847 else if (*root_x + XINT (dx) + width <= FRAME_MAC_DISPLAY_INFO (f)->width)
3848 /* It fits to the right of the pointer. */
3849 *root_x += XINT (dx);
3850 else if (width + XINT (dx) <= *root_x)
3851 /* It fits to the left of the pointer. */
3852 *root_x -= width + XINT (dx);
3853 else
3854 /* Put it left-justified on the screen -- it ought to fit that way. */
3855 *root_x = 0;
3856 }
3857
3858
3859 DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0,
3860 doc: /* Show STRING in a "tooltip" window on frame FRAME.
3861 A tooltip window is a small window displaying a string.
3862
3863 This is an internal function; Lisp code should call `tooltip-show'.
3864
3865 FRAME nil or omitted means use the selected frame.
3866
3867 PARMS is an optional list of frame parameters which can be used to
3868 change the tooltip's appearance.
3869
3870 Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil
3871 means use the default timeout of 5 seconds.
3872
3873 If the list of frame parameters PARMS contains a `left' parameter,
3874 the tooltip is displayed at that x-position. Otherwise it is
3875 displayed at the mouse position, with offset DX added (default is 5 if
3876 DX isn't specified). Likewise for the y-position; if a `top' frame
3877 parameter is specified, it determines the y-position of the tooltip
3878 window, otherwise it is displayed at the mouse position, with offset
3879 DY added (default is -10).
3880
3881 A tooltip's maximum size is specified by `x-max-tooltip-size'.
3882 Text larger than the specified size is clipped. */)
3883 (string, frame, parms, timeout, dx, dy)
3884 Lisp_Object string, frame, parms, timeout, dx, dy;
3885 {
3886 struct frame *f;
3887 struct window *w;
3888 int root_x, root_y;
3889 struct buffer *old_buffer;
3890 struct text_pos pos;
3891 int i, width, height;
3892 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
3893 int old_windows_or_buffers_changed = windows_or_buffers_changed;
3894 int count = SPECPDL_INDEX ();
3895
3896 specbind (Qinhibit_redisplay, Qt);
3897
3898 GCPRO4 (string, parms, frame, timeout);
3899
3900 CHECK_STRING (string);
3901 f = check_x_frame (frame);
3902 if (NILP (timeout))
3903 timeout = make_number (5);
3904 else
3905 CHECK_NATNUM (timeout);
3906
3907 if (NILP (dx))
3908 dx = make_number (5);
3909 else
3910 CHECK_NUMBER (dx);
3911
3912 if (NILP (dy))
3913 dy = make_number (-10);
3914 else
3915 CHECK_NUMBER (dy);
3916
3917 if (NILP (last_show_tip_args))
3918 last_show_tip_args = Fmake_vector (make_number (3), Qnil);
3919
3920 if (!NILP (tip_frame))
3921 {
3922 Lisp_Object last_string = AREF (last_show_tip_args, 0);
3923 Lisp_Object last_frame = AREF (last_show_tip_args, 1);
3924 Lisp_Object last_parms = AREF (last_show_tip_args, 2);
3925
3926 if (EQ (frame, last_frame)
3927 && !NILP (Fequal (last_string, string))
3928 && !NILP (Fequal (last_parms, parms)))
3929 {
3930 struct frame *f = XFRAME (tip_frame);
3931
3932 /* Only DX and DY have changed. */
3933 if (!NILP (tip_timer))
3934 {
3935 Lisp_Object timer = tip_timer;
3936 tip_timer = Qnil;
3937 call1 (Qcancel_timer, timer);
3938 }
3939
3940 BLOCK_INPUT;
3941 compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f),
3942 FRAME_PIXEL_HEIGHT (f), &root_x, &root_y);
3943 mac_move_window (FRAME_MAC_WINDOW (f), root_x, root_y, false);
3944 UNBLOCK_INPUT;
3945 goto start_timer;
3946 }
3947 }
3948
3949 /* Hide a previous tip, if any. */
3950 Fx_hide_tip ();
3951
3952 ASET (last_show_tip_args, 0, string);
3953 ASET (last_show_tip_args, 1, frame);
3954 ASET (last_show_tip_args, 2, parms);
3955
3956 /* Add default values to frame parameters. */
3957 if (NILP (Fassq (Qname, parms)))
3958 parms = Fcons (Fcons (Qname, build_string ("tooltip")), parms);
3959 if (NILP (Fassq (Qinternal_border_width, parms)))
3960 parms = Fcons (Fcons (Qinternal_border_width, make_number (3)), parms);
3961 if (NILP (Fassq (Qborder_width, parms)))
3962 parms = Fcons (Fcons (Qborder_width, make_number (1)), parms);
3963 if (NILP (Fassq (Qborder_color, parms)))
3964 parms = Fcons (Fcons (Qborder_color, build_string ("lightyellow")), parms);
3965 if (NILP (Fassq (Qbackground_color, parms)))
3966 parms = Fcons (Fcons (Qbackground_color, build_string ("lightyellow")),
3967 parms);
3968
3969 /* Create a frame for the tooltip, and record it in the global
3970 variable tip_frame. */
3971 frame = x_create_tip_frame (FRAME_MAC_DISPLAY_INFO (f), parms, string);
3972 f = XFRAME (frame);
3973
3974 /* Set up the frame's root window. */
3975 w = XWINDOW (FRAME_ROOT_WINDOW (f));
3976 w->left_col = w->top_line = make_number (0);
3977
3978 if (CONSP (Vx_max_tooltip_size)
3979 && INTEGERP (XCAR (Vx_max_tooltip_size))
3980 && XINT (XCAR (Vx_max_tooltip_size)) > 0
3981 && INTEGERP (XCDR (Vx_max_tooltip_size))
3982 && XINT (XCDR (Vx_max_tooltip_size)) > 0)
3983 {
3984 w->total_cols = XCAR (Vx_max_tooltip_size);
3985 w->total_lines = XCDR (Vx_max_tooltip_size);
3986 }
3987 else
3988 {
3989 w->total_cols = make_number (80);
3990 w->total_lines = make_number (40);
3991 }
3992
3993 FRAME_TOTAL_COLS (f) = XINT (w->total_cols);
3994 adjust_glyphs (f);
3995 w->pseudo_window_p = 1;
3996
3997 /* Display the tooltip text in a temporary buffer. */
3998 old_buffer = current_buffer;
3999 set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer));
4000 current_buffer->truncate_lines = Qnil;
4001 clear_glyph_matrix (w->desired_matrix);
4002 clear_glyph_matrix (w->current_matrix);
4003 SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
4004 try_window (FRAME_ROOT_WINDOW (f), pos, 0);
4005
4006 /* Compute width and height of the tooltip. */
4007 width = height = 0;
4008 for (i = 0; i < w->desired_matrix->nrows; ++i)
4009 {
4010 struct glyph_row *row = &w->desired_matrix->rows[i];
4011 struct glyph *last;
4012 int row_width;
4013
4014 /* Stop at the first empty row at the end. */
4015 if (!row->enabled_p || !row->displays_text_p)
4016 break;
4017
4018 /* Let the row go over the full width of the frame. */
4019 row->full_width_p = 1;
4020
4021 /* There's a glyph at the end of rows that is used to place
4022 the cursor there. Don't include the width of this glyph. */
4023 if (row->used[TEXT_AREA])
4024 {
4025 last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
4026 row_width = row->pixel_width - last->pixel_width;
4027 }
4028 else
4029 row_width = row->pixel_width;
4030
4031 height += row->height;
4032 width = max (width, row_width);
4033 }
4034
4035 /* Add the frame's internal border to the width and height the X
4036 window should have. */
4037 height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
4038 width += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
4039
4040 /* Move the tooltip window where the mouse pointer is. Resize and
4041 show it. */
4042 compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
4043
4044 BLOCK_INPUT;
4045 mac_move_window (FRAME_MAC_WINDOW (f), root_x, root_y, false);
4046 mac_size_window (FRAME_MAC_WINDOW (f), width, height, true);
4047 mac_show_window (FRAME_MAC_WINDOW (f));
4048 mac_bring_window_to_front (FRAME_MAC_WINDOW (f));
4049 UNBLOCK_INPUT;
4050
4051 FRAME_PIXEL_WIDTH (f) = width;
4052 FRAME_PIXEL_HEIGHT (f) = height;
4053
4054 /* Draw into the window. */
4055 w->must_be_updated_p = 1;
4056 update_single_window (w, 1);
4057
4058 /* Restore original current buffer. */
4059 set_buffer_internal_1 (old_buffer);
4060 windows_or_buffers_changed = old_windows_or_buffers_changed;
4061
4062 start_timer:
4063 /* Let the tip disappear after timeout seconds. */
4064 tip_timer = call3 (intern ("run-at-time"), timeout, Qnil,
4065 intern ("x-hide-tip"));
4066
4067 UNGCPRO;
4068 return unbind_to (count, Qnil);
4069 }
4070
4071
4072 DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
4073 doc: /* Hide the current tooltip window, if there is any.
4074 Value is t if tooltip was open, nil otherwise. */)
4075 ()
4076 {
4077 int count;
4078 Lisp_Object deleted, frame, timer;
4079 struct gcpro gcpro1, gcpro2;
4080
4081 /* Return quickly if nothing to do. */
4082 if (NILP (tip_timer) && NILP (tip_frame))
4083 return Qnil;
4084
4085 frame = tip_frame;
4086 timer = tip_timer;
4087 GCPRO2 (frame, timer);
4088 tip_frame = tip_timer = deleted = Qnil;
4089
4090 count = SPECPDL_INDEX ();
4091 specbind (Qinhibit_redisplay, Qt);
4092 specbind (Qinhibit_quit, Qt);
4093
4094 if (!NILP (timer))
4095 call1 (Qcancel_timer, timer);
4096
4097 if (FRAMEP (frame))
4098 {
4099 Fdelete_frame (frame, Qnil);
4100 deleted = Qt;
4101 }
4102
4103 UNGCPRO;
4104 return unbind_to (count, deleted);
4105 }
4106
4107
4108 \f
4109 /***********************************************************************
4110 File selection dialog
4111 ***********************************************************************/
4112
4113 #if TARGET_API_MAC_CARBON
4114 DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
4115 doc: /* Read file name, prompting with PROMPT in directory DIR.
4116 Use a file selection dialog.
4117 Select DEFAULT-FILENAME in the dialog's file selection box, if
4118 specified. Ensure that file exists if MUSTMATCH is non-nil.
4119 If ONLY-DIR-P is non-nil, the user can only select directories. */)
4120 (prompt, dir, default_filename, mustmatch, only_dir_p)
4121 Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
4122 {
4123 return mac_file_dialog (prompt, dir, default_filename, mustmatch, only_dir_p);
4124 }
4125 #endif
4126
4127 \f
4128 /***********************************************************************
4129 Fonts
4130 ***********************************************************************/
4131
4132 DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table,
4133 Smac_clear_font_name_table, 0, 0, 0,
4134 doc: /* Clear the font name table. */)
4135 ()
4136 {
4137 check_mac ();
4138 mac_clear_font_name_table ();
4139 return Qnil;
4140 }
4141
4142 #if USE_MAC_FONT_PANEL
4143 DEFUN ("mac-set-font-panel-visible-p", Fmac_set_font_panel_visible_p,
4144 Smac_set_font_panel_visible_p, 1, 1, 0,
4145 doc: /* Make the font panel visible if and only if FLAG is non-nil.
4146 This is for internal use only. Use `mac-font-panel-mode' instead. */)
4147 (flag)
4148 Lisp_Object flag;
4149 {
4150 OSStatus err = noErr;
4151
4152 check_mac ();
4153
4154 BLOCK_INPUT;
4155 if (NILP (flag) != !mac_font_panel_visible_p ())
4156 {
4157 err = mac_show_hide_font_panel ();
4158 if (err == noErr && !NILP (flag))
4159 {
4160 Lisp_Object focus_frame = x_get_focus_frame (SELECTED_FRAME ());
4161 struct frame *f = (NILP (focus_frame) ? SELECTED_FRAME ()
4162 : XFRAME (focus_frame));
4163
4164 mac_set_font_info_for_selection (f, DEFAULT_FACE_ID, 0);
4165 }
4166 }
4167 UNBLOCK_INPUT;
4168
4169 if (err != noErr)
4170 error ("Cannot change visibility of the font panel");
4171 return Qnil;
4172 }
4173 #endif
4174
4175 #if USE_ATSUI
4176 extern Lisp_Object mac_atsu_font_face_attributes P_ ((ATSUFontID));
4177
4178 DEFUN ("mac-atsu-font-face-attributes", Fmac_atsu_font_face_attributes,
4179 Smac_atsu_font_face_attributes, 1, 1, 0,
4180 doc: /* Return plist of face attributes and values for ATSU font ID.
4181 ID is specified by either an integer or a float. */)
4182 (id)
4183 Lisp_Object id;
4184 {
4185 ATSUFontID font_id;
4186 Lisp_Object result;
4187
4188 check_mac ();
4189 CHECK_NUMBER_OR_FLOAT (id);
4190 font_id = INTEGERP (id) ? XINT (id) : XFLOAT_DATA (id);
4191 BLOCK_INPUT;
4192 result = mac_atsu_font_face_attributes (font_id);
4193 UNBLOCK_INPUT;
4194 return result;
4195 }
4196 #endif
4197
4198 \f
4199 /***********************************************************************
4200 Initialization
4201 ***********************************************************************/
4202
4203 /* Keep this list in the same order as frame_parms in frame.c.
4204 Use 0 for unsupported frame parameters. */
4205
4206 frame_parm_handler mac_frame_parm_handlers[] =
4207 {
4208 x_set_autoraise,
4209 x_set_autolower,
4210 x_set_background_color,
4211 x_set_border_color,
4212 x_set_border_width,
4213 x_set_cursor_color,
4214 x_set_cursor_type,
4215 mac_set_font,
4216 x_set_foreground_color,
4217 x_set_icon_name,
4218 0, /* MAC_TODO: x_set_icon_type, */
4219 x_set_internal_border_width,
4220 x_set_menu_bar_lines,
4221 x_set_mouse_color,
4222 x_explicitly_set_name,
4223 x_set_scroll_bar_width,
4224 x_set_title,
4225 x_set_unsplittable,
4226 x_set_vertical_scroll_bars,
4227 x_set_visibility,
4228 x_set_tool_bar_lines,
4229 0, /* MAC_TODO: x_set_scroll_bar_foreground, */
4230 0, /* MAC_TODO: x_set_scroll_bar_background, */
4231 x_set_screen_gamma,
4232 x_set_line_spacing,
4233 x_set_fringe_width,
4234 x_set_fringe_width,
4235 0, /* x_set_wait_for_wm, */
4236 x_set_fullscreen,
4237 0, /* x_set_font_backend, */
4238 0 /* x_set_alpha, */
4239 };
4240
4241 void
4242 syms_of_macfns ()
4243 {
4244 #ifdef MAC_OSX
4245 /* This is zero if not using Mac native windows. */
4246 mac_in_use = 0;
4247 #else
4248 /* Certainly running on Mac native windows. */
4249 mac_in_use = 1;
4250 #endif
4251
4252 /* The section below is built by the lisp expression at the top of the file,
4253 just above where these variables are declared. */
4254 /*&&& init symbols here &&&*/
4255 Qnone = intern ("none");
4256 staticpro (&Qnone);
4257 Qsuppress_icon = intern ("suppress-icon");
4258 staticpro (&Qsuppress_icon);
4259 Qundefined_color = intern ("undefined-color");
4260 staticpro (&Qundefined_color);
4261 Qcancel_timer = intern ("cancel-timer");
4262 staticpro (&Qcancel_timer);
4263 /* This is the end of symbol initialization. */
4264
4265 /* Text property `display' should be nonsticky by default. */
4266 Vtext_property_default_nonsticky
4267 = Fcons (Fcons (Qdisplay, Qt), Vtext_property_default_nonsticky);
4268
4269
4270 Fput (Qundefined_color, Qerror_conditions,
4271 Fcons (Qundefined_color, Fcons (Qerror, Qnil)));
4272 Fput (Qundefined_color, Qerror_message,
4273 build_string ("Undefined color"));
4274
4275 DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
4276 doc: /* The shape of the pointer when over text.
4277 Changing the value does not affect existing frames
4278 unless you set the mouse color. */);
4279 Vx_pointer_shape = Qnil;
4280
4281 #if 0 /* This doesn't really do anything. */
4282 DEFVAR_LISP ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape,
4283 doc: /* The shape of the pointer when not over text.
4284 This variable takes effect when you create a new frame
4285 or when you set the mouse color. */);
4286 #endif
4287 Vx_nontext_pointer_shape = Qnil;
4288
4289 DEFVAR_LISP ("x-hourglass-pointer-shape", &Vx_hourglass_pointer_shape,
4290 doc: /* The shape of the pointer when Emacs is busy.
4291 This variable takes effect when you create a new frame
4292 or when you set the mouse color. */);
4293 Vx_hourglass_pointer_shape = Qnil;
4294
4295 #if 0 /* This doesn't really do anything. */
4296 DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape,
4297 doc: /* The shape of the pointer when over the mode line.
4298 This variable takes effect when you create a new frame
4299 or when you set the mouse color. */);
4300 #endif
4301 Vx_mode_pointer_shape = Qnil;
4302
4303 DEFVAR_LISP ("x-sensitive-text-pointer-shape",
4304 &Vx_sensitive_text_pointer_shape,
4305 doc: /* The shape of the pointer when over mouse-sensitive text.
4306 This variable takes effect when you create a new frame
4307 or when you set the mouse color. */);
4308 Vx_sensitive_text_pointer_shape = Qnil;
4309
4310 DEFVAR_LISP ("x-window-horizontal-drag-cursor",
4311 &Vx_window_horizontal_drag_shape,
4312 doc: /* Pointer shape to use for indicating a window can be dragged horizontally.
4313 This variable takes effect when you create a new frame
4314 or when you set the mouse color. */);
4315 Vx_window_horizontal_drag_shape = Qnil;
4316
4317 DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel,
4318 doc: /* A string indicating the foreground color of the cursor box. */);
4319 Vx_cursor_fore_pixel = Qnil;
4320
4321 DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
4322 doc: /* Maximum size for tooltips. Value is a pair (COLUMNS . ROWS).
4323 Text larger than this is clipped. */);
4324 Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
4325
4326 DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
4327 doc: /* Non-nil if no window manager is in use.
4328 Emacs doesn't try to figure this out; this is always nil
4329 unless you set it to something else. */);
4330 /* We don't have any way to find this out, so set it to nil
4331 and maybe the user would like to set it to t. */
4332 Vx_no_window_manager = Qnil;
4333
4334 DEFVAR_LISP ("x-pixel-size-width-font-regexp",
4335 &Vx_pixel_size_width_font_regexp,
4336 doc: /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'.
4337
4338 Since Emacs gets width of a font matching with this regexp from
4339 PIXEL_SIZE field of the name, font finding mechanism gets faster for
4340 such a font. This is especially effective for such large fonts as
4341 Chinese, Japanese, and Korean. */);
4342 Vx_pixel_size_width_font_regexp = Qnil;
4343
4344 #if TARGET_API_MAC_CARBON
4345 DEFVAR_LISP ("mac-carbon-version-string", &Vmac_carbon_version_string,
4346 doc: /* Version info for Carbon API. */);
4347 {
4348 OSErr err;
4349 UInt32 response;
4350 char carbon_version[16] = "Unknown";
4351
4352 err = Gestalt (gestaltCarbonVersion, &response);
4353 if (err == noErr)
4354 sprintf (carbon_version, "%u.%u.%u",
4355 (response >> 8) & 0xf, (response >> 4) & 0xf, response & 0xf);
4356 Vmac_carbon_version_string = build_string (carbon_version);
4357 }
4358 #endif /* TARGET_API_MAC_CARBON */
4359
4360 /* X window properties. */
4361 defsubr (&Sx_change_window_property);
4362 defsubr (&Sx_delete_window_property);
4363 defsubr (&Sx_window_property);
4364
4365 defsubr (&Sxw_display_color_p);
4366 defsubr (&Sx_display_grayscale_p);
4367 defsubr (&Sxw_color_defined_p);
4368 defsubr (&Sxw_color_values);
4369 defsubr (&Sx_server_max_request_size);
4370 defsubr (&Sx_server_vendor);
4371 defsubr (&Sx_server_version);
4372 defsubr (&Sx_display_pixel_width);
4373 defsubr (&Sx_display_pixel_height);
4374 defsubr (&Sx_display_mm_width);
4375 defsubr (&Sx_display_mm_height);
4376 defsubr (&Sx_display_screens);
4377 defsubr (&Sx_display_planes);
4378 defsubr (&Sx_display_color_cells);
4379 defsubr (&Sx_display_visual_class);
4380 defsubr (&Sx_display_backing_store);
4381 defsubr (&Sx_display_save_under);
4382 defsubr (&Sx_create_frame);
4383 defsubr (&Sx_open_connection);
4384 defsubr (&Sx_close_connection);
4385 defsubr (&Sx_display_list);
4386 defsubr (&Sx_synchronize);
4387 defsubr (&Sx_focus_frame);
4388
4389 /* Setting callback functions for fontset handler. */
4390 get_font_info_func = x_get_font_info;
4391
4392 #if 0 /* This function pointer doesn't seem to be used anywhere.
4393 And the pointer assigned has the wrong type, anyway. */
4394 list_fonts_func = x_list_fonts;
4395 #endif
4396
4397 load_font_func = x_load_font;
4398 find_ccl_program_func = x_find_ccl_program;
4399 query_font_func = x_query_font;
4400 set_frame_fontset_func = mac_set_font;
4401 check_window_system_func = check_mac;
4402
4403 hourglass_atimer = NULL;
4404 hourglass_shown_p = 0;
4405
4406 defsubr (&Sx_show_tip);
4407 defsubr (&Sx_hide_tip);
4408 tip_timer = Qnil;
4409 staticpro (&tip_timer);
4410 tip_frame = Qnil;
4411 staticpro (&tip_frame);
4412
4413 last_show_tip_args = Qnil;
4414 staticpro (&last_show_tip_args);
4415
4416 #if TARGET_API_MAC_CARBON
4417 defsubr (&Sx_file_dialog);
4418 #endif
4419 defsubr (&Smac_clear_font_name_table);
4420 #if USE_MAC_FONT_PANEL
4421 defsubr (&Smac_set_font_panel_visible_p);
4422 #endif
4423 #if USE_ATSUI
4424 defsubr (&Smac_atsu_font_face_attributes);
4425 #endif
4426 }
4427
4428 /* arch-tag: d7591289-f374-4377-b245-12f5dbbb8edc
4429 (do not change this comment) */