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