comparison src/macterm.c @ 83353:532e0a9335a9

Merged in changes from CVS trunk. Plus added lisp/term tweaks. Patches applied: * lorentey@elte.hu--2004/emacs--cvs-trunk--0--base-0 tag of miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-474 * lorentey@elte.hu--2004/emacs--cvs-trunk--0--patch-1 Add CVS metadata files. * lorentey@elte.hu--2004/emacs--cvs-trunk--0--patch-2 Update from CVS. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-393
author Karoly Lorentey <lorentey@elte.hu>
date Sun, 04 Sep 2005 03:48:17 +0000
parents 24c69010999c ac7314b59792
children 46dfd959d88a
comparison
equal deleted inserted replaced
83352:b258b3492423 83353:532e0a9335a9
1 /* Implementation of GUI terminal on the Mac OS. 1 /* Implementation of GUI terminal on the Mac OS.
2 Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. 2 Copyright (C) 2000, 2001, 2002, 2003, 2004,
3 2005 Free Software Foundation, Inc.
3 4
4 This file is part of GNU Emacs. 5 This file is part of GNU Emacs.
5 6
6 GNU Emacs is free software; you can redistribute it and/or modify 7 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 it under the terms of the GNU General Public License as published by
20 21
21 /* Contributed by Andrew Choi (akochoi@mac.com). */ 22 /* Contributed by Andrew Choi (akochoi@mac.com). */
22 23
23 #include <config.h> 24 #include <config.h>
24 #include <signal.h> 25 #include <signal.h>
26
25 #include <stdio.h> 27 #include <stdio.h>
26 #include <stdlib.h> 28
27 #include "lisp.h" 29 #include "lisp.h"
28 #include "charset.h"
29 #include "blockinput.h" 30 #include "blockinput.h"
30 31
31 #include "macterm.h" 32 #include "macterm.h"
32 33
33 #ifndef MAC_OSX 34 #ifndef MAC_OSX
60 #endif 61 #endif
61 #endif /* not TARGET_API_MAC_CARBON */ 62 #endif /* not TARGET_API_MAC_CARBON */
62 63
63 #include "systty.h" 64 #include "systty.h"
64 #include "systime.h" 65 #include "systime.h"
65 #include "atimer.h"
66 #include "keymap.h"
67 66
68 #include <ctype.h> 67 #include <ctype.h>
69 #include <errno.h> 68 #include <errno.h>
70 #include <setjmp.h> 69 #include <setjmp.h>
71 #include <sys/stat.h> 70 #include <sys/stat.h>
72 #include <sys/param.h> 71 #include <sys/param.h>
73 72
74 #include "keyboard.h" 73 #include "charset.h"
74 #include "coding.h"
75 #include "frame.h" 75 #include "frame.h"
76 #include "dispextern.h" 76 #include "dispextern.h"
77 #include "fontset.h" 77 #include "fontset.h"
78 #include "termhooks.h" 78 #include "termhooks.h"
79 #include "termopts.h" 79 #include "termopts.h"
80 #include "termchar.h" 80 #include "termchar.h"
81 #include "gnu.h" 81 #include "gnu.h"
82 #include "disptab.h" 82 #include "disptab.h"
83 #include "buffer.h" 83 #include "buffer.h"
84 #include "window.h" 84 #include "window.h"
85 #include "keyboard.h"
85 #include "intervals.h" 86 #include "intervals.h"
86 #include "composite.h" 87 #include "atimer.h"
87 #include "coding.h" 88 #include "keymap.h"
88 89
89 /* Set of macros that handle mapping of Mac modifier keys to emacs. */ 90 /* Set of macros that handle mapping of Mac modifier keys to emacs. */
90 #define macCtrlKey (NILP (Vmac_reverse_ctrl_meta) ? controlKey : \ 91 #define macCtrlKey (NILP (Vmac_reverse_ctrl_meta) ? controlKey : \
91 (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey)) 92 (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey))
92 #define macShiftKey (shiftKey) 93 #define macShiftKey (shiftKey)
93 #define macMetaKey (NILP (Vmac_reverse_ctrl_meta) ? \ 94 #define macMetaKey (NILP (Vmac_reverse_ctrl_meta) ? \
94 (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey) \ 95 (NILP (Vmac_command_key_is_meta) ? optionKey : cmdKey) \
95 : controlKey) 96 : controlKey)
96 #define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey) 97 #define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey)
97
98 #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
99 98
100 99
101 /* Non-nil means Emacs uses toolkit scroll bars. */ 100 /* Non-nil means Emacs uses toolkit scroll bars. */
102 101
103 Lisp_Object Vx_toolkit_scroll_bars; 102 Lisp_Object Vx_toolkit_scroll_bars;
111 110
112 static int any_help_event_p; 111 static int any_help_event_p;
113 112
114 /* Last window where we saw the mouse. Used by mouse-autoselect-window. */ 113 /* Last window where we saw the mouse. Used by mouse-autoselect-window. */
115 static Lisp_Object last_window; 114 static Lisp_Object last_window;
116
117 /* Non-zero means make use of UNDERLINE_POSITION font properties. */
118
119 int x_use_underline_position_properties;
120
121 /* Non-zero means draw block and hollow cursor as wide as the glyph
122 under it. For example, if a block cursor is over a tab, it will be
123 drawn as wide as that tab on the display. */
124
125 115
126 /* This is a chain of structures for all the X displays currently in 116 /* This is a chain of structures for all the X displays currently in
127 use. */ 117 use. */
128 118
129 struct x_display_info *x_display_list; 119 struct x_display_info *x_display_list;
145 This is set by update_begin and looked at by all the XT functions. 135 This is set by update_begin and looked at by all the XT functions.
146 It is zero while not inside an update. In that case, the XT 136 It is zero while not inside an update. In that case, the XT
147 functions assume that `selected_frame' is the frame to apply to. */ 137 functions assume that `selected_frame' is the frame to apply to. */
148 138
149 extern struct frame *updating_frame; 139 extern struct frame *updating_frame;
150
151 extern int waiting_for_input;
152 140
153 /* This is a frame waiting to be auto-raised, within XTread_socket. */ 141 /* This is a frame waiting to be auto-raised, within XTread_socket. */
154 142
155 struct frame *pending_autoraise_frame; 143 struct frame *pending_autoraise_frame;
156 144
175 is off. */ 163 is off. */
176 164
177 /* Where the mouse was last time we reported a mouse event. */ 165 /* Where the mouse was last time we reported a mouse event. */
178 166
179 static Rect last_mouse_glyph; 167 static Rect last_mouse_glyph;
180 static Lisp_Object last_mouse_press_frame;
181 168
182 /* The scroll bar in which the last X motion event occurred. 169 /* The scroll bar in which the last X motion event occurred.
183 170
184 If the last X motion event occurred in a scroll bar, we set this so 171 If the last X motion event occurred in a scroll bar, we set this so
185 XTmouse_position can know whether to report a scroll bar motion or 172 XTmouse_position can know whether to report a scroll bar motion or
209 static int volatile input_signal_count; 196 static int volatile input_signal_count;
210 #else 197 #else
211 static int input_signal_count; 198 static int input_signal_count;
212 #endif 199 #endif
213 200
214 /* Used locally within XTread_socket. */ 201 extern Lisp_Object Vsystem_name;
215
216 static int x_noop_count;
217
218 /* Initial values of argv and argc. */
219
220 extern char **initial_argv;
221 extern int initial_argc;
222
223 extern Lisp_Object Vcommand_line_args, Vsystem_name;
224
225 /* Tells if a window manager is present or not. */
226
227 extern Lisp_Object Vx_no_window_manager;
228
229 extern int errno;
230 202
231 /* A mask of extra modifier bits to put into every keyboard char. */ 203 /* A mask of extra modifier bits to put into every keyboard char. */
232 204
233 extern int extra_keyboard_modifiers; 205 extern EMACS_INT extra_keyboard_modifiers;
234 206
235 /* The keysyms to use for the various modifiers. */ 207 /* The keysyms to use for the various modifiers. */
236 208
237 static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value; 209 static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value;
238
239 static Lisp_Object Qvendor_specific_keysyms;
240
241 #if 0
242 extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *));
243 #endif
244 210
245 extern int inhibit_window_system; 211 extern int inhibit_window_system;
246 212
247 #if __MRC__ && !TARGET_API_MAC_CARBON 213 #if __MRC__ && !TARGET_API_MAC_CARBON
248 QDGlobals qd; /* QuickDraw global information structure. */ 214 QDGlobals qd; /* QuickDraw global information structure. */
249 #endif 215 #endif
250 216
251 217 #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
252 struct frame * x_window_to_frame (struct mac_display_info *, WindowPtr); 218
253 struct mac_display_info *mac_display_info_for_display (Display *); 219 struct mac_display_info *mac_display_info_for_display (Display *);
254 static void x_update_window_end P_ ((struct window *, int, int)); 220 static void x_update_window_end P_ ((struct window *, int, int));
255 static int x_io_error_quitter P_ ((Display *)); 221 static int x_io_error_quitter P_ ((Display *));
256 int x_catch_errors P_ ((Display *)); 222 int x_catch_errors P_ ((Display *));
257 void x_uncatch_errors P_ ((Display *, int)); 223 void x_uncatch_errors P_ ((Display *, int));
287 static void x_clip_to_row P_ ((struct window *, struct glyph_row *, int, GC)); 253 static void x_clip_to_row P_ ((struct window *, struct glyph_row *, int, GC));
288 static void x_flush P_ ((struct frame *f)); 254 static void x_flush P_ ((struct frame *f));
289 static void x_update_begin P_ ((struct frame *)); 255 static void x_update_begin P_ ((struct frame *));
290 static void x_update_window_begin P_ ((struct window *)); 256 static void x_update_window_begin P_ ((struct window *));
291 static void x_after_update_window_line P_ ((struct glyph_row *)); 257 static void x_after_update_window_line P_ ((struct glyph_row *));
292 258 static void x_scroll_bar_report_motion P_ ((struct frame **, Lisp_Object *,
293 static int is_emacs_window (WindowPtr); 259 enum scroll_bar_part *,
294 260 Lisp_Object *, Lisp_Object *,
295 int x_bitmap_icon (struct frame *, Lisp_Object); 261 unsigned long *));
296 void x_make_frame_visible (struct frame *); 262
297 263 static int is_emacs_window P_ ((WindowPtr));
298 extern void window_scroll (Lisp_Object, int, int, int); 264
265 static void XSetFont P_ ((Display *, GC, XFontStruct *));
299 266
300 /* Defined in macmenu.h. */ 267 /* Defined in macmenu.h. */
301 extern void menubar_selection_callback (FRAME_PTR, int); 268 extern void menubar_selection_callback (FRAME_PTR, int);
302 extern void set_frame_menubar (FRAME_PTR, int, int); 269
270 #define GC_FORE_COLOR(gc) (&(gc)->fore_color)
271 #define GC_BACK_COLOR(gc) (&(gc)->back_color)
272 #define GC_FONT(gc) ((gc)->xgcv.font)
273 #define MAC_WINDOW_NORMAL_GC(w) (((mac_output *) GetWRefCon (w))->normal_gc)
274
303 275
304 /* X display function emulation */ 276 /* X display function emulation */
305 277
306 void 278 void
307 XFreePixmap (display, pixmap) 279 XFreePixmap (display, pixmap)
309 Pixmap pixmap; 281 Pixmap pixmap;
310 { 282 {
311 DisposeGWorld (pixmap); 283 DisposeGWorld (pixmap);
312 } 284 }
313 285
314
315 /* Set foreground color for subsequent QuickDraw commands. Assume
316 graphic port has already been set. */
317
318 static void
319 mac_set_forecolor (unsigned long color)
320 {
321 RGBColor fg_color;
322
323 fg_color.red = RED16_FROM_ULONG (color);
324 fg_color.green = GREEN16_FROM_ULONG (color);
325 fg_color.blue = BLUE16_FROM_ULONG (color);
326
327 RGBForeColor (&fg_color);
328 }
329
330
331 /* Set background color for subsequent QuickDraw commands. Assume
332 graphic port has already been set. */
333
334 static void
335 mac_set_backcolor (unsigned long color)
336 {
337 RGBColor bg_color;
338
339 bg_color.red = RED16_FROM_ULONG (color);
340 bg_color.green = GREEN16_FROM_ULONG (color);
341 bg_color.blue = BLUE16_FROM_ULONG (color);
342
343 RGBBackColor (&bg_color);
344 }
345
346 /* Set foreground and background color for subsequent QuickDraw
347 commands. Assume that the graphic port has already been set. */
348
349 static void
350 mac_set_colors (gc, bg_save)
351 GC gc;
352 RGBColor *bg_save;
353 {
354 if (bg_save)
355 GetBackColor (bg_save);
356 mac_set_forecolor (gc->foreground);
357 mac_set_backcolor (gc->background);
358 }
359 286
360 /* Mac version of XDrawLine. */ 287 /* Mac version of XDrawLine. */
361 288
362 static void 289 static void
363 XDrawLine (display, w, gc, x1, y1, x2, y2) 290 XDrawLine (display, w, gc, x1, y1, x2, y2)
364 Display *display; 291 Display *display;
365 WindowPtr w; 292 WindowPtr w;
366 GC gc; 293 GC gc;
367 int x1, y1, x2, y2; 294 int x1, y1, x2, y2;
368 { 295 {
369 RGBColor old_bg;
370
371 SetPortWindowPort (w); 296 SetPortWindowPort (w);
372 297
373 mac_set_colors (gc, &old_bg); 298 RGBForeColor (GC_FORE_COLOR (gc));
374 299
375 MoveTo (x1, y1); 300 MoveTo (x1, y1);
376 LineTo (x2, y2); 301 LineTo (x2, y2);
377
378 RGBBackColor (&old_bg);
379 } 302 }
380 303
381 void 304 void
382 mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2) 305 mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2)
383 Display *display; 306 Display *display;
389 GDHandle old_gdh; 312 GDHandle old_gdh;
390 313
391 GetGWorld (&old_port, &old_gdh); 314 GetGWorld (&old_port, &old_gdh);
392 SetGWorld (p, NULL); 315 SetGWorld (p, NULL);
393 316
394 mac_set_colors (gc, NULL); 317 RGBForeColor (GC_FORE_COLOR (gc));
395 318
396 LockPixels (GetGWorldPixMap (p)); 319 LockPixels (GetGWorldPixMap (p));
397 MoveTo (x1, y1); 320 MoveTo (x1, y1);
398 LineTo (x2, y2); 321 LineTo (x2, y2);
399 UnlockPixels (GetGWorldPixMap (p)); 322 UnlockPixels (GetGWorldPixMap (p));
400 323
401 SetGWorld (old_port, old_gdh); 324 SetGWorld (old_port, old_gdh);
402 } 325 }
326
327
328 static void
329 mac_erase_rectangle (w, gc, x, y, width, height)
330 WindowPtr w;
331 GC gc;
332 int x, y;
333 unsigned int width, height;
334 {
335 Rect r;
336
337 SetPortWindowPort (w);
338
339 RGBBackColor (GC_BACK_COLOR (gc));
340 SetRect (&r, x, y, x + width, y + height);
341
342 EraseRect (&r);
343
344 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
345 }
346
403 347
404 /* Mac version of XClearArea. */ 348 /* Mac version of XClearArea. */
405 349
406 void 350 void
407 XClearArea (display, w, x, y, width, height, exposures) 351 XClearArea (display, w, x, y, width, height, exposures)
409 WindowPtr w; 353 WindowPtr w;
410 int x, y; 354 int x, y;
411 unsigned int width, height; 355 unsigned int width, height;
412 int exposures; 356 int exposures;
413 { 357 {
414 struct mac_output *mwp = (mac_output *) GetWRefCon (w); 358 mac_erase_rectangle (w, MAC_WINDOW_NORMAL_GC (w), x, y, width, height);
415 Rect r;
416 XGCValues xgc;
417 RGBColor old_bg;
418
419 xgc.foreground = mwp->x_compatible.foreground_pixel;
420 xgc.background = mwp->x_compatible.background_pixel;
421
422 SetPortWindowPort (w);
423
424 mac_set_colors (&xgc, &old_bg);
425 SetRect (&r, x, y, x + width, y + height);
426
427 EraseRect (&r);
428
429 RGBBackColor (&old_bg);
430 } 359 }
431 360
432 /* Mac version of XClearWindow. */ 361 /* Mac version of XClearWindow. */
433 362
434 static void 363 static void
435 XClearWindow (display, w) 364 XClearWindow (display, w)
436 Display *display; 365 Display *display;
437 WindowPtr w; 366 WindowPtr w;
438 { 367 {
439 struct mac_output *mwp = (mac_output *) GetWRefCon (w);
440 XGCValues xgc;
441
442 xgc.foreground = mwp->x_compatible.foreground_pixel;
443 xgc.background = mwp->x_compatible.background_pixel;
444
445 SetPortWindowPort (w); 368 SetPortWindowPort (w);
446 369
447 mac_set_colors (&xgc, NULL); 370 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
448 371
449 #if TARGET_API_MAC_CARBON 372 #if TARGET_API_MAC_CARBON
450 { 373 {
451 Rect r; 374 Rect r;
452 375
470 unsigned short *bits; 393 unsigned short *bits;
471 int overlay_p; 394 int overlay_p;
472 { 395 {
473 BitMap bitmap; 396 BitMap bitmap;
474 Rect r; 397 Rect r;
475 RGBColor old_bg;
476 398
477 bitmap.rowBytes = sizeof(unsigned short); 399 bitmap.rowBytes = sizeof(unsigned short);
478 bitmap.baseAddr = (char *)bits; 400 bitmap.baseAddr = (char *)bits;
479 SetRect (&(bitmap.bounds), 0, 0, width, height); 401 SetRect (&(bitmap.bounds), 0, 0, width, height);
480 402
481 SetPortWindowPort (w); 403 SetPortWindowPort (w);
482 404
483 mac_set_colors (gc, &old_bg); 405 RGBForeColor (GC_FORE_COLOR (gc));
406 RGBBackColor (GC_BACK_COLOR (gc));
484 SetRect (&r, x, y, x + width, y + height); 407 SetRect (&r, x, y, x + width, y + height);
485 408
486 #if TARGET_API_MAC_CARBON 409 #if TARGET_API_MAC_CARBON
487 LockPortBits (GetWindowPort (w)); 410 LockPortBits (GetWindowPort (w));
488 CopyBits (&bitmap, GetPortBitMapForCopyBits (GetWindowPort (w)), 411 CopyBits (&bitmap, GetPortBitMapForCopyBits (GetWindowPort (w)),
491 #else /* not TARGET_API_MAC_CARBON */ 414 #else /* not TARGET_API_MAC_CARBON */
492 CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r, 415 CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r,
493 overlay_p ? srcOr : srcCopy, 0); 416 overlay_p ? srcOr : srcCopy, 0);
494 #endif /* not TARGET_API_MAC_CARBON */ 417 #endif /* not TARGET_API_MAC_CARBON */
495 418
496 RGBBackColor (&old_bg); 419 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
497 } 420 }
498 421
499 422
500 /* Mac replacement for XSetClipRectangles. */ 423 /* Mac replacement for XSetClipRectangles. */
501 424
597 Display *display; /* not used */ 520 Display *display; /* not used */
598 WindowPtr w; 521 WindowPtr w;
599 char *data; 522 char *data;
600 unsigned int width, height; 523 unsigned int width, height;
601 unsigned long fg, bg; 524 unsigned long fg, bg;
602 unsigned int depth; /* not used */ 525 unsigned int depth;
603 { 526 {
604 Pixmap pixmap; 527 Pixmap pixmap;
605 BitMap bitmap; 528 BitMap bitmap;
606 CGrafPtr old_port; 529 CGrafPtr old_port;
607 GDHandle old_gdh; 530 GDHandle old_gdh;
531 static GC gc = NULL; /* not reentrant */
532
533 if (gc == NULL)
534 gc = XCreateGC (display, w, 0, NULL);
608 535
609 pixmap = XCreatePixmap (display, w, width, height, depth); 536 pixmap = XCreatePixmap (display, w, width, height, depth);
610 if (pixmap == NULL) 537 if (pixmap == NULL)
611 return NULL; 538 return NULL;
612 539
613 GetGWorld (&old_port, &old_gdh); 540 GetGWorld (&old_port, &old_gdh);
614 SetGWorld (pixmap, NULL); 541 SetGWorld (pixmap, NULL);
615 mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height); 542 mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height);
616 mac_set_forecolor (fg); 543 XSetForeground (display, gc, fg);
617 mac_set_backcolor (bg); 544 XSetBackground (display, gc, bg);
545 RGBForeColor (GC_FORE_COLOR (gc));
546 RGBBackColor (GC_BACK_COLOR (gc));
618 LockPixels (GetGWorldPixMap (pixmap)); 547 LockPixels (GetGWorldPixMap (pixmap));
619 #if TARGET_API_MAC_CARBON 548 #if TARGET_API_MAC_CARBON
620 CopyBits (&bitmap, GetPortBitMapForCopyBits (pixmap), 549 CopyBits (&bitmap, GetPortBitMapForCopyBits (pixmap),
621 &bitmap.bounds, &bitmap.bounds, srcCopy, 0); 550 &bitmap.bounds, &bitmap.bounds, srcCopy, 0);
622 #else /* not TARGET_API_MAC_CARBON */ 551 #else /* not TARGET_API_MAC_CARBON */
640 GC gc; 569 GC gc;
641 int x, y; 570 int x, y;
642 unsigned int width, height; 571 unsigned int width, height;
643 { 572 {
644 Rect r; 573 Rect r;
645 RGBColor old_bg;
646 574
647 SetPortWindowPort (w); 575 SetPortWindowPort (w);
648 576
649 mac_set_colors (gc, &old_bg); 577 RGBForeColor (GC_FORE_COLOR (gc));
650 SetRect (&r, x, y, x + width, y + height); 578 SetRect (&r, x, y, x + width, y + height);
651 579
652 PaintRect (&r); /* using foreground color of gc */ 580 PaintRect (&r); /* using foreground color of gc */
653
654 RGBBackColor (&old_bg);
655 } 581 }
656 582
657 583
658 #if 0 /* TODO: figure out if we need to do this on Mac. */ 584 #if 0 /* TODO: figure out if we need to do this on Mac. */
659 static void 585 static void
668 GDHandle old_gdh; 594 GDHandle old_gdh;
669 Rect r; 595 Rect r;
670 596
671 GetGWorld (&old_port, &old_gdh); 597 GetGWorld (&old_port, &old_gdh);
672 SetGWorld (p, NULL); 598 SetGWorld (p, NULL);
673 mac_set_colors (gc, NULL); 599 RGBForeColor (GC_FORE_COLOR (gc));
674 SetRect (&r, x, y, x + width, y + height); 600 SetRect (&r, x, y, x + width, y + height);
675 601
676 LockPixels (GetGWorldPixMap (p)); 602 LockPixels (GetGWorldPixMap (p));
677 PaintRect (&r); /* using foreground color of gc */ 603 PaintRect (&r); /* using foreground color of gc */
678 UnlockPixels (GetGWorldPixMap (p)); 604 UnlockPixels (GetGWorldPixMap (p));
691 GC gc; 617 GC gc;
692 int x, y; 618 int x, y;
693 unsigned int width, height; 619 unsigned int width, height;
694 { 620 {
695 Rect r; 621 Rect r;
696 RGBColor old_bg;
697 622
698 SetPortWindowPort (w); 623 SetPortWindowPort (w);
699 624
700 mac_set_colors (gc, &old_bg); 625 RGBForeColor (GC_FORE_COLOR (gc));
701 SetRect (&r, x, y, x + width + 1, y + height + 1); 626 SetRect (&r, x, y, x + width + 1, y + height + 1);
702 627
703 FrameRect (&r); /* using foreground color of gc */ 628 FrameRect (&r); /* using foreground color of gc */
704
705 RGBBackColor (&old_bg);
706 } 629 }
707 630
708 631
709 #if 0 /* TODO: figure out if we need to do this on Mac. */ 632 #if 0 /* TODO: figure out if we need to do this on Mac. */
710 /* Mac replacement for XDrawRectangle: dest is a Pixmap. */ 633 /* Mac replacement for XDrawRectangle: dest is a Pixmap. */
721 GDHandle old_gdh; 644 GDHandle old_gdh;
722 Rect r; 645 Rect r;
723 646
724 GetGWorld (&old_port, &old_gdh); 647 GetGWorld (&old_port, &old_gdh);
725 SetGWorld (p, NULL); 648 SetGWorld (p, NULL);
726 mac_set_colors (gc, NULL); 649 RGBForeColor (GC_FORE_COLOR (gc));
727 SetRect (&r, x, y, x + width + 1, y + height + 1); 650 SetRect (&r, x, y, x + width + 1, y + height + 1);
728 651
729 LockPixels (GetGWorldPixMap (p)); 652 LockPixels (GetGWorldPixMap (p));
730 FrameRect (&r); /* using foreground color of gc */ 653 FrameRect (&r); /* using foreground color of gc */
731 UnlockPixels (GetGWorldPixMap (p)); 654 UnlockPixels (GetGWorldPixMap (p));
743 GC gc; 666 GC gc;
744 int x, y; 667 int x, y;
745 char *buf; 668 char *buf;
746 int nchars, mode, bytes_per_char; 669 int nchars, mode, bytes_per_char;
747 { 670 {
748 RGBColor old_bg;
749
750 SetPortWindowPort (w);
751 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 671 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
752 UInt32 textFlags, savedFlags; 672 UInt32 textFlags, savedFlags;
753 if (!NILP(Vmac_use_core_graphics)) { 673 if (!NILP(Vmac_use_core_graphics)) {
754 textFlags = kQDUseCGTextRendering; 674 textFlags = kQDUseCGTextRendering;
755 savedFlags = SwapQDTextFlags(textFlags); 675 savedFlags = SwapQDTextFlags(textFlags);
756 } 676 }
757 #endif 677 #endif
758 678
759 mac_set_colors (gc, &old_bg); 679 SetPortWindowPort (w);
760 680
761 TextFont (gc->font->mac_fontnum); 681 RGBForeColor (GC_FORE_COLOR (gc));
762 TextSize (gc->font->mac_fontsize); 682 if (mode != srcOr)
763 TextFace (gc->font->mac_fontface); 683 RGBBackColor (GC_BACK_COLOR (gc));
684
685 TextFont (GC_FONT (gc)->mac_fontnum);
686 TextSize (GC_FONT (gc)->mac_fontsize);
687 TextFace (GC_FONT (gc)->mac_fontface);
764 TextMode (mode); 688 TextMode (mode);
765 689
766 MoveTo (x, y); 690 MoveTo (x, y);
767 DrawText (buf, 0, nchars * bytes_per_char); 691 DrawText (buf, 0, nchars * bytes_per_char);
768 692
769 RGBBackColor (&old_bg); 693 if (mode != srcOr)
694 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
770 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 695 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
771 if (!NILP(Vmac_use_core_graphics)) 696 if (!NILP(Vmac_use_core_graphics))
772 SwapQDTextFlags(savedFlags); 697 SwapQDTextFlags(savedFlags);
773 #endif 698 #endif
774 } 699 }
869 #else /* not TARGET_API_MAC_CARBON */ 794 #else /* not TARGET_API_MAC_CARBON */
870 CopyBits (&(((GrafPtr)src)->portBits), &(dest->portBits), 795 CopyBits (&(((GrafPtr)src)->portBits), &(dest->portBits),
871 &src_r, &dest_r, srcCopy, 0); 796 &src_r, &dest_r, srcCopy, 0);
872 #endif /* not TARGET_API_MAC_CARBON */ 797 #endif /* not TARGET_API_MAC_CARBON */
873 UnlockPixels (GetGWorldPixMap (src)); 798 UnlockPixels (GetGWorldPixMap (src));
799
800 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest)));
874 } 801 }
875 802
876 803
877 static void 804 static void
878 mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y, 805 mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
907 CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits), 834 CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits),
908 &(dest->portBits), &src_r, &src_r, &dest_r); 835 &(dest->portBits), &src_r, &src_r, &dest_r);
909 #endif /* not TARGET_API_MAC_CARBON */ 836 #endif /* not TARGET_API_MAC_CARBON */
910 UnlockPixels (GetGWorldPixMap (mask)); 837 UnlockPixels (GetGWorldPixMap (mask));
911 UnlockPixels (GetGWorldPixMap (src)); 838 UnlockPixels (GetGWorldPixMap (src));
912 } 839
913 840 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest)));
914 841 }
915 #if 0 842
916 /* Convert a pair of local coordinates to global (screen) coordinates.
917 Assume graphic port has been properly set. */
918 static void
919 local_to_global_coord (short *h, short *v)
920 {
921 Point p;
922
923 p.h = *h;
924 p.v = *v;
925
926 LocalToGlobal (&p);
927
928 *h = p.h;
929 *v = p.v;
930 }
931 #endif
932 843
933 /* Mac replacement for XCopyArea: used only for scrolling. */ 844 /* Mac replacement for XCopyArea: used only for scrolling. */
934 845
935 static void 846 static void
936 mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y) 847 mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
951 DisposeRgn (dummy); 862 DisposeRgn (dummy);
952 #else /* not TARGET_API_MAC_CARBON */ 863 #else /* not TARGET_API_MAC_CARBON */
953 Rect src_r, dest_r; 864 Rect src_r, dest_r;
954 865
955 SetPort (w); 866 SetPort (w);
956 #if 0
957 mac_set_colors (gc, NULL);
958 #endif
959 867
960 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 868 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
961 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 869 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
962 870
963 #if 0
964 /* Need to use global coordinates and screenBits since src and dest
965 areas overlap in general. */
966 local_to_global_coord (&src_r.left, &src_r.top);
967 local_to_global_coord (&src_r.right, &src_r.bottom);
968 local_to_global_coord (&dest_r.left, &dest_r.top);
969 local_to_global_coord (&dest_r.right, &dest_r.bottom);
970
971 CopyBits (&qd.screenBits, &qd.screenBits, &src_r, &dest_r, srcCopy, 0);
972 #else
973 /* In Color QuickDraw, set ForeColor and BackColor as follows to avoid 871 /* In Color QuickDraw, set ForeColor and BackColor as follows to avoid
974 color mapping in CopyBits. Otherwise, it will be slow. */ 872 color mapping in CopyBits. Otherwise, it will be slow. */
975 ForeColor (blackColor); 873 ForeColor (blackColor);
976 BackColor (whiteColor); 874 BackColor (whiteColor);
977 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0); 875 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
978 876
979 mac_set_colors (gc, NULL); 877 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
980 #endif
981 #endif /* not TARGET_API_MAC_CARBON */ 878 #endif /* not TARGET_API_MAC_CARBON */
982 } 879 }
983 880
984 881
985 #if 0 /* TODO: figure out if we need to do this on Mac. */ 882 #if 0 /* TODO: figure out if we need to do this on Mac. */
1065 962
1066 963
1067 /* Mac replacement for XChangeGC. */ 964 /* Mac replacement for XChangeGC. */
1068 965
1069 static void 966 static void
1070 XChangeGC (void * ignore, XGCValues* gc, unsigned long mask, 967 XChangeGC (display, gc, mask, xgcv)
1071 XGCValues *xgcv) 968 Display *display;
969 GC gc;
970 unsigned long mask;
971 XGCValues *xgcv;
1072 { 972 {
1073 if (mask & GCForeground) 973 if (mask & GCForeground)
1074 gc->foreground = xgcv->foreground; 974 XSetForeground (display, gc, xgcv->foreground);
1075 if (mask & GCBackground) 975 if (mask & GCBackground)
1076 gc->background = xgcv->background; 976 XSetBackground (display, gc, xgcv->background);
1077 if (mask & GCFont) 977 if (mask & GCFont)
1078 gc->font = xgcv->font; 978 XSetFont (display, gc, xgcv->font);
1079 } 979 }
1080 980
1081 981
1082 /* Mac replacement for XCreateGC. */ 982 /* Mac replacement for XCreateGC. */
1083 983
1084 XGCValues * 984 GC
1085 XCreateGC (void * ignore, Window window, unsigned long mask, 985 XCreateGC (display, window, mask, xgcv)
1086 XGCValues *xgcv) 986 Display *display;
1087 { 987 Window window;
1088 XGCValues *gc = (XGCValues *) xmalloc (sizeof (XGCValues)); 988 unsigned long mask;
1089 bzero (gc, sizeof (XGCValues)); 989 XGCValues *xgcv;
1090 990 {
1091 XChangeGC (ignore, gc, mask, xgcv); 991 GC gc = xmalloc (sizeof (*gc));
992
993 if (gc)
994 {
995 bzero (gc, sizeof (*gc));
996 XChangeGC (display, gc, mask, xgcv);
997 }
1092 998
1093 return gc; 999 return gc;
1094 } 1000 }
1095 1001
1096 1002
1106 1012
1107 1013
1108 /* Mac replacement for XGetGCValues. */ 1014 /* Mac replacement for XGetGCValues. */
1109 1015
1110 static void 1016 static void
1111 XGetGCValues (void* ignore, XGCValues *gc, 1017 XGetGCValues (display, gc, mask, xgcv)
1112 unsigned long mask, XGCValues *xgcv) 1018 Display *display;
1113 { 1019 GC gc;
1114 XChangeGC (ignore, xgcv, mask, gc); 1020 unsigned long mask;
1021 XGCValues *xgcv;
1022 {
1023 if (mask & GCForeground)
1024 xgcv->foreground = gc->xgcv.foreground;
1025 if (mask & GCBackground)
1026 xgcv->background = gc->xgcv.background;
1027 if (mask & GCFont)
1028 xgcv->font = gc->xgcv.font;
1115 } 1029 }
1116 1030
1117 1031
1118 /* Mac replacement for XSetForeground. */ 1032 /* Mac replacement for XSetForeground. */
1119 1033
1121 XSetForeground (display, gc, color) 1035 XSetForeground (display, gc, color)
1122 Display *display; 1036 Display *display;
1123 GC gc; 1037 GC gc;
1124 unsigned long color; 1038 unsigned long color;
1125 { 1039 {
1126 gc->foreground = color; 1040 if (gc->xgcv.foreground != color)
1041 {
1042 gc->xgcv.foreground = color;
1043 gc->fore_color.red = RED16_FROM_ULONG (color);
1044 gc->fore_color.green = GREEN16_FROM_ULONG (color);
1045 gc->fore_color.blue = BLUE16_FROM_ULONG (color);
1046 }
1127 } 1047 }
1128 1048
1129 1049
1130 /* Mac replacement for XSetBackground. */ 1050 /* Mac replacement for XSetBackground. */
1131 1051
1133 XSetBackground (display, gc, color) 1053 XSetBackground (display, gc, color)
1134 Display *display; 1054 Display *display;
1135 GC gc; 1055 GC gc;
1136 unsigned long color; 1056 unsigned long color;
1137 { 1057 {
1138 gc->background = color; 1058 if (gc->xgcv.background != color)
1059 {
1060 gc->xgcv.background = color;
1061 gc->back_color.red = RED16_FROM_ULONG (color);
1062 gc->back_color.green = GREEN16_FROM_ULONG (color);
1063 gc->back_color.blue = BLUE16_FROM_ULONG (color);
1064 }
1065 }
1066
1067
1068 /* Mac replacement for XSetFont. */
1069
1070 static void
1071 XSetFont (display, gc, font)
1072 Display *display;
1073 GC gc;
1074 XFontStruct *font;
1075 {
1076 gc->xgcv.font = font;
1139 } 1077 }
1140 1078
1141 1079
1142 /* Mac replacement for XSetWindowBackground. */ 1080 /* Mac replacement for XSetWindowBackground. */
1143 1081
1180 } 1118 }
1181 } 1119 }
1182 #endif 1120 #endif
1183 } 1121 }
1184 1122
1185
1186 /* Mac replacement for XSetFont. */
1187
1188 static void
1189 XSetFont (display, gc, font)
1190 Display *display;
1191 GC gc;
1192 XFontStruct *font;
1193 {
1194 gc->font = font;
1195 }
1196
1197
1198 /* x_sync is a no-op on Mac. */ 1123 /* x_sync is a no-op on Mac. */
1199 void 1124 void
1200 x_sync (f) 1125 x_sync (f)
1201 void *f; 1126 void *f;
1202 { 1127 {
1343 1268
1344 XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1269 XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1345 f->output_data.mac->normal_gc, x, y0, x, y1); 1270 f->output_data.mac->normal_gc, x, y0, x, y1);
1346 } 1271 }
1347 1272
1348
1349 /* End update of window W (which is equal to updated_window). 1273 /* End update of window W (which is equal to updated_window).
1350 1274
1351 Draw vertical borders between horizontally adjacent windows, and 1275 Draw vertical borders between horizontally adjacent windows, and
1352 display W's cursor if CURSOR_ON_P is non-zero. 1276 display W's cursor if CURSOR_ON_P is non-zero.
1353 1277
1355 glyphs in mouse-face were overwritten. In that case we have to 1279 glyphs in mouse-face were overwritten. In that case we have to
1356 make sure that the mouse-highlight is properly redrawn. 1280 make sure that the mouse-highlight is properly redrawn.
1357 1281
1358 W may be a menu bar pseudo-window in case we don't have X toolkit 1282 W may be a menu bar pseudo-window in case we don't have X toolkit
1359 support. Such windows don't have a cursor, so don't display it 1283 support. Such windows don't have a cursor, so don't display it
1360 here. */ 1284 here. */
1361 1285
1362 static void 1286 static void
1363 x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p) 1287 x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p)
1364 struct window *w; 1288 struct window *w;
1365 int cursor_on_p, mouse_face_overwritten_p; 1289 int cursor_on_p, mouse_face_overwritten_p;
1387 { 1311 {
1388 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 1312 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
1389 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 1313 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
1390 dpyinfo->mouse_face_window = Qnil; 1314 dpyinfo->mouse_face_window = Qnil;
1391 } 1315 }
1392
1393 #if 0
1394 /* Unhide the caret. This won't actually show the cursor, unless it
1395 was visible before the corresponding call to HideCaret in
1396 x_update_window_begin. */
1397 if (w32_use_visible_system_caret)
1398 SendMessage (w32_system_caret_hwnd, WM_EMACS_SHOW_CARET, 0, 0);
1399 #endif
1400 1316
1401 updated_window = NULL; 1317 updated_window = NULL;
1402 } 1318 }
1403 1319
1404 1320
1481 width != 0) 1397 width != 0)
1482 && (height = desired_row->visible_height, 1398 && (height = desired_row->visible_height,
1483 height > 0)) 1399 height > 0))
1484 { 1400 {
1485 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y)); 1401 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
1402
1486 /* Internal border is drawn below the tool bar. */ 1403 /* Internal border is drawn below the tool bar. */
1487 if (WINDOWP (f->tool_bar_window) 1404 if (WINDOWP (f->tool_bar_window)
1488 && w == XWINDOW (f->tool_bar_window)) 1405 && w == XWINDOW (f->tool_bar_window))
1489 y -= width; 1406 y -= width;
1490 1407
1491 BLOCK_INPUT; 1408 BLOCK_INPUT;
1492
1493 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1409 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1494 0, y, width, height, 0); 1410 0, y, width, height, 0);
1495 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1411 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1496 FRAME_PIXEL_WIDTH (f) - width, y, 1412 FRAME_PIXEL_WIDTH (f) - width, y,
1497 width, height, 0); 1413 width, height, 0);
1498
1499 UNBLOCK_INPUT; 1414 UNBLOCK_INPUT;
1500 } 1415 }
1501 } 1416 }
1502 1417
1503 1418
1513 struct draw_fringe_bitmap_params *p; 1428 struct draw_fringe_bitmap_params *p;
1514 { 1429 {
1515 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1430 struct frame *f = XFRAME (WINDOW_FRAME (w));
1516 Display *display = FRAME_MAC_DISPLAY (f); 1431 Display *display = FRAME_MAC_DISPLAY (f);
1517 WindowPtr window = FRAME_MAC_WINDOW (f); 1432 WindowPtr window = FRAME_MAC_WINDOW (f);
1518 XGCValues gcv;
1519 GC gc = f->output_data.mac->normal_gc; 1433 GC gc = f->output_data.mac->normal_gc;
1520 struct face *face = p->face; 1434 struct face *face = p->face;
1521 int rowY; 1435 int rowY;
1522 1436
1523 /* Must clip because of partially visible lines. */ 1437 /* Must clip because of partially visible lines. */
1537 else 1451 else
1538 x_clip_to_row (w, row, -1, gc); 1452 x_clip_to_row (w, row, -1, gc);
1539 1453
1540 if (p->bx >= 0 && !p->overlay_p) 1454 if (p->bx >= 0 && !p->overlay_p)
1541 { 1455 {
1542 XGCValues gcv;
1543 gcv.foreground = face->background;
1544
1545 #if 0 /* MAC_TODO: stipple */ 1456 #if 0 /* MAC_TODO: stipple */
1546 /* In case the same realized face is used for fringes and 1457 /* In case the same realized face is used for fringes and
1547 for something displayed in the text (e.g. face `region' on 1458 for something displayed in the text (e.g. face `region' on
1548 mono-displays, the fill style may have been changed to 1459 mono-displays, the fill style may have been changed to
1549 FillSolid in x_draw_glyph_string_background. */ 1460 FillSolid in x_draw_glyph_string_background. */
1551 XSetFillStyle (FRAME_X_DISPLAY (f), face->gc, FillOpaqueStippled); 1462 XSetFillStyle (FRAME_X_DISPLAY (f), face->gc, FillOpaqueStippled);
1552 else 1463 else
1553 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background); 1464 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background);
1554 #endif 1465 #endif
1555 1466
1556 XFillRectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1467 mac_erase_rectangle (window, face->gc, p->bx, p->by, p->nx, p->ny);
1557 &gcv,
1558 p->bx, p->by, p->nx, p->ny);
1559 1468
1560 #if 0 /* MAC_TODO: stipple */ 1469 #if 0 /* MAC_TODO: stipple */
1561 if (!face->stipple) 1470 if (!face->stipple)
1562 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->foreground); 1471 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->foreground);
1563 #endif 1472 #endif
1564 } 1473 }
1565 1474
1566 if (p->which) 1475 if (p->which)
1567 { 1476 {
1568 unsigned short *bits = p->bits + p->dh; 1477 unsigned short *bits = p->bits + p->dh;
1569 1478 XGCValues gcv;
1570 gcv.foreground = (p->cursor_p 1479
1571 ? (p->overlay_p ? face->background 1480 XGetGCValues (display, face->gc, GCForeground, &gcv);
1572 : f->output_data.mac->cursor_pixel) 1481 XSetForeground (display, face->gc,
1573 : face->foreground); 1482 (p->cursor_p
1574 gcv.background = face->background; 1483 ? (p->overlay_p ? face->background
1575 1484 : f->output_data.mac->cursor_pixel)
1576 mac_draw_bitmap (display, window, &gcv, p->x, p->y, 1485 : face->foreground));
1486 mac_draw_bitmap (display, window, face->gc, p->x, p->y,
1577 p->wd, p->h, bits, p->overlay_p); 1487 p->wd, p->h, bits, p->overlay_p);
1488 XSetForeground (display, face->gc, gcv.foreground);
1578 } 1489 }
1579 1490
1580 mac_reset_clipping (display, window); 1491 mac_reset_clipping (display, window);
1581 } 1492 }
1582 1493
1583 1494
1495
1584 /* This is called when starting Emacs and when restarting after 1496 /* This is called when starting Emacs and when restarting after
1585 suspend. When starting Emacs, no window is mapped. And nothing 1497 suspend. When starting Emacs, no window is mapped. And nothing
1586 must be done to Emacs's own window if it is suspended (though that 1498 must be done to Emacs's own window if it is suspended (though that
1587 rarely happens). */ 1499 rarely happens). */
1588 1500
1596 1508
1597 static void 1509 static void
1598 XTreset_terminal_modes () 1510 XTreset_terminal_modes ()
1599 { 1511 {
1600 } 1512 }
1513
1601 1514
1602 1515
1603 /*********************************************************************** 1516 /***********************************************************************
1604 Display Iterator 1517 Display Iterator
1605 ***********************************************************************/ 1518 ***********************************************************************/
1784 /*********************************************************************** 1697 /***********************************************************************
1785 Glyph display 1698 Glyph display
1786 ***********************************************************************/ 1699 ***********************************************************************/
1787 1700
1788 1701
1702
1789 static void x_set_glyph_string_clipping P_ ((struct glyph_string *)); 1703 static void x_set_glyph_string_clipping P_ ((struct glyph_string *));
1790 static void x_set_glyph_string_gc P_ ((struct glyph_string *)); 1704 static void x_set_glyph_string_gc P_ ((struct glyph_string *));
1791 static void x_draw_glyph_string_background P_ ((struct glyph_string *, 1705 static void x_draw_glyph_string_background P_ ((struct glyph_string *,
1792 int)); 1706 int));
1793 static void x_draw_glyph_string_foreground P_ ((struct glyph_string *)); 1707 static void x_draw_glyph_string_foreground P_ ((struct glyph_string *));
1794 static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *)); 1708 static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *));
1795 static void x_draw_glyph_string_box P_ ((struct glyph_string *)); 1709 static void x_draw_glyph_string_box P_ ((struct glyph_string *));
1796 static void x_draw_glyph_string P_ ((struct glyph_string *)); 1710 static void x_draw_glyph_string P_ ((struct glyph_string *));
1711 static void mac_compute_glyph_string_overhangs P_ ((struct glyph_string *));
1797 static void x_set_cursor_gc P_ ((struct glyph_string *)); 1712 static void x_set_cursor_gc P_ ((struct glyph_string *));
1798 static void x_set_mode_line_face_gc P_ ((struct glyph_string *)); 1713 static void x_set_mode_line_face_gc P_ ((struct glyph_string *));
1799 static void x_set_mouse_face_gc P_ ((struct glyph_string *)); 1714 static void x_set_mouse_face_gc P_ ((struct glyph_string *));
1800 /*static int x_alloc_lighter_color P_ ((struct frame *, Display *, Colormap, 1715 /*static int x_alloc_lighter_color P_ ((struct frame *, Display *, Colormap,
1801 unsigned long *, double, int));*/ 1716 unsigned long *, double, int));*/
2043 static INLINE void 1958 static INLINE void
2044 x_clear_glyph_string_rect (s, x, y, w, h) 1959 x_clear_glyph_string_rect (s, x, y, w, h)
2045 struct glyph_string *s; 1960 struct glyph_string *s;
2046 int x, y, w, h; 1961 int x, y, w, h;
2047 { 1962 {
2048 XGCValues xgcv; 1963 mac_erase_rectangle (s->window, s->gc, x, y, w, h);
2049
2050 xgcv.foreground = s->gc->background;
2051 XFillRectangle (s->display, s->window, &xgcv, x, y, w, h);
2052 } 1964 }
2053 1965
2054 1966
2055 /* We prefer not to use XDrawImageString (srcCopy text transfer mode) 1967 /* We prefer not to use XDrawImageString (srcCopy text transfer mode)
2056 on Mac OS X because: 1968 on Mac OS X because:
2634 int left_x, top_y, right_x, bottom_y, width, left_p, right_p; 2546 int left_x, top_y, right_x, bottom_y, width, left_p, right_p;
2635 Rect *clip_rect; 2547 Rect *clip_rect;
2636 { 2548 {
2637 XGCValues xgcv; 2549 XGCValues xgcv;
2638 2550
2639 xgcv.foreground = s->face->box_color; 2551 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
2552 XSetForeground (s->display, s->gc, s->face->box_color);
2640 mac_set_clip_rectangle (s->display, s->window, clip_rect); 2553 mac_set_clip_rectangle (s->display, s->window, clip_rect);
2641 2554
2642 /* Top. */ 2555 /* Top. */
2643 XFillRectangle (s->display, s->window, &xgcv, 2556 XFillRectangle (s->display, s->window, s->gc,
2644 left_x, top_y, right_x - left_x + 1, width); 2557 left_x, top_y, right_x - left_x + 1, width);
2645 2558
2646 /* Left. */ 2559 /* Left. */
2647 if (left_p) 2560 if (left_p)
2648 XFillRectangle (s->display, s->window, &xgcv, 2561 XFillRectangle (s->display, s->window, s->gc,
2649 left_x, top_y, width, bottom_y - top_y + 1); 2562 left_x, top_y, width, bottom_y - top_y + 1);
2650 2563
2651 /* Bottom. */ 2564 /* Bottom. */
2652 XFillRectangle (s->display, s->window, &xgcv, 2565 XFillRectangle (s->display, s->window, s->gc,
2653 left_x, bottom_y - width + 1, right_x - left_x + 1, width); 2566 left_x, bottom_y - width + 1, right_x - left_x + 1, width);
2654 2567
2655 /* Right. */ 2568 /* Right. */
2656 if (right_p) 2569 if (right_p)
2657 XFillRectangle (s->display, s->window, &xgcv, 2570 XFillRectangle (s->display, s->window, s->gc,
2658 right_x - width + 1, top_y, width, bottom_y - top_y + 1); 2571 right_x - width + 1, top_y, width, bottom_y - top_y + 1);
2659 2572
2573 XSetForeground (s->display, s->gc, xgcv.foreground);
2660 mac_reset_clipping (s->display, s->window); 2574 mac_reset_clipping (s->display, s->window);
2661 } 2575 }
2662 2576
2663 2577
2664 /* Draw a box around glyph string S. */ 2578 /* Draw a box around glyph string S. */
3073 XFillRectangle (s->display, s->window, gc, x, y, w, h); 2987 XFillRectangle (s->display, s->window, gc, x, y, w, h);
3074 XSetFillStyle (s->display, gc, FillSolid); 2988 XSetFillStyle (s->display, gc, FillSolid);
3075 } 2989 }
3076 else 2990 else
3077 #endif /* MAC_TODO */ 2991 #endif /* MAC_TODO */
3078 { 2992 mac_erase_rectangle (s->window, gc, x, y, w, h);
3079 XGCValues xgcv;
3080 XGetGCValues (s->display, gc, GCForeground | GCBackground, &xgcv);
3081 XSetForeground (s->display, gc, xgcv.background);
3082 XFillRectangle (s->display, s->window, gc, x, y, w, h);
3083 XSetForeground (s->display, gc, xgcv.foreground);
3084 }
3085 2993
3086 mac_reset_clipping (s->display, s->window); 2994 mac_reset_clipping (s->display, s->window);
3087 } 2995 }
3088 } 2996 }
3089 else if (!s->background_filled_p) 2997 else if (!s->background_filled_p)
3395 XFlush (FRAME_MAC_DISPLAY (f)); 3303 XFlush (FRAME_MAC_DISPLAY (f));
3396 UNBLOCK_INPUT; 3304 UNBLOCK_INPUT;
3397 } 3305 }
3398 } 3306 }
3399 3307
3400
3401 3308
3402 /* Specify how many text lines, from the top of the window, 3309 /* Specify how many text lines, from the top of the window,
3403 should be affected by insert-lines and delete-lines operations. 3310 should be affected by insert-lines and delete-lines operations.
3404 This, and those operations, are used only within an update 3311 This, and those operations, are used only within an update
3405 that is bounded by calls to x_update_begin and x_update_end. */ 3312 that is bounded by calls to x_update_begin and x_update_end. */
3828 UNBLOCK_INPUT; 3735 UNBLOCK_INPUT;
3829 3736
3830 return value; 3737 return value;
3831 } 3738 }
3832 3739
3833
3834
3835 #if 0
3836 /* Mouse clicks and mouse movement. Rah. */
3837
3838 /* Prepare a mouse-event in *RESULT for placement in the input queue.
3839
3840 If the event is a button press, then note that we have grabbed
3841 the mouse. */
3842
3843 static Lisp_Object
3844 construct_mouse_click (result, event, f)
3845 struct input_event *result;
3846 EventRecord *event;
3847 struct frame *f;
3848 {
3849 Point mouseLoc;
3850
3851 result->kind = MOUSE_CLICK_EVENT;
3852 result->code = 0; /* only one mouse button */
3853 result->timestamp = event->when;
3854 result->modifiers = event->what == mouseDown ? down_modifier : up_modifier;
3855
3856 mouseLoc = event->where;
3857
3858 SetPortWindowPort (FRAME_MAC_WINDOW (f));
3859
3860 GlobalToLocal (&mouseLoc);
3861 XSETINT (result->x, mouseLoc.h);
3862 XSETINT (result->y, mouseLoc.v);
3863
3864 XSETFRAME (result->frame_or_window, f);
3865
3866 result->arg = Qnil;
3867 return Qnil;
3868 }
3869 #endif
3870 3740
3871 3741
3872 /* Function to report a mouse movement to the mainstream Emacs code. 3742 /* Function to report a mouse movement to the mainstream Emacs code.
3873 The input handler calls this. 3743 The input handler calls this.
3874 3744
3922 last_mouse_scroll_bar = Qnil; 3792 last_mouse_scroll_bar = Qnil;
3923 note_mouse_highlight (frame, pos->h, pos->v); 3793 note_mouse_highlight (frame, pos->h, pos->v);
3924 } 3794 }
3925 } 3795 }
3926 3796
3927 /* This is used for debugging, to turn off note_mouse_highlight. */
3928
3929 int disable_mouse_highlight;
3930
3931
3932 3797
3933 /************************************************************************ 3798 /************************************************************************
3934 Mouse Face 3799 Mouse Face
3935 ************************************************************************/ 3800 ************************************************************************/
3936 3801
3937 static struct scroll_bar *x_window_to_scroll_bar ();
3938 static void x_scroll_bar_report_motion ();
3939 static int glyph_rect P_ ((struct frame *f, int, int, Rect *)); 3802 static int glyph_rect P_ ((struct frame *f, int, int, Rect *));
3940 3803
3941 3804
3942 /* MAC TODO: This should be called from somewhere (or removed) ++KFS */ 3805 /* MAC TODO: This should be called from somewhere (or removed) ++KFS */
3943 3806
4145 static pascal void scroll_bar_timer_callback P_ ((EventLoopTimerRef, void *)); 4008 static pascal void scroll_bar_timer_callback P_ ((EventLoopTimerRef, void *));
4146 static OSStatus install_scroll_bar_timer P_ ((void)); 4009 static OSStatus install_scroll_bar_timer P_ ((void));
4147 static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval)); 4010 static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval));
4148 static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode)); 4011 static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode));
4149 static void construct_scroll_bar_click P_ ((struct scroll_bar *, int, 4012 static void construct_scroll_bar_click P_ ((struct scroll_bar *, int,
4150 unsigned long,
4151 struct input_event *)); 4013 struct input_event *));
4152 static OSErr get_control_part_bounds P_ ((ControlHandle, ControlPartCode, 4014 static OSErr get_control_part_bounds P_ ((ControlHandle, ControlPartCode,
4153 Rect *)); 4015 Rect *));
4154 static void x_scroll_bar_handle_press P_ ((struct scroll_bar *, 4016 static void x_scroll_bar_handle_press P_ ((struct scroll_bar *,
4155 ControlPartCode, 4017 ControlPartCode,
4156 unsigned long,
4157 struct input_event *)); 4018 struct input_event *));
4158 static void x_scroll_bar_handle_release P_ ((struct scroll_bar *, 4019 static void x_scroll_bar_handle_release P_ ((struct scroll_bar *,
4159 unsigned long,
4160 struct input_event *)); 4020 struct input_event *));
4161 static void x_scroll_bar_handle_drag P_ ((WindowPtr, struct scroll_bar *, 4021 static void x_scroll_bar_handle_drag P_ ((WindowPtr, struct scroll_bar *,
4162 Point, unsigned long, 4022 Point, struct input_event *));
4163 struct input_event *));
4164 static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *, 4023 static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *,
4165 int, int, int)); 4024 int, int, int));
4166 4025
4167 /* Last scroll bar part sent in x_scroll_bar_handle_*. */ 4026 /* Last scroll bar part sent in x_scroll_bar_handle_*. */
4168 4027
4257 4116
4258 return -1; 4117 return -1;
4259 } 4118 }
4260 4119
4261 static void 4120 static void
4262 construct_scroll_bar_click (bar, part, timestamp, bufp) 4121 construct_scroll_bar_click (bar, part, bufp)
4263 struct scroll_bar *bar; 4122 struct scroll_bar *bar;
4264 int part; 4123 int part;
4265 unsigned long timestamp;
4266 struct input_event *bufp; 4124 struct input_event *bufp;
4267 { 4125 {
4268 bufp->kind = SCROLL_BAR_CLICK_EVENT; 4126 bufp->kind = SCROLL_BAR_CLICK_EVENT;
4269 bufp->frame_or_window = bar->window; 4127 bufp->frame_or_window = bar->window;
4270 bufp->arg = Qnil; 4128 bufp->arg = Qnil;
4271 bufp->part = part; 4129 bufp->part = part;
4272 bufp->code = 0; 4130 bufp->code = 0;
4273 bufp->timestamp = timestamp;
4274 XSETINT (bufp->x, 0); 4131 XSETINT (bufp->x, 0);
4275 XSETINT (bufp->y, 0); 4132 XSETINT (bufp->y, 0);
4276 bufp->modifiers = 0; 4133 bufp->modifiers = 0;
4277 } 4134 }
4278 4135
4292 4149
4293 return err; 4150 return err;
4294 } 4151 }
4295 4152
4296 static void 4153 static void
4297 x_scroll_bar_handle_press (bar, part_code, timestamp, bufp) 4154 x_scroll_bar_handle_press (bar, part_code, bufp)
4298 struct scroll_bar *bar; 4155 struct scroll_bar *bar;
4299 ControlPartCode part_code; 4156 ControlPartCode part_code;
4300 unsigned long timestamp;
4301 struct input_event *bufp; 4157 struct input_event *bufp;
4302 { 4158 {
4303 int part = control_part_code_to_scroll_bar_part (part_code); 4159 int part = control_part_code_to_scroll_bar_part (part_code);
4304 4160
4305 if (part < 0) 4161 if (part < 0)
4306 return; 4162 return;
4307 4163
4308 if (part != scroll_bar_handle) 4164 if (part != scroll_bar_handle)
4309 { 4165 {
4310 construct_scroll_bar_click (bar, part, timestamp, bufp); 4166 construct_scroll_bar_click (bar, part, bufp);
4311 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code); 4167 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code);
4312 set_scroll_bar_timer (SCROLL_BAR_FIRST_DELAY); 4168 set_scroll_bar_timer (SCROLL_BAR_FIRST_DELAY);
4313 } 4169 }
4314 4170
4315 last_scroll_bar_part = part; 4171 last_scroll_bar_part = part;
4316 bar->dragging = Qnil; 4172 bar->dragging = Qnil;
4317 tracked_scroll_bar = bar; 4173 tracked_scroll_bar = bar;
4318 } 4174 }
4319 4175
4320 static void 4176 static void
4321 x_scroll_bar_handle_release (bar, timestamp, bufp) 4177 x_scroll_bar_handle_release (bar, bufp)
4322 struct scroll_bar *bar; 4178 struct scroll_bar *bar;
4323 unsigned long timestamp;
4324 struct input_event *bufp; 4179 struct input_event *bufp;
4325 { 4180 {
4326 if (last_scroll_bar_part != scroll_bar_handle 4181 if (last_scroll_bar_part != scroll_bar_handle
4327 || !GC_NILP (bar->dragging)) 4182 || !GC_NILP (bar->dragging))
4328 construct_scroll_bar_click (bar, scroll_bar_end_scroll, timestamp, bufp); 4183 construct_scroll_bar_click (bar, scroll_bar_end_scroll, bufp);
4329 4184
4330 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), 0); 4185 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), 0);
4331 set_scroll_bar_timer (kEventDurationForever); 4186 set_scroll_bar_timer (kEventDurationForever);
4332 4187
4333 last_scroll_bar_part = -1; 4188 last_scroll_bar_part = -1;
4334 bar->dragging = Qnil; 4189 bar->dragging = Qnil;
4335 tracked_scroll_bar = NULL; 4190 tracked_scroll_bar = NULL;
4336 } 4191 }
4337 4192
4338 static void 4193 static void
4339 x_scroll_bar_handle_drag (win, bar, mouse_pos, timestamp, bufp) 4194 x_scroll_bar_handle_drag (win, bar, mouse_pos, bufp)
4340 WindowPtr win; 4195 WindowPtr win;
4341 struct scroll_bar *bar; 4196 struct scroll_bar *bar;
4342 Point mouse_pos; 4197 Point mouse_pos;
4343 unsigned long timestamp;
4344 struct input_event *bufp; 4198 struct input_event *bufp;
4345 { 4199 {
4346 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar); 4200 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
4347 4201
4348 if (last_scroll_bar_part == scroll_bar_handle) 4202 if (last_scroll_bar_part == scroll_bar_handle)
4358 4212
4359 top = mouse_pos.v - XINT (bar->dragging) - XINT (bar->track_top); 4213 top = mouse_pos.v - XINT (bar->dragging) - XINT (bar->track_top);
4360 top_range = (XINT (bar->track_height) - (r.bottom - r.top)) * 4214 top_range = (XINT (bar->track_height) - (r.bottom - r.top)) *
4361 (1.0 + (float) GetControlViewSize (ch) / GetControl32BitMaximum (ch)) 4215 (1.0 + (float) GetControlViewSize (ch) / GetControl32BitMaximum (ch))
4362 + .5; 4216 + .5;
4363 4217
4364 if (top < 0) 4218 if (top < 0)
4365 top = 0; 4219 top = 0;
4366 if (top > top_range) 4220 if (top > top_range)
4367 top = top_range; 4221 top = top_range;
4368 4222
4369 construct_scroll_bar_click (bar, scroll_bar_handle, timestamp, bufp); 4223 construct_scroll_bar_click (bar, scroll_bar_handle, bufp);
4370 XSETINT (bufp->x, top); 4224 XSETINT (bufp->x, top);
4371 XSETINT (bufp->y, top_range); 4225 XSETINT (bufp->y, top_range);
4372 } 4226 }
4373 else 4227 else
4374 { 4228 {
4402 if (unhilite_p) 4256 if (unhilite_p)
4403 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), 0); 4257 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), 0);
4404 else if (part != last_scroll_bar_part 4258 else if (part != last_scroll_bar_part
4405 || scroll_bar_timer_event_posted_p) 4259 || scroll_bar_timer_event_posted_p)
4406 { 4260 {
4407 construct_scroll_bar_click (bar, part, timestamp, bufp); 4261 construct_scroll_bar_click (bar, part, bufp);
4408 last_scroll_bar_part = part; 4262 last_scroll_bar_part = part;
4409 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code); 4263 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code);
4410 set_scroll_bar_timer (SCROLL_BAR_CONTINUOUS_DELAY); 4264 set_scroll_bar_timer (SCROLL_BAR_CONTINUOUS_DELAY);
4411 } 4265 }
4412 } 4266 }
4473 r.top = disp_top; 4327 r.top = disp_top;
4474 r.right = left + width; 4328 r.right = left + width;
4475 r.bottom = disp_top + disp_height; 4329 r.bottom = disp_top + disp_height;
4476 4330
4477 #if TARGET_API_MAC_CARBON 4331 #if TARGET_API_MAC_CARBON
4478 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, 4332 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", width < disp_height,
4479 kControlScrollBarProc, (long) bar); 4333 0, 0, 0, kControlScrollBarProc, (long) bar);
4480 #else 4334 #else
4481 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, 4335 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", width < disp_height,
4482 scrollBarProc, (long) bar); 4336 0, 0, 0, scrollBarProc, (long) bar);
4483 #endif 4337 #endif
4484 SET_SCROLL_BAR_CONTROL_HANDLE (bar, ch); 4338 SET_SCROLL_BAR_CONTROL_HANDLE (bar, ch);
4485 4339
4486 XSETWINDOW (bar->window, w); 4340 XSETWINDOW (bar->window, w);
4487 XSETINT (bar->top, top); 4341 XSETINT (bar->top, top);
4602 XWINDOW (bar->window)->vertical_scroll_bar = Qnil; 4456 XWINDOW (bar->window)->vertical_scroll_bar = Qnil;
4603 4457
4604 UNBLOCK_INPUT; 4458 UNBLOCK_INPUT;
4605 } 4459 }
4606 4460
4461
4607 /* Set the handle of the vertical scroll bar for WINDOW to indicate 4462 /* Set the handle of the vertical scroll bar for WINDOW to indicate
4608 that we are displaying PORTION characters out of a total of WHOLE 4463 that we are displaying PORTION characters out of a total of WHOLE
4609 characters, starting at POSITION. If WINDOW has no scroll bar, 4464 characters, starting at POSITION. If WINDOW has no scroll bar,
4610 create one. */ 4465 create one. */
4466
4611 static void 4467 static void
4612 XTset_vertical_scroll_bar (w, portion, whole, position) 4468 XTset_vertical_scroll_bar (w, portion, whole, position)
4613 struct window *w; 4469 struct window *w;
4614 int portion, whole, position; 4470 int portion, whole, position;
4615 { 4471 {
4682 if (!(XINT (bar->left) == sb_left 4538 if (!(XINT (bar->left) == sb_left
4683 && XINT (bar->top) == top 4539 && XINT (bar->top) == top
4684 && XINT (bar->width) == sb_width 4540 && XINT (bar->width) == sb_width
4685 && XINT (bar->height) == height)) 4541 && XINT (bar->height) == height))
4686 { 4542 {
4687 /* Clear areas not covered by the scroll bar because it's not as 4543 /* Since toolkit scroll bars are smaller than the space reserved
4688 wide as the area reserved for it . This makes sure a 4544 for them on the frame, we have to clear "under" them. */
4689 previous mode line display is cleared after C-x 2 C-x 1, for
4690 example. */
4691 int area_width = WINDOW_SCROLL_BAR_AREA_WIDTH (w);
4692 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 4545 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
4693 left, top, area_width, height, 0); 4546 left, top, width, height, 0);
4694 4547
4695 #if 0 4548 #if 0
4696 if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f)) 4549 if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f))
4697 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 4550 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
4698 sb_left - 1, top, 1, height, 0); 4551 sb_left - 1, top, 1, height, 0);
4700 4553
4701 HideControl (ch); 4554 HideControl (ch);
4702 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top); 4555 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top);
4703 SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, 4556 SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
4704 disp_height); 4557 disp_height);
4705 ShowControl (ch); 4558 if (sb_width < disp_height)
4559 ShowControl (ch);
4706 4560
4707 /* Remember new settings. */ 4561 /* Remember new settings. */
4708 XSETINT (bar->left, sb_left); 4562 XSETINT (bar->left, sb_left);
4709 XSETINT (bar->top, top); 4563 XSETINT (bar->top, top);
4710 XSETINT (bar->width, sb_width); 4564 XSETINT (bar->width, sb_width);
4803 static void 4657 static void
4804 XTredeem_scroll_bar (window) 4658 XTredeem_scroll_bar (window)
4805 struct window *window; 4659 struct window *window;
4806 { 4660 {
4807 struct scroll_bar *bar; 4661 struct scroll_bar *bar;
4662 struct frame *f;
4808 4663
4809 /* We can't redeem this window's scroll bar if it doesn't have one. */ 4664 /* We can't redeem this window's scroll bar if it doesn't have one. */
4810 if (NILP (window->vertical_scroll_bar)) 4665 if (NILP (window->vertical_scroll_bar))
4811 abort (); 4666 abort ();
4812 4667
4813 bar = XSCROLL_BAR (window->vertical_scroll_bar); 4668 bar = XSCROLL_BAR (window->vertical_scroll_bar);
4814 4669
4815 /* Unlink it from the condemned list. */ 4670 /* Unlink it from the condemned list. */
4816 { 4671 f = XFRAME (WINDOW_FRAME (window));
4817 FRAME_PTR f = XFRAME (WINDOW_FRAME (window)); 4672 if (NILP (bar->prev))
4818 4673 {
4819 if (NILP (bar->prev)) 4674 /* If the prev pointer is nil, it must be the first in one of
4820 { 4675 the lists. */
4821 /* If the prev pointer is nil, it must be the first in one of 4676 if (EQ (FRAME_SCROLL_BARS (f), window->vertical_scroll_bar))
4822 the lists. */ 4677 /* It's not condemned. Everything's fine. */
4823 if (EQ (FRAME_SCROLL_BARS (f), window->vertical_scroll_bar)) 4678 return;
4824 /* It's not condemned. Everything's fine. */ 4679 else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f),
4825 return; 4680 window->vertical_scroll_bar))
4826 else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f), 4681 FRAME_CONDEMNED_SCROLL_BARS (f) = bar->next;
4827 window->vertical_scroll_bar)) 4682 else
4828 FRAME_CONDEMNED_SCROLL_BARS (f) = bar->next; 4683 /* If its prev pointer is nil, it must be at the front of
4829 else 4684 one or the other! */
4830 /* If its prev pointer is nil, it must be at the front of 4685 abort ();
4831 one or the other! */ 4686 }
4832 abort (); 4687 else
4833 } 4688 XSCROLL_BAR (bar->prev)->next = bar->next;
4834 else 4689
4835 XSCROLL_BAR (bar->prev)->next = bar->next; 4690 if (! NILP (bar->next))
4836 4691 XSCROLL_BAR (bar->next)->prev = bar->prev;
4837 if (! NILP (bar->next)) 4692
4838 XSCROLL_BAR (bar->next)->prev = bar->prev; 4693 bar->next = FRAME_SCROLL_BARS (f);
4839 4694 bar->prev = Qnil;
4840 bar->next = FRAME_SCROLL_BARS (f); 4695 XSETVECTOR (FRAME_SCROLL_BARS (f), bar);
4841 bar->prev = Qnil; 4696 if (! NILP (bar->next))
4842 XSETVECTOR (FRAME_SCROLL_BARS (f), bar); 4697 XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar);
4843 if (! NILP (bar->next))
4844 XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar);
4845 }
4846 } 4698 }
4847 4699
4848 /* Remove all scroll bars on FRAME that haven't been saved since the 4700 /* Remove all scroll bars on FRAME that haven't been saved since the
4849 last call to `*condemn_scroll_bars_hook'. */ 4701 last call to `*condemn_scroll_bars_hook'. */
4850 4702
4979 } 4831 }
4980 } 4832 }
4981 4833
4982 #endif /* !USE_TOOLKIT_SCROLL_BARS */ 4834 #endif /* !USE_TOOLKIT_SCROLL_BARS */
4983 4835
4984 /* Return information to the user about the current position of the 4836 /* Return information to the user about the current position of the mouse
4985 mouse on the scroll bar. */ 4837 on the scroll bar. */
4986 4838
4987 static void 4839 static void
4988 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) 4840 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
4989 FRAME_PTR *fp; 4841 FRAME_PTR *fp;
4990 Lisp_Object *bar_window; 4842 Lisp_Object *bar_window;
5498 DisposeRgn (region); 5350 DisposeRgn (region);
5499 #endif /* not TARGET_API_MAC_CARBON */ 5351 #endif /* not TARGET_API_MAC_CARBON */
5500 } 5352 }
5501 5353
5502 5354
5355
5503 /* Calculate the absolute position in frame F 5356 /* Calculate the absolute position in frame F
5504 from its current recorded position values and gravity. */ 5357 from its current recorded position values and gravity. */
5505 5358
5506 void 5359 void
5507 x_calc_absolute_position (f) 5360 x_calc_absolute_position (f)
5729 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f), 5582 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f),
5730 0, 0, 0, 0, pix_x, pix_y); 5583 0, 0, 0, 0, pix_x, pix_y);
5731 UNBLOCK_INPUT; 5584 UNBLOCK_INPUT;
5732 #endif 5585 #endif
5733 } 5586 }
5734
5735 5587
5736 /* focus shifting, raising and lowering. */ 5588 /* focus shifting, raising and lowering. */
5737 5589
5738 void 5590 void
5739 x_focus_on_frame (f) 5591 x_focus_on_frame (f)
5756 struct frame *f; 5608 struct frame *f;
5757 { 5609 {
5758 } 5610 }
5759 5611
5760 /* Raise frame F. */ 5612 /* Raise frame F. */
5613
5761 void 5614 void
5762 x_raise_frame (f) 5615 x_raise_frame (f)
5763 struct frame *f; 5616 struct frame *f;
5764 { 5617 {
5765 if (f->async_visible) 5618 if (f->async_visible)
5769 UNBLOCK_INPUT; 5622 UNBLOCK_INPUT;
5770 } 5623 }
5771 } 5624 }
5772 5625
5773 /* Lower frame F. */ 5626 /* Lower frame F. */
5627
5774 void 5628 void
5775 x_lower_frame (f) 5629 x_lower_frame (f)
5776 struct frame *f; 5630 struct frame *f;
5777 { 5631 {
5778 if (f->async_visible) 5632 if (f->async_visible)
5793 else 5647 else
5794 x_lower_frame (f); 5648 x_lower_frame (f);
5795 } 5649 }
5796 5650
5797 /* Change of visibility. */ 5651 /* Change of visibility. */
5652
5653 static void
5654 mac_handle_visibility_change (f)
5655 struct frame *f;
5656 {
5657 WindowPtr wp = FRAME_MAC_WINDOW (f);
5658 int visible = 0, iconified = 0;
5659 struct input_event buf;
5660
5661 if (IsWindowVisible (wp))
5662 if (IsWindowCollapsed (wp))
5663 iconified = 1;
5664 else
5665 visible = 1;
5666
5667 if (!f->async_visible && visible)
5668 {
5669 if (f->iconified)
5670 {
5671 /* wait_reading_process_output will notice this and update
5672 the frame's display structures. If we were made
5673 invisible, we should not set garbaged, because that stops
5674 redrawing on Update events. */
5675 SET_FRAME_GARBAGED (f);
5676
5677 EVENT_INIT (buf);
5678 buf.kind = DEICONIFY_EVENT;
5679 XSETFRAME (buf.frame_or_window, f);
5680 kbd_buffer_store_event (&buf);
5681 }
5682 else if (! NILP (Vframe_list) && ! NILP (XCDR (Vframe_list)))
5683 /* Force a redisplay sooner or later to update the
5684 frame titles in case this is the second frame. */
5685 record_asynch_buffer_change ();
5686 }
5687 else if (f->async_visible && !visible)
5688 if (iconified)
5689 {
5690 EVENT_INIT (buf);
5691 buf.kind = ICONIFY_EVENT;
5692 XSETFRAME (buf.frame_or_window, f);
5693 kbd_buffer_store_event (&buf);
5694 }
5695
5696 f->async_visible = visible;
5697 f->async_iconified = iconified;
5698 }
5798 5699
5799 /* This tries to wait until the frame is really visible. 5700 /* This tries to wait until the frame is really visible.
5800 However, if the window manager asks the user where to position 5701 However, if the window manager asks the user where to position
5801 the frame, this will return before the user finishes doing that. 5702 the frame, this will return before the user finishes doing that.
5802 The frame will not actually be visible at that time, 5703 The frame will not actually be visible at that time,
5818 call x_set_offset a second time 5719 call x_set_offset a second time
5819 if we get to x_make_frame_visible a second time 5720 if we get to x_make_frame_visible a second time
5820 before the window gets really visible. */ 5721 before the window gets really visible. */
5821 if (! FRAME_ICONIFIED_P (f) 5722 if (! FRAME_ICONIFIED_P (f)
5822 && ! f->output_data.mac->asked_for_visible) 5723 && ! f->output_data.mac->asked_for_visible)
5823 x_set_offset (f, f->left_pos, f->top_pos, 0); 5724 #if TARGET_API_MAC_CARBON
5725 if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition)))
5726 {
5727 struct frame *sf = SELECTED_FRAME ();
5728 if (!FRAME_MAC_P (sf))
5729 RepositionWindow (FRAME_MAC_WINDOW (f), NULL,
5730 kWindowCenterOnMainScreen);
5731 else
5732 RepositionWindow (FRAME_MAC_WINDOW (f),
5733 FRAME_MAC_WINDOW (sf),
5734 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
5735 kWindowCascadeStartAtParentWindowScreen
5736 #else
5737 kWindowCascadeOnParentWindowScreen
5738 #endif
5739 );
5740 x_real_positions (f, &f->left_pos, &f->top_pos);
5741 }
5742 else
5743 #endif
5744 x_set_offset (f, f->left_pos, f->top_pos, 0);
5824 5745
5825 f->output_data.mac->asked_for_visible = 1; 5746 f->output_data.mac->asked_for_visible = 1;
5826 5747
5827 #if TARGET_API_MAC_CARBON 5748 SelectWindow (FRAME_MAC_WINDOW (f));
5828 if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition))) 5749 CollapseWindow (FRAME_MAC_WINDOW (f), false);
5829 {
5830 struct frame *sf = SELECTED_FRAME ();
5831 if (!FRAME_MAC_P (sf))
5832 RepositionWindow (FRAME_MAC_WINDOW (f), NULL,
5833 kWindowCenterOnMainScreen);
5834 else
5835 RepositionWindow (FRAME_MAC_WINDOW (f),
5836 FRAME_MAC_WINDOW (sf),
5837 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
5838 kWindowCascadeStartAtParentWindowScreen
5839 #else
5840 kWindowCascadeOnParentWindowScreen
5841 #endif
5842 );
5843 x_real_positions (f, &f->left_pos, &f->top_pos);
5844 }
5845 #endif
5846 ShowWindow (FRAME_MAC_WINDOW (f)); 5750 ShowWindow (FRAME_MAC_WINDOW (f));
5847 } 5751 }
5848 5752
5849 XFlush (FRAME_MAC_DISPLAY (f)); 5753 XFlush (FRAME_MAC_DISPLAY (f));
5850 5754
5899 5803
5900 void 5804 void
5901 x_make_frame_invisible (f) 5805 x_make_frame_invisible (f)
5902 struct frame *f; 5806 struct frame *f;
5903 { 5807 {
5808 /* A deactivate event does not occur when the last visible frame is
5809 made invisible. So if we clear the highlight here, it will not
5810 be rehighlighted when it is made visible. */
5811 #if 0
5904 /* Don't keep the highlight on an invisible frame. */ 5812 /* Don't keep the highlight on an invisible frame. */
5905 if (FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame == f) 5813 if (FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame == f)
5906 FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame = 0; 5814 FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame = 0;
5815 #endif
5907 5816
5908 BLOCK_INPUT; 5817 BLOCK_INPUT;
5909 5818
5910 /* Before unmapping the window, update the WM_SIZE_HINTS property to claim 5819 /* Before unmapping the window, update the WM_SIZE_HINTS property to claim
5911 that the current position of the window is user-specified, rather than 5820 that the current position of the window is user-specified, rather than
5914 by hand again (they have already done that once for this window.) */ 5823 by hand again (they have already done that once for this window.) */
5915 x_wm_set_size_hint (f, (long) 0, 1); 5824 x_wm_set_size_hint (f, (long) 0, 1);
5916 5825
5917 HideWindow (FRAME_MAC_WINDOW (f)); 5826 HideWindow (FRAME_MAC_WINDOW (f));
5918 5827
5919 /* We can't distinguish this from iconification
5920 just by the event that we get from the server.
5921 So we can't win using the usual strategy of letting
5922 FRAME_SAMPLE_VISIBILITY set this. So do it by hand,
5923 and synchronize with the server to make sure we agree. */
5924 f->visible = 0;
5925 FRAME_ICONIFIED_P (f) = 0;
5926 f->async_visible = 0;
5927 f->async_iconified = 0;
5928
5929 UNBLOCK_INPUT; 5828 UNBLOCK_INPUT;
5829
5830 #if !USE_CARBON_EVENTS
5831 mac_handle_visibility_change (f);
5832 #endif
5930 } 5833 }
5931 5834
5932 /* Change window state from mapped to iconified. */ 5835 /* Change window state from mapped to iconified. */
5933 5836
5934 void 5837 void
5935 x_iconify_frame (f) 5838 x_iconify_frame (f)
5936 struct frame *f; 5839 struct frame *f;
5937 { 5840 {
5841 OSErr err;
5842
5843 /* A deactivate event does not occur when the last visible frame is
5844 iconified. So if we clear the highlight here, it will not be
5845 rehighlighted when it is deiconified. */
5846 #if 0
5938 /* Don't keep the highlight on an invisible frame. */ 5847 /* Don't keep the highlight on an invisible frame. */
5939 if (FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame == f) 5848 if (FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame == f)
5940 FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame = 0; 5849 FRAME_MAC_DISPLAY_INFO (f)->x_highlight_frame = 0;
5941 5850 #endif
5942 #if 0 5851
5943 /* Review: Since window is still visible in dock, still allow updates? */
5944 if (f->async_iconified) 5852 if (f->async_iconified)
5945 return; 5853 return;
5946 #endif
5947 5854
5948 BLOCK_INPUT; 5855 BLOCK_INPUT;
5949 5856
5950 CollapseWindow (FRAME_MAC_WINDOW (f), true); 5857 FRAME_SAMPLE_VISIBILITY (f);
5858
5859 if (! FRAME_VISIBLE_P (f))
5860 ShowWindow (FRAME_MAC_WINDOW (f));
5861
5862 err = CollapseWindow (FRAME_MAC_WINDOW (f), true);
5951 5863
5952 UNBLOCK_INPUT; 5864 UNBLOCK_INPUT;
5865
5866 if (err != noErr)
5867 error ("Can't notify window manager of iconification");
5868
5869 #if !USE_CARBON_EVENTS
5870 mac_handle_visibility_change (f);
5871 #endif
5953 } 5872 }
5954 5873
5955 5874
5956 /* Free X resources of frame F. */ 5875 /* Free X resources of frame F. */
5957 5876
6177 { 6096 {
6178 return (FRAME_MAC_FONT_TABLE (f) + font_idx); 6097 return (FRAME_MAC_FONT_TABLE (f) + font_idx);
6179 } 6098 }
6180 6099
6181 /* the global font name table */ 6100 /* the global font name table */
6182 char **font_name_table = NULL; 6101 static char **font_name_table = NULL;
6183 int font_name_table_size = 0; 6102 static int font_name_table_size = 0;
6184 int font_name_count = 0; 6103 static int font_name_count = 0;
6185 6104
6186 /* Alist linking character set strings to Mac text encoding and Emacs 6105 /* Alist linking character set strings to Mac text encoding and Emacs
6187 coding system. */ 6106 coding system. */
6188 static Lisp_Object Vmac_charset_info_alist; 6107 static Lisp_Object Vmac_charset_info_alist;
6189 6108
7336 fontp->default_ascent = 0; 7255 fontp->default_ascent = 0;
7337 #endif 7256 #endif
7338 7257
7339 /* Set global flag fonts_changed_p to non-zero if the font loaded 7258 /* Set global flag fonts_changed_p to non-zero if the font loaded
7340 has a character with a smaller width than any other character 7259 has a character with a smaller width than any other character
7341 before, or if the font loaded has a smalle>r height than any 7260 before, or if the font loaded has a smaller height than any
7342 other font loaded before. If this happens, it will make a 7261 other font loaded before. If this happens, it will make a
7343 glyph matrix reallocation necessary. */ 7262 glyph matrix reallocation necessary. */
7344 fonts_changed_p |= x_compute_min_glyph_bounds (f); 7263 fonts_changed_p |= x_compute_min_glyph_bounds (f);
7345 UNBLOCK_INPUT; 7264 UNBLOCK_INPUT;
7346 return fontp; 7265 return fontp;
7433 #define DEFAULT_NUM_COLS 80 7352 #define DEFAULT_NUM_COLS 80
7434 7353
7435 #define MIN_DOC_SIZE 64 7354 #define MIN_DOC_SIZE 64
7436 #define MAX_DOC_SIZE 32767 7355 #define MAX_DOC_SIZE 32767
7437 7356
7438 #if 0
7439 /* sleep time for WaitNextEvent */
7440 #define WNE_SLEEP_AT_SUSPEND 10
7441 #define WNE_SLEEP_AT_RESUME 1
7442
7443 /* the flag appl_is_suspended is used both for determining the sleep
7444 time to be passed to WaitNextEvent and whether the cursor should be
7445 drawn when updating the display. The cursor is turned off when
7446 Emacs is suspended. Redrawing it is unnecessary and what needs to
7447 be done depends on whether the cursor lies inside or outside the
7448 redraw region. So we might as well skip drawing it when Emacs is
7449 suspended. */
7450 static Boolean app_is_suspended = false;
7451 static long app_sleep_time = WNE_SLEEP_AT_RESUME;
7452 #endif
7453
7454 #define EXTRA_STACK_ALLOC (256 * 1024) 7357 #define EXTRA_STACK_ALLOC (256 * 1024)
7455 7358
7456 #define ARGV_STRING_LIST_ID 129 7359 #define ARGV_STRING_LIST_ID 129
7457 #define ABOUT_ALERT_ID 128 7360 #define ABOUT_ALERT_ID 128
7458 #define RAM_TOO_LARGE_ALERT_ID 129 7361 #define RAM_TOO_LARGE_ALERT_ID 129
7483 Lisp_Object Vmac_pass_command_to_system; 7386 Lisp_Object Vmac_pass_command_to_system;
7484 7387
7485 /* If Non-nil, the Mac "Control" key is passed on to the Mac Toolbox 7388 /* If Non-nil, the Mac "Control" key is passed on to the Mac Toolbox
7486 for processing before Emacs sees it. */ 7389 for processing before Emacs sees it. */
7487 Lisp_Object Vmac_pass_control_to_system; 7390 Lisp_Object Vmac_pass_control_to_system;
7391 #endif
7488 7392
7489 /* Points to the variable `inev' in the function XTread_socket. It is 7393 /* Points to the variable `inev' in the function XTread_socket. It is
7490 used for passing an input event to the function back from a Carbon 7394 used for passing an input event to the function back from
7491 event handler. */ 7395 Carbon/Apple event handlers. */
7492 static struct input_event *read_socket_inev = NULL; 7396 static struct input_event *read_socket_inev = NULL;
7493 #endif
7494 7397
7495 /* Set in term/mac-win.el to indicate that event loop can now generate 7398 /* Set in term/mac-win.el to indicate that event loop can now generate
7496 drag and drop events. */ 7399 drag and drop events. */
7497 Lisp_Object Qmac_ready_for_drag_n_drop; 7400 Lisp_Object Qmac_ready_for_drag_n_drop;
7498
7499 Lisp_Object drag_and_drop_file_list;
7500 7401
7501 Point saved_menu_event_location; 7402 Point saved_menu_event_location;
7502 7403
7503 /* Apple Events */ 7404 /* Apple Events */
7504 static void init_required_apple_events (void); 7405 static void init_required_apple_events (void);
7775 below. */ 7676 below. */
7776 if (win != tip_window) 7677 if (win != tip_window)
7777 { 7678 {
7778 if (f->async_visible == 0) 7679 if (f->async_visible == 0)
7779 { 7680 {
7681 /* Update events may occur when a frame gets iconified. */
7682 #if 0
7780 f->async_visible = 1; 7683 f->async_visible = 1;
7781 f->async_iconified = 0; 7684 f->async_iconified = 0;
7782 SET_FRAME_GARBAGED (f); 7685 SET_FRAME_GARBAGED (f);
7783 7686 #endif
7784 /* An update event is equivalent to MapNotify on X, so report
7785 visibility changes properly. */
7786 if (! NILP(Vframe_list) && ! NILP (XCDR (Vframe_list)))
7787 /* Force a redisplay sooner or later to update the
7788 frame titles in case this is the second frame. */
7789 record_asynch_buffer_change ();
7790 } 7687 }
7791 else 7688 else
7792 { 7689 {
7793 Rect r; 7690 Rect r;
7794
7795 #if TARGET_API_MAC_CARBON 7691 #if TARGET_API_MAC_CARBON
7796 { 7692 RgnHandle region = NewRgn ();
7797 RgnHandle region = NewRgn (); 7693
7798 7694 GetPortVisibleRegion (GetWindowPort (win), region);
7799 GetPortVisibleRegion (GetWindowPort (win), region); 7695 GetRegionBounds (region, &r);
7800 GetRegionBounds (region, &r); 7696 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
7801 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); 7697 UpdateControls (win, region);
7802 UpdateControls (win, region); 7698 DisposeRgn (region);
7803 DisposeRgn (region);
7804 }
7805 #else 7699 #else
7806 r = (*win->visRgn)->rgnBBox; 7700 r = (*win->visRgn)->rgnBBox;
7807 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); 7701 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
7808 UpdateControls (win, win->visRgn); 7702 UpdateControls (win, win->visRgn);
7809 #endif 7703 #endif
7810 } 7704 }
7811 } 7705 }
7812 7706
7813 EndUpdate (win); 7707 EndUpdate (win);
7814 } 7708 }
7815 7709
7831 7725
7832 static void 7726 static void
7833 do_app_resume () 7727 do_app_resume ()
7834 { 7728 {
7835 /* Window-activate events will do the job. */ 7729 /* Window-activate events will do the job. */
7836 #if 0
7837 app_is_suspended = false;
7838 app_sleep_time = WNE_SLEEP_AT_RESUME;
7839 #endif
7840 } 7730 }
7841 7731
7842 static void 7732 static void
7843 do_app_suspend () 7733 do_app_suspend ()
7844 { 7734 {
7845 /* Window-deactivate events will do the job. */ 7735 /* Window-deactivate events will do the job. */
7846 #if 0
7847 app_is_suspended = true;
7848 app_sleep_time = WNE_SLEEP_AT_SUSPEND;
7849 #endif
7850 } 7736 }
7851 7737
7852 7738
7853 static void 7739 static void
7854 do_apple_menu (SInt16 menu_item) 7740 do_apple_menu (SInt16 menu_item)
8345 SetEventParameter (event, kEventParamCurrentBounds, 8231 SetEventParameter (event, kEventParamCurrentBounds,
8346 typeQDRectangle, sizeof (Rect), &bounds); 8232 typeQDRectangle, sizeof (Rect), &bounds);
8347 return noErr; 8233 return noErr;
8348 } 8234 }
8349 break; 8235 break;
8236
8237 case kEventWindowShown:
8238 case kEventWindowHidden:
8239 case kEventWindowExpanded:
8240 case kEventWindowCollapsed:
8241 result = CallNextEventHandler (next_handler, event);
8242
8243 mac_handle_visibility_change (mac_window_to_frame (wp));
8244 return noErr;
8245
8246 break;
8350 } 8247 }
8351 8248
8352 return eventNotHandledErr; 8249 return eventNotHandledErr;
8353 } 8250 }
8354 8251
8398 SetPortWindowPort (wp); 8295 SetPortWindowPort (wp);
8399 GlobalToLocal (&point); 8296 GlobalToLocal (&point);
8400 XSETINT (read_socket_inev->x, point.h); 8297 XSETINT (read_socket_inev->x, point.h);
8401 XSETINT (read_socket_inev->y, point.v); 8298 XSETINT (read_socket_inev->y, point.v);
8402 XSETFRAME (read_socket_inev->frame_or_window, f); 8299 XSETFRAME (read_socket_inev->frame_or_window, f);
8403 read_socket_inev->timestamp =
8404 EventTimeToTicks (GetEventTime (event)) * (1000/60);
8405 8300
8406 return noErr; 8301 return noErr;
8407 } 8302 }
8408 break; 8303 break;
8409 8304
8422 { 8317 {
8423 OSErr err = noErr; 8318 OSErr err = noErr;
8424 #if USE_CARBON_EVENTS 8319 #if USE_CARBON_EVENTS
8425 EventTypeSpec specs_window[] = 8320 EventTypeSpec specs_window[] =
8426 {{kEventClassWindow, kEventWindowUpdate}, 8321 {{kEventClassWindow, kEventWindowUpdate},
8427 {kEventClassWindow, kEventWindowBoundsChanging}}; 8322 {kEventClassWindow, kEventWindowBoundsChanging},
8323 {kEventClassWindow, kEventWindowShown},
8324 {kEventClassWindow, kEventWindowHidden},
8325 {kEventClassWindow, kEventWindowExpanded},
8326 {kEventClassWindow, kEventWindowCollapsed}};
8428 EventTypeSpec specs_mouse[] = {{kEventClassMouse, kEventMouseWheelMoved}}; 8327 EventTypeSpec specs_mouse[] = {{kEventClassMouse, kEventMouseWheelMoved}};
8429 static EventHandlerUPP handle_window_eventUPP = NULL; 8328 static EventHandlerUPP handle_window_eventUPP = NULL;
8430 static EventHandlerUPP handle_mouse_eventUPP = NULL; 8329 static EventHandlerUPP handle_mouse_eventUPP = NULL;
8431 8330
8432 if (handle_window_eventUPP == NULL) 8331 if (handle_window_eventUPP == NULL)
8471 static pascal OSErr 8370 static pascal OSErr
8472 do_ae_open_application(const AppleEvent *pae, AppleEvent *preply, long prefcon) 8371 do_ae_open_application(const AppleEvent *pae, AppleEvent *preply, long prefcon)
8473 { 8372 {
8474 return noErr; 8373 return noErr;
8475 } 8374 }
8476
8477
8478 /* Defined in mac.c. */
8479 extern int
8480 path_from_vol_dir_name (char *, int, short, long, char *);
8481 8375
8482 8376
8483 /* Called when we receive an AppleEvent with an ID of 8377 /* Called when we receive an AppleEvent with an ID of
8484 "kAEOpenDocuments". This routine gets the direct parameter, 8378 "kAEOpenDocuments". This routine gets the direct parameter,
8485 extracts the FSSpecs in it, and puts their names on a list. */ 8379 extracts the FSSpecs in it, and puts their names on a list. */
8501 AEDesc the_desc; 8395 AEDesc the_desc;
8502 AEKeyword keyword; 8396 AEKeyword keyword;
8503 DescType actual_type; 8397 DescType actual_type;
8504 Size actual_size; 8398 Size actual_size;
8505 SelectionRange position; 8399 SelectionRange position;
8400 Lisp_Object file_list = Qnil;
8401
8402 xassert (read_socket_inev);
8506 8403
8507 err = AEGetParamDesc (message, keyDirectObject, typeAEList, &the_desc); 8404 err = AEGetParamDesc (message, keyDirectObject, typeAEList, &the_desc);
8508 if (err != noErr) 8405 if (err != noErr)
8509 goto descriptor_error_exit; 8406 goto descriptor_error_exit;
8510 8407
8511 err = AEGetParamPtr (message, keyAEPosition, typeChar, &actual_type, &position, sizeof(SelectionRange), &actual_size); 8408 err = AEGetParamPtr (message, keyAEPosition, typeChar, &actual_type, &position, sizeof(SelectionRange), &actual_size);
8512 if (err == noErr) 8409 if (err == noErr)
8513 drag_and_drop_file_list = Fcons (list3 (make_number (position.lineNum + 1), 8410 file_list = Fcons (list3 (make_number (position.lineNum + 1),
8514 make_number (position.startRange + 1), 8411 make_number (position.startRange + 1),
8515 make_number (position.endRange + 1)), 8412 make_number (position.endRange + 1)),
8516 drag_and_drop_file_list); 8413 file_list);
8517 8414
8518 /* Check to see that we got all of the required parameters from the 8415 /* Check to see that we got all of the required parameters from the
8519 event descriptor. For an 'odoc' event this should just be the 8416 event descriptor. For an 'odoc' event this should just be the
8520 file list. */ 8417 file list. */
8521 err = AEGetAttributePtr(message, keyMissedKeywordAttr, typeWildCard, 8418 err = AEGetAttributePtr(message, keyMissedKeywordAttr, typeWildCard,
8565 8462
8566 if (fsspec_to_posix_pathname (&fs, unix_path_name, 8463 if (fsspec_to_posix_pathname (&fs, unix_path_name,
8567 sizeof (unix_path_name) - 1) == noErr) 8464 sizeof (unix_path_name) - 1) == noErr)
8568 #endif 8465 #endif
8569 /* x-dnd functions expect undecoded filenames. */ 8466 /* x-dnd functions expect undecoded filenames. */
8570 drag_and_drop_file_list = 8467 file_list = Fcons (make_unibyte_string (unix_path_name,
8571 Fcons (make_unibyte_string (unix_path_name, 8468 strlen (unix_path_name)),
8572 strlen (unix_path_name)), 8469 file_list);
8573 drag_and_drop_file_list);
8574 } 8470 }
8471 }
8472
8473 /* Build a DRAG_N_DROP_EVENT type event as is done in
8474 constuct_drag_n_drop in w32term.c. */
8475 if (!NILP (file_list))
8476 {
8477 struct frame *f = mac_focus_frame (&one_mac_display_info);
8478 WindowPtr wp;
8479 Lisp_Object frame;
8480
8481 read_socket_inev->kind = DRAG_N_DROP_EVENT;
8482 read_socket_inev->code = 0;
8483 read_socket_inev->modifiers = 0;
8484
8485 XSETINT (read_socket_inev->x, 0);
8486 XSETINT (read_socket_inev->y, 0);
8487
8488 XSETFRAME (frame, f);
8489 read_socket_inev->frame_or_window = Fcons (frame, file_list);
8490
8491 #if 0
8492 /* Regardless of whether Emacs was suspended or in the
8493 foreground, ask it to redraw its entire screen. Otherwise
8494 parts of the screen can be left in an inconsistent
8495 state. */
8496 wp = FRAME_MAC_WINDOW (f);
8497 if (wp)
8498 #if TARGET_API_MAC_CARBON
8499 {
8500 Rect r;
8501
8502 GetWindowPortBounds (wp, &r);
8503 InvalWindowRect (wp, &r);
8504 }
8505 #else /* not TARGET_API_MAC_CARBON */
8506 InvalRect (&(wp->portRect));
8507 #endif /* not TARGET_API_MAC_CARBON */
8508 #endif
8575 } 8509 }
8576 } 8510 }
8577 8511
8578 error_exit: 8512 error_exit:
8579 /* Nuke the coerced file list in any case */ 8513 /* Nuke the coerced file list in any case */
8663 Point mouse; 8597 Point mouse;
8664 OSErr result; 8598 OSErr result;
8665 ItemReference theItem; 8599 ItemReference theItem;
8666 HFSFlavor data; 8600 HFSFlavor data;
8667 Size size = sizeof (HFSFlavor); 8601 Size size = sizeof (HFSFlavor);
8602 Lisp_Object file_list;
8668 8603
8669 if (GetFrontWindowOfClass (kMovableModalWindowClass, false)) 8604 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
8670 return dragNotAcceptedErr; 8605 return dragNotAcceptedErr;
8671 8606
8672 drag_and_drop_file_list = Qnil; 8607 file_list = Qnil;
8673 GetDragMouse (theDrag, &mouse, 0L); 8608 GetDragMouse (theDrag, &mouse, 0L);
8674 CountDragItems (theDrag, &items); 8609 CountDragItems (theDrag, &items);
8675 for (index = 1; index <= items; index++) 8610 for (index = 1; index <= items; index++)
8676 { 8611 {
8677 /* Only handle file references. */ 8612 /* Only handle file references. */
8693 #else 8628 #else
8694 if (fsspec_to_posix_pathname (&data.fileSpec, unix_path_name, 8629 if (fsspec_to_posix_pathname (&data.fileSpec, unix_path_name,
8695 sizeof (unix_path_name) - 1) == noErr) 8630 sizeof (unix_path_name) - 1) == noErr)
8696 #endif 8631 #endif
8697 /* x-dnd functions expect undecoded filenames. */ 8632 /* x-dnd functions expect undecoded filenames. */
8698 drag_and_drop_file_list = 8633 file_list = Fcons (make_unibyte_string (unix_path_name,
8699 Fcons (make_unibyte_string (unix_path_name, 8634 strlen (unix_path_name)),
8700 strlen (unix_path_name)), 8635 file_list);
8701 drag_and_drop_file_list);
8702 } 8636 }
8703 } 8637 }
8704 /* If there are items in the list, construct an event and post it to 8638 /* If there are items in the list, construct an event and post it to
8705 the queue like an interrupt using kbd_buffer_store_event. */ 8639 the queue like an interrupt using kbd_buffer_store_event. */
8706 if (!NILP (drag_and_drop_file_list)) 8640 if (!NILP (file_list))
8707 { 8641 {
8708 struct input_event event; 8642 struct input_event event;
8709 Lisp_Object frame; 8643 Lisp_Object frame;
8710 struct frame *f = mac_window_to_frame (window); 8644 struct frame *f = mac_window_to_frame (window);
8711 SInt16 modifiers; 8645 SInt16 modifiers;
8718 event.modifiers = mac_to_emacs_modifiers (modifiers); 8652 event.modifiers = mac_to_emacs_modifiers (modifiers);
8719 event.timestamp = TickCount () * (1000 / 60); 8653 event.timestamp = TickCount () * (1000 / 60);
8720 XSETINT (event.x, mouse.h); 8654 XSETINT (event.x, mouse.h);
8721 XSETINT (event.y, mouse.v); 8655 XSETINT (event.y, mouse.v);
8722 XSETFRAME (frame, f); 8656 XSETFRAME (frame, f);
8723 event.frame_or_window = Fcons (frame, drag_and_drop_file_list); 8657 event.frame_or_window = Fcons (frame, file_list);
8724 event.arg = Qnil; 8658 event.arg = Qnil;
8725 /* Post to the interrupt queue */ 8659 /* Post to the interrupt queue */
8726 kbd_buffer_store_event (&event); 8660 kbd_buffer_store_event (&event);
8727 /* MAC_TODO: Mimic behavior of windows by switching contexts to Emacs */ 8661 /* MAC_TODO: Mimic behavior of windows by switching contexts to Emacs */
8728 { 8662 {
8977 while (mac_wait_next_event (&er, 0, true)) 8911 while (mac_wait_next_event (&er, 0, true))
8978 #endif /* !USE_CARBON_EVENTS */ 8912 #endif /* !USE_CARBON_EVENTS */
8979 { 8913 {
8980 int do_help = 0; 8914 int do_help = 0;
8981 struct frame *f; 8915 struct frame *f;
8916 unsigned long timestamp;
8982 8917
8983 /* It is necessary to set this (additional) argument slot of an 8918 /* It is necessary to set this (additional) argument slot of an
8984 event to nil because keyboard.c protects incompletely 8919 event to nil because keyboard.c protects incompletely
8985 processed event from being garbage collected by placing them 8920 processed event from being garbage collected by placing them
8986 in the kbd_buffer_gcpro vector. */ 8921 in the kbd_buffer_gcpro vector. */
8987 EVENT_INIT (inev); 8922 EVENT_INIT (inev);
8988 inev.kind = NO_EVENT; 8923 inev.kind = NO_EVENT;
8989 inev.arg = Qnil; 8924 inev.arg = Qnil;
8925
8926 #if USE_CARBON_EVENTS
8927 timestamp = GetEventTime (eventRef) / kEventDurationMillisecond;
8928 #else
8929 timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
8930 #endif
8990 8931
8991 #if USE_CARBON_EVENTS 8932 #if USE_CARBON_EVENTS
8992 /* Handle new events */ 8933 /* Handle new events */
8993 if (!mac_convert_event_ref (eventRef, &er)) 8934 if (!mac_convert_event_ref (eventRef, &er))
8994 { 8935 {
9087 inev.code = mac_get_emulated_btn (er.modifiers); 9028 inev.code = mac_get_emulated_btn (er.modifiers);
9088 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); 9029 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
9089 #endif 9030 #endif
9090 XSETINT (inev.x, mouse_loc.h); 9031 XSETINT (inev.x, mouse_loc.h);
9091 XSETINT (inev.y, mouse_loc.v); 9032 XSETINT (inev.y, mouse_loc.v);
9092 inev.timestamp = er.when * (1000 / 60);
9093 /* ticks to milliseconds */
9094 9033
9095 if (dpyinfo->grabbed && tracked_scroll_bar 9034 if (dpyinfo->grabbed && tracked_scroll_bar
9096 || ch != 0 9035 || ch != 0
9097 #ifndef USE_TOOLKIT_SCROLL_BARS 9036 #ifndef USE_TOOLKIT_SCROLL_BARS
9098 /* control_part_code becomes kControlNoPart if 9037 /* control_part_code becomes kControlNoPart if
9122 if (er.modifiers & controlKey) 9061 if (er.modifiers & controlKey)
9123 x_scroll_bar_handle_click (bar, control_part_code, 9062 x_scroll_bar_handle_click (bar, control_part_code,
9124 &er, &inev); 9063 &er, &inev);
9125 else if (er.what == mouseDown) 9064 else if (er.what == mouseDown)
9126 x_scroll_bar_handle_press (bar, control_part_code, 9065 x_scroll_bar_handle_press (bar, control_part_code,
9127 inev.timestamp, &inev); 9066 &inev);
9128 else 9067 else
9129 x_scroll_bar_handle_release (bar, inev.timestamp, 9068 x_scroll_bar_handle_release (bar, &inev);
9130 &inev);
9131 #else /* not USE_TOOLKIT_SCROLL_BARS */ 9069 #else /* not USE_TOOLKIT_SCROLL_BARS */
9132 x_scroll_bar_handle_click (bar, control_part_code, 9070 x_scroll_bar_handle_click (bar, control_part_code,
9133 &er, &inev); 9071 &er, &inev);
9134 if (er.what == mouseDown 9072 if (er.what == mouseDown
9135 && control_part_code == kControlIndicatorPart) 9073 && control_part_code == kControlIndicatorPart)
9299 GlobalToLocal (&mouse_pos); 9237 GlobalToLocal (&mouse_pos);
9300 9238
9301 if (dpyinfo->grabbed && tracked_scroll_bar) 9239 if (dpyinfo->grabbed && tracked_scroll_bar)
9302 #ifdef USE_TOOLKIT_SCROLL_BARS 9240 #ifdef USE_TOOLKIT_SCROLL_BARS
9303 x_scroll_bar_handle_drag (wp, tracked_scroll_bar, 9241 x_scroll_bar_handle_drag (wp, tracked_scroll_bar,
9304 mouse_pos, er.when * (1000 / 60), 9242 mouse_pos, &inev);
9305 &inev);
9306 #else /* not USE_TOOLKIT_SCROLL_BARS */ 9243 #else /* not USE_TOOLKIT_SCROLL_BARS */
9307 x_scroll_bar_note_movement (tracked_scroll_bar, 9244 x_scroll_bar_note_movement (tracked_scroll_bar,
9308 mouse_pos.v 9245 mouse_pos.v
9309 - XINT (tracked_scroll_bar->top), 9246 - XINT (tracked_scroll_bar->top),
9310 er.when * (1000 / 60)); 9247 er.when * (1000 / 60));
9388 { 9325 {
9389 struct input_event event; 9326 struct input_event event;
9390 9327
9391 EVENT_INIT (event); 9328 EVENT_INIT (event);
9392 event.kind = NO_EVENT; 9329 event.kind = NO_EVENT;
9393 x_scroll_bar_handle_release (tracked_scroll_bar, 9330 x_scroll_bar_handle_release (tracked_scroll_bar, &event);
9394 er.when * (1000 / 60),
9395 &event);
9396 if (event.kind != NO_EVENT) 9331 if (event.kind != NO_EVENT)
9397 { 9332 {
9333 event.timestamp = timestamp;
9398 kbd_buffer_store_event_hold (&event, hold_quit); 9334 kbd_buffer_store_event_hold (&event, hold_quit);
9399 count++; 9335 count++;
9400 } 9336 }
9401 } 9337 }
9402 #endif 9338 #endif
9468 9404
9469 EVENT_INIT (event); 9405 EVENT_INIT (event);
9470 event.kind = LANGUAGE_CHANGE_EVENT; 9406 event.kind = LANGUAGE_CHANGE_EVENT;
9471 event.arg = Qnil; 9407 event.arg = Qnil;
9472 event.code = current_key_script; 9408 event.code = current_key_script;
9409 event.timestamp = timestamp;
9473 kbd_buffer_store_event (&event); 9410 kbd_buffer_store_event (&event);
9474 count++; 9411 count++;
9475 } 9412 }
9476 last_key_script = current_key_script; 9413 last_key_script = current_key_script;
9477 } 9414 }
9532 #if USE_CARBON_EVENTS 9469 #if USE_CARBON_EVENTS
9533 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); 9470 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
9534 #else 9471 #else
9535 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); 9472 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
9536 #endif 9473 #endif
9474 inev.modifiers |= (extra_keyboard_modifiers
9475 & (meta_modifier | alt_modifier
9476 | hyper_modifier | super_modifier));
9537 XSETFRAME (inev.frame_or_window, mac_focus_frame (dpyinfo)); 9477 XSETFRAME (inev.frame_or_window, mac_focus_frame (dpyinfo));
9538 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
9539 break; 9478 break;
9540 9479
9541 case kHighLevelEvent: 9480 case kHighLevelEvent:
9542 drag_and_drop_file_list = Qnil; 9481 read_socket_inev = &inev;
9543 9482 AEProcessAppleEvent (&er);
9544 AEProcessAppleEvent(&er); 9483 read_socket_inev = NULL;
9545 9484 break;
9546 /* Build a DRAG_N_DROP_EVENT type event as is done in 9485
9547 constuct_drag_n_drop in w32term.c. */
9548 if (!NILP (drag_and_drop_file_list))
9549 {
9550 struct frame *f = mac_focus_frame (dpyinfo);
9551 WindowPtr wp;
9552 Lisp_Object frame;
9553
9554 inev.kind = DRAG_N_DROP_EVENT;
9555 inev.code = 0;
9556 inev.timestamp = er.when * (1000 / 60);
9557 /* ticks to milliseconds */
9558 #if USE_CARBON_EVENTS
9559 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
9560 #else
9561 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
9562 #endif
9563
9564 XSETINT (inev.x, 0);
9565 XSETINT (inev.y, 0);
9566
9567 XSETFRAME (frame, f);
9568 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
9569
9570 #if 0
9571 /* Regardless of whether Emacs was suspended or in the
9572 foreground, ask it to redraw its entire screen.
9573 Otherwise parts of the screen can be left in an
9574 inconsistent state. */
9575 wp = FRAME_MAC_WINDOW (f);
9576 if (wp)
9577 #if TARGET_API_MAC_CARBON
9578 {
9579 Rect r;
9580
9581 GetWindowPortBounds (wp, &r);
9582 InvalWindowRect (wp, &r);
9583 }
9584 #else /* not TARGET_API_MAC_CARBON */
9585 InvalRect (&(wp->portRect));
9586 #endif /* not TARGET_API_MAC_CARBON */
9587 #endif
9588 }
9589 default: 9486 default:
9590 break; 9487 break;
9591 } 9488 }
9592 #if USE_CARBON_EVENTS 9489 #if USE_CARBON_EVENTS
9593 ReleaseEvent (eventRef); 9490 ReleaseEvent (eventRef);
9594 #endif 9491 #endif
9595 9492
9596 if (inev.kind != NO_EVENT) 9493 if (inev.kind != NO_EVENT)
9597 { 9494 {
9495 inev.timestamp = timestamp;
9598 kbd_buffer_store_event_hold (&inev, hold_quit); 9496 kbd_buffer_store_event_hold (&inev, hold_quit);
9599 count++; 9497 count++;
9600 } 9498 }
9601 9499
9602 if (do_help 9500 if (do_help
9631 if (pending_autoraise_frame) 9529 if (pending_autoraise_frame)
9632 { 9530 {
9633 x_raise_frame (pending_autoraise_frame); 9531 x_raise_frame (pending_autoraise_frame);
9634 pending_autoraise_frame = 0; 9532 pending_autoraise_frame = 0;
9635 } 9533 }
9534
9535 #if !USE_CARBON_EVENTS
9536 /* Check which frames are still visible. We do this here because
9537 there doesn't seem to be any direct notification from the Window
9538 Manager that the visibility of a window has changed (at least,
9539 not in all cases). */
9540 {
9541 Lisp_Object tail, frame;
9542
9543 FOR_EACH_FRAME (tail, frame)
9544 {
9545 struct frame *f = XFRAME (frame);
9546
9547 /* The tooltip has been drawn already. Avoid the
9548 SET_FRAME_GARBAGED in mac_handle_visibility_change. */
9549 if (EQ (frame, tip_frame))
9550 continue;
9551
9552 if (FRAME_MAC_P (f))
9553 mac_handle_visibility_change (f);
9554 }
9555 }
9556 #endif
9636 9557
9637 UNBLOCK_INPUT; 9558 UNBLOCK_INPUT;
9638 return count; 9559 return count;
9639 } 9560 }
9640 9561
10065 RemoveEventFromQueue (GetMainEventQueue (), event); 9986 RemoveEventFromQueue (GetMainEventQueue (), event);
10066 ReleaseEvent (event); 9987 ReleaseEvent (event);
10067 kbd_buffer_store_event (&e); 9988 kbd_buffer_store_event (&e);
10068 } 9989 }
10069 } 9990 }
10070 #endif /* MAC_OSX */ 9991 #endif /* MAC_OSX */
10071 9992
10072 static void 9993 static void
10073 init_menu_bar () 9994 init_menu_bar ()
10074 { 9995 {
10075 #ifdef MAC_OSX 9996 #ifdef MAC_OSX
10169 TTY_MEMORY_BELOW_FRAME (CURTTY ()) = 0; /* we don't remember what 10090 TTY_MEMORY_BELOW_FRAME (CURTTY ()) = 0; /* we don't remember what
10170 scrolls off the 10091 scrolls off the
10171 bottom */ 10092 bottom */
10172 baud_rate = 19200; 10093 baud_rate = 19200;
10173 10094
10174 x_noop_count = 0;
10175 last_tool_bar_item = -1; 10095 last_tool_bar_item = -1;
10176 any_help_event_p = 0; 10096 any_help_event_p = 0;
10177 10097
10178 /* Try to use interrupt input; if we can't, then start polling. */ 10098 /* Try to use interrupt input; if we can't, then start polling. */
10179 Fset_input_mode (Qt, Qnil, Qt, Qnil); 10099 Fset_input_mode (Qt, Qnil, Qt, Qnil);
10241 x_display_name_list = Qnil; 10161 x_display_name_list = Qnil;
10242 10162
10243 staticpro (&last_mouse_scroll_bar); 10163 staticpro (&last_mouse_scroll_bar);
10244 last_mouse_scroll_bar = Qnil; 10164 last_mouse_scroll_bar = Qnil;
10245 10165
10246 staticpro (&Qvendor_specific_keysyms);
10247 Qvendor_specific_keysyms = intern ("vendor-specific-keysyms");
10248
10249 staticpro (&last_mouse_press_frame);
10250 last_mouse_press_frame = Qnil;
10251
10252 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop"); 10166 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop");
10253 staticpro (&Qmac_ready_for_drag_n_drop); 10167 staticpro (&Qmac_ready_for_drag_n_drop);
10254 10168
10255 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, 10169 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
10256 doc: /* If not nil, Emacs uses toolkit scroll bars. */); 10170 doc: /* If not nil, Emacs uses toolkit scroll bars. */);
10258 Vx_toolkit_scroll_bars = Qt; 10172 Vx_toolkit_scroll_bars = Qt;
10259 #else 10173 #else
10260 Vx_toolkit_scroll_bars = Qnil; 10174 Vx_toolkit_scroll_bars = Qnil;
10261 #endif 10175 #endif
10262 10176
10263 DEFVAR_BOOL ("x-use-underline-position-properties",
10264 &x_use_underline_position_properties,
10265 doc: /* *Non-nil means make use of UNDERLINE_POSITION font properties.
10266 nil means ignore them. If you encounter fonts with bogus
10267 UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
10268 to 4.1, set this to nil. */);
10269 x_use_underline_position_properties = 0;
10270
10271 staticpro (&last_mouse_motion_frame); 10177 staticpro (&last_mouse_motion_frame);
10272 last_mouse_motion_frame = Qnil; 10178 last_mouse_motion_frame = Qnil;
10273 10179
10274 DEFVAR_LISP ("mac-command-key-is-meta", &Vmac_command_key_is_meta, 10180 DEFVAR_LISP ("mac-command-key-is-meta", &Vmac_command_key_is_meta,
10275 doc: /* Non-nil means that the command key is used as the Emacs meta key. 10181 doc: /* Non-nil means that the command key is used as the Emacs meta key.
10290 DEFVAR_LISP ("mac-emulate-three-button-mouse", 10196 DEFVAR_LISP ("mac-emulate-three-button-mouse",
10291 &Vmac_emulate_three_button_mouse, 10197 &Vmac_emulate_three_button_mouse,
10292 doc: /* t means that when the option-key is held down while pressing the 10198 doc: /* t means that when the option-key is held down while pressing the
10293 mouse button, the click will register as mouse-2 and while the 10199 mouse button, the click will register as mouse-2 and while the
10294 command-key is held down, the click will register as mouse-3. 10200 command-key is held down, the click will register as mouse-3.
10295 'reverse means that the the option-key will register for mouse-3 10201 'reverse means that the option-key will register for mouse-3
10296 and the command-key will register for mouse-2. nil means that 10202 and the command-key will register for mouse-2. nil means that
10297 no emulation should be done and the modifiers should be placed 10203 no emulation should be done and the modifiers should be placed
10298 on the mouse-1 event. */); 10204 on the mouse-1 event. */);
10299 Vmac_emulate_three_button_mouse = Qnil; 10205 Vmac_emulate_three_button_mouse = Qnil;
10300 10206