aboutsummaryrefslogtreecommitdiffstats
path: root/src/macterm.c
diff options
context:
space:
mode:
authorKaroly Lorentey2005-09-04 03:48:17 +0000
committerKaroly Lorentey2005-09-04 03:48:17 +0000
commitfbf349734468d48b421c3d03074bb66dfcf3115b (patch)
tree0a7d1ee844b6c591a5a499d23e35931945106e5a /src/macterm.c
parentf0caabd962b662cccbea472995d86af718cc8d0b (diff)
parent4b5fa40e1f1ba3cafde672863a0331311d1c2695 (diff)
downloademacs-fbf349734468d48b421c3d03074bb66dfcf3115b.tar.gz
emacs-fbf349734468d48b421c3d03074bb66dfcf3115b.zip
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
Diffstat (limited to 'src/macterm.c')
-rw-r--r--src/macterm.c980
1 files changed, 443 insertions, 537 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 303557daca1..d6dbecfe800 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -1,5 +1,6 @@
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
4This file is part of GNU Emacs. 5This file is part of GNU Emacs.
5 6
@@ -22,10 +23,10 @@ Boston, MA 02110-1301, USA. */
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"
@@ -62,8 +63,6 @@ Boston, MA 02110-1301, USA. */
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>
@@ -71,7 +70,8 @@ Boston, MA 02110-1301, USA. */
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"
@@ -82,9 +82,10 @@ Boston, MA 02110-1301, USA. */
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 : \
@@ -94,8 +95,6 @@ Boston, MA 02110-1301, USA. */
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. */
@@ -114,15 +113,6 @@ static int any_help_event_p;
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. */
115static Lisp_Object last_window; 114static Lisp_Object last_window;
116 115
117/* Non-zero means make use of UNDERLINE_POSITION font properties. */
118
119int 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
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
@@ -148,8 +138,6 @@ struct mac_display_info one_mac_display_info;
148 138
149extern struct frame *updating_frame; 139extern struct frame *updating_frame;
150 140
151extern int waiting_for_input;
152
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
155struct frame *pending_autoraise_frame; 143struct frame *pending_autoraise_frame;
@@ -177,7 +165,6 @@ struct frame *pending_autoraise_frame;
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
179static Rect last_mouse_glyph; 167static Rect last_mouse_glyph;
180static 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
@@ -211,45 +198,24 @@ static int volatile input_signal_count;
211static int input_signal_count; 198static int input_signal_count;
212#endif 199#endif
213 200
214/* Used locally within XTread_socket. */ 201extern Lisp_Object Vsystem_name;
215
216static int x_noop_count;
217
218/* Initial values of argv and argc. */
219
220extern char **initial_argv;
221extern int initial_argc;
222
223extern Lisp_Object Vcommand_line_args, Vsystem_name;
224
225/* Tells if a window manager is present or not. */
226
227extern Lisp_Object Vx_no_window_manager;
228
229extern 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
233extern int extra_keyboard_modifiers; 205extern 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
237static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value; 209static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value;
238 210
239static Lisp_Object Qvendor_specific_keysyms;
240
241#if 0
242extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *));
243#endif
244
245extern int inhibit_window_system; 211extern int inhibit_window_system;
246 212
247#if __MRC__ && !TARGET_API_MAC_CARBON 213#if __MRC__ && !TARGET_API_MAC_CARBON
248QDGlobals qd; /* QuickDraw global information structure. */ 214QDGlobals qd; /* QuickDraw global information structure. */
249#endif 215#endif
250 216
217#define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
251 218
252struct frame * x_window_to_frame (struct mac_display_info *, WindowPtr);
253struct mac_display_info *mac_display_info_for_display (Display *); 219struct mac_display_info *mac_display_info_for_display (Display *);
254static void x_update_window_end P_ ((struct window *, int, int)); 220static void x_update_window_end P_ ((struct window *, int, int));
255static int x_io_error_quitter P_ ((Display *)); 221static int x_io_error_quitter P_ ((Display *));
@@ -289,17 +255,23 @@ static void x_flush P_ ((struct frame *f));
289static void x_update_begin P_ ((struct frame *)); 255static void x_update_begin P_ ((struct frame *));
290static void x_update_window_begin P_ ((struct window *)); 256static void x_update_window_begin P_ ((struct window *));
291static void x_after_update_window_line P_ ((struct glyph_row *)); 257static void x_after_update_window_line P_ ((struct glyph_row *));
258static void x_scroll_bar_report_motion P_ ((struct frame **, Lisp_Object *,
259 enum scroll_bar_part *,
260 Lisp_Object *, Lisp_Object *,
261 unsigned long *));
292 262
293static int is_emacs_window (WindowPtr); 263static int is_emacs_window P_ ((WindowPtr));
294 264
295int x_bitmap_icon (struct frame *, Lisp_Object); 265static void XSetFont P_ ((Display *, GC, XFontStruct *));
296void x_make_frame_visible (struct frame *);
297
298extern void window_scroll (Lisp_Object, int, int, int);
299 266
300/* Defined in macmenu.h. */ 267/* Defined in macmenu.h. */
301extern void menubar_selection_callback (FRAME_PTR, int); 268extern void menubar_selection_callback (FRAME_PTR, int);
302extern 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
@@ -312,51 +284,6 @@ XFreePixmap (display, pixmap)
312} 284}
313 285
314 286
315/* Set foreground color for subsequent QuickDraw commands. Assume
316 graphic port has already been set. */
317
318static void
319mac_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
334static void
335mac_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
349static void
350mac_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
360/* Mac version of XDrawLine. */ 287/* Mac version of XDrawLine. */
361 288
362static void 289static void
@@ -366,16 +293,12 @@ XDrawLine (display, w, gc, x1, y1, x2, y2)
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
381void 304void
@@ -391,7 +314,7 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2)
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);
@@ -401,32 +324,38 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2)
401 SetGWorld (old_port, old_gdh); 324 SetGWorld (old_port, old_gdh);
402} 325}
403 326
404/* Mac version of XClearArea. */
405 327
406void 328static void
407XClearArea (display, w, x, y, width, height, exposures) 329mac_erase_rectangle (w, gc, x, y, width, height)
408 Display *display;
409 WindowPtr w; 330 WindowPtr w;
331 GC gc;
410 int x, y; 332 int x, y;
411 unsigned int width, height; 333 unsigned int width, height;
412 int exposures;
413{ 334{
414 struct mac_output *mwp = (mac_output *) GetWRefCon (w);
415 Rect r; 335 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 336
422 SetPortWindowPort (w); 337 SetPortWindowPort (w);
423 338
424 mac_set_colors (&xgc, &old_bg); 339 RGBBackColor (GC_BACK_COLOR (gc));
425 SetRect (&r, x, y, x + width, y + height); 340 SetRect (&r, x, y, x + width, y + height);
426 341
427 EraseRect (&r); 342 EraseRect (&r);
428 343
429 RGBBackColor (&old_bg); 344 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w)));
345}
346
347
348/* Mac version of XClearArea. */
349
350void
351XClearArea (display, w, x, y, width, height, exposures)
352 Display *display;
353 WindowPtr w;
354 int x, y;
355 unsigned int width, height;
356 int exposures;
357{
358 mac_erase_rectangle (w, MAC_WINDOW_NORMAL_GC (w), x, y, width, height);
430} 359}
431 360
432/* Mac version of XClearWindow. */ 361/* Mac version of XClearWindow. */
@@ -436,15 +365,9 @@ 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 {
@@ -472,7 +395,6 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, 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;
@@ -480,7 +402,8 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
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
@@ -493,7 +416,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
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
@@ -599,12 +522,16 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
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)
@@ -613,8 +540,10 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
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),
@@ -642,16 +571,13 @@ XFillRectangle (display, w, gc, x, y, width, height)
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
@@ -670,7 +596,7 @@ mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height)
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));
@@ -693,16 +619,13 @@ mac_draw_rectangle (display, w, gc, x, y, width, height)
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
@@ -723,7 +646,7 @@ mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
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));
@@ -745,9 +668,6 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
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)) {
@@ -756,17 +676,22 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
756 } 676 }
757#endif 677#endif
758 678
759 mac_set_colors (gc, &old_bg); 679 SetPortWindowPort (w);
680
681 RGBForeColor (GC_FORE_COLOR (gc));
682 if (mode != srcOr)
683 RGBBackColor (GC_BACK_COLOR (gc));
760 684
761 TextFont (gc->font->mac_fontnum); 685 TextFont (GC_FONT (gc)->mac_fontnum);
762 TextSize (gc->font->mac_fontsize); 686 TextSize (GC_FONT (gc)->mac_fontsize);
763 TextFace (gc->font->mac_fontface); 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);
@@ -871,6 +796,8 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
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
@@ -909,26 +836,10 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
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}
913
914
915#if 0
916/* Convert a pair of local coordinates to global (screen) coordinates.
917 Assume graphic port has been properly set. */
918static void
919local_to_global_coord (short *h, short *v)
920{
921 Point p;
922 839
923 p.h = *h; 840 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest)));
924 p.v = *v;
925
926 LocalToGlobal (&p);
927
928 *h = p.h;
929 *v = p.v;
930} 841}
931#endif 842
932 843
933/* Mac replacement for XCopyArea: used only for scrolling. */ 844/* Mac replacement for XCopyArea: used only for scrolling. */
934 845
@@ -953,31 +864,17 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
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
@@ -1067,28 +964,37 @@ mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y,
1067/* Mac replacement for XChangeGC. */ 964/* Mac replacement for XChangeGC. */
1068 965
1069static void 966static void
1070XChangeGC (void * ignore, XGCValues* gc, unsigned long mask, 967XChangeGC (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
1084XGCValues * 984GC
1085XCreateGC (void * ignore, Window window, unsigned long mask, 985XCreateGC (display, window, mask, xgcv)
1086 XGCValues *xgcv) 986 Display *display;
987 Window window;
988 unsigned long mask;
989 XGCValues *xgcv;
1087{ 990{
1088 XGCValues *gc = (XGCValues *) xmalloc (sizeof (XGCValues)); 991 GC gc = xmalloc (sizeof (*gc));
1089 bzero (gc, sizeof (XGCValues));
1090 992
1091 XChangeGC (ignore, gc, mask, xgcv); 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}
@@ -1108,10 +1014,18 @@ XFreeGC (display, gc)
1108/* Mac replacement for XGetGCValues. */ 1014/* Mac replacement for XGetGCValues. */
1109 1015
1110static void 1016static void
1111XGetGCValues (void* ignore, XGCValues *gc, 1017XGetGCValues (display, gc, mask, xgcv)
1112 unsigned long mask, XGCValues *xgcv) 1018 Display *display;
1019 GC gc;
1020 unsigned long mask;
1021 XGCValues *xgcv;
1113{ 1022{
1114 XChangeGC (ignore, xgcv, mask, gc); 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
@@ -1123,7 +1037,13 @@ XSetForeground (display, gc, color)
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
@@ -1135,7 +1055,25 @@ XSetBackground (display, gc, color)
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
1070static void
1071XSetFont (display, gc, font)
1072 Display *display;
1073 GC gc;
1074 XFontStruct *font;
1075{
1076 gc->xgcv.font = font;
1139} 1077}
1140 1078
1141 1079
@@ -1182,19 +1120,6 @@ XSetWindowBackground (display, w, color)
1182#endif 1120#endif
1183} 1121}
1184 1122
1185
1186/* Mac replacement for XSetFont. */
1187
1188static void
1189XSetFont (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. */
1199void 1124void
1200x_sync (f) 1125x_sync (f)
@@ -1345,7 +1270,6 @@ mac_draw_vertical_window_border (w, x, y0, y1)
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
@@ -1357,7 +1281,7 @@ mac_draw_vertical_window_border (w, x, y0, y1)
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
1362static void 1286static void
1363x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p) 1287x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p)
@@ -1390,14 +1314,6 @@ x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p)
1390 dpyinfo->mouse_face_window = Qnil; 1314 dpyinfo->mouse_face_window = Qnil;
1391 } 1315 }
1392 1316
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
1401 updated_window = NULL; 1317 updated_window = NULL;
1402} 1318}
1403 1319
@@ -1483,19 +1399,18 @@ x_after_update_window_line (desired_row)
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}
@@ -1515,7 +1430,6 @@ x_draw_fringe_bitmap (w, row, p)
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;
@@ -1539,9 +1453,6 @@ x_draw_fringe_bitmap (w, row, p)
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
@@ -1553,9 +1464,7 @@ x_draw_fringe_bitmap (w, row, p)
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)
@@ -1566,21 +1475,24 @@ x_draw_fringe_bitmap (w, row, p)
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;
1478 XGCValues gcv;
1569 1479
1570 gcv.foreground = (p->cursor_p 1480 XGetGCValues (display, face->gc, GCForeground, &gcv);
1571 ? (p->overlay_p ? face->background 1481 XSetForeground (display, face->gc,
1572 : f->output_data.mac->cursor_pixel) 1482 (p->cursor_p
1573 : face->foreground); 1483 ? (p->overlay_p ? face->background
1574 gcv.background = face->background; 1484 : f->output_data.mac->cursor_pixel)
1575 1485 : face->foreground));
1576 mac_draw_bitmap (display, window, &gcv, p->x, p->y, 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
@@ -1599,6 +1511,7 @@ XTreset_terminal_modes ()
1599{ 1511{
1600} 1512}
1601 1513
1514
1602 1515
1603/*********************************************************************** 1516/***********************************************************************
1604 Display Iterator 1517 Display Iterator
@@ -1786,6 +1699,7 @@ mac_encode_char (c, char2b, font_info, two_byte_p)
1786 ***********************************************************************/ 1699 ***********************************************************************/
1787 1700
1788 1701
1702
1789static void x_set_glyph_string_clipping P_ ((struct glyph_string *)); 1703static void x_set_glyph_string_clipping P_ ((struct glyph_string *));
1790static void x_set_glyph_string_gc P_ ((struct glyph_string *)); 1704static void x_set_glyph_string_gc P_ ((struct glyph_string *));
1791static void x_draw_glyph_string_background P_ ((struct glyph_string *, 1705static void x_draw_glyph_string_background P_ ((struct glyph_string *,
@@ -1794,6 +1708,7 @@ static void x_draw_glyph_string_foreground P_ ((struct glyph_string *));
1794static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *)); 1708static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *));
1795static void x_draw_glyph_string_box P_ ((struct glyph_string *)); 1709static void x_draw_glyph_string_box P_ ((struct glyph_string *));
1796static void x_draw_glyph_string P_ ((struct glyph_string *)); 1710static void x_draw_glyph_string P_ ((struct glyph_string *));
1711static void mac_compute_glyph_string_overhangs P_ ((struct glyph_string *));
1797static void x_set_cursor_gc P_ ((struct glyph_string *)); 1712static void x_set_cursor_gc P_ ((struct glyph_string *));
1798static void x_set_mode_line_face_gc P_ ((struct glyph_string *)); 1713static void x_set_mode_line_face_gc P_ ((struct glyph_string *));
1799static void x_set_mouse_face_gc P_ ((struct glyph_string *)); 1714static void x_set_mouse_face_gc P_ ((struct glyph_string *));
@@ -2045,10 +1960,7 @@ 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
@@ -2636,27 +2548,29 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width,
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
@@ -3075,13 +2989,7 @@ x_draw_stretch_glyph_string (s)
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 }
@@ -3397,7 +3305,6 @@ XTring_bell ()
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.
@@ -3832,43 +3739,6 @@ x_get_keysym_name (keysym)
3832 3739
3833 3740
3834 3741
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
3843static Lisp_Object
3844construct_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
3871
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
@@ -3924,18 +3794,11 @@ note_mouse_movement (frame, pos)
3924 } 3794 }
3925} 3795}
3926 3796
3927/* This is used for debugging, to turn off note_mouse_highlight. */
3928
3929int disable_mouse_highlight;
3930
3931
3932 3797
3933/************************************************************************ 3798/************************************************************************
3934 Mouse Face 3799 Mouse Face
3935 ************************************************************************/ 3800 ************************************************************************/
3936 3801
3937static struct scroll_bar *x_window_to_scroll_bar ();
3938static void x_scroll_bar_report_motion ();
3939static int glyph_rect P_ ((struct frame *f, int, int, Rect *)); 3802static int glyph_rect P_ ((struct frame *f, int, int, Rect *));
3940 3803
3941 3804
@@ -4147,20 +4010,16 @@ static OSStatus install_scroll_bar_timer P_ ((void));
4147static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval)); 4010static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval));
4148static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode)); 4011static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode));
4149static void construct_scroll_bar_click P_ ((struct scroll_bar *, int, 4012static void construct_scroll_bar_click P_ ((struct scroll_bar *, int,
4150 unsigned long,
4151 struct input_event *)); 4013 struct input_event *));
4152static OSErr get_control_part_bounds P_ ((ControlHandle, ControlPartCode, 4014static OSErr get_control_part_bounds P_ ((ControlHandle, ControlPartCode,
4153 Rect *)); 4015 Rect *));
4154static void x_scroll_bar_handle_press P_ ((struct scroll_bar *, 4016static 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 *));
4158static void x_scroll_bar_handle_release P_ ((struct scroll_bar *, 4019static void x_scroll_bar_handle_release P_ ((struct scroll_bar *,
4159 unsigned long,
4160 struct input_event *)); 4020 struct input_event *));
4161static void x_scroll_bar_handle_drag P_ ((WindowPtr, struct scroll_bar *, 4021static void x_scroll_bar_handle_drag P_ ((WindowPtr, struct scroll_bar *,
4162 Point, unsigned long, 4022 Point, struct input_event *));
4163 struct input_event *));
4164static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *, 4023static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *,
4165 int, int, int)); 4024 int, int, int));
4166 4025
@@ -4259,10 +4118,9 @@ control_part_code_to_scroll_bar_part (part_code)
4259} 4118}
4260 4119
4261static void 4120static void
4262construct_scroll_bar_click (bar, part, timestamp, bufp) 4121construct_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;
@@ -4270,7 +4128,6 @@ construct_scroll_bar_click (bar, part, timestamp, bufp)
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;
@@ -4294,10 +4151,9 @@ get_control_part_bounds (ch, part_code, rect)
4294} 4151}
4295 4152
4296static void 4153static void
4297x_scroll_bar_handle_press (bar, part_code, timestamp, bufp) 4154x_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);
@@ -4307,7 +4163,7 @@ x_scroll_bar_handle_press (bar, part_code, timestamp, bufp)
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 }
@@ -4318,14 +4174,13 @@ x_scroll_bar_handle_press (bar, part_code, timestamp, bufp)
4318} 4174}
4319 4175
4320static void 4176static void
4321x_scroll_bar_handle_release (bar, timestamp, bufp) 4177x_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);
@@ -4336,11 +4191,10 @@ x_scroll_bar_handle_release (bar, timestamp, bufp)
4336} 4191}
4337 4192
4338static void 4193static void
4339x_scroll_bar_handle_drag (win, bar, mouse_pos, timestamp, bufp) 4194x_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);
@@ -4360,13 +4214,13 @@ x_scroll_bar_handle_drag (win, bar, mouse_pos, timestamp, bufp)
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 }
@@ -4404,7 +4258,7 @@ x_scroll_bar_handle_drag (win, bar, mouse_pos, timestamp, bufp)
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);
@@ -4475,11 +4329,11 @@ x_scroll_bar_create (w, top, left, width, height, disp_top, disp_height)
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
@@ -4604,10 +4458,12 @@ x_scroll_bar_remove (bar)
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
4611static void 4467static void
4612XTset_vertical_scroll_bar (w, portion, whole, position) 4468XTset_vertical_scroll_bar (w, portion, whole, position)
4613 struct window *w; 4469 struct window *w;
@@ -4684,13 +4540,10 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
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))
@@ -4702,7 +4555,8 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
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);
@@ -4805,6 +4659,7 @@ 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))
@@ -4813,36 +4668,33 @@ XTredeem_scroll_bar (window)
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
4835 XSCROLL_BAR (bar->prev)->next = bar->next;
4836 4689
4837 if (! NILP (bar->next)) 4690 if (! NILP (bar->next))
4838 XSCROLL_BAR (bar->next)->prev = bar->prev; 4691 XSCROLL_BAR (bar->next)->prev = bar->prev;
4839 4692
4840 bar->next = FRAME_SCROLL_BARS (f); 4693 bar->next = FRAME_SCROLL_BARS (f);
4841 bar->prev = Qnil; 4694 bar->prev = Qnil;
4842 XSETVECTOR (FRAME_SCROLL_BARS (f), bar); 4695 XSETVECTOR (FRAME_SCROLL_BARS (f), bar);
4843 if (! NILP (bar->next)) 4696 if (! NILP (bar->next))
4844 XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); 4697 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
@@ -4981,8 +4833,8 @@ x_scroll_bar_note_movement (bar, y_pos, t)
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
4987static void 4839static void
4988x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) 4840x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
@@ -5500,6 +5352,7 @@ mac_get_window_bounds (f, inner, outer)
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
@@ -5731,7 +5584,6 @@ x_set_mouse_pixel_position (f, 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
@@ -5758,6 +5610,7 @@ x_unfocus_frame (f)
5758} 5610}
5759 5611
5760/* Raise frame F. */ 5612/* Raise frame F. */
5613
5761void 5614void
5762x_raise_frame (f) 5615x_raise_frame (f)
5763 struct frame *f; 5616 struct frame *f;
@@ -5771,6 +5624,7 @@ x_raise_frame (f)
5771} 5624}
5772 5625
5773/* Lower frame F. */ 5626/* Lower frame F. */
5627
5774void 5628void
5775x_lower_frame (f) 5629x_lower_frame (f)
5776 struct frame *f; 5630 struct frame *f;
@@ -5796,6 +5650,53 @@ XTframe_raise_lower (f, raise_flag)
5796 5650
5797/* Change of visibility. */ 5651/* Change of visibility. */
5798 5652
5653static void
5654mac_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}
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.
@@ -5820,29 +5721,32 @@ x_make_frame_visible (f)
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);
5824
5825 f->output_data.mac->asked_for_visible = 1;
5826
5827#if TARGET_API_MAC_CARBON 5724#if TARGET_API_MAC_CARBON
5828 if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition))) 5725 if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition)))
5829 { 5726 {
5830 struct frame *sf = SELECTED_FRAME (); 5727 struct frame *sf = SELECTED_FRAME ();
5831 if (!FRAME_MAC_P (sf)) 5728 if (!FRAME_MAC_P (sf))
5832 RepositionWindow (FRAME_MAC_WINDOW (f), NULL, 5729 RepositionWindow (FRAME_MAC_WINDOW (f), NULL,
5833 kWindowCenterOnMainScreen); 5730 kWindowCenterOnMainScreen);
5834 else 5731 else
5835 RepositionWindow (FRAME_MAC_WINDOW (f), 5732 RepositionWindow (FRAME_MAC_WINDOW (f),
5836 FRAME_MAC_WINDOW (sf), 5733 FRAME_MAC_WINDOW (sf),
5837#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 5734#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
5838 kWindowCascadeStartAtParentWindowScreen 5735 kWindowCascadeStartAtParentWindowScreen
5839#else 5736#else
5840 kWindowCascadeOnParentWindowScreen 5737 kWindowCascadeOnParentWindowScreen
5841#endif 5738#endif
5842 ); 5739 );
5843 x_real_positions (f, &f->left_pos, &f->top_pos); 5740 x_real_positions (f, &f->left_pos, &f->top_pos);
5844 } 5741 }
5742 else
5845#endif 5743#endif
5744 x_set_offset (f, f->left_pos, f->top_pos, 0);
5745
5746 f->output_data.mac->asked_for_visible = 1;
5747
5748 SelectWindow (FRAME_MAC_WINDOW (f));
5749 CollapseWindow (FRAME_MAC_WINDOW (f), false);
5846 ShowWindow (FRAME_MAC_WINDOW (f)); 5750 ShowWindow (FRAME_MAC_WINDOW (f));
5847 } 5751 }
5848 5752
@@ -5901,9 +5805,14 @@ void
5901x_make_frame_invisible (f) 5805x_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
@@ -5916,17 +5825,11 @@ x_make_frame_invisible (f)
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. */
@@ -5935,21 +5838,37 @@ void
5935x_iconify_frame (f) 5838x_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;
5850#endif
5941 5851
5942#if 0
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
@@ -6179,9 +6098,9 @@ x_get_font_info (f, font_idx)
6179} 6098}
6180 6099
6181/* the global font name table */ 6100/* the global font name table */
6182char **font_name_table = NULL; 6101static char **font_name_table = NULL;
6183int font_name_table_size = 0; 6102static int font_name_table_size = 0;
6184int font_name_count = 0; 6103static 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. */
@@ -7338,7 +7257,7 @@ x_load_font (f, fontname, size)
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);
@@ -7435,22 +7354,6 @@ x_find_ccl_program (fontp)
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. */
7450static Boolean app_is_suspended = false;
7451static 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
@@ -7485,19 +7388,17 @@ Lisp_Object Vmac_pass_command_to_system;
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. */
7487Lisp_Object Vmac_pass_control_to_system; 7390Lisp_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. */
7492static struct input_event *read_socket_inev = NULL; 7396static 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. */
7497Lisp_Object Qmac_ready_for_drag_n_drop; 7400Lisp_Object Qmac_ready_for_drag_n_drop;
7498 7401
7499Lisp_Object drag_and_drop_file_list;
7500
7501Point saved_menu_event_location; 7402Point saved_menu_event_location;
7502 7403
7503/* Apple Events */ 7404/* Apple Events */
@@ -7777,37 +7678,30 @@ do_window_update (WindowPtr win)
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 ();
7798 7693
7799 GetPortVisibleRegion (GetWindowPort (win), region); 7694 GetPortVisibleRegion (GetWindowPort (win), region);
7800 GetRegionBounds (region, &r); 7695 GetRegionBounds (region, &r);
7801 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top); 7696 expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
7802 UpdateControls (win, region); 7697 UpdateControls (win, region);
7803 DisposeRgn (region); 7698 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);
@@ -7833,20 +7727,12 @@ static void
7833do_app_resume () 7727do_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
7842static void 7732static void
7843do_app_suspend () 7733do_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
@@ -8347,6 +8233,17 @@ mac_handle_window_event (next_handler, event, data)
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;
@@ -8400,8 +8297,6 @@ mac_handle_mouse_event (next_handler, event, data)
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 }
@@ -8424,7 +8319,11 @@ install_window_handler (window)
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;
@@ -8475,11 +8374,6 @@ do_ae_open_application(const AppleEvent *pae, AppleEvent *preply, long prefcon)
8475} 8374}
8476 8375
8477 8376
8478/* Defined in mac.c. */
8479extern int
8480path_from_vol_dir_name (char *, int, short, long, char *);
8481
8482
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. */
@@ -8503,6 +8397,9 @@ do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
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)
@@ -8510,10 +8407,10 @@ do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
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
@@ -8567,12 +8464,49 @@ do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
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 }
8575 } 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
8509 }
8576 } 8510 }
8577 8511
8578error_exit: 8512error_exit:
@@ -8665,11 +8599,12 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
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++)
@@ -8695,15 +8630,14 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
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;
@@ -8720,7 +8654,7 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
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);
@@ -8979,6 +8913,7 @@ XTread_socket (sd, expected, hold_quit)
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
@@ -8989,6 +8924,12 @@ XTread_socket (sd, expected, hold_quit)
8989 inev.arg = Qnil; 8924 inev.arg = Qnil;
8990 8925
8991#if USE_CARBON_EVENTS 8926#if USE_CARBON_EVENTS
8927 timestamp = GetEventTime (eventRef) / kEventDurationMillisecond;
8928#else
8929 timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
8930#endif
8931
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 {
@@ -9089,8 +9030,6 @@ XTread_socket (sd, expected, hold_quit)
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
@@ -9124,10 +9063,9 @@ XTread_socket (sd, expected, hold_quit)
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);
@@ -9301,8 +9239,7 @@ XTread_socket (sd, expected, hold_quit)
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
@@ -9390,11 +9327,10 @@ XTread_socket (sd, expected, hold_quit)
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 }
@@ -9470,6 +9406,7 @@ XTread_socket (sd, expected, hold_quit)
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 }
@@ -9534,58 +9471,18 @@ XTread_socket (sd, expected, hold_quit)
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
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 9485
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 }
@@ -9595,6 +9492,7 @@ XTread_socket (sd, expected, hold_quit)
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 }
@@ -9634,6 +9532,29 @@ XTread_socket (sd, expected, hold_quit)
9634 pending_autoraise_frame = 0; 9532 pending_autoraise_frame = 0;
9635 } 9533 }
9636 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
9557
9637 UNBLOCK_INPUT; 9558 UNBLOCK_INPUT;
9638 return count; 9559 return count;
9639} 9560}
@@ -10067,7 +9988,7 @@ mac_check_for_quit_char ()
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
10072static void 9993static void
10073init_menu_bar () 9994init_menu_bar ()
@@ -10171,7 +10092,6 @@ mac_initialize ()
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
@@ -10243,12 +10163,6 @@ syms_of_macterm ()
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
@@ -10260,14 +10174,6 @@ syms_of_macterm ()
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.
10266nil means ignore them. If you encounter fonts with bogus
10267UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
10268to 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
@@ -10292,7 +10198,7 @@ useful for non-standard keyboard layouts. */);
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
10293mouse button, the click will register as mouse-2 and while the 10199mouse button, the click will register as mouse-2 and while the
10294command-key is held down, the click will register as mouse-3. 10200command-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
10296and the command-key will register for mouse-2. nil means that 10202and the command-key will register for mouse-2. nil means that
10297no emulation should be done and the modifiers should be placed 10203no emulation should be done and the modifiers should be placed
10298on the mouse-1 event. */); 10204on the mouse-1 event. */);