comparison src/macterm.c @ 89943:4c90ffeb71c5

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-15 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-218 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-220 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-221 Restore deleted tagline in etc/TUTORIAL.ru * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-222 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-228 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-229 Remove TeX output files from the archive * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-230 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-247 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-248 src/lisp.h (CYCLE_CHECK): Macro moved from xfaces.c * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-249 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-256 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-258 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-263 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-264 Update from CVS: lispref/display.texi: emacs -> Emacs. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-265 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-274 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-275 Update from CVS: man/makefile.w32-in: Revert last change * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-276 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-295 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-296 Allow restarting an existing debugger session that's exited * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-297 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-299 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-300 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-327 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-328 Update from CVS: src/.gdbinit (xsymbol): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-329 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-344 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-345 Tweak source regexps so that building in place won't cause problems * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-346 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-351 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-352 Update from CVS: lisp/flymake.el: New file. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-353 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-361 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-362 Support " [...]" style defaults in minibuffer-electric-default-mode * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-363 (read-number): Use canonical format for default in prompt. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-364 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-367 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-368 Improve display-supports-face-attributes-p on non-ttys * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369 Rewrite face-differs-from-default-p * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-370 Move `display-supports-face-attributes-p' entirely into C code * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-371 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-372 Simplify face-differs-from-default-p; don't consider :stipple. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-373 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-374 (tty_supports_face_attributes_p): Ensure attributes differ from default * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-375 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-376 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-377 (Fdisplay_supports_face_attributes_p): Work around bootstrapping problem * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-378 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-380 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-381 Face merging cleanups * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-382 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-384 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-385 src/xfaces.c (push_named_merge_point): Return 0 if a cycle is detected * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-386 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-395 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-396 Tweak arch tagging to make build/install-in-place less annoying * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-397 Work around vc-arch problems when building eshell * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-398 Tweak permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-399 Tweak directory permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-400 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-401 More build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-402 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-403 Yet more build-in-place tweaking of arch tagging * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-404 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-409 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-410 Make sure image types are initialized for lookup too * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-411 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-416 Update from CVS
author Miles Bader <miles@gnu.org>
date Mon, 28 Jun 2004 07:56:49 +0000
parents 68c22ea6027c 5e784b2ea638
children 59dcbfe97385
comparison
equal deleted inserted replaced
89942:9cb747ae49af 89943:4c90ffeb71c5
51 #include <LowMem.h> 51 #include <LowMem.h>
52 #include <Controls.h> 52 #include <Controls.h>
53 #if defined (__MRC__) || (__MSL__ >= 0x6000) 53 #if defined (__MRC__) || (__MSL__ >= 0x6000)
54 #include <ControlDefinitions.h> 54 #include <ControlDefinitions.h>
55 #endif 55 #endif
56 #include <Gestalt.h>
57 56
58 #if __profile__ 57 #if __profile__
59 #include <profiler.h> 58 #include <profiler.h>
60 #endif 59 #endif
61 #endif /* not MAC_OSX */ 60 #endif /* not MAC_OSX */
193 along with the position query. So, we just keep track of the time 192 along with the position query. So, we just keep track of the time
194 of the last movement we received, and return that in hopes that 193 of the last movement we received, and return that in hopes that
195 it's somewhat accurate. */ 194 it's somewhat accurate. */
196 195
197 static Time last_mouse_movement_time; 196 static Time last_mouse_movement_time;
198
199 enum mouse_tracking_type {
200 mouse_tracking_none,
201 mouse_tracking_mouse_movement,
202 mouse_tracking_scroll_bar
203 };
204
205 enum mouse_tracking_type mouse_tracking_in_progress = mouse_tracking_none;
206 197
207 struct scroll_bar *tracked_scroll_bar = NULL; 198 struct scroll_bar *tracked_scroll_bar = NULL;
208 199
209 /* Incremented by XTread_socket whenever it really tries to read 200 /* Incremented by XTread_socket whenever it really tries to read
210 events. */ 201 events. */
292 void activate_scroll_bars (FRAME_PTR); 283 void activate_scroll_bars (FRAME_PTR);
293 void deactivate_scroll_bars (FRAME_PTR); 284 void deactivate_scroll_bars (FRAME_PTR);
294 285
295 static int is_emacs_window (WindowPtr); 286 static int is_emacs_window (WindowPtr);
296 287
297 extern int image_ascent (struct image *, struct face *);
298 int x_bitmap_icon (struct frame *, Lisp_Object); 288 int x_bitmap_icon (struct frame *, Lisp_Object);
299 void x_make_frame_visible (struct frame *); 289 void x_make_frame_visible (struct frame *);
300 290
301 extern void window_scroll (Lisp_Object, int, int, int); 291 extern void window_scroll (Lisp_Object, int, int, int);
302 292
309 void 299 void
310 XFreePixmap (display, pixmap) 300 XFreePixmap (display, pixmap)
311 Display *display; /* not used */ 301 Display *display; /* not used */
312 Pixmap pixmap; 302 Pixmap pixmap;
313 { 303 {
314 DisposeGWorld (pixmap); 304 DisposeGWorld (pixmap);
315 } 305 }
316 306
317 307
318 /* Set foreground color for subsequent QuickDraw commands. Assume 308 /* Set foreground color for subsequent QuickDraw commands. Assume
319 graphic port has already been set. */ 309 graphic port has already been set. */
363 Display *display; 353 Display *display;
364 WindowPtr w; 354 WindowPtr w;
365 GC gc; 355 GC gc;
366 int x1, y1, x2, y2; 356 int x1, y1, x2, y2;
367 { 357 {
368 #if TARGET_API_MAC_CARBON 358 SetPortWindowPort (w);
369 SetPort (GetWindowPort (w));
370 #else
371 SetPort (w);
372 #endif
373 359
374 mac_set_colors (gc); 360 mac_set_colors (gc);
375 361
376 MoveTo (x1, y1); 362 MoveTo (x1, y1);
377 LineTo (x2, y2); 363 LineTo (x2, y2);
382 Display *display; 368 Display *display;
383 Pixmap p; 369 Pixmap p;
384 GC gc; 370 GC gc;
385 int x1, y1, x2, y2; 371 int x1, y1, x2, y2;
386 { 372 {
373 CGrafPtr old_port;
374 GDHandle old_gdh;
375
376 GetGWorld (&old_port, &old_gdh);
387 SetGWorld (p, NULL); 377 SetGWorld (p, NULL);
388 378
389 mac_set_colors (gc); 379 mac_set_colors (gc);
390 380
391 LockPixels (GetGWorldPixMap (p)); 381 LockPixels (GetGWorldPixMap (p));
392 MoveTo (x1, y1); 382 MoveTo (x1, y1);
393 LineTo (x2, y2); 383 LineTo (x2, y2);
394 UnlockPixels (GetGWorldPixMap (p)); 384 UnlockPixels (GetGWorldPixMap (p));
385
386 SetGWorld (old_port, old_gdh);
395 } 387 }
396 388
397 /* Mac version of XClearArea. */ 389 /* Mac version of XClearArea. */
398 390
399 void 391 void
409 XGCValues xgc; 401 XGCValues xgc;
410 402
411 xgc.foreground = mwp->x_compatible.foreground_pixel; 403 xgc.foreground = mwp->x_compatible.foreground_pixel;
412 xgc.background = mwp->x_compatible.background_pixel; 404 xgc.background = mwp->x_compatible.background_pixel;
413 405
414 #if TARGET_API_MAC_CARBON 406 SetPortWindowPort (w);
415 SetPort (GetWindowPort (w));
416 #else
417 SetPort (w);
418 #endif
419 407
420 mac_set_colors (&xgc); 408 mac_set_colors (&xgc);
421 SetRect (&r, x, y, x + width, y + height); 409 SetRect (&r, x, y, x + width, y + height);
422 410
423 EraseRect (&r); 411 EraseRect (&r);
434 XGCValues xgc; 422 XGCValues xgc;
435 423
436 xgc.foreground = mwp->x_compatible.foreground_pixel; 424 xgc.foreground = mwp->x_compatible.foreground_pixel;
437 xgc.background = mwp->x_compatible.background_pixel; 425 xgc.background = mwp->x_compatible.background_pixel;
438 426
439 #if TARGET_API_MAC_CARBON 427 SetPortWindowPort (w);
440 SetPort (GetWindowPort (w));
441 #else
442 SetPort (w);
443 #endif
444 428
445 mac_set_colors (&xgc); 429 mac_set_colors (&xgc);
446 430
447 #if TARGET_API_MAC_CARBON 431 #if TARGET_API_MAC_CARBON
448 { 432 {
473 457
474 bitmap.rowBytes = sizeof(unsigned short); 458 bitmap.rowBytes = sizeof(unsigned short);
475 bitmap.baseAddr = (char *)bits; 459 bitmap.baseAddr = (char *)bits;
476 SetRect (&(bitmap.bounds), 0, 0, width, height); 460 SetRect (&(bitmap.bounds), 0, 0, width, height);
477 461
478 #if TARGET_API_MAC_CARBON 462 SetPortWindowPort (w);
479 SetPort (GetWindowPort (w));
480 #else
481 SetPort (w);
482 #endif
483 463
484 mac_set_colors (gc); 464 mac_set_colors (gc);
485 SetRect (&r, x, y, x + width, y + height); 465 SetRect (&r, x, y, x + width, y + height);
486 466
487 #if TARGET_API_MAC_CARBON 467 #if TARGET_API_MAC_CARBON
502 mac_set_clip_rectangle (display, w, r) 482 mac_set_clip_rectangle (display, w, r)
503 Display *display; 483 Display *display;
504 WindowPtr w; 484 WindowPtr w;
505 Rect *r; 485 Rect *r;
506 { 486 {
507 #if TARGET_API_MAC_CARBON 487 SetPortWindowPort (w);
508 SetPort (GetWindowPort (w));
509 #else
510 SetPort (w);
511 #endif
512 488
513 ClipRect (r); 489 ClipRect (r);
514 } 490 }
515 491
516 492
521 Display *display; 497 Display *display;
522 WindowPtr w; 498 WindowPtr w;
523 { 499 {
524 Rect r; 500 Rect r;
525 501
526 #if TARGET_API_MAC_CARBON 502 SetPortWindowPort (w);
527 SetPort (GetWindowPort (w));
528 #else
529 SetPort (w);
530 #endif
531 503
532 SetRect (&r, -32767, -32767, 32767, 32767); 504 SetRect (&r, -32767, -32767, 32767, 32767);
533 ClipRect (&r); 505 ClipRect (&r);
534 } 506 }
535 507
594 { 566 {
595 Pixmap pixmap; 567 Pixmap pixmap;
596 Rect r; 568 Rect r;
597 QDErr err; 569 QDErr err;
598 570
599 #if TARGET_API_MAC_CARBON 571 SetPortWindowPort (w);
600 SetPort (GetWindowPort (w));
601 #else
602 SetPort (w);
603 #endif
604 572
605 SetRect (&r, 0, 0, width, height); 573 SetRect (&r, 0, 0, width, height);
606 err = NewGWorld (&pixmap, depth, &r, NULL, NULL, 0); 574 err = NewGWorld (&pixmap, depth, &r, NULL, NULL, 0);
607 if (err != noErr) 575 if (err != noErr)
608 return NULL; 576 return NULL;
619 unsigned long fg, bg; 587 unsigned long fg, bg;
620 unsigned int depth; /* not used */ 588 unsigned int depth; /* not used */
621 { 589 {
622 Pixmap pixmap; 590 Pixmap pixmap;
623 BitMap bitmap; 591 BitMap bitmap;
592 CGrafPtr old_port;
593 GDHandle old_gdh;
624 594
625 pixmap = XCreatePixmap (display, w, width, height, depth); 595 pixmap = XCreatePixmap (display, w, width, height, depth);
626 if (pixmap == NULL) 596 if (pixmap == NULL)
627 return NULL; 597 return NULL;
628 598
599 GetGWorld (&old_port, &old_gdh);
629 SetGWorld (pixmap, NULL); 600 SetGWorld (pixmap, NULL);
630 mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height); 601 mac_create_bitmap_from_bitmap_data (&bitmap, data, width, height);
631 mac_set_forecolor (fg); 602 mac_set_forecolor (fg);
632 mac_set_backcolor (bg); 603 mac_set_backcolor (bg);
633 LockPixels (GetGWorldPixMap (pixmap)); 604 LockPixels (GetGWorldPixMap (pixmap));
637 #else /* not TARGET_API_MAC_CARBON */ 608 #else /* not TARGET_API_MAC_CARBON */
638 CopyBits (&bitmap, &(((GrafPtr)pixmap)->portBits), 609 CopyBits (&bitmap, &(((GrafPtr)pixmap)->portBits),
639 &bitmap.bounds, &bitmap.bounds, srcCopy, 0); 610 &bitmap.bounds, &bitmap.bounds, srcCopy, 0);
640 #endif /* not TARGET_API_MAC_CARBON */ 611 #endif /* not TARGET_API_MAC_CARBON */
641 UnlockPixels (GetGWorldPixMap (pixmap)); 612 UnlockPixels (GetGWorldPixMap (pixmap));
613 SetGWorld (old_port, old_gdh);
642 mac_free_bitmap (&bitmap); 614 mac_free_bitmap (&bitmap);
643 615
644 return pixmap; 616 return pixmap;
645 } 617 }
646 618
655 int x, y; 627 int x, y;
656 unsigned int width, height; 628 unsigned int width, height;
657 { 629 {
658 Rect r; 630 Rect r;
659 631
660 #if TARGET_API_MAC_CARBON 632 SetPortWindowPort (w);
661 SetPort (GetWindowPort (w));
662 #else
663 SetPort (w);
664 #endif
665 633
666 mac_set_colors (gc); 634 mac_set_colors (gc);
667 SetRect (&r, x, y, x + width, y + height); 635 SetRect (&r, x, y, x + width, y + height);
668 636
669 PaintRect (&r); /* using foreground color of gc */ 637 PaintRect (&r); /* using foreground color of gc */
676 Pixmap p; 644 Pixmap p;
677 GC gc; 645 GC gc;
678 int x, y; 646 int x, y;
679 unsigned int width, height; 647 unsigned int width, height;
680 { 648 {
649 CGrafPtr old_port;
650 GDHandle old_gdh;
681 Rect r; 651 Rect r;
682 652
653 GetGWorld (&old_port, &old_gdh);
683 SetGWorld (p, NULL); 654 SetGWorld (p, NULL);
684 mac_set_colors (gc); 655 mac_set_colors (gc);
685 SetRect (&r, x, y, x + width, y + height); 656 SetRect (&r, x, y, x + width, y + height);
686 657
687 LockPixels (GetGWorldPixMap (p)); 658 LockPixels (GetGWorldPixMap (p));
688 PaintRect (&r); /* using foreground color of gc */ 659 PaintRect (&r); /* using foreground color of gc */
689 UnlockPixels (GetGWorldPixMap (p)); 660 UnlockPixels (GetGWorldPixMap (p));
661
662 SetGWorld (old_port, old_gdh);
690 } 663 }
691 664
692 665
693 /* Mac replacement for XDrawRectangle: dest is a window. */ 666 /* Mac replacement for XDrawRectangle: dest is a window. */
694 667
700 int x, y; 673 int x, y;
701 unsigned int width, height; 674 unsigned int width, height;
702 { 675 {
703 Rect r; 676 Rect r;
704 677
705 #if TARGET_API_MAC_CARBON 678 SetPortWindowPort (w);
706 SetPort (GetWindowPort (w));
707 #else
708 SetPort (w);
709 #endif
710 679
711 mac_set_colors (gc); 680 mac_set_colors (gc);
712 SetRect (&r, x, y, x + width + 1, y + height + 1); 681 SetRect (&r, x, y, x + width + 1, y + height + 1);
713 682
714 FrameRect (&r); /* using foreground color of gc */ 683 FrameRect (&r); /* using foreground color of gc */
723 Pixmap p; 692 Pixmap p;
724 GC gc; 693 GC gc;
725 int x, y; 694 int x, y;
726 unsigned int width, height; 695 unsigned int width, height;
727 { 696 {
697 CGrafPtr old_port;
698 GDHandle old_gdh;
728 Rect r; 699 Rect r;
729 700
701 GetGWorld (&old_port, &old_gdh);
730 SetGWorld (p, NULL); 702 SetGWorld (p, NULL);
731 mac_set_colors (gc); 703 mac_set_colors (gc);
732 SetRect (&r, x, y, x + width + 1, y + height + 1); 704 SetRect (&r, x, y, x + width + 1, y + height + 1);
733 705
734 LockPixels (GetGWorldPixMap (p)); 706 LockPixels (GetGWorldPixMap (p));
735 FrameRect (&r); /* using foreground color of gc */ 707 FrameRect (&r); /* using foreground color of gc */
736 UnlockPixels (GetGWorldPixMap (p)); 708 UnlockPixels (GetGWorldPixMap (p));
709
710 SetGWorld (old_port, old_gdh);
737 } 711 }
738 712
739 713
740 static void 714 static void
741 mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, 715 mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
745 GC gc; 719 GC gc;
746 int x, y; 720 int x, y;
747 char *buf; 721 char *buf;
748 int nchars, mode, bytes_per_char; 722 int nchars, mode, bytes_per_char;
749 { 723 {
750 #if TARGET_API_MAC_CARBON 724 SetPortWindowPort (w);
751 SetPort (GetWindowPort (w));
752 #else
753 SetPort (w);
754 #endif
755 725
756 mac_set_colors (gc); 726 mac_set_colors (gc);
757 727
758 TextFont (gc->font->mac_fontnum); 728 TextFont (gc->font->mac_fontnum);
759 TextSize (gc->font->mac_fontsize); 729 TextSize (gc->font->mac_fontsize);
840 unsigned int width, height; 810 unsigned int width, height;
841 int dest_x, dest_y; 811 int dest_x, dest_y;
842 { 812 {
843 Rect src_r, dest_r; 813 Rect src_r, dest_r;
844 814
845 #if TARGET_API_MAC_CARBON 815 SetPortWindowPort (dest);
846 SetPort (GetWindowPort (dest));
847 #else
848 SetPort (dest);
849 #endif
850 816
851 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 817 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
852 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 818 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
853 819
854 ForeColor (blackColor); 820 ForeColor (blackColor);
880 unsigned int width, height; 846 unsigned int width, height;
881 int dest_x, dest_y; 847 int dest_x, dest_y;
882 { 848 {
883 Rect src_r, dest_r; 849 Rect src_r, dest_r;
884 850
885 #if TARGET_API_MAC_CARBON 851 SetPortWindowPort (dest);
886 SetPort (GetWindowPort (dest));
887 #else
888 SetPort (dest);
889 #endif
890 852
891 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 853 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
892 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 854 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
893 855
894 ForeColor (blackColor); 856 ForeColor (blackColor);
944 Rect gw_r, src_r, dest_r; 906 Rect gw_r, src_r, dest_r;
945 907
946 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 908 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
947 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 909 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
948 910
949 SetPort (GetWindowPort (w)); 911 SetPortWindowPort (w);
950 912
951 ForeColor (blackColor); 913 ForeColor (blackColor);
952 BackColor (whiteColor); 914 BackColor (whiteColor);
953 915
954 LockPortBits (GetWindowPort (w)); 916 LockPortBits (GetWindowPort (w));
1002 GC gc; 964 GC gc;
1003 int src_x, src_y; 965 int src_x, src_y;
1004 unsigned int width, height; 966 unsigned int width, height;
1005 int dest_x, dest_y; 967 int dest_x, dest_y;
1006 { 968 {
969 CGrafPtr old_port;
970 GDHandle old_gdh;
1007 Rect src_r, dest_r; 971 Rect src_r, dest_r;
1008 972
973 GetGWorld (&old_port, &old_gdh);
1009 SetGWorld (dest, NULL); 974 SetGWorld (dest, NULL);
1010 ForeColor (blackColor); 975 ForeColor (blackColor);
1011 BackColor (whiteColor); 976 BackColor (whiteColor);
1012 977
1013 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 978 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1022 CopyBits (&(((GrafPtr)src)->portBits), &(((GrafPtr)dest)->portBits), 987 CopyBits (&(((GrafPtr)src)->portBits), &(((GrafPtr)dest)->portBits),
1023 &src_r, &dest_r, srcCopy, 0); 988 &src_r, &dest_r, srcCopy, 0);
1024 #endif /* not TARGET_API_MAC_CARBON */ 989 #endif /* not TARGET_API_MAC_CARBON */
1025 UnlockPixels (GetGWorldPixMap (dest)); 990 UnlockPixels (GetGWorldPixMap (dest));
1026 UnlockPixels (GetGWorldPixMap (src)); 991 UnlockPixels (GetGWorldPixMap (src));
992
993 SetGWorld (old_port, old_gdh);
1027 } 994 }
1028 995
1029 996
1030 static void 997 static void
1031 mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y, 998 mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y,
1035 GC gc; 1002 GC gc;
1036 int src_x, src_y; 1003 int src_x, src_y;
1037 unsigned int width, height; 1004 unsigned int width, height;
1038 int dest_x, dest_y; 1005 int dest_x, dest_y;
1039 { 1006 {
1007 CGrafPtr old_port;
1008 GDHandle old_gdh;
1040 Rect src_r, dest_r; 1009 Rect src_r, dest_r;
1041 1010
1011 GetGWorld (&old_port, &old_gdh);
1042 SetGWorld (dest, NULL); 1012 SetGWorld (dest, NULL);
1043 ForeColor (blackColor); 1013 ForeColor (blackColor);
1044 BackColor (whiteColor); 1014 BackColor (whiteColor);
1045 1015
1046 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 1016 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1057 &(((GrafPtr)dest)->portBits), &src_r, &src_r, &dest_r); 1027 &(((GrafPtr)dest)->portBits), &src_r, &src_r, &dest_r);
1058 #endif /* not TARGET_API_MAC_CARBON */ 1028 #endif /* not TARGET_API_MAC_CARBON */
1059 UnlockPixels (GetGWorldPixMap (dest)); 1029 UnlockPixels (GetGWorldPixMap (dest));
1060 UnlockPixels (GetGWorldPixMap (mask)); 1030 UnlockPixels (GetGWorldPixMap (mask));
1061 UnlockPixels (GetGWorldPixMap (src)); 1031 UnlockPixels (GetGWorldPixMap (src));
1032
1033 SetGWorld (old_port, old_gdh);
1062 } 1034 }
1063 1035
1064 1036
1065 /* Mac replacement for XChangeGC. */ 1037 /* Mac replacement for XChangeGC. */
1066 1038
1179 { 1151 {
1180 Lisp_Object rest, frame; 1152 Lisp_Object rest, frame;
1181 FOR_EACH_FRAME (rest, frame) 1153 FOR_EACH_FRAME (rest, frame)
1182 x_flush (XFRAME (frame)); 1154 x_flush (XFRAME (frame));
1183 } 1155 }
1184 else if (FRAME_X_P (f)) 1156 else if (FRAME_MAC_P (f))
1185 XFlush (FRAME_MAC_DISPLAY (f)); 1157 XFlush (FRAME_MAC_DISPLAY (f));
1186 UNBLOCK_INPUT; 1158 UNBLOCK_INPUT;
1187 #endif /* TARGET_API_MAC_CARBON */ 1159 #endif /* TARGET_API_MAC_CARBON */
1188 } 1160 }
1189 1161
1259 if (!NILP (display_info->mouse_face_window) 1231 if (!NILP (display_info->mouse_face_window)
1260 && w == XWINDOW (display_info->mouse_face_window)) 1232 && w == XWINDOW (display_info->mouse_face_window))
1261 { 1233 {
1262 int i; 1234 int i;
1263 1235
1264 for (i = 0; i < w->desired_matrix->nrows; ++i) 1236 for (i = 0; i < w->desired_matrix->nrows; ++i)
1265 if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i)) 1237 if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i))
1266 break; 1238 break;
1267 1239
1268 if (i < w->desired_matrix->nrows) 1240 if (i < w->desired_matrix->nrows)
1269 clear_mouse_face (display_info); 1241 clear_mouse_face (display_info);
1281 mac_draw_vertical_window_border (w, x, y0, y1) 1253 mac_draw_vertical_window_border (w, x, y0, y1)
1282 struct window *w; 1254 struct window *w;
1283 int x, y0, y1; 1255 int x, y0, y1;
1284 { 1256 {
1285 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1257 struct frame *f = XFRAME (WINDOW_FRAME (w));
1286 1258
1287 XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1259 XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1288 f->output_data.mac->normal_gc, x, y0, x, y1); 1260 f->output_data.mac->normal_gc, x, y0, x, y1);
1289 } 1261 }
1290 1262
1291 1263
1354 struct frame *f; 1326 struct frame *f;
1355 { 1327 {
1356 /* Reset the background color of Mac OS Window to that of the frame after 1328 /* Reset the background color of Mac OS Window to that of the frame after
1357 update so that it is used by Mac Toolbox to clear the update region before 1329 update so that it is used by Mac Toolbox to clear the update region before
1358 an update event is generated. */ 1330 an update event is generated. */
1359 #if TARGET_API_MAC_CARBON 1331 SetPortWindowPort (FRAME_MAC_WINDOW (f));
1360 SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
1361 #else
1362 SetPort (FRAME_MAC_WINDOW (f));
1363 #endif
1364 1332
1365 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f)); 1333 mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
1366 1334
1367 /* Mouse highlight may be displayed again. */ 1335 /* Mouse highlight may be displayed again. */
1368 FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0; 1336 FRAME_MAC_DISPLAY_INFO (f)->mouse_face_defer = 0;
1379 1347
1380 static void 1348 static void
1381 XTframe_up_to_date (f) 1349 XTframe_up_to_date (f)
1382 struct frame *f; 1350 struct frame *f;
1383 { 1351 {
1384 if (FRAME_X_P (f)) 1352 if (FRAME_MAC_P (f))
1385 { 1353 {
1386 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); 1354 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
1387 1355
1388 if (dpyinfo->mouse_face_deferred_gc 1356 if (dpyinfo->mouse_face_deferred_gc
1389 || f == dpyinfo->mouse_face_mouse_frame) 1357 || f == dpyinfo->mouse_face_mouse_frame)
1523 ? (p->overlay_p ? face->background 1491 ? (p->overlay_p ? face->background
1524 : f->output_data.mac->cursor_pixel) 1492 : f->output_data.mac->cursor_pixel)
1525 : face->foreground); 1493 : face->foreground);
1526 gcv.background = face->background; 1494 gcv.background = face->background;
1527 1495
1528 mac_draw_bitmap (display, window, &gcv, p->x, p->y, 1496 mac_draw_bitmap (display, window, &gcv, p->x, p->y,
1529 p->wd, p->h, bits, p->overlay_p); 1497 p->wd, p->h, bits, p->overlay_p);
1530 } 1498 }
1531 1499
1532 mac_reset_clipping (display, window); 1500 mac_reset_clipping (display, window);
1533 } 1501 }
1757 static void x_draw_image_foreground P_ ((struct glyph_string *)); 1725 static void x_draw_image_foreground P_ ((struct glyph_string *));
1758 static void x_draw_image_foreground_1 P_ ((struct glyph_string *, Pixmap)); 1726 static void x_draw_image_foreground_1 P_ ((struct glyph_string *, Pixmap));
1759 static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int, 1727 static void x_clear_glyph_string_rect P_ ((struct glyph_string *, int,
1760 int, int, int)); 1728 int, int, int));
1761 static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int, 1729 static void x_draw_relief_rect P_ ((struct frame *, int, int, int, int,
1762 int, int, int, int, Rect *)); 1730 int, int, int, int, int, int,
1731 Rect *));
1763 static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int, 1732 static void x_draw_box_rect P_ ((struct glyph_string *, int, int, int, int,
1764 int, int, int, Rect *)); 1733 int, int, int, Rect *));
1765 1734
1766 #if GLYPH_DEBUG 1735 #if GLYPH_DEBUG
1767 static void x_check_font P_ ((struct frame *, XFontStruct *)); 1736 static void x_check_font P_ ((struct frame *, XFontStruct *));
2481 side of the rectangle. CLIP_RECT is the clipping rectangle to use 2450 side of the rectangle. CLIP_RECT is the clipping rectangle to use
2482 when drawing. */ 2451 when drawing. */
2483 2452
2484 static void 2453 static void
2485 x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, 2454 x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2486 raised_p, left_p, right_p, clip_rect) 2455 raised_p, top_p, bot_p, left_p, right_p, clip_rect)
2487 struct frame *f; 2456 struct frame *f;
2488 int left_x, top_y, right_x, bottom_y, width, left_p, right_p, raised_p; 2457 int left_x, top_y, right_x, bottom_y, width;
2458 int top_p, bot_p, left_p, right_p, raised_p;
2489 Rect *clip_rect; 2459 Rect *clip_rect;
2490 { 2460 {
2491 Display *dpy = FRAME_MAC_DISPLAY (f); 2461 Display *dpy = FRAME_MAC_DISPLAY (f);
2492 Window window = FRAME_MAC_WINDOW (f); 2462 Window window = FRAME_MAC_WINDOW (f);
2493 int i; 2463 int i;
2498 else 2468 else
2499 gc = f->output_data.mac->black_relief.gc; 2469 gc = f->output_data.mac->black_relief.gc;
2500 mac_set_clip_rectangle (dpy, window, clip_rect); 2470 mac_set_clip_rectangle (dpy, window, clip_rect);
2501 2471
2502 /* Top. */ 2472 /* Top. */
2503 for (i = 0; i < width; ++i) 2473 if (top_p)
2504 XDrawLine (dpy, window, gc, 2474 for (i = 0; i < width; ++i)
2505 left_x + i * left_p, top_y + i, 2475 XDrawLine (dpy, window, gc,
2506 right_x - i * right_p, top_y + i); 2476 left_x + i * left_p, top_y + i,
2477 right_x - i * right_p, top_y + i);
2507 2478
2508 /* Left. */ 2479 /* Left. */
2509 if (left_p) 2480 if (left_p)
2510 for (i = 0; i < width; ++i) 2481 for (i = 0; i < width; ++i)
2511 XDrawLine (dpy, window, gc, 2482 XDrawLine (dpy, window, gc,
2518 gc = f->output_data.mac->white_relief.gc; 2489 gc = f->output_data.mac->white_relief.gc;
2519 mac_set_clip_rectangle (dpy, window, 2490 mac_set_clip_rectangle (dpy, window,
2520 clip_rect); 2491 clip_rect);
2521 2492
2522 /* Bottom. */ 2493 /* Bottom. */
2523 for (i = 0; i < width; ++i) 2494 if (bot_p)
2524 XDrawLine (dpy, window, gc, 2495 for (i = 0; i < width; ++i)
2525 left_x + i * left_p, bottom_y - i, 2496 XDrawLine (dpy, window, gc,
2526 right_x - i * right_p, bottom_y - i); 2497 left_x + i * left_p, bottom_y - i,
2498 right_x - i * right_p, bottom_y - i);
2527 2499
2528 /* Right. */ 2500 /* Right. */
2529 if (right_p) 2501 if (right_p)
2530 for (i = 0; i < width; ++i) 2502 for (i = 0; i < width; ++i)
2531 XDrawLine (dpy, window, gc, 2503 XDrawLine (dpy, window, gc,
2627 left_p, right_p, &clip_rect); 2599 left_p, right_p, &clip_rect);
2628 else 2600 else
2629 { 2601 {
2630 x_setup_relief_colors (s); 2602 x_setup_relief_colors (s);
2631 x_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y, 2603 x_draw_relief_rect (s->f, left_x, top_y, right_x, bottom_y,
2632 width, raised_p, left_p, right_p, &clip_rect); 2604 width, raised_p, 1, 1, left_p, right_p, &clip_rect);
2633 } 2605 }
2634 } 2606 }
2635 2607
2636 2608
2637 /* Draw foreground of image glyph string S. */ 2609 /* Draw foreground of image glyph string S. */
2638 2610
2639 static void 2611 static void
2640 x_draw_image_foreground (s) 2612 x_draw_image_foreground (s)
2641 struct glyph_string *s; 2613 struct glyph_string *s;
2642 { 2614 {
2643 int x; 2615 int x = s->x;
2644 int y = s->ybase - image_ascent (s->img, s->face); 2616 int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
2645 2617
2646 /* If first glyph of S has a left box line, start drawing it to the 2618 /* If first glyph of S has a left box line, start drawing it to the
2647 right of that line. */ 2619 right of that line. */
2648 if (s->face->box != FACE_NO_BOX 2620 if (s->face->box != FACE_NO_BOX
2649 && s->first_glyph->left_box_line_p) 2621 && s->first_glyph->left_box_line_p
2650 x = s->x + abs (s->face->box_line_width); 2622 && s->slice.x == 0)
2651 else 2623 x += abs (s->face->box_line_width);
2652 x = s->x;
2653 2624
2654 /* If there is a margin around the image, adjust x- and y-position 2625 /* If there is a margin around the image, adjust x- and y-position
2655 by that margin. */ 2626 by that margin. */
2656 x += s->img->hmargin; 2627 if (s->slice.x == 0)
2657 y += s->img->vmargin; 2628 x += s->img->hmargin;
2629 if (s->slice.y == 0)
2630 y += s->img->vmargin;
2658 2631
2659 if (s->img->pixmap) 2632 if (s->img->pixmap)
2660 { 2633 {
2661 if (s->img->mask) 2634 if (s->img->mask)
2662 { 2635 {
2665 2638
2666 get_glyph_string_clip_rect (s, &nr); 2639 get_glyph_string_clip_rect (s, &nr);
2667 CONVERT_TO_XRECT (clip_rect, nr); 2640 CONVERT_TO_XRECT (clip_rect, nr);
2668 image_rect.x = x; 2641 image_rect.x = x;
2669 image_rect.y = y; 2642 image_rect.y = y;
2670 image_rect.width = s->img->width; 2643 image_rect.width = s->slice.width;
2671 image_rect.height = s->img->height; 2644 image_rect.height = s->slice.height;
2672 if (x_intersect_rectangles (&clip_rect, &image_rect, &r)) 2645 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2673 mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask, 2646 mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask,
2674 s->window, s->gc, r.x - x, r.y - y, 2647 s->window, s->gc,
2648 s->slice.x + r.x - x, s->slice.y + r.y - y,
2675 r.width, r.height, r.x, r.y); 2649 r.width, r.height, r.x, r.y);
2676 } 2650 }
2677 else 2651 else
2678 { 2652 {
2679 Rect nr; 2653 Rect nr;
2681 2655
2682 get_glyph_string_clip_rect (s, &nr); 2656 get_glyph_string_clip_rect (s, &nr);
2683 CONVERT_TO_XRECT (clip_rect, nr); 2657 CONVERT_TO_XRECT (clip_rect, nr);
2684 image_rect.x = x; 2658 image_rect.x = x;
2685 image_rect.y = y; 2659 image_rect.y = y;
2686 image_rect.width = s->img->width; 2660 image_rect.width = s->slice.width;
2687 image_rect.height = s->img->height; 2661 image_rect.height = s->slice.height;
2688 if (x_intersect_rectangles (&clip_rect, &image_rect, &r)) 2662 if (x_intersect_rectangles (&clip_rect, &image_rect, &r))
2689 mac_copy_area (s->display, s->img->pixmap, s->window, s->gc, 2663 mac_copy_area (s->display, s->img->pixmap, s->window, s->gc,
2690 r.x - x, r.y - y, r.width, r.height, r.x, r.y); 2664 s->slice.x + r.x - x, s->slice.y + r.y - y,
2665 r.width, r.height, r.x, r.y);
2666
2667 /* When the image has a mask, we can expect that at
2668 least part of a mouse highlight or a block cursor will
2669 be visible. If the image doesn't have a mask, make
2670 a block cursor visible by drawing a rectangle around
2671 the image. I believe it's looking better if we do
2672 nothing here for mouse-face. */
2673 if (s->hl == DRAW_CURSOR)
2674 {
2675 int r = s->img->relief;
2676 if (r < 0) r = -r;
2677 mac_draw_rectangle (s->display, s->window, s->gc,
2678 x - r, y - r,
2679 s->slice.width + r*2 - 1,
2680 s->slice.height + r*2 - 1);
2681 }
2682 }
2683 }
2684 else
2685 /* Draw a rectangle if image could not be loaded. */
2686 mac_draw_rectangle (s->display, s->window, s->gc, x, y,
2687 s->slice.width - 1, s->slice.height - 1);
2688 }
2689
2690
2691 /* Draw a relief around the image glyph string S. */
2692
2693 static void
2694 x_draw_image_relief (s)
2695 struct glyph_string *s;
2696 {
2697 int x0, y0, x1, y1, thick, raised_p;
2698 Rect r;
2699 int x = s->x;
2700 int y = s->ybase - image_ascent (s->img, s->face, &s->slice);
2701
2702 /* If first glyph of S has a left box line, start drawing it to the
2703 right of that line. */
2704 if (s->face->box != FACE_NO_BOX
2705 && s->first_glyph->left_box_line_p
2706 && s->slice.x == 0)
2707 x += abs (s->face->box_line_width);
2708
2709 /* If there is a margin around the image, adjust x- and y-position
2710 by that margin. */
2711 if (s->slice.x == 0)
2712 x += s->img->hmargin;
2713 if (s->slice.y == 0)
2714 y += s->img->vmargin;
2715
2716 if (s->hl == DRAW_IMAGE_SUNKEN
2717 || s->hl == DRAW_IMAGE_RAISED)
2718 {
2719 thick = tool_bar_button_relief >= 0 ? tool_bar_button_relief : DEFAULT_TOOL_BAR_BUTTON_RELIEF;
2720 raised_p = s->hl == DRAW_IMAGE_RAISED;
2721 }
2722 else
2723 {
2724 thick = abs (s->img->relief);
2725 raised_p = s->img->relief > 0;
2726 }
2727
2728 x0 = x - thick;
2729 y0 = y - thick;
2730 x1 = x + s->slice.width + thick - 1;
2731 y1 = y + s->slice.height + thick - 1;
2732
2733 x_setup_relief_colors (s);
2734 get_glyph_string_clip_rect (s, &r);
2735 x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p,
2736 s->slice.y == 0,
2737 s->slice.y + s->slice.height == s->img->height,
2738 s->slice.x == 0,
2739 s->slice.x + s->slice.width == s->img->width,
2740 &r);
2741 }
2742
2743
2744 /* Draw the foreground of image glyph string S to PIXMAP. */
2745
2746 static void
2747 x_draw_image_foreground_1 (s, pixmap)
2748 struct glyph_string *s;
2749 Pixmap pixmap;
2750 {
2751 int x = 0;
2752 int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
2753
2754 /* If first glyph of S has a left box line, start drawing it to the
2755 right of that line. */
2756 if (s->face->box != FACE_NO_BOX
2757 && s->first_glyph->left_box_line_p
2758 && s->slice.x == 0)
2759 x += abs (s->face->box_line_width);
2760
2761 /* If there is a margin around the image, adjust x- and y-position
2762 by that margin. */
2763 if (s->slice.x == 0)
2764 x += s->img->hmargin;
2765 if (s->slice.y == 0)
2766 y += s->img->vmargin;
2767
2768 if (s->img->pixmap)
2769 {
2770 if (s->img->mask)
2771 mac_copy_area_with_mask_to_pixmap (s->display, s->img->pixmap,
2772 s->img->mask, pixmap, s->gc,
2773 s->slice.x, s->slice.y,
2774 s->slice.width, s->slice.height,
2775 x, y);
2776 else
2777 {
2778 mac_copy_area_to_pixmap (s->display, s->img->pixmap, pixmap, s->gc,
2779 s->slice.x, s->slice.y,
2780 s->slice.width, s->slice.height,
2781 x, y);
2691 2782
2692 /* When the image has a mask, we can expect that at 2783 /* When the image has a mask, we can expect that at
2693 least part of a mouse highlight or a block cursor will 2784 least part of a mouse highlight or a block cursor will
2694 be visible. If the image doesn't have a mask, make 2785 be visible. If the image doesn't have a mask, make
2695 a block cursor visible by drawing a rectangle around 2786 a block cursor visible by drawing a rectangle around
2698 if (s->hl == DRAW_CURSOR) 2789 if (s->hl == DRAW_CURSOR)
2699 { 2790 {
2700 int r = s->img->relief; 2791 int r = s->img->relief;
2701 if (r < 0) r = -r; 2792 if (r < 0) r = -r;
2702 mac_draw_rectangle (s->display, s->window, s->gc, x - r, y - r, 2793 mac_draw_rectangle (s->display, s->window, s->gc, x - r, y - r,
2703 s->img->width + r*2 - 1, s->img->height + r*2 - 1); 2794 s->slice.width + r*2 - 1,
2704 } 2795 s->slice.height + r*2 - 1);
2705 }
2706 }
2707 else
2708 /* Draw a rectangle if image could not be loaded. */
2709 mac_draw_rectangle (s->display, s->window, s->gc, x, y,
2710 s->img->width - 1, s->img->height - 1);
2711 }
2712
2713
2714 /* Draw a relief around the image glyph string S. */
2715
2716 static void
2717 x_draw_image_relief (s)
2718 struct glyph_string *s;
2719 {
2720 int x0, y0, x1, y1, thick, raised_p;
2721 Rect r;
2722 int x;
2723 int y = s->ybase - image_ascent (s->img, s->face);
2724
2725 /* If first glyph of S has a left box line, start drawing it to the
2726 right of that line. */
2727 if (s->face->box != FACE_NO_BOX
2728 && s->first_glyph->left_box_line_p)
2729 x = s->x + abs (s->face->box_line_width);
2730 else
2731 x = s->x;
2732
2733 /* If there is a margin around the image, adjust x- and y-position
2734 by that margin. */
2735 x += s->img->hmargin;
2736 y += s->img->vmargin;
2737
2738 if (s->hl == DRAW_IMAGE_SUNKEN
2739 || s->hl == DRAW_IMAGE_RAISED)
2740 {
2741 thick = tool_bar_button_relief >= 0 ? tool_bar_button_relief : DEFAULT_TOOL_BAR_BUTTON_RELIEF;
2742 raised_p = s->hl == DRAW_IMAGE_RAISED;
2743 }
2744 else
2745 {
2746 thick = abs (s->img->relief);
2747 raised_p = s->img->relief > 0;
2748 }
2749
2750 x0 = x - thick;
2751 y0 = y - thick;
2752 x1 = x + s->img->width + thick - 1;
2753 y1 = y + s->img->height + thick - 1;
2754
2755 x_setup_relief_colors (s);
2756 get_glyph_string_clip_rect (s, &r);
2757 x_draw_relief_rect (s->f, x0, y0, x1, y1, thick, raised_p, 1, 1, &r);
2758 }
2759
2760
2761 /* Draw the foreground of image glyph string S to PIXMAP. */
2762
2763 static void
2764 x_draw_image_foreground_1 (s, pixmap)
2765 struct glyph_string *s;
2766 Pixmap pixmap;
2767 {
2768 int x;
2769 int y = s->ybase - s->y - image_ascent (s->img, s->face);
2770
2771 /* If first glyph of S has a left box line, start drawing it to the
2772 right of that line. */
2773 if (s->face->box != FACE_NO_BOX
2774 && s->first_glyph->left_box_line_p)
2775 x = abs (s->face->box_line_width);
2776 else
2777 x = 0;
2778
2779 /* If there is a margin around the image, adjust x- and y-position
2780 by that margin. */
2781 x += s->img->hmargin;
2782 y += s->img->vmargin;
2783
2784 if (s->img->pixmap)
2785 {
2786 if (s->img->mask)
2787 mac_copy_area_with_mask_to_pixmap (s->display, s->img->pixmap,
2788 s->img->mask, pixmap, s->gc,
2789 0, 0, s->img->width, s->img->height,
2790 x, y);
2791 else
2792 {
2793 mac_copy_area_to_pixmap (s->display, s->img->pixmap, pixmap, s->gc,
2794 0, 0, s->img->width, s->img->height, x, y);
2795
2796 /* When the image has a mask, we can expect that at
2797 least part of a mouse highlight or a block cursor will
2798 be visible. If the image doesn't have a mask, make
2799 a block cursor visible by drawing a rectangle around
2800 the image. I believe it's looking better if we do
2801 nothing here for mouse-face. */
2802 if (s->hl == DRAW_CURSOR)
2803 {
2804 int r = s->img->relief;
2805 if (r < 0) r = -r;
2806 mac_draw_rectangle (s->display, s->window, s->gc, x - r, y - r,
2807 s->img->width + r*2 - 1,
2808 s->img->height + r*2 - 1);
2809 } 2796 }
2810 } 2797 }
2811 } 2798 }
2812 else 2799 else
2813 /* Draw a rectangle if image could not be loaded. */ 2800 /* Draw a rectangle if image could not be loaded. */
2814 mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y, 2801 mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y,
2815 s->img->width - 1, s->img->height - 1); 2802 s->slice.width - 1, s->slice.height - 1);
2816 } 2803 }
2817 2804
2818 2805
2819 /* Draw part of the background of glyph string S. X, Y, W, and H 2806 /* Draw part of the background of glyph string S. X, Y, W, and H
2820 give the rectangle to draw. */ 2807 give the rectangle to draw. */
2867 2854
2868 /* Fill background with face under the image. Do it only if row is 2855 /* Fill background with face under the image. Do it only if row is
2869 taller than image or if image has a clip mask to reduce 2856 taller than image or if image has a clip mask to reduce
2870 flickering. */ 2857 flickering. */
2871 s->stippled_p = s->face->stipple != 0; 2858 s->stippled_p = s->face->stipple != 0;
2872 if (height > s->img->height 2859 if (height > s->slice.height
2873 || s->img->hmargin 2860 || s->img->hmargin
2874 || s->img->vmargin 2861 || s->img->vmargin
2875 || s->img->mask 2862 || s->img->mask
2876 || s->img->pixmap == 0 2863 || s->img->pixmap == 0
2877 || s->width != s->background_width) 2864 || s->width != s->background_width)
2878 { 2865 {
2879 if (box_line_hwidth && s->first_glyph->left_box_line_p) 2866 x = s->x;
2880 x = s->x + box_line_hwidth; 2867 if (s->first_glyph->left_box_line_p
2881 else 2868 && s->slice.x == 0)
2882 x = s->x; 2869 x += box_line_hwidth;
2883 2870
2884 y = s->y + box_line_vwidth; 2871 y = s->y;
2872 if (s->slice.y == 0)
2873 y += box_line_vwidth;
2885 2874
2886 if (s->img->mask) 2875 if (s->img->mask)
2887 { 2876 {
2888 /* Create a pixmap as large as the glyph string. Fill it 2877 /* Create a pixmap as large as the glyph string. Fill it
2889 with the background color. Copy the image to it, using 2878 with the background color. Copy the image to it, using
3693 result->timestamp = event->when; 3682 result->timestamp = event->when;
3694 result->modifiers = event->what == mouseDown ? down_modifier : up_modifier; 3683 result->modifiers = event->what == mouseDown ? down_modifier : up_modifier;
3695 3684
3696 mouseLoc = event->where; 3685 mouseLoc = event->where;
3697 3686
3698 #if TARGET_API_MAC_CARBON 3687 SetPortWindowPort (FRAME_MAC_WINDOW (f));
3699 SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
3700 #else
3701 SetPort (FRAME_MAC_WINDOW (f));
3702 #endif
3703 3688
3704 GlobalToLocal (&mouseLoc); 3689 GlobalToLocal (&mouseLoc);
3705 XSETINT (result->x, mouseLoc.h); 3690 XSETINT (result->x, mouseLoc.h);
3706 XSETINT (result->y, mouseLoc.v); 3691 XSETINT (result->y, mouseLoc.v);
3707 3692
3726 static void 3711 static void
3727 note_mouse_movement (frame, pos) 3712 note_mouse_movement (frame, pos)
3728 FRAME_PTR frame; 3713 FRAME_PTR frame;
3729 Point *pos; 3714 Point *pos;
3730 { 3715 {
3716 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (frame);
3731 #if TARGET_API_MAC_CARBON 3717 #if TARGET_API_MAC_CARBON
3732 Rect r; 3718 Rect r;
3733 #endif 3719 #endif
3734 3720
3735 last_mouse_movement_time = TickCount () * (1000 / 60); /* to milliseconds */ 3721 last_mouse_movement_time = TickCount () * (1000 / 60); /* to milliseconds */
3740 if (!PtInRect (*pos, GetWindowPortBounds (FRAME_MAC_WINDOW (frame), &r))) 3726 if (!PtInRect (*pos, GetWindowPortBounds (FRAME_MAC_WINDOW (frame), &r)))
3741 #else 3727 #else
3742 if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect)) 3728 if (!PtInRect (*pos, &FRAME_MAC_WINDOW (frame)->portRect))
3743 #endif 3729 #endif
3744 { 3730 {
3745 frame->mouse_moved = 1; 3731 if (frame == dpyinfo->mouse_face_mouse_frame)
3746 last_mouse_scroll_bar = Qnil; 3732 /* This case corresponds to LeaveNotify in X11. */
3747 note_mouse_highlight (frame, -1, -1); 3733 {
3734 /* If we move outside the frame, then we're certainly no
3735 longer on any text in the frame. */
3736 clear_mouse_face (dpyinfo);
3737 dpyinfo->mouse_face_mouse_frame = 0;
3738 if (!dpyinfo->grabbed)
3739 rif->define_frame_cursor (frame,
3740 frame->output_data.mac->nontext_cursor);
3741 }
3748 } 3742 }
3749 /* Has the mouse moved off the glyph it was on at the last sighting? */ 3743 /* Has the mouse moved off the glyph it was on at the last sighting? */
3750 else if (pos->h < last_mouse_glyph.left 3744 else if (pos->h < last_mouse_glyph.left
3751 || pos->h >= last_mouse_glyph.right 3745 || pos->h >= last_mouse_glyph.right
3752 || pos->v < last_mouse_glyph.top 3746 || pos->v < last_mouse_glyph.top
3840 return 1; 3834 return 1;
3841 } 3835 }
3842 3836
3843 /* x is to the right of the last glyph in the row. */ 3837 /* x is to the right of the last glyph in the row. */
3844 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx); 3838 rect->left = WINDOW_TO_FRAME_PIXEL_X (w, gx);
3845 /* Shouldn't this be a pixel value? 3839 /* Shouldn't this be a pixel value?
3846 WINDOW_RIGHT_EDGE_X (w) seems to be the right value. 3840 WINDOW_RIGHT_EDGE_X (w) seems to be the right value.
3847 ++KFS */ 3841 ++KFS */
3848 rect->right = WINDOW_RIGHT_EDGE_COL (w); 3842 rect->right = WINDOW_RIGHT_EDGE_COL (w);
3849 return 1; 3843 return 1;
3850 } 3844 }
3890 last_mouse_glyph.bottom = gy + height; 3884 last_mouse_glyph.bottom = gy + height;
3891 } 3885 }
3892 } 3886 }
3893 3887
3894 3888
3889 static WindowPtr
3890 mac_front_window ()
3891 {
3892 #if TARGET_API_MAC_CARBON
3893 return GetFrontWindowOfClass (kDocumentWindowClass, true);
3894 #else
3895 WindowPtr front_window = FrontWindow ();
3896
3897 if (tip_window && front_window == tip_window)
3898 return GetNextWindow (front_window);
3899 else
3900 return front_window;
3901 #endif
3902 }
3903
3904 #define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
3905
3895 /* Return the current position of the mouse. 3906 /* Return the current position of the mouse.
3896 *fp should be a frame which indicates which display to ask about. 3907 *fp should be a frame which indicates which display to ask about.
3897 3908
3898 If the mouse movement started in a scroll bar, set *fp, *bar_window, 3909 If the mouse movement started in a scroll bar, set *fp, *bar_window,
3899 and *part to the frame, window, and scroll bar part that the mouse 3910 and *part to the frame, window, and scroll bar part that the mouse
3921 Lisp_Object *x, *y; 3932 Lisp_Object *x, *y;
3922 unsigned long *time; 3933 unsigned long *time;
3923 { 3934 {
3924 Point mouse_pos; 3935 Point mouse_pos;
3925 int ignore1, ignore2; 3936 int ignore1, ignore2;
3926 WindowPtr wp = FrontWindow (); 3937 WindowPtr wp = mac_front_window ();
3927 struct frame *f; 3938 struct frame *f;
3928 Lisp_Object frame, tail; 3939 Lisp_Object frame, tail;
3929 3940
3930 if (is_emacs_window(wp)) 3941 if (is_emacs_window(wp))
3931 f = ((mac_output *) GetWRefCon (wp))->mFP; 3942 f = mac_window_to_frame (wp);
3932 3943
3933 BLOCK_INPUT; 3944 BLOCK_INPUT;
3934 3945
3935 if (! NILP (last_mouse_scroll_bar) && insist == 0) 3946 if (! NILP (last_mouse_scroll_bar) && insist == 0)
3936 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time); 3947 x_scroll_bar_report_motion (fp, bar_window, part, x, y, time);
3940 FOR_EACH_FRAME (tail, frame) 3951 FOR_EACH_FRAME (tail, frame)
3941 XFRAME (frame)->mouse_moved = 0; 3952 XFRAME (frame)->mouse_moved = 0;
3942 3953
3943 last_mouse_scroll_bar = Qnil; 3954 last_mouse_scroll_bar = Qnil;
3944 3955
3945 #if TARGET_API_MAC_CARBON 3956 SetPortWindowPort (wp);
3946 SetPort (GetWindowPort (wp));
3947 #else
3948 SetPort (wp);
3949 #endif
3950 3957
3951 GetMouse (&mouse_pos); 3958 GetMouse (&mouse_pos);
3952 3959
3953 pixel_to_glyph_coords (f, mouse_pos.h, mouse_pos.v, &ignore1, &ignore2, 3960 pixel_to_glyph_coords (f, mouse_pos.h, mouse_pos.v, &ignore1, &ignore2,
3954 &last_mouse_glyph, insist); 3961 &last_mouse_glyph, insist);
3982 int y = button_event->where.v; 3989 int y = button_event->where.v;
3983 3990
3984 if (button_event->what == mouseDown) 3991 if (button_event->what == mouseDown)
3985 handle_tool_bar_click (f, x, y, 1, 0); 3992 handle_tool_bar_click (f, x, y, 1, 0);
3986 else 3993 else
3987 handle_tool_bar_click (f, x, y, 0, 3994 handle_tool_bar_click (f, x, y, 0,
3988 x_mac_to_emacs_modifiers (FRAME_MAC_DISPLAY_INFO (f), 3995 x_mac_to_emacs_modifiers (FRAME_MAC_DISPLAY_INFO (f),
3989 button_event->modifiers)); 3996 button_event->modifiers));
3990 } 3997 }
3991 3998
3992 3999
4439 struct scroll_bar *bar; 4446 struct scroll_bar *bar;
4440 int part_code; 4447 int part_code;
4441 EventRecord *er; 4448 EventRecord *er;
4442 struct input_event *bufp; 4449 struct input_event *bufp;
4443 { 4450 {
4451 int win_y, top_range;
4452
4444 if (! GC_WINDOWP (bar->window)) 4453 if (! GC_WINDOWP (bar->window))
4445 abort (); 4454 abort ();
4446 4455
4447 bufp->kind = SCROLL_BAR_CLICK_EVENT; 4456 bufp->kind = SCROLL_BAR_CLICK_EVENT;
4448 bufp->frame_or_window = bar->window; 4457 bufp->frame_or_window = bar->window;
4473 bar->dragging = make_number (0); 4482 bar->dragging = make_number (0);
4474 XSETVECTOR (last_mouse_scroll_bar, bar); 4483 XSETVECTOR (last_mouse_scroll_bar, bar);
4475 bufp->part = scroll_bar_handle; 4484 bufp->part = scroll_bar_handle;
4476 break; 4485 break;
4477 } 4486 }
4487
4488 win_y = XINT (bufp->y) - XINT (bar->top);
4489 top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (0/*dummy*/, XINT (bar->height));
4490
4491 win_y -= VERTICAL_SCROLL_BAR_TOP_BORDER;
4492
4493 win_y -= 24;
4494
4495 if (! NILP (bar->dragging))
4496 win_y -= XINT (bar->dragging);
4497
4498 if (win_y < 0)
4499 win_y = 0;
4500 if (win_y > top_range)
4501 win_y = top_range;
4502
4503 XSETINT (bufp->x, win_y);
4504 XSETINT (bufp->y, top_range);
4478 } 4505 }
4479 4506
4480 4507
4481 /* Handle some mouse motion while someone is dragging the scroll bar. 4508 /* Handle some mouse motion while someone is dragging the scroll bar.
4482 4509
4522 enum scroll_bar_part *part; 4549 enum scroll_bar_part *part;
4523 Lisp_Object *x, *y; 4550 Lisp_Object *x, *y;
4524 unsigned long *time; 4551 unsigned long *time;
4525 { 4552 {
4526 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); 4553 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
4527 WindowPtr wp = FrontWindow (); 4554 WindowPtr wp = mac_front_window ();
4528 Point mouse_pos; 4555 Point mouse_pos;
4529 struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP; 4556 struct frame *f = mac_window_to_frame (wp);
4530 int win_y, top_range; 4557 int win_y, top_range;
4531 4558
4532 #if TARGET_API_MAC_CARBON 4559 SetPortWindowPort (wp);
4533 SetPort (GetWindowPort (wp));
4534 #else
4535 SetPort (wp);
4536 #endif
4537 4560
4538 GetMouse (&mouse_pos); 4561 GetMouse (&mouse_pos);
4539 4562
4540 win_y = mouse_pos.v - XINT (bar->top); 4563 win_y = mouse_pos.v - XINT (bar->top);
4541 top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height)); 4564 top_range = VERTICAL_SCROLL_BAR_TOP_RANGE (f, XINT (bar->height));
4643 y = WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y); 4666 y = WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y);
4644 4667
4645 /* Compute the proper height and ascent of the rectangle, based 4668 /* Compute the proper height and ascent of the rectangle, based
4646 on the actual glyph. Using the full height of the row looks 4669 on the actual glyph. Using the full height of the row looks
4647 bad when there are tall images on that row. */ 4670 bad when there are tall images on that row. */
4648 h = max (FRAME_LINE_HEIGHT (f), cursor_glyph->ascent + cursor_glyph->descent); 4671 h = max (min (FRAME_LINE_HEIGHT (f), row->height),
4672 cursor_glyph->ascent + cursor_glyph->descent);
4649 if (h < row->height) 4673 if (h < row->height)
4650 y += row->ascent /* - w->phys_cursor_ascent */ + cursor_glyph->descent - h; 4674 y += row->ascent /* - w->phys_cursor_ascent */ + cursor_glyph->descent - h;
4651 h--; 4675 h--;
4652 4676
4653 /* The foreground of cursor_gc is typically the same as the normal 4677 /* The foreground of cursor_gc is typically the same as the normal
4757 static void 4781 static void
4758 mac_define_frame_cursor (f, cursor) 4782 mac_define_frame_cursor (f, cursor)
4759 struct frame *f; 4783 struct frame *f;
4760 Cursor cursor; 4784 Cursor cursor;
4761 { 4785 {
4762 /* MAC TODO */ 4786 #if TARGET_API_MAC_CARBON
4787 SetThemeCursor (cursor);
4788 #else
4789 SetCursor (*cursor);
4790 #endif
4763 } 4791 }
4764 4792
4765 4793
4766 /* RIF: Clear area on frame F. */ 4794 /* RIF: Clear area on frame F. */
4767 4795
4931 4959
4932 /* Compute the scroll bar width in character columns. */ 4960 /* Compute the scroll bar width in character columns. */
4933 if (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0) 4961 if (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) > 0)
4934 { 4962 {
4935 int wid = FRAME_COLUMN_WIDTH (f); 4963 int wid = FRAME_COLUMN_WIDTH (f);
4936 FRAME_CONFIG_SCROLL_BAR_COLS (f) 4964 FRAME_CONFIG_SCROLL_BAR_COLS (f)
4937 = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + wid-1) / wid; 4965 = (FRAME_CONFIG_SCROLL_BAR_WIDTH (f) + wid-1) / wid;
4938 } 4966 }
4939 else 4967 else
4940 { 4968 {
4941 int wid = FRAME_COLUMN_WIDTH (f); 4969 int wid = FRAME_COLUMN_WIDTH (f);
5025 if (f->output_data.mac->parent_desc != FRAME_MAC_DISPLAY_INFO (f)->root_window) 5053 if (f->output_data.mac->parent_desc != FRAME_MAC_DISPLAY_INFO (f)->root_window)
5026 { 5054 {
5027 GrafPtr savePort; 5055 GrafPtr savePort;
5028 GetPort (&savePort); 5056 GetPort (&savePort);
5029 5057
5030 #if TARGET_API_MAC_CARBON 5058 SetPortWindowPort (FRAME_MAC_WINDOW (f));
5031 SetPort (GetWindowPort (FRAME_MAC_WINDOW (f)));
5032 #else
5033 SetPort (FRAME_MAC_WINDOW (f));
5034 #endif
5035 5059
5036 #if TARGET_API_MAC_CARBON 5060 #if TARGET_API_MAC_CARBON
5037 { 5061 {
5038 Rect r; 5062 Rect r;
5039 5063
5404 void 5428 void
5405 x_free_frame_resources (f) 5429 x_free_frame_resources (f)
5406 struct frame *f; 5430 struct frame *f;
5407 { 5431 {
5408 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); 5432 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
5433 WindowPtr wp = FRAME_MAC_WINDOW (f);
5409 5434
5410 BLOCK_INPUT; 5435 BLOCK_INPUT;
5411 5436
5412 DisposeWindow (FRAME_MAC_WINDOW (f)); 5437 DisposeWindow (wp);
5438 if (wp == tip_window)
5439 /* Neither WaitNextEvent nor ReceiveNextEvent receives `window
5440 closed' event. So we reset tip_window here. */
5441 tip_window = NULL;
5413 5442
5414 free_frame_menubar (f); 5443 free_frame_menubar (f);
5415 5444
5416 if (FRAME_FACE_CACHE (f)) 5445 if (FRAME_FACE_CACHE (f))
5417 free_frame_faces (f); 5446 free_frame_faces (f);
5824 case smJapanese: 5853 case smJapanese:
5825 coding_system = Qsjis; 5854 coding_system = Qsjis;
5826 break; 5855 break;
5827 case smKorean: 5856 case smKorean:
5828 coding_system = Qeuc_kr; 5857 coding_system = Qeuc_kr;
5829 break; 5858 break;
5830 default: 5859 default:
5831 return; 5860 return;
5832 } 5861 }
5833 5862
5834 setup_coding_system (coding_system, &coding); 5863 setup_coding_system (coding_system, &coding);
6275 ptr + sizeof ("-0-0-75-75-m-0-") - 1); 6304 ptr + sizeof ("-0-0-75-75-m-0-") - 1);
6276 fontname = build_string (scaled); 6305 fontname = build_string (scaled);
6277 if (fast_string_match (pattern_regex, fontname) >= 0) 6306 if (fast_string_match (pattern_regex, fontname) >= 0)
6278 { 6307 {
6279 font_list = Fcons (fontname, font_list); 6308 font_list = Fcons (fontname, font_list);
6280 6309
6281 n_fonts++; 6310 n_fonts++;
6282 if (maxnames > 0 && n_fonts >= maxnames) 6311 if (maxnames > 0 && n_fonts >= maxnames)
6283 break; 6312 break;
6284 } 6313 }
6285 } 6314 }
6931 6960
6932 Lisp_Object drag_and_drop_file_list; 6961 Lisp_Object drag_and_drop_file_list;
6933 6962
6934 Point saved_menu_event_location; 6963 Point saved_menu_event_location;
6935 6964
6965 #if !TARGET_API_MAC_CARBON
6966 /* Place holder for the default arrow cursor. */
6967 CursPtr arrow_cursor;
6968 #endif
6969
6936 /* Apple Events */ 6970 /* Apple Events */
6937 static void init_required_apple_events (void); 6971 static void init_required_apple_events (void);
6938 static pascal OSErr 6972 static pascal OSErr
6939 do_ae_open_application (const AppleEvent *, AppleEvent *, long); 6973 do_ae_open_application (const AppleEvent *, AppleEvent *, long);
6940 static pascal OSErr 6974 static pascal OSErr
6980 7014
6981 static int 7015 static int
6982 mac_get_emulated_btn ( UInt32 modifiers ) 7016 mac_get_emulated_btn ( UInt32 modifiers )
6983 { 7017 {
6984 int result = 0; 7018 int result = 0;
6985 if (Vmac_emulate_three_button_mouse != Qnil) { 7019 if (!NILP (Vmac_emulate_three_button_mouse)) {
6986 int cmdIs3 = (Vmac_emulate_three_button_mouse != Qreverse); 7020 int cmdIs3 = !EQ (Vmac_emulate_three_button_mouse, Qreverse);
6987 if (modifiers & controlKey) 7021 if (modifiers & controlKey)
6988 result = cmdIs3 ? 2 : 1; 7022 result = cmdIs3 ? 2 : 1;
6989 else if (modifiers & optionKey) 7023 else if (modifiers & optionKey)
6990 result = cmdIs3 ? 1 : 2; 7024 result = cmdIs3 ? 1 : 2;
6991 } 7025 }
6992 return result; 7026 return result;
6993 } 7027 }
6994 7028
6995 #if USE_CARBON_EVENTS 7029 #if USE_CARBON_EVENTS
6999 mac_event_to_emacs_modifiers (EventRef eventRef) 7033 mac_event_to_emacs_modifiers (EventRef eventRef)
7000 { 7034 {
7001 UInt32 mods = 0; 7035 UInt32 mods = 0;
7002 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL, 7036 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL,
7003 sizeof (UInt32), NULL, &mods); 7037 sizeof (UInt32), NULL, &mods);
7004 if (Vmac_emulate_three_button_mouse != Qnil && 7038 if (!NILP (Vmac_emulate_three_button_mouse) &&
7005 GetEventClass(eventRef) == kEventClassMouse) 7039 GetEventClass(eventRef) == kEventClassMouse)
7006 { 7040 {
7007 mods &= ~(optionKey & cmdKey); 7041 mods &= ~(optionKey & cmdKey);
7008 } 7042 }
7009 return mac_to_emacs_modifiers (mods); 7043 return mac_to_emacs_modifiers (mods);
7018 GetEventParameter (ref, kEventParamMouseButton, typeMouseButton, NULL, 7052 GetEventParameter (ref, kEventParamMouseButton, typeMouseButton, NULL,
7019 sizeof (EventMouseButton), NULL, &result); 7053 sizeof (EventMouseButton), NULL, &result);
7020 switch (result) 7054 switch (result)
7021 { 7055 {
7022 case kEventMouseButtonPrimary: 7056 case kEventMouseButtonPrimary:
7023 if (Vmac_emulate_three_button_mouse == Qnil) 7057 if (NILP (Vmac_emulate_three_button_mouse))
7024 return 0; 7058 return 0;
7025 else { 7059 else {
7026 UInt32 mods = 0; 7060 UInt32 mods = 0;
7027 GetEventParameter (ref, kEventParamKeyModifiers, typeUInt32, NULL, 7061 GetEventParameter (ref, kEventParamKeyModifiers, typeUInt32, NULL,
7028 sizeof (UInt32), NULL, &mods); 7062 sizeof (UInt32), NULL, &mods);
7117 InitDialogs (NULL); 7151 InitDialogs (NULL);
7118 #endif /* !TARGET_API_MAC_CARBON */ 7152 #endif /* !TARGET_API_MAC_CARBON */
7119 InitCursor (); 7153 InitCursor ();
7120 7154
7121 #if !TARGET_API_MAC_CARBON 7155 #if !TARGET_API_MAC_CARBON
7156 arrow_cursor = &qd.arrow;
7157
7122 /* set up some extra stack space for use by emacs */ 7158 /* set up some extra stack space for use by emacs */
7123 SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC)); 7159 SetApplLimit ((Ptr) ((long) GetApplLimit () - EXTRA_STACK_ALLOC));
7124 7160
7125 /* MaxApplZone must be called for AppleScript to execute more 7161 /* MaxApplZone must be called for AppleScript to execute more
7126 complicated scripts */ 7162 complicated scripts */
7145 } 7181 }
7146 7182
7147 static void 7183 static void
7148 do_window_update (WindowPtr win) 7184 do_window_update (WindowPtr win)
7149 { 7185 {
7150 struct mac_output *mwp = (mac_output *) GetWRefCon (win); 7186 struct frame *f = mac_window_to_frame (win);
7151 struct frame *f = mwp->mFP; 7187
7188 if (win == tip_window)
7189 /* The tooltip has been drawn already. Avoid the
7190 SET_FRAME_GARBAGED below. */
7191 return;
7152 7192
7153 if (f) 7193 if (f)
7154 { 7194 {
7155 if (f->async_visible == 0) 7195 if (f->async_visible == 0)
7156 { 7196 {
7197 } 7237 }
7198 7238
7199 static void 7239 static void
7200 do_window_activate (WindowPtr win) 7240 do_window_activate (WindowPtr win)
7201 { 7241 {
7202 mac_output *mwp;
7203 struct frame *f; 7242 struct frame *f;
7204 7243
7205 if (is_emacs_window (win)) 7244 if (is_emacs_window (win))
7206 { 7245 {
7207 mwp = (mac_output *) GetWRefCon (win); 7246 f = mac_window_to_frame (win);
7208 f = mwp->mFP;
7209 7247
7210 if (f) 7248 if (f)
7211 { 7249 {
7212 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f); 7250 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);
7213 activate_scroll_bars (f); 7251 activate_scroll_bars (f);
7216 } 7254 }
7217 7255
7218 static void 7256 static void
7219 do_window_deactivate (WindowPtr win) 7257 do_window_deactivate (WindowPtr win)
7220 { 7258 {
7221 mac_output *mwp;
7222 struct frame *f; 7259 struct frame *f;
7223 7260
7224 if (is_emacs_window (win)) 7261 if (is_emacs_window (win))
7225 { 7262 {
7226 mwp = (mac_output *) GetWRefCon (win); 7263 f = mac_window_to_frame (win);
7227 f = mwp->mFP;
7228 7264
7229 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) 7265 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
7230 { 7266 {
7231 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0); 7267 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);
7232 deactivate_scroll_bars (f); 7268 deactivate_scroll_bars (f);
7236 7272
7237 static void 7273 static void
7238 do_app_resume () 7274 do_app_resume ()
7239 { 7275 {
7240 WindowPtr wp; 7276 WindowPtr wp;
7241 mac_output *mwp;
7242 struct frame *f; 7277 struct frame *f;
7243 7278
7244 wp = FrontWindow(); 7279 wp = mac_front_window ();
7245 if (is_emacs_window (wp)) 7280 if (is_emacs_window (wp))
7246 { 7281 {
7247 mwp = (mac_output *) GetWRefCon (wp); 7282 f = mac_window_to_frame (wp);
7248 f = mwp->mFP;
7249 7283
7250 if (f) 7284 if (f)
7251 { 7285 {
7252 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f); 7286 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);
7253 activate_scroll_bars (f); 7287 activate_scroll_bars (f);
7260 7294
7261 static void 7295 static void
7262 do_app_suspend () 7296 do_app_suspend ()
7263 { 7297 {
7264 WindowPtr wp; 7298 WindowPtr wp;
7265 mac_output *mwp;
7266 struct frame *f; 7299 struct frame *f;
7267 7300
7268 wp = FrontWindow(); 7301 wp = mac_front_window ();
7269 if (is_emacs_window (wp)) 7302 if (is_emacs_window (wp))
7270 { 7303 {
7271 mwp = (mac_output *) GetWRefCon (wp); 7304 f = mac_window_to_frame (wp);
7272 f = mwp->mFP;
7273 7305
7274 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame) 7306 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
7275 { 7307 {
7276 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0); 7308 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);
7277 deactivate_scroll_bars (f); 7309 deactivate_scroll_bars (f);
7282 app_sleep_time = WNE_SLEEP_AT_SUSPEND; 7314 app_sleep_time = WNE_SLEEP_AT_SUSPEND;
7283 } 7315 }
7284 7316
7285 7317
7286 static void 7318 static void
7287 do_mouse_moved (Point mouse_pos) 7319 do_mouse_moved (mouse_pos, f)
7288 { 7320 Point mouse_pos;
7289 WindowPtr wp = FrontWindow (); 7321 FRAME_PTR *f;
7290 struct frame *f; 7322 {
7323 WindowPtr wp = mac_front_window ();
7324 struct x_display_info *dpyinfo;
7291 7325
7292 if (is_emacs_window (wp)) 7326 if (is_emacs_window (wp))
7293 { 7327 {
7294 f = ((mac_output *) GetWRefCon (wp))->mFP; 7328 *f = mac_window_to_frame (wp);
7295 7329 dpyinfo = FRAME_MAC_DISPLAY_INFO (*f);
7296 #if TARGET_API_MAC_CARBON 7330
7297 SetPort (GetWindowPort (wp)); 7331 if (dpyinfo->mouse_face_hidden)
7298 #else 7332 {
7299 SetPort (wp); 7333 dpyinfo->mouse_face_hidden = 0;
7300 #endif 7334 clear_mouse_face (dpyinfo);
7335 }
7336
7337 SetPortWindowPort (wp);
7301 7338
7302 GlobalToLocal (&mouse_pos); 7339 GlobalToLocal (&mouse_pos);
7303 7340
7304 note_mouse_movement (f, &mouse_pos); 7341 if (dpyinfo->grabbed && tracked_scroll_bar)
7305 } 7342 x_scroll_bar_note_movement (tracked_scroll_bar,
7306 } 7343 mouse_pos.v
7307 7344 - XINT (tracked_scroll_bar->top),
7308 7345 TickCount() * (1000 / 60));
7309 static void
7310 do_os_event (EventRecord *erp)
7311 {
7312 switch((erp->message >> 24) & 0x000000FF)
7313 {
7314 case suspendResumeMessage:
7315 if((erp->message & resumeFlag) == 1)
7316 do_app_resume ();
7317 else 7346 else
7318 do_app_suspend (); 7347 note_mouse_movement (*f, &mouse_pos);
7319 break; 7348 }
7320 7349 }
7321 case mouseMovedMessage: 7350
7322 do_mouse_moved (erp->where);
7323 break;
7324 }
7325 }
7326
7327 static void
7328 do_events (EventRecord *erp)
7329 {
7330 switch (erp->what)
7331 {
7332 case updateEvt:
7333 do_window_update ((WindowPtr) erp->message);
7334 break;
7335
7336 case osEvt:
7337 do_os_event (erp);
7338 break;
7339
7340 case activateEvt:
7341 if ((erp->modifiers & activeFlag) != 0)
7342 do_window_activate ((WindowPtr) erp->message);
7343 else
7344 do_window_deactivate ((WindowPtr) erp->message);
7345 break;
7346 }
7347 }
7348 7351
7349 static void 7352 static void
7350 do_apple_menu (SInt16 menu_item) 7353 do_apple_menu (SInt16 menu_item)
7351 { 7354 {
7352 #if !TARGET_API_MAC_CARBON 7355 #if !TARGET_API_MAC_CARBON
7380 do_apple_menu (menu_item); 7383 do_apple_menu (menu_item);
7381 break; 7384 break;
7382 7385
7383 default: 7386 default:
7384 { 7387 {
7385 WindowPtr wp = FrontWindow (); 7388 struct frame *f = mac_window_to_frame (mac_front_window ());
7386 struct frame *f = ((mac_output *) GetWRefCon (wp))->mFP;
7387 MenuHandle menu = GetMenuHandle (menu_id); 7389 MenuHandle menu = GetMenuHandle (menu_id);
7388 if (menu) 7390 if (menu)
7389 { 7391 {
7390 UInt32 refcon; 7392 UInt32 refcon;
7391 7393
7406 do_grow_window (WindowPtr w, EventRecord *e) 7408 do_grow_window (WindowPtr w, EventRecord *e)
7407 { 7409 {
7408 long grow_size; 7410 long grow_size;
7409 Rect limit_rect; 7411 Rect limit_rect;
7410 int rows, columns; 7412 int rows, columns;
7411 mac_output *mwp = (mac_output *) GetWRefCon (w); 7413 struct frame *f = mac_window_to_frame (w);
7412 struct frame *f = mwp->mFP;
7413 7414
7414 SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE); 7415 SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE);
7415 7416
7416 grow_size = GrowWindow (w, e->where, &limit_rect); 7417 grow_size = GrowWindow (w, e->where, &limit_rect);
7417 7418
7436 { 7437 {
7437 GrafPtr save_port; 7438 GrafPtr save_port;
7438 Rect zoom_rect, port_rect; 7439 Rect zoom_rect, port_rect;
7439 Point top_left; 7440 Point top_left;
7440 int w_title_height, columns, rows, width, height, dummy, x, y; 7441 int w_title_height, columns, rows, width, height, dummy, x, y;
7441 mac_output *mwp = (mac_output *) GetWRefCon (w); 7442 struct frame *f = mac_window_to_frame (w);
7442 struct frame *f = mwp->mFP;
7443 7443
7444 GetPort (&save_port); 7444 GetPort (&save_port);
7445 7445
7446 #if TARGET_API_MAC_CARBON 7446 SetPortWindowPort (w);
7447 SetPort (GetWindowPort (w));
7448 #else
7449 SetPort (w);
7450 #endif
7451 7447
7452 /* Clear window to avoid flicker. */ 7448 /* Clear window to avoid flicker. */
7453 #if TARGET_API_MAC_CARBON 7449 #if TARGET_API_MAC_CARBON
7454 { 7450 {
7455 Rect r; 7451 Rect r;
7498 (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState 7494 (**((WStateDataHandle) ((WindowPeek) w)->dataHandle)).stdState
7499 = zoom_rect; 7495 = zoom_rect;
7500 } 7496 }
7501 #endif /* not TARGET_API_MAC_CARBON */ 7497 #endif /* not TARGET_API_MAC_CARBON */
7502 7498
7503 ZoomWindow (w, zoom_in_or_out, w == FrontWindow ()); 7499 ZoomWindow (w, zoom_in_or_out, w == mac_front_window ());
7504 7500
7505 /* retrieve window size and update application values */ 7501 /* retrieve window size and update application values */
7506 #if TARGET_API_MAC_CARBON 7502 #if TARGET_API_MAC_CARBON
7507 GetWindowPortBounds (w, &port_rect); 7503 GetWindowPortBounds (w, &port_rect);
7508 #else 7504 #else
7509 port_rect = w->portRect; 7505 port_rect = w->portRect;
7510 #endif 7506 #endif
7511 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top); 7507 rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top);
7512 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left); 7508 columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left);
7513 x_set_window_size (mwp->mFP, 0, columns, rows); 7509 x_set_window_size (f, 0, columns, rows);
7514 7510
7515 SetPort (save_port); 7511 SetPort (save_port);
7516 } 7512 }
7517 7513
7518 /* Initialize Drag And Drop to allow files to be dropped onto emacs frames */ 7514 /* Initialize Drag And Drop to allow files to be dropped onto emacs frames */
7839 the queue like an interrupt using kbd_buffer_store_event. */ 7835 the queue like an interrupt using kbd_buffer_store_event. */
7840 if (!NILP (drag_and_drop_file_list)) 7836 if (!NILP (drag_and_drop_file_list))
7841 { 7837 {
7842 struct input_event event; 7838 struct input_event event;
7843 Lisp_Object frame; 7839 Lisp_Object frame;
7844 struct frame *f = ((mac_output *) GetWRefCon(window))->mFP; 7840 struct frame *f = mac_window_to_frame (window);
7845 SetPort (GetWindowPort (window)); 7841 SetPortWindowPort (window);
7846 GlobalToLocal (&mouse); 7842 GlobalToLocal (&mouse);
7847 7843
7848 event.kind = DRAG_N_DROP_EVENT; 7844 event.kind = DRAG_N_DROP_EVENT;
7849 event.code = 0; 7845 event.code = 0;
7850 event.modifiers = 0; 7846 event.modifiers = 0;
8014 } 8010 }
8015 8011
8016 /* Emacs calls this whenever it wants to read an input event from the 8012 /* Emacs calls this whenever it wants to read an input event from the
8017 user. */ 8013 user. */
8018 int 8014 int
8019 XTread_socket (int sd, int expected, struct input_event *hold_quit) 8015 XTread_socket (sd, expected, hold_quit)
8016 int sd, expected;
8017 struct input_event *hold_quit;
8020 { 8018 {
8021 struct input_event inev; 8019 struct input_event inev;
8022 int count = 0; 8020 int count = 0;
8023 #if USE_CARBON_EVENTS 8021 #if USE_CARBON_EVENTS
8024 OSStatus rneResult;
8025 EventRef eventRef; 8022 EventRef eventRef;
8026 EventMouseButton mouseBtn; 8023 EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget ();
8024 #else
8025 EventMask event_mask;
8027 #endif 8026 #endif
8028 EventRecord er; 8027 EventRecord er;
8029 int the_modifiers; 8028 struct mac_display_info *dpyinfo = &one_mac_display_info;
8030 EventMask event_mask; 8029
8031
8032 #if 0
8033 if (interrupt_input_blocked) 8030 if (interrupt_input_blocked)
8034 { 8031 {
8035 interrupt_input_pending = 1; 8032 interrupt_input_pending = 1;
8036 return -1; 8033 return -1;
8037 } 8034 }
8038 #endif
8039 8035
8040 interrupt_input_pending = 0; 8036 interrupt_input_pending = 0;
8041 BLOCK_INPUT; 8037 BLOCK_INPUT;
8042 8038
8043 /* So people can tell when we have read the available input. */ 8039 /* So people can tell when we have read the available input. */
8055 } 8051 }
8056 8052
8057 if (terminate_flag) 8053 if (terminate_flag)
8058 Fkill_emacs (make_number (1)); 8054 Fkill_emacs (make_number (1));
8059 8055
8060 /* It is necessary to set this (additional) argument slot of an 8056 #if !USE_CARBON_EVENTS
8061 event to nil because keyboard.c protects incompletely processed
8062 event from being garbage collected by placing them in the
8063 kbd_buffer_gcpro vector. */
8064 EVENT_INIT (inev);
8065 inev.kind = NO_EVENT;
8066 inev.arg = Qnil;
8067
8068 event_mask = everyEvent; 8057 event_mask = everyEvent;
8069 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) 8058 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop)))
8070 event_mask -= highLevelEventMask; 8059 event_mask -= highLevelEventMask;
8071 8060
8061 while (WaitNextEvent (event_mask, &er,
8062 (expected ? app_sleep_time : 0L), NULL))
8063 #else
8064 while (!ReceiveNextEvent (0, NULL,
8065 (expected ? TicksToEventTime (app_sleep_time) : 0),
8066 kEventRemoveFromQueue, &eventRef))
8067 #endif /* !USE_CARBON_EVENTS */
8068 {
8069 int do_help = 0;
8070 struct frame *f;
8071
8072 expected = 0;
8073
8074 /* It is necessary to set this (additional) argument slot of an
8075 event to nil because keyboard.c protects incompletely
8076 processed event from being garbage collected by placing them
8077 in the kbd_buffer_gcpro vector. */
8078 EVENT_INIT (inev);
8079 inev.kind = NO_EVENT;
8080 inev.arg = Qnil;
8081
8072 #if USE_CARBON_EVENTS 8082 #if USE_CARBON_EVENTS
8073 rneResult = ReceiveNextEvent (0, NULL,
8074 expected
8075 ? TicksToEventTime (app_sleep_time)
8076 : 0,
8077 kEventRemoveFromQueue, &eventRef);
8078 if (!rneResult)
8079 {
8080 /* Handle new events */ 8083 /* Handle new events */
8081 if (!mac_convert_event_ref (eventRef, &er)) 8084 if (!mac_convert_event_ref (eventRef, &er))
8082 switch (GetEventClass (eventRef)) 8085 switch (GetEventClass (eventRef))
8083 { 8086 {
8084 case kEventClassMouse: 8087 case kEventClassMouse:
8085 if (GetEventKind (eventRef) == kEventMouseWheelMoved) 8088 if (GetEventKind (eventRef) == kEventMouseWheelMoved)
8086 { 8089 {
8087 SInt32 delta; 8090 SInt32 delta;
8088 Point point; 8091 Point point;
8089 WindowPtr window_ptr = FrontNonFloatingWindow (); 8092 WindowPtr window_ptr = mac_front_window ();
8090 struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); 8093
8091 if (!IsValidWindowPtr (window_ptr)) 8094 if (!IsValidWindowPtr (window_ptr))
8092 { 8095 {
8093 SysBeep(1); 8096 SysBeep(1);
8094 UNBLOCK_INPUT; 8097 break;
8095 return 0;
8096 } 8098 }
8097 8099
8098 GetEventParameter(eventRef, kEventParamMouseWheelDelta, 8100 GetEventParameter(eventRef, kEventParamMouseWheelDelta,
8099 typeSInt32, NULL, sizeof (SInt32), 8101 typeSInt32, NULL, sizeof (SInt32),
8100 NULL, &delta); 8102 NULL, &delta);
8101 GetEventParameter(eventRef, kEventParamMouseLocation, 8103 GetEventParameter(eventRef, kEventParamMouseLocation,
8102 typeQDPoint, NULL, sizeof (Point), 8104 typeQDPoint, NULL, sizeof (Point),
8103 NULL, &point); 8105 NULL, &point);
8104 inev.kind = WHEEL_EVENT; 8106 inev.kind = WHEEL_EVENT;
8105 inev.code = 0; 8107 inev.code = 0;
8106 inev.modifiers = (mac_event_to_emacs_modifiers(eventRef) 8108 inev.modifiers = (mac_event_to_emacs_modifiers (eventRef)
8107 | ((delta < 0) ? down_modifier 8109 | ((delta < 0) ? down_modifier
8108 : up_modifier)); 8110 : up_modifier));
8109 SetPort (GetWindowPort (window_ptr)); 8111 SetPortWindowPort (window_ptr);
8110 GlobalToLocal (&point); 8112 GlobalToLocal (&point);
8111 XSETINT (inev.x, point.h); 8113 XSETINT (inev.x, point.h);
8112 XSETINT (inev.y, point.v); 8114 XSETINT (inev.y, point.v);
8113 XSETFRAME (inev.frame_or_window, mwp->mFP); 8115 XSETFRAME (inev.frame_or_window,
8116 mac_window_to_frame (window_ptr));
8114 inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60); 8117 inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60);
8115 } 8118 }
8116 else 8119 else
8117 SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); 8120 SendEventToEventTarget (eventRef, toolbox_dispatcher);
8118 8121
8119 break; 8122 break;
8120 default: 8123 default:
8121 /* Send the event to the appropriate receiver. */ 8124 /* Send the event to the appropriate receiver. */
8122 SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); 8125 SendEventToEventTarget (eventRef, toolbox_dispatcher);
8123 } 8126 }
8124 else 8127 else
8128 #endif /* USE_CARBON_EVENTS */
8129 switch (er.what)
8130 {
8131 case mouseDown:
8132 case mouseUp:
8133 {
8134 WindowPtr window_ptr;
8135 SInt16 part_code;
8136 int tool_bar_p = 0;
8137
8138 if (dpyinfo->grabbed && last_mouse_frame
8139 && FRAME_LIVE_P (last_mouse_frame))
8140 {
8141 window_ptr = FRAME_MAC_WINDOW (last_mouse_frame);
8142 part_code = inContent;
8143 }
8144 else
8145 {
8146 window_ptr = FrontWindow ();
8147 if (tip_window && window_ptr == tip_window)
8148 {
8149 HideWindow (tip_window);
8150 window_ptr = FrontWindow ();
8151 }
8152
8153 #if USE_CARBON_EVENTS
8154 /* This is needed to send mouse events like aqua
8155 window buttons to the correct handler. */
8156 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8157 != eventNotHandledErr)
8158 break;
8159
8160 if (!is_emacs_window (window_ptr))
8161 break;
8162 #endif
8163 part_code = FindWindow (er.where, &window_ptr);
8164 }
8165
8166 switch (part_code)
8167 {
8168 case inMenuBar:
8169 if (er.what == mouseDown)
8170 {
8171 f = mac_window_to_frame (mac_front_window ());
8172 saved_menu_event_location = er.where;
8173 inev.kind = MENU_BAR_ACTIVATE_EVENT;
8174 XSETFRAME (inev.frame_or_window, f);
8175 }
8176 break;
8177
8178 case inContent:
8179 if (window_ptr != mac_front_window ())
8180 SelectWindow (window_ptr);
8181 else
8182 {
8183 SInt16 control_part_code;
8184 ControlHandle ch;
8185 Point mouse_loc = er.where;
8186
8187 f = mac_window_to_frame (window_ptr);
8188 /* convert to local coordinates of new window */
8189 SetPortWindowPort (window_ptr);
8190
8191 GlobalToLocal (&mouse_loc);
8192 #if TARGET_API_MAC_CARBON
8193 ch = FindControlUnderMouse (mouse_loc, window_ptr,
8194 &control_part_code);
8125 #else 8195 #else
8126 if (WaitNextEvent (event_mask, &er, (expected ? app_sleep_time : 0L), NULL)) 8196 control_part_code = FindControl (mouse_loc, window_ptr,
8127 #endif /* USE_CARBON_EVENTS */ 8197 &ch);
8128 switch (er.what) 8198 #endif
8129 {
8130 case mouseDown:
8131 case mouseUp:
8132 {
8133 WindowPtr window_ptr = FrontWindow ();
8134 SInt16 part_code;
8135 8199
8136 #if USE_CARBON_EVENTS 8200 #if USE_CARBON_EVENTS
8137 /* This is needed to send mouse events like aqua window buttons 8201 inev.code = mac_get_mouse_btn (eventRef);
8138 to the correct handler. */ 8202 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8139 if (eventNotHandledErr != SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) { 8203 #else
8204 inev.code = mac_get_emulated_btn (er.modifiers);
8205 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8206 #endif
8207 XSETINT (inev.x, mouse_loc.h);
8208 XSETINT (inev.y, mouse_loc.v);
8209 inev.timestamp = er.when * (1000 / 60);
8210 /* ticks to milliseconds */
8211
8212 if (dpyinfo->grabbed && tracked_scroll_bar
8213 #if TARGET_API_MAC_CARBON
8214 || ch != 0
8215 #else
8216 || control_part_code != 0
8217 #endif
8218 )
8219 {
8220 struct scroll_bar *bar;
8221
8222 if (dpyinfo->grabbed && tracked_scroll_bar)
8223 {
8224 bar = tracked_scroll_bar;
8225 control_part_code = kControlIndicatorPart;
8226 }
8227 else
8228 bar = (struct scroll_bar *) GetControlReference (ch);
8229 x_scroll_bar_handle_click (bar, control_part_code,
8230 &er, &inev);
8231 if (er.what == mouseDown
8232 && control_part_code == kControlIndicatorPart)
8233 tracked_scroll_bar = bar;
8234 else
8235 tracked_scroll_bar = NULL;
8236 }
8237 else
8238 {
8239 Lisp_Object window;
8240 int x = mouse_loc.h;
8241 int y = mouse_loc.v;
8242
8243 window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
8244 if (EQ (window, f->tool_bar_window))
8245 {
8246 if (er.what == mouseDown)
8247 handle_tool_bar_click (f, x, y, 1, 0);
8248 else
8249 handle_tool_bar_click (f, x, y, 0,
8250 inev.modifiers);
8251 tool_bar_p = 1;
8252 }
8253 else
8254 {
8255 XSETFRAME (inev.frame_or_window, f);
8256 inev.kind = MOUSE_CLICK_EVENT;
8257 }
8258 }
8259
8260 if (er.what == mouseDown)
8261 {
8262 dpyinfo->grabbed |= (1 << inev.code);
8263 last_mouse_frame = f;
8264 /* Ignore any mouse motion that happened
8265 before this event; any subsequent
8266 mouse-movement Emacs events should reflect
8267 only motion after the ButtonPress. */
8268 if (f != 0)
8269 f->mouse_moved = 0;
8270
8271 if (!tool_bar_p)
8272 last_tool_bar_item = -1;
8273 }
8274 else
8275 {
8276 if (dpyinfo->grabbed & (1 << inev.code) == 0)
8277 /* If a button is released though it was not
8278 previously pressed, that would be because
8279 of multi-button emulation. */
8280 dpyinfo->grabbed = 0;
8281 else
8282 dpyinfo->grabbed &= ~(1 << inev.code);
8283 }
8284
8285 switch (er.what)
8286 {
8287 case mouseDown:
8288 inev.modifiers |= down_modifier;
8289 break;
8290 case mouseUp:
8291 inev.modifiers |= up_modifier;
8292 break;
8293 }
8294 }
8295 break;
8296
8297 case inDrag:
8298 #if TARGET_API_MAC_CARBON
8299 if (er.what == mouseDown)
8300 {
8301 BitMap bm;
8302
8303 GetQDGlobalsScreenBits (&bm);
8304 DragWindow (window_ptr, er.where, &bm.bounds);
8305 }
8306 #else /* not TARGET_API_MAC_CARBON */
8307 DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
8308 #endif /* not TARGET_API_MAC_CARBON */
8309 break;
8310
8311 case inGoAway:
8312 if (TrackGoAway (window_ptr, er.where))
8313 {
8314 inev.kind = DELETE_WINDOW_EVENT;
8315 XSETFRAME (inev.frame_or_window,
8316 mac_window_to_frame (window_ptr));
8317 }
8318 break;
8319
8320 /* window resize handling added --ben */
8321 case inGrow:
8322 if (er.what == mouseDown)
8323 {
8324 do_grow_window(window_ptr, &er);
8325 break;
8326 }
8327
8328 /* window zoom handling added --ben */
8329 case inZoomIn:
8330 case inZoomOut:
8331 if (TrackBox (window_ptr, er.where, part_code))
8332 do_zoom_window (window_ptr, part_code);
8333 break;
8334
8335 default:
8336 break;
8337 }
8338 }
8339 break;
8340
8341 case updateEvt:
8342 #if USE_CARBON_EVENTS
8343 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8344 != eventNotHandledErr)
8140 break; 8345 break;
8346 #endif
8347 do_window_update ((WindowPtr) er.message);
8348 break;
8349
8350 case osEvt:
8351 #if USE_CARBON_EVENTS
8352 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8353 != eventNotHandledErr)
8354 break;
8355 #endif
8356 switch ((er.message >> 24) & 0x000000FF)
8357 {
8358 case suspendResumeMessage:
8359 if ((er.message & resumeFlag) == 1)
8360 do_app_resume ();
8361 else
8362 do_app_suspend ();
8363 break;
8364
8365 case mouseMovedMessage:
8366 previous_help_echo_string = help_echo_string;
8367 help_echo_string = help_echo_object = help_echo_window = Qnil;
8368 help_echo_pos = -1;
8369
8370 do_mouse_moved (er.where, &f);
8371
8372 /* If the contents of the global variable
8373 help_echo_string has changed, generate a
8374 HELP_EVENT. */
8375 if (!NILP (help_echo_string) || !NILP (previous_help_echo_string))
8376 do_help = 1;
8377 break;
8378 }
8379 break;
8380
8381 case activateEvt:
8382 {
8383 WindowPtr window_ptr = (WindowPtr) er.message;
8384
8385 #if USE_CARBON_EVENTS
8386 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8387 != eventNotHandledErr)
8388 break;
8389 #endif
8390 if (window_ptr == tip_window)
8391 {
8392 HideWindow (tip_window);
8393 break;
8394 }
8395
8396 if ((er.modifiers & activeFlag) != 0)
8397 {
8398 Point mouse_loc = er.where;
8399
8400 do_window_activate (window_ptr);
8401
8402 SetPortWindowPort (window_ptr);
8403 GlobalToLocal (&mouse_loc);
8404 /* activateEvt counts as mouse movement,
8405 so update things that depend on mouse position. */
8406 note_mouse_movement (mac_window_to_frame (window_ptr),
8407 &mouse_loc);
8408 }
8409 else
8410 {
8411 do_window_deactivate (window_ptr);
8412
8413 f = mac_window_to_frame (window_ptr);
8414 if (f == dpyinfo->mouse_face_mouse_frame)
8415 {
8416 /* If we move outside the frame, then we're
8417 certainly no longer on any text in the
8418 frame. */
8419 clear_mouse_face (dpyinfo);
8420 dpyinfo->mouse_face_mouse_frame = 0;
8421 }
8422
8423 /* Generate a nil HELP_EVENT to cancel a help-echo.
8424 Do it only if there's something to cancel.
8425 Otherwise, the startup message is cleared when the
8426 mouse leaves the frame. */
8427 if (any_help_event_p)
8428 do_help = -1;
8429 }
8141 } 8430 }
8142 8431 break;
8143 if (!is_emacs_window(window_ptr)) 8432
8144 break; 8433 case keyDown:
8145 #endif 8434 case autoKey:
8146 8435 {
8147 if (mouse_tracking_in_progress == mouse_tracking_scroll_bar 8436 int keycode = (er.message & keyCodeMask) >> 8;
8148 && er.what == mouseUp) 8437 int xkeysym;
8149 { 8438
8150 struct mac_output *mwp = (mac_output *) GetWRefCon (window_ptr); 8439 #if USE_CARBON_EVENTS
8151 Point mouse_loc = er.where; 8440 /* When using Carbon Events, we need to pass raw keyboard
8152 8441 events to the TSM ourselves. If TSM handles it, it
8153 /* Convert to local coordinates of new window. */ 8442 will pass back noErr, otherwise it will pass back
8443 "eventNotHandledErr" and we can process it
8444 normally. */
8445 if ((!NILP (Vmac_pass_command_to_system)
8446 || !(er.modifiers & cmdKey))
8447 && (!NILP (Vmac_pass_control_to_system)
8448 || !(er.modifiers & controlKey)))
8449 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
8450 != eventNotHandledErr)
8451 break;
8452 #endif
8453
8154 #if TARGET_API_MAC_CARBON 8454 #if TARGET_API_MAC_CARBON
8155 SetPort (GetWindowPort (window_ptr)); 8455 if (!IsValidWindowPtr (mac_front_window ()))
8456 {
8457 SysBeep (1);
8458 break;
8459 }
8460 #endif
8461
8462 ObscureCursor ();
8463
8464 if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight))
8465 {
8466 clear_mouse_face (dpyinfo);
8467 dpyinfo->mouse_face_hidden = 1;
8468 }
8469
8470 if (keycode_to_xkeysym (keycode, &xkeysym))
8471 {
8472 inev.code = 0xff00 | xkeysym;
8473 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
8474 }
8475 else
8476 {
8477 if (er.modifiers & (controlKey |
8478 (NILP (Vmac_command_key_is_meta) ? optionKey
8479 : cmdKey)))
8480 {
8481 /* This code comes from Keyboard Resource,
8482 Appendix C of IM - Text. This is necessary
8483 since shift is ignored in KCHR table
8484 translation when option or command is pressed.
8485 It also does not translate correctly
8486 control-shift chars like C-% so mask off shift
8487 here also */
8488 int new_modifiers = er.modifiers & 0xe600;
8489 /* mask off option and command */
8490 int new_keycode = keycode | new_modifiers;
8491 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
8492 unsigned long some_state = 0;
8493 inev.code = KeyTranslate (kchr_ptr, new_keycode,
8494 &some_state) & 0xff;
8495 }
8496 else
8497 inev.code = er.message & charCodeMask;
8498 inev.kind = ASCII_KEYSTROKE_EVENT;
8499 }
8500 }
8501
8502 /* If variable mac-convert-keyboard-input-to-latin-1 is
8503 non-nil, convert non-ASCII characters typed at the Mac
8504 keyboard (presumed to be in the Mac Roman encoding) to
8505 iso-latin-1 encoding before they are passed to Emacs.
8506 This enables the Mac keyboard to be used to enter
8507 non-ASCII iso-latin-1 characters directly. */
8508 if (mac_keyboard_text_encoding != kTextEncodingMacRoman
8509 && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128)
8510 {
8511 static TECObjectRef converter = NULL;
8512 OSStatus the_err = noErr;
8513 OSStatus convert_status = noErr;
8514
8515 if (converter == NULL)
8516 {
8517 the_err = TECCreateConverter (&converter,
8518 kTextEncodingMacRoman,
8519 mac_keyboard_text_encoding);
8520 current_mac_keyboard_text_encoding
8521 = mac_keyboard_text_encoding;
8522 }
8523 else if (mac_keyboard_text_encoding
8524 != current_mac_keyboard_text_encoding)
8525 {
8526 /* Free the converter for the current encoding
8527 before creating a new one. */
8528 TECDisposeConverter (converter);
8529 the_err = TECCreateConverter (&converter,
8530 kTextEncodingMacRoman,
8531 mac_keyboard_text_encoding);
8532 current_mac_keyboard_text_encoding
8533 = mac_keyboard_text_encoding;
8534 }
8535
8536 if (the_err == noErr)
8537 {
8538 unsigned char ch = inev.code;
8539 ByteCount actual_input_length, actual_output_length;
8540 unsigned char outch;
8541
8542 convert_status = TECConvertText (converter, &ch, 1,
8543 &actual_input_length,
8544 &outch, 1,
8545 &actual_output_length);
8546 if (convert_status == noErr
8547 && actual_input_length == 1
8548 && actual_output_length == 1)
8549 inev.code = outch;
8550 }
8551 }
8552
8553 #if USE_CARBON_EVENTS
8554 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8156 #else 8555 #else
8157 SetPort (window_ptr); 8556 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8158 #endif 8557 #endif
8159 8558 XSETFRAME (inev.frame_or_window,
8160 GlobalToLocal (&mouse_loc); 8559 mac_window_to_frame (mac_front_window ()));
8161 8560 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
8162 #if USE_CARBON_EVENTS 8561 break;
8163 inev.code = mac_get_mouse_btn (eventRef); 8562
8164 #else 8563 case kHighLevelEvent:
8165 inev.code = mac_get_emulate_btn (er.modifiers); 8564 drag_and_drop_file_list = Qnil;
8166 #endif 8565
8167 inev.kind = SCROLL_BAR_CLICK_EVENT; 8566 AEProcessAppleEvent(&er);
8168 inev.frame_or_window = tracked_scroll_bar->window; 8567
8169 inev.part = scroll_bar_handle; 8568 /* Build a DRAG_N_DROP_EVENT type event as is done in
8569 constuct_drag_n_drop in w32term.c. */
8570 if (!NILP (drag_and_drop_file_list))
8571 {
8572 struct frame *f = NULL;
8573 WindowPtr wp;
8574 Lisp_Object frame;
8575
8576 wp = mac_front_window ();
8577
8578 if (!wp)
8579 {
8580 struct frame *f = XFRAME (XCAR (Vframe_list));
8581 CollapseWindow (FRAME_MAC_WINDOW (f), false);
8582 wp = mac_front_window ();
8583 }
8584
8585 if (wp && is_emacs_window (wp))
8586 f = mac_window_to_frame (wp);
8587
8588 inev.kind = DRAG_N_DROP_EVENT;
8589 inev.code = 0;
8590 inev.timestamp = er.when * (1000 / 60);
8591 /* ticks to milliseconds */
8170 #if USE_CARBON_EVENTS 8592 #if USE_CARBON_EVENTS
8171 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); 8593 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8172 #else 8594 #else
8173 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); 8595 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8174 #endif 8596 #endif
8175 inev.modifiers |= up_modifier; 8597
8176 inev.timestamp = er.when * (1000 / 60); 8598 XSETINT (inev.x, 0);
8177 /* ticks to milliseconds */ 8599 XSETINT (inev.y, 0);
8178 8600
8179 XSETINT (inev.x, tracked_scroll_bar->left + 2); 8601 XSETFRAME (frame, f);
8180 XSETINT (inev.y, mouse_loc.v - 24); 8602 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
8181 tracked_scroll_bar->dragging = Qnil; 8603
8182 mouse_tracking_in_progress = mouse_tracking_none; 8604 /* Regardless of whether Emacs was suspended or in the
8183 tracked_scroll_bar = NULL; 8605 foreground, ask it to redraw its entire screen.
8184 break; 8606 Otherwise parts of the screen can be left in an
8185 } 8607 inconsistent state. */
8186 8608 if (wp)
8187 part_code = FindWindow (er.where, &window_ptr); 8609 #if TARGET_API_MAC_CARBON
8188
8189 switch (part_code)
8190 {
8191 case inMenuBar:
8192 if (er.what == mouseDown)
8193 { 8610 {
8194 struct frame *f = ((mac_output *) 8611 Rect r;
8195 GetWRefCon (FrontWindow ()))->mFP; 8612
8196 saved_menu_event_location = er.where; 8613 GetWindowPortBounds (wp, &r);
8197 inev.kind = MENU_BAR_ACTIVATE_EVENT; 8614 InvalWindowRect (wp, &r);
8198 XSETFRAME (inev.frame_or_window, f);
8199 }
8200 break;
8201
8202 case inContent:
8203 if (window_ptr != FrontWindow ())
8204 SelectWindow (window_ptr);
8205 else
8206 {
8207 SInt16 control_part_code;
8208 ControlHandle ch;
8209 struct mac_output *mwp = (mac_output *)
8210 GetWRefCon (window_ptr);
8211 Point mouse_loc = er.where;
8212
8213 /* convert to local coordinates of new window */
8214 #if TARGET_API_MAC_CARBON
8215 SetPort (GetWindowPort (window_ptr));
8216 #else
8217 SetPort (window_ptr);
8218 #endif
8219
8220 GlobalToLocal (&mouse_loc);
8221 #if TARGET_API_MAC_CARBON
8222 ch = FindControlUnderMouse (mouse_loc, window_ptr,
8223 &control_part_code);
8224 #else
8225 control_part_code = FindControl (mouse_loc, window_ptr, &ch);
8226 #endif
8227
8228 #if USE_CARBON_EVENTS
8229 inev.code = mac_get_mouse_btn (eventRef);
8230 #else
8231 inev.code = mac_get_emulate_btn (er.modifiers);
8232 #endif
8233 XSETINT (inev.x, mouse_loc.h);
8234 XSETINT (inev.y, mouse_loc.v);
8235 inev.timestamp = er.when * (1000 / 60);
8236 /* ticks to milliseconds */
8237
8238 #if TARGET_API_MAC_CARBON
8239 if (ch != 0)
8240 #else
8241 if (control_part_code != 0)
8242 #endif
8243 {
8244 struct scroll_bar *bar = (struct scroll_bar *)
8245 GetControlReference (ch);
8246 x_scroll_bar_handle_click (bar, control_part_code, &er,
8247 &inev);
8248 if (er.what == mouseDown
8249 && control_part_code == kControlIndicatorPart)
8250 {
8251 mouse_tracking_in_progress
8252 = mouse_tracking_scroll_bar;
8253 tracked_scroll_bar = bar;
8254 }
8255 else
8256 {
8257 mouse_tracking_in_progress = mouse_tracking_none;
8258 tracked_scroll_bar = NULL;
8259 }
8260 }
8261 else
8262 {
8263 Lisp_Object window;
8264
8265 XSETFRAME (inev.frame_or_window, mwp->mFP);
8266 if (er.what == mouseDown)
8267 mouse_tracking_in_progress
8268 = mouse_tracking_mouse_movement;
8269 else
8270 mouse_tracking_in_progress = mouse_tracking_none;
8271 window = window_from_coordinates (mwp->mFP, inev.x, inev.y, 0, 0, 0, 1);
8272
8273 if (EQ (window, mwp->mFP->tool_bar_window))
8274 {
8275 if (er.what == mouseDown)
8276 handle_tool_bar_click (mwp->mFP, inev.x, inev.y, 1, 0);
8277 else
8278 handle_tool_bar_click (mwp->mFP, inev.x, inev.y, 0,
8279 #if USE_CARBON_EVENTS
8280 mac_event_to_emacs_modifiers (eventRef)
8281 #else
8282 er.modifiers
8283 #endif
8284 );
8285 break;
8286 }
8287 else
8288 inev.kind = MOUSE_CLICK_EVENT;
8289 }
8290
8291 #if USE_CARBON_EVENTS
8292 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8293 #else
8294 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8295 #endif
8296
8297 switch (er.what)
8298 {
8299 case mouseDown:
8300 inev.modifiers |= down_modifier;
8301 break;
8302 case mouseUp:
8303 inev.modifiers |= up_modifier;
8304 break;
8305 }
8306 }
8307 break;
8308
8309 case inDrag:
8310 #if TARGET_API_MAC_CARBON
8311 if (er.what == mouseDown)
8312 {
8313 BitMap bm;
8314
8315 GetQDGlobalsScreenBits (&bm);
8316 DragWindow (window_ptr, er.where, &bm.bounds);
8317 } 8615 }
8318 #else /* not TARGET_API_MAC_CARBON */ 8616 #else /* not TARGET_API_MAC_CARBON */
8319 DragWindow (window_ptr, er.where, &qd.screenBits.bounds); 8617 InvalRect (&(wp->portRect));
8320 #endif /* not TARGET_API_MAC_CARBON */ 8618 #endif /* not TARGET_API_MAC_CARBON */
8321 break;
8322
8323 case inGoAway:
8324 if (TrackGoAway (window_ptr, er.where))
8325 {
8326 inev.kind = DELETE_WINDOW_EVENT;
8327 XSETFRAME (inev.frame_or_window,
8328 ((mac_output *) GetWRefCon (window_ptr))->mFP);
8329 }
8330 break;
8331
8332 /* window resize handling added --ben */
8333 case inGrow:
8334 if (er.what == mouseDown)
8335 {
8336 do_grow_window(window_ptr, &er);
8337 break;
8338 }
8339
8340 /* window zoom handling added --ben */
8341 case inZoomIn:
8342 case inZoomOut:
8343 if (TrackBox (window_ptr, er.where, part_code))
8344 do_zoom_window (window_ptr, part_code);
8345 break;
8346
8347 default:
8348 break;
8349 } 8619 }
8620 default:
8621 break;
8350 } 8622 }
8351 break;
8352
8353 case updateEvt:
8354 case osEvt:
8355 case activateEvt:
8356 #if USE_CARBON_EVENTS 8623 #if USE_CARBON_EVENTS
8357 if (eventNotHandledErr == SendEventToEventTarget (eventRef, GetEventDispatcherTarget ())) 8624 ReleaseEvent (eventRef);
8358 #endif 8625 #endif
8359 do_events (&er); 8626
8360 break; 8627 if (inev.kind != NO_EVENT)
8361
8362 case keyDown:
8363 case autoKey:
8364 { 8628 {
8365 int keycode = (er.message & keyCodeMask) >> 8; 8629 kbd_buffer_store_event_hold (&inev, hold_quit);
8366 int xkeysym; 8630 count++;
8367 8631 }
8368 #if USE_CARBON_EVENTS 8632
8369 /* When using Carbon Events, we need to pass raw keyboard events 8633 if (do_help
8370 to the TSM ourselves. If TSM handles it, it will pass back 8634 && !(hold_quit && hold_quit->kind != NO_EVENT))
8371 noErr, otherwise it will pass back "eventNotHandledErr" and 8635 {
8372 we can process it normally. */ 8636 Lisp_Object frame;
8373 if ((!NILP (Vmac_pass_command_to_system) 8637
8374 || !(er.modifiers & cmdKey)) 8638 if (f)
8375 && (!NILP (Vmac_pass_control_to_system) 8639 XSETFRAME (frame, f);
8376 || !(er.modifiers & controlKey))) 8640 else
8641 frame = Qnil;
8642
8643 if (do_help > 0)
8377 { 8644 {
8378 OSStatus err; 8645 any_help_event_p = 1;
8379 err = SendEventToEventTarget (eventRef, 8646 gen_help_event (help_echo_string, frame, help_echo_window,
8380 GetEventDispatcherTarget ()); 8647 help_echo_object, help_echo_pos);
8381 if (err != eventNotHandledErr)
8382 break;
8383 }
8384 #endif
8385
8386 if (!IsValidWindowPtr (FrontNonFloatingWindow ()))
8387 {
8388 SysBeep (1);
8389 UNBLOCK_INPUT;
8390 return 0;
8391 }
8392
8393 ObscureCursor ();
8394
8395 if (keycode_to_xkeysym (keycode, &xkeysym))
8396 {
8397 inev.code = 0xff00 | xkeysym;
8398 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
8399 } 8648 }
8400 else 8649 else
8401 { 8650 {
8402 if (er.modifiers & (controlKey | 8651 help_echo_string = Qnil;
8403 (NILP (Vmac_command_key_is_meta) ? optionKey 8652 gen_help_event (Qnil, frame, Qnil, Qnil, 0);
8404 : cmdKey)))
8405 {
8406 /* This code comes from Keyboard Resource, Appendix
8407 C of IM - Text. This is necessary since shift is
8408 ignored in KCHR table translation when option or
8409 command is pressed. It also does not translate
8410 correctly control-shift chars like C-% so mask off
8411 shift here also */
8412 int new_modifiers = er.modifiers & 0xe600;
8413 /* mask off option and command */
8414 int new_keycode = keycode | new_modifiers;
8415 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
8416 unsigned long some_state = 0;
8417 inev.code = KeyTranslate (kchr_ptr, new_keycode,
8418 &some_state) & 0xff;
8419 }
8420 else
8421 inev.code = er.message & charCodeMask;
8422 inev.kind = ASCII_KEYSTROKE_EVENT;
8423 } 8653 }
8654 count++;
8424 } 8655 }
8425 8656
8426 /* If variable mac-convert-keyboard-input-to-latin-1 is non-nil, 8657 }
8427 convert non-ASCII characters typed at the Mac keyboard
8428 (presumed to be in the Mac Roman encoding) to iso-latin-1
8429 encoding before they are passed to Emacs. This enables the
8430 Mac keyboard to be used to enter non-ASCII iso-latin-1
8431 characters directly. */
8432 if (mac_keyboard_text_encoding != kTextEncodingMacRoman
8433 && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128)
8434 {
8435 static TECObjectRef converter = NULL;
8436 OSStatus the_err = noErr;
8437 OSStatus convert_status = noErr;
8438
8439 if (converter == NULL)
8440 {
8441 the_err = TECCreateConverter (&converter,
8442 kTextEncodingMacRoman,
8443 mac_keyboard_text_encoding);
8444 current_mac_keyboard_text_encoding
8445 = mac_keyboard_text_encoding;
8446 }
8447 else if (mac_keyboard_text_encoding
8448 != current_mac_keyboard_text_encoding)
8449 {
8450 /* Free the converter for the current encoding before
8451 creating a new one. */
8452 TECDisposeConverter (converter);
8453 the_err = TECCreateConverter (&converter,
8454 kTextEncodingMacRoman,
8455 mac_keyboard_text_encoding);
8456 current_mac_keyboard_text_encoding
8457 = mac_keyboard_text_encoding;
8458 }
8459
8460 if (the_err == noErr)
8461 {
8462 unsigned char ch = inev.code;
8463 ByteCount actual_input_length, actual_output_length;
8464 unsigned char outch;
8465
8466 convert_status = TECConvertText (converter, &ch, 1,
8467 &actual_input_length,
8468 &outch, 1,
8469 &actual_output_length);
8470 if (convert_status == noErr
8471 && actual_input_length == 1
8472 && actual_output_length == 1)
8473 inev.code = outch;
8474 }
8475 }
8476
8477 #if USE_CARBON_EVENTS
8478 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8479 #else
8480 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8481 #endif
8482
8483 {
8484 mac_output *mwp
8485 = (mac_output *) GetWRefCon (FrontNonFloatingWindow ());
8486 XSETFRAME (inev.frame_or_window, mwp->mFP);
8487 }
8488
8489 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
8490 break;
8491
8492 case kHighLevelEvent:
8493 drag_and_drop_file_list = Qnil;
8494
8495 AEProcessAppleEvent(&er);
8496
8497 /* Build a DRAG_N_DROP_EVENT type event as is done in
8498 constuct_drag_n_drop in w32term.c. */
8499 if (!NILP (drag_and_drop_file_list))
8500 {
8501 struct frame *f = NULL;
8502 WindowPtr wp;
8503 Lisp_Object frame;
8504
8505 wp = FrontNonFloatingWindow ();
8506
8507 if (!wp)
8508 {
8509 struct frame *f = XFRAME (XCAR (Vframe_list));
8510 CollapseWindow (FRAME_MAC_WINDOW (f), false);
8511 wp = FrontNonFloatingWindow ();
8512 }
8513
8514 if (wp && is_emacs_window(wp))
8515 f = ((mac_output *) GetWRefCon (wp))->mFP;
8516
8517 inev.kind = DRAG_N_DROP_EVENT;
8518 inev.code = 0;
8519 inev.timestamp = er.when * (1000 / 60);
8520 /* ticks to milliseconds */
8521 #if USE_CARBON_EVENTS
8522 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8523 #else
8524 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8525 #endif
8526
8527 XSETINT (inev.x, 0);
8528 XSETINT (inev.y, 0);
8529
8530 XSETFRAME (frame, f);
8531 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
8532
8533 /* Regardless of whether Emacs was suspended or in the
8534 foreground, ask it to redraw its entire screen.
8535 Otherwise parts of the screen can be left in an
8536 inconsistent state. */
8537 if (wp)
8538 #if TARGET_API_MAC_CARBON
8539 {
8540 Rect r;
8541
8542 GetWindowPortBounds (wp, &r);
8543 InvalWindowRect (wp, &r);
8544 }
8545 #else /* not TARGET_API_MAC_CARBON */
8546 InvalRect (&(wp->portRect));
8547 #endif /* not TARGET_API_MAC_CARBON */
8548 }
8549 default:
8550 break;
8551 }
8552 #if USE_CARBON_EVENTS
8553 ReleaseEvent (eventRef);
8554 }
8555 #endif
8556 8658
8557 /* If the focus was just given to an autoraising frame, 8659 /* If the focus was just given to an autoraising frame,
8558 raise it now. */ 8660 raise it now. */
8559 /* ??? This ought to be able to handle more than one such frame. */ 8661 /* ??? This ought to be able to handle more than one such frame. */
8560 if (pending_autoraise_frame) 8662 if (pending_autoraise_frame)
8564 } 8666 }
8565 8667
8566 #if !TARGET_API_MAC_CARBON 8668 #if !TARGET_API_MAC_CARBON
8567 check_alarm (); /* simulate the handling of a SIGALRM */ 8669 check_alarm (); /* simulate the handling of a SIGALRM */
8568 #endif 8670 #endif
8569
8570 {
8571 static Point old_mouse_pos = { -1, -1 };
8572
8573 if (app_is_suspended)
8574 {
8575 old_mouse_pos.h = -1;
8576 old_mouse_pos.v = -1;
8577 }
8578 else
8579 {
8580 Point mouse_pos;
8581 WindowPtr wp;
8582 struct frame *f;
8583 Lisp_Object bar;
8584 struct scroll_bar *sb;
8585
8586 wp = FrontWindow ();
8587 if (is_emacs_window (wp))
8588 {
8589 f = ((mac_output *) GetWRefCon (wp))->mFP;
8590
8591 #if TARGET_API_MAC_CARBON
8592 SetPort (GetWindowPort (wp));
8593 #else
8594 SetPort (wp);
8595 #endif
8596
8597 GetMouse (&mouse_pos);
8598
8599 if (!EqualPt (mouse_pos, old_mouse_pos))
8600 {
8601 if (mouse_tracking_in_progress == mouse_tracking_scroll_bar
8602 && tracked_scroll_bar)
8603 x_scroll_bar_note_movement (tracked_scroll_bar,
8604 mouse_pos.v
8605 - XINT (tracked_scroll_bar->top),
8606 TickCount() * (1000 / 60));
8607 else
8608 note_mouse_movement (f, &mouse_pos);
8609
8610 old_mouse_pos = mouse_pos;
8611 }
8612 }
8613 }
8614 }
8615
8616 if (inev.kind != NO_EVENT)
8617 {
8618 kbd_buffer_store_event_hold (&inev, hold_quit);
8619 count++;
8620 }
8621 8671
8622 UNBLOCK_INPUT; 8672 UNBLOCK_INPUT;
8623 return count; 8673 return count;
8624 } 8674 }
8625 8675
8645 8695
8646 /* Initialize the struct pointed to by MW to represent a new COLS x 8696 /* Initialize the struct pointed to by MW to represent a new COLS x
8647 ROWS Macintosh window, using font with name FONTNAME and size 8697 ROWS Macintosh window, using font with name FONTNAME and size
8648 FONTSIZE. */ 8698 FONTSIZE. */
8649 void 8699 void
8650 NewMacWindow (FRAME_PTR fp) 8700 make_mac_frame (FRAME_PTR fp)
8651 { 8701 {
8652 mac_output *mwp; 8702 mac_output *mwp;
8653 #if TARGET_API_MAC_CARBON 8703 #if TARGET_API_MAC_CARBON
8654 static int making_terminal_window = 0; 8704 static int making_terminal_window = 0;
8655 #else 8705 #else
8664 (WindowPtr) -1))) 8714 (WindowPtr) -1)))
8665 abort (); 8715 abort ();
8666 making_terminal_window = 0; 8716 making_terminal_window = 0;
8667 } 8717 }
8668 else 8718 else
8669 if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1))) 8719 {
8670 abort (); 8720 #if TARGET_API_MAC_CARBON
8721 Rect r;
8722
8723 SetRect (&r, 0, 0, 1, 1);
8724 if (CreateNewWindow (kDocumentWindowClass,
8725 kWindowStandardDocumentAttributes
8726 /* | kWindowToolbarButtonAttribute */,
8727 &r, &mwp->mWP) != noErr)
8728 #else
8729 if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1)))
8730 #endif
8731 abort ();
8732 }
8671 8733
8672 SetWRefCon (mwp->mWP, (long) mwp); 8734 SetWRefCon (mwp->mWP, (long) mwp);
8673 /* so that update events can find this mac_output struct */ 8735 /* so that update events can find this mac_output struct */
8674 mwp->mFP = fp; /* point back to emacs frame */ 8736 mwp->mFP = fp; /* point back to emacs frame */
8675 8737
8676 #if TARGET_API_MAC_CARBON 8738 SetPortWindowPort (mwp->mWP);
8677 SetPort (GetWindowPort (mwp->mWP));
8678 #else
8679 SetPort (mwp->mWP);
8680 #endif
8681
8682 mwp->fontset = -1;
8683 8739
8684 SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false); 8740 SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false);
8685 ShowWindow (mwp->mWP);
8686
8687 } 8741 }
8688 8742
8689 8743
8690 void 8744 void
8691 make_mac_frame (struct frame *f) 8745 make_mac_terminal_frame (struct frame *f)
8692 { 8746 {
8747 Lisp_Object frame;
8748
8749 XSETFRAME (frame, f);
8750
8751 f->output_method = output_mac;
8752 f->output_data.mac = (struct mac_output *)
8753 xmalloc (sizeof (struct mac_output));
8754 bzero (f->output_data.mac, sizeof (struct mac_output));
8755
8756 XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f);
8757
8758 FRAME_COLS (f) = 96;
8759 FRAME_LINES (f) = 4;
8760
8761 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
8762 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;
8763
8693 FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR; 8764 FRAME_DESIRED_CURSOR (f) = FILLED_BOX_CURSOR;
8694
8695 NewMacWindow(f);
8696 8765
8697 f->output_data.mac->cursor_pixel = 0; 8766 f->output_data.mac->cursor_pixel = 0;
8698 f->output_data.mac->border_pixel = 0x00ff00; 8767 f->output_data.mac->border_pixel = 0x00ff00;
8699 f->output_data.mac->mouse_pixel = 0xff00ff; 8768 f->output_data.mac->mouse_pixel = 0xff00ff;
8700 f->output_data.mac->cursor_foreground_pixel = 0x0000ff; 8769 f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
8701 8770
8702 FRAME_FONTSET (f) = -1; 8771 FRAME_FONTSET (f) = -1;
8703 f->output_data.mac->scroll_bar_foreground_pixel = -1;
8704 f->output_data.mac->scroll_bar_background_pixel = -1;
8705 f->output_data.mac->explicit_parent = 0; 8772 f->output_data.mac->explicit_parent = 0;
8706 f->left_pos = 4; 8773 f->left_pos = 4;
8707 f->top_pos = 4; 8774 f->top_pos = 4;
8708 f->border_width = 0; 8775 f->border_width = 0;
8709 8776
8710 f->internal_border_width = 0; 8777 f->internal_border_width = 0;
8711 8778
8712 f->output_method = output_mac;
8713
8714 f->auto_raise = 1; 8779 f->auto_raise = 1;
8715 f->auto_lower = 1; 8780 f->auto_lower = 1;
8716 8781
8717 f->new_text_cols = 0; 8782 f->new_text_cols = 0;
8718 f->new_text_lines = 0; 8783 f->new_text_lines = 0;
8719 }
8720
8721 void
8722 make_mac_terminal_frame (struct frame *f)
8723 {
8724 Lisp_Object frame;
8725
8726 XSETFRAME (frame, f);
8727
8728 f->output_method = output_mac;
8729 f->output_data.mac = (struct mac_output *)
8730 xmalloc (sizeof (struct mac_output));
8731 bzero (f->output_data.mac, sizeof (struct mac_output));
8732 FRAME_FONTSET (f) = -1;
8733 f->output_data.mac->scroll_bar_foreground_pixel = -1;
8734 f->output_data.mac->scroll_bar_background_pixel = -1;
8735
8736 XSETFRAME (FRAME_KBOARD (f)->Vdefault_minibuffer_frame, f);
8737
8738 FRAME_COLS (f) = 96;
8739 FRAME_LINES (f) = 4;
8740
8741 FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
8742 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_right;
8743 8784
8744 make_mac_frame (f); 8785 make_mac_frame (f);
8745 8786
8746 x_make_gc (f); 8787 x_make_gc (f);
8747 8788
8755 Fcons (Fcons (Qforeground_color, 8796 Fcons (Fcons (Qforeground_color,
8756 build_string ("black")), Qnil)); 8797 build_string ("black")), Qnil));
8757 Fmodify_frame_parameters (frame, 8798 Fmodify_frame_parameters (frame,
8758 Fcons (Fcons (Qbackground_color, 8799 Fcons (Fcons (Qbackground_color,
8759 build_string ("white")), Qnil)); 8800 build_string ("white")), Qnil));
8801
8802 ShowWindow (f->output_data.mac->mWP);
8760 } 8803 }
8761 8804
8762 8805
8763 /*********************************************************************** 8806 /***********************************************************************
8764 Initialization 8807 Initialization
8795 8838
8796 dpyinfo->reference_count = 0; 8839 dpyinfo->reference_count = 0;
8797 dpyinfo->resx = 75.0; 8840 dpyinfo->resx = 75.0;
8798 dpyinfo->resy = 75.0; 8841 dpyinfo->resy = 75.0;
8799 dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType); 8842 dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType);
8843 #ifdef MAC_OSX
8844 /* HasDepth returns true if it is possible to have a 32 bit display,
8845 but this may not be what is actually used. Mac OSX can do better. */
8846 dpyinfo->n_planes = CGDisplayBitsPerPixel (CGMainDisplayID ());
8847 #else
8800 for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1) 8848 for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1)
8801 if (HasDepth (main_device_handle, dpyinfo->n_planes, 8849 if (HasDepth (main_device_handle, dpyinfo->n_planes,
8802 gdDevType, dpyinfo->color_p)) 8850 gdDevType, dpyinfo->color_p))
8803 break; 8851 break;
8852 #endif
8804 dpyinfo->height = (**main_device_handle).gdRect.bottom; 8853 dpyinfo->height = (**main_device_handle).gdRect.bottom;
8805 dpyinfo->width = (**main_device_handle).gdRect.right; 8854 dpyinfo->width = (**main_device_handle).gdRect.right;
8806 dpyinfo->grabbed = 0; 8855 dpyinfo->grabbed = 0;
8807 dpyinfo->root_window = NULL; 8856 dpyinfo->root_window = NULL;
8808 dpyinfo->image_cache = make_image_cache (); 8857 dpyinfo->image_cache = make_image_cache ();
8809 8858
8810 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 8859 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
8811 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1; 8860 dpyinfo->mouse_face_end_row = dpyinfo->mouse_face_end_col = -1;
8812 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; 8861 dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID;
8813 dpyinfo->mouse_face_window = Qnil; 8862 dpyinfo->mouse_face_window = Qnil;
8863 dpyinfo->mouse_face_overlay = Qnil;
8864 dpyinfo->mouse_face_hidden = 0;
8814 } 8865 }
8815 8866
8816 struct mac_display_info * 8867 struct mac_display_info *
8817 mac_term_init (display_name, xrm_option, resource_name) 8868 mac_term_init (display_name, xrm_option, resource_name)
8818 Lisp_Object display_name; 8869 Lisp_Object display_name;
8957 9008
8958 /* Redetermine modifiers because they are based on lisp variables */ 9009 /* Redetermine modifiers because they are based on lisp variables */
8959 mac_determine_quit_char_modifiers (); 9010 mac_determine_quit_char_modifiers ();
8960 9011
8961 /* Fill the queue with events */ 9012 /* Fill the queue with events */
9013 BLOCK_INPUT;
8962 ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &event); 9014 ReceiveNextEvent (0, NULL, kEventDurationNoWait, false, &event);
8963 event = FindSpecificEventInQueue (GetMainEventQueue (), quit_char_comp, 9015 event = FindSpecificEventInQueue (GetMainEventQueue (), quit_char_comp,
8964 NULL); 9016 NULL);
9017 UNBLOCK_INPUT;
8965 if (event) 9018 if (event)
8966 { 9019 {
8967 struct input_event e; 9020 struct input_event e;
8968 struct mac_output *mwp = 9021
8969 (mac_output *) GetWRefCon (FrontNonFloatingWindow ());
8970 /* Use an input_event to emulate what the interrupt handler does. */ 9022 /* Use an input_event to emulate what the interrupt handler does. */
8971 EVENT_INIT (e); 9023 EVENT_INIT (e);
8972 e.kind = ASCII_KEYSTROKE_EVENT; 9024 e.kind = ASCII_KEYSTROKE_EVENT;
8973 e.code = quit_char; 9025 e.code = quit_char;
8974 e.arg = NULL; 9026 e.arg = Qnil;
8975 e.modifiers = NULL; 9027 e.modifiers = NULL;
8976 e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); 9028 e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60);
8977 XSETFRAME (e.frame_or_window, mwp->mFP); 9029 XSETFRAME (e.frame_or_window, mac_window_to_frame (mac_front_window ()));
8978 /* Remove event from queue to prevent looping. */ 9030 /* Remove event from queue to prevent looping. */
8979 RemoveEventFromQueue (GetMainEventQueue (), event); 9031 RemoveEventFromQueue (GetMainEventQueue (), event);
8980 ReleaseEvent (event); 9032 ReleaseEvent (event);
8981 kbd_buffer_store_event (&e); 9033 kbd_buffer_store_event (&e);
8982 } 9034 }
9183 DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta, 9235 DEFVAR_LISP ("mac-reverse-ctrl-meta", &Vmac_reverse_ctrl_meta,
9184 doc: /* Non-nil means that the control and meta keys are reversed. This is 9236 doc: /* Non-nil means that the control and meta keys are reversed. This is
9185 useful for non-standard keyboard layouts. */); 9237 useful for non-standard keyboard layouts. */);
9186 Vmac_reverse_ctrl_meta = Qnil; 9238 Vmac_reverse_ctrl_meta = Qnil;
9187 9239
9188 DEFVAR_LISP ("mac-emulate-three-button-mouse", 9240 DEFVAR_LISP ("mac-emulate-three-button-mouse",
9189 &Vmac_emulate_three_button_mouse, 9241 &Vmac_emulate_three_button_mouse,
9190 doc: /* t means that when the option-key is held down while pressing the 9242 doc: /* t means that when the option-key is held down while pressing the
9191 mouse button, the click will register as mouse-2 and while the 9243 mouse button, the click will register as mouse-2 and while the
9192 command-key is held down, the click will register as mouse-3. 9244 command-key is held down, the click will register as mouse-3.
9193 'reverse means that the the option-key will register for mouse-3 9245 'reverse means that the the option-key will register for mouse-3
9194 and the command-key will register for mouse-2. nil means that 9246 and the command-key will register for mouse-2. nil means that
9195 not emulation should be done and the modifiers should be placed 9247 not emulation should be done and the modifiers should be placed
9196 on the mouse-1 event. */); 9248 on the mouse-1 event. */);