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