aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2005-10-16 02:22:59 +0000
committerYAMAMOTO Mitsuharu2005-10-16 02:22:59 +0000
commit236072aebf0f353cbec253a46923c68868b64bc2 (patch)
treee09733421cd8f163bc9907a5d2b9a021e3d03447 /src
parent0abf3e71f3208b0568d1d2c12a2b05cbb387c23e (diff)
downloademacs-236072aebf0f353cbec253a46923c68868b64bc2.tar.gz
emacs-236072aebf0f353cbec253a46923c68868b64bc2.zip
(MAC_WINDOW_NORMAL_GC): Remove macro.
(FRAME_NORMAL_GC): New macro. (mac_draw_line, mac_clear_area, mac_clear_window) (mac_fill_rectangle, mac_draw_string, mac_draw_string_16) (mac_draw_image_string, mac_draw_image_string_16): Rename from XDrawLine, XClearArea, XClearWindow, XFillRectangle, XDrawString, XDrawString16, XDrawImageString, and XDrawImageString16, respectively. All uses changed. (mac_draw_line, mac_erase_rectangle, mac_clear_area) (mac_clear_window, mac_draw_bitmap, mac_draw_rectangle) (mac_invert_rectangle, mac_draw_string_common, mac_draw_string) (mac_draw_string_16, mac_draw_image_string) (mac_draw_image_string_16, mac_copy_area, mac_copy_area_with_mask) (mac_scroll_area): Drawing functions now take frame as destination. All uses changed. (mac_draw_string_common): Get port height with FRAME_PIXEL_HEIGHT. (x_draw_fringe_bitmap): Set clipping area in face->gc.
Diffstat (limited to 'src')
-rw-r--r--src/macterm.c650
1 files changed, 184 insertions, 466 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 20218b1954a..99536072a5e 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -271,7 +271,7 @@ extern void menubar_selection_callback (FRAME_PTR, int);
271#define GC_BACK_COLOR(gc) (&(gc)->back_color) 271#define GC_BACK_COLOR(gc) (&(gc)->back_color)
272#define GC_FONT(gc) ((gc)->xgcv.font) 272#define GC_FONT(gc) ((gc)->xgcv.font)
273#define GC_CLIP_REGION(gc) ((gc)->clip_region) 273#define GC_CLIP_REGION(gc) ((gc)->clip_region)
274#define MAC_WINDOW_NORMAL_GC(w) (((mac_output *) GetWRefCon (w))->normal_gc) 274#define FRAME_NORMAL_GC(f) ((f)->output_data.mac->normal_gc)
275 275
276static RgnHandle saved_port_clip_region = NULL; 276static RgnHandle saved_port_clip_region = NULL;
277 277
@@ -317,13 +317,12 @@ XFreePixmap (display, pixmap)
317/* Mac version of XDrawLine. */ 317/* Mac version of XDrawLine. */
318 318
319static void 319static void
320XDrawLine (display, w, gc, x1, y1, x2, y2) 320mac_draw_line (f, gc, x1, y1, x2, y2)
321 Display *display; 321 struct frame *f;
322 WindowPtr w;
323 GC gc; 322 GC gc;
324 int x1, y1, x2, y2; 323 int x1, y1, x2, y2;
325{ 324{
326 SetPortWindowPort (w); 325 SetPortWindowPort (FRAME_MAC_WINDOW (f));
327 326
328 RGBForeColor (GC_FORE_COLOR (gc)); 327 RGBForeColor (GC_FORE_COLOR (gc));
329 328
@@ -358,15 +357,15 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2)
358 357
359 358
360static void 359static void
361mac_erase_rectangle (w, gc, x, y, width, height) 360mac_erase_rectangle (f, gc, x, y, width, height)
362 WindowPtr w; 361 struct frame *f;
363 GC gc; 362 GC gc;
364 int x, y; 363 int x, y;
365 unsigned int width, height; 364 unsigned int width, height;
366{ 365{
367 Rect r; 366 Rect r;
368 367
369 SetPortWindowPort (w); 368 SetPortWindowPort (FRAME_MAC_WINDOW (f));
370 369
371 RGBBackColor (GC_BACK_COLOR (gc)); 370 RGBBackColor (GC_BACK_COLOR (gc));
372 SetRect (&r, x, y, x + width, y + height); 371 SetRect (&r, x, y, x + width, y + height);
@@ -375,43 +374,40 @@ mac_erase_rectangle (w, gc, x, y, width, height)
375 EraseRect (&r); 374 EraseRect (&r);
376 mac_end_clip (GC_CLIP_REGION (gc)); 375 mac_end_clip (GC_CLIP_REGION (gc));
377 376
378 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 377 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
379} 378}
380 379
381 380
382/* Mac version of XClearArea. */ 381/* Mac version of XClearArea. */
383 382
384void 383void
385XClearArea (display, w, x, y, width, height, exposures) 384mac_clear_area (f, x, y, width, height)
386 Display *display; 385 struct frame *f;
387 WindowPtr w;
388 int x, y; 386 int x, y;
389 unsigned int width, height; 387 unsigned int width, height;
390 int exposures;
391{ 388{
392 mac_erase_rectangle (w, MAC_WINDOW_NORMAL_GC (w), x, y, width, height); 389 mac_erase_rectangle (f, FRAME_NORMAL_GC (f), x, y, width, height);
393} 390}
394 391
395/* Mac version of XClearWindow. */ 392/* Mac version of XClearWindow. */
396 393
397static void 394static void
398XClearWindow (display, w) 395mac_clear_window (f)
399 Display *display; 396 struct frame *f;
400 WindowPtr w;
401{ 397{
402 SetPortWindowPort (w); 398 SetPortWindowPort (FRAME_MAC_WINDOW (f));
403 399
404 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 400 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
405 401
406#if TARGET_API_MAC_CARBON 402#if TARGET_API_MAC_CARBON
407 { 403 {
408 Rect r; 404 Rect r;
409 405
410 GetWindowPortBounds (w, &r); 406 GetWindowPortBounds (FRAME_MAC_WINDOW (f), &r);
411 EraseRect (&r); 407 EraseRect (&r);
412 } 408 }
413#else /* not TARGET_API_MAC_CARBON */ 409#else /* not TARGET_API_MAC_CARBON */
414 EraseRect (&(w->portRect)); 410 EraseRect (&(FRAME_MAC_WINDOW (f)->portRect));
415#endif /* not TARGET_API_MAC_CARBON */ 411#endif /* not TARGET_API_MAC_CARBON */
416} 412}
417 413
@@ -419,9 +415,8 @@ XClearWindow (display, w)
419/* Mac replacement for XCopyArea. */ 415/* Mac replacement for XCopyArea. */
420 416
421static void 417static void
422mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p) 418mac_draw_bitmap (f, gc, x, y, width, height, bits, overlay_p)
423 Display *display; 419 struct frame *f;
424 WindowPtr w;
425 GC gc; 420 GC gc;
426 int x, y, width, height; 421 int x, y, width, height;
427 unsigned short *bits; 422 unsigned short *bits;
@@ -434,7 +429,7 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
434 bitmap.baseAddr = (char *)bits; 429 bitmap.baseAddr = (char *)bits;
435 SetRect (&(bitmap.bounds), 0, 0, width, height); 430 SetRect (&(bitmap.bounds), 0, 0, width, height);
436 431
437 SetPortWindowPort (w); 432 SetPortWindowPort (FRAME_MAC_WINDOW (f));
438 433
439 RGBForeColor (GC_FORE_COLOR (gc)); 434 RGBForeColor (GC_FORE_COLOR (gc));
440 RGBBackColor (GC_BACK_COLOR (gc)); 435 RGBBackColor (GC_BACK_COLOR (gc));
@@ -442,17 +437,22 @@ mac_draw_bitmap (display, w, gc, x, y, width, height, bits, overlay_p)
442 437
443 mac_begin_clip (GC_CLIP_REGION (gc)); 438 mac_begin_clip (GC_CLIP_REGION (gc));
444#if TARGET_API_MAC_CARBON 439#if TARGET_API_MAC_CARBON
445 LockPortBits (GetWindowPort (w)); 440 {
446 CopyBits (&bitmap, GetPortBitMapForCopyBits (GetWindowPort (w)), 441 CGrafPtr port;
447 &(bitmap.bounds), &r, overlay_p ? srcOr : srcCopy, 0); 442
448 UnlockPortBits (GetWindowPort (w)); 443 GetPort (&port);
444 LockPortBits (port);
445 CopyBits (&bitmap, GetPortBitMapForCopyBits (port),
446 &(bitmap.bounds), &r, overlay_p ? srcOr : srcCopy, 0);
447 UnlockPortBits (port);
448 }
449#else /* not TARGET_API_MAC_CARBON */ 449#else /* not TARGET_API_MAC_CARBON */
450 CopyBits (&bitmap, &(w->portBits), &(bitmap.bounds), &r, 450 CopyBits (&bitmap, &(FRAME_MAC_WINDOW (f)->portBits), &(bitmap.bounds), &r,
451 overlay_p ? srcOr : srcCopy, 0); 451 overlay_p ? srcOr : srcCopy, 0);
452#endif /* not TARGET_API_MAC_CARBON */ 452#endif /* not TARGET_API_MAC_CARBON */
453 mac_end_clip (GC_CLIP_REGION (gc)); 453 mac_end_clip (GC_CLIP_REGION (gc));
454 454
455 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 455 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
456} 456}
457 457
458 458
@@ -569,16 +569,15 @@ XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
569/* Mac replacement for XFillRectangle. */ 569/* Mac replacement for XFillRectangle. */
570 570
571static void 571static void
572XFillRectangle (display, w, gc, x, y, width, height) 572mac_fill_rectangle (f, gc, x, y, width, height)
573 Display *display; 573 struct frame *f;
574 WindowPtr w;
575 GC gc; 574 GC gc;
576 int x, y; 575 int x, y;
577 unsigned int width, height; 576 unsigned int width, height;
578{ 577{
579 Rect r; 578 Rect r;
580 579
581 SetPortWindowPort (w); 580 SetPortWindowPort (FRAME_MAC_WINDOW (f));
582 581
583 RGBForeColor (GC_FORE_COLOR (gc)); 582 RGBForeColor (GC_FORE_COLOR (gc));
584 SetRect (&r, x, y, x + width, y + height); 583 SetRect (&r, x, y, x + width, y + height);
@@ -589,46 +588,18 @@ XFillRectangle (display, w, gc, x, y, width, height)
589} 588}
590 589
591 590
592#if 0 /* TODO: figure out if we need to do this on Mac. */
593static void
594mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height)
595 Display *display;
596 Pixmap p;
597 GC gc;
598 int x, y;
599 unsigned int width, height;
600{
601 CGrafPtr old_port;
602 GDHandle old_gdh;
603 Rect r;
604
605 GetGWorld (&old_port, &old_gdh);
606 SetGWorld (p, NULL);
607 RGBForeColor (GC_FORE_COLOR (gc));
608 SetRect (&r, x, y, x + width, y + height);
609
610 LockPixels (GetGWorldPixMap (p));
611 PaintRect (&r); /* using foreground color of gc */
612 UnlockPixels (GetGWorldPixMap (p));
613
614 SetGWorld (old_port, old_gdh);
615}
616#endif
617
618
619/* Mac replacement for XDrawRectangle: dest is a window. */ 591/* Mac replacement for XDrawRectangle: dest is a window. */
620 592
621static void 593static void
622mac_draw_rectangle (display, w, gc, x, y, width, height) 594mac_draw_rectangle (f, gc, x, y, width, height)
623 Display *display; 595 struct frame *f;
624 WindowPtr w;
625 GC gc; 596 GC gc;
626 int x, y; 597 int x, y;
627 unsigned int width, height; 598 unsigned int width, height;
628{ 599{
629 Rect r; 600 Rect r;
630 601
631 SetPortWindowPort (w); 602 SetPortWindowPort (FRAME_MAC_WINDOW (f));
632 603
633 RGBForeColor (GC_FORE_COLOR (gc)); 604 RGBForeColor (GC_FORE_COLOR (gc));
634 SetRect (&r, x, y, x + width + 1, y + height + 1); 605 SetRect (&r, x, y, x + width + 1, y + height + 1);
@@ -639,35 +610,6 @@ mac_draw_rectangle (display, w, gc, x, y, width, height)
639} 610}
640 611
641 612
642#if 0 /* TODO: figure out if we need to do this on Mac. */
643/* Mac replacement for XDrawRectangle: dest is a Pixmap. */
644
645static void
646mac_draw_rectangle_to_pixmap (display, p, gc, x, y, width, height)
647 Display *display;
648 Pixmap p;
649 GC gc;
650 int x, y;
651 unsigned int width, height;
652{
653 CGrafPtr old_port;
654 GDHandle old_gdh;
655 Rect r;
656
657 GetGWorld (&old_port, &old_gdh);
658 SetGWorld (p, NULL);
659 RGBForeColor (GC_FORE_COLOR (gc));
660 SetRect (&r, x, y, x + width + 1, y + height + 1);
661
662 LockPixels (GetGWorldPixMap (p));
663 FrameRect (&r); /* using foreground color of gc */
664 UnlockPixels (GetGWorldPixMap (p));
665
666 SetGWorld (old_port, old_gdh);
667}
668#endif
669
670
671#if USE_ATSUI 613#if USE_ATSUI
672static OSStatus 614static OSStatus
673atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout) 615atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout)
@@ -724,16 +666,16 @@ atsu_get_text_layout_with_text_ptr (text, text_length, style, text_layout)
724} 666}
725#endif 667#endif
726 668
669
727static void 670static void
728mac_invert_rectangle (display, w, x, y, width, height) 671mac_invert_rectangle (f, x, y, width, height)
729 Display *display; 672 struct frame *f;
730 WindowPtr w;
731 int x, y; 673 int x, y;
732 unsigned int width, height; 674 unsigned int width, height;
733{ 675{
734 Rect r; 676 Rect r;
735 677
736 SetPortWindowPort (w); 678 SetPortWindowPort (FRAME_MAC_WINDOW (f));
737 679
738 SetRect (&r, x, y, x + width, y + height); 680 SetRect (&r, x, y, x + width, y + height);
739 681
@@ -742,10 +684,8 @@ mac_invert_rectangle (display, w, x, y, width, height)
742 684
743 685
744static void 686static void
745mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode, 687mac_draw_string_common (f, gc, x, y, buf, nchars, mode, bytes_per_char)
746 bytes_per_char) 688 struct frame *f;
747 Display *display;
748 WindowPtr w;
749 GC gc; 689 GC gc;
750 int x, y; 690 int x, y;
751 char *buf; 691 char *buf;
@@ -759,7 +699,7 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
759 } 699 }
760#endif 700#endif
761 701
762 SetPortWindowPort (w); 702 SetPortWindowPort (FRAME_MAC_WINDOW (f));
763 703
764 RGBForeColor (GC_FORE_COLOR (gc)); 704 RGBForeColor (GC_FORE_COLOR (gc));
765 if (mode != srcOr) 705 if (mode != srcOr)
@@ -804,16 +744,13 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
804 { 744 {
805 CGrafPtr port; 745 CGrafPtr port;
806 CGContextRef context; 746 CGContextRef context;
807 Rect rect; 747 float port_height = FRAME_PIXEL_HEIGHT (f);
808 float port_height;
809 ATSUAttributeTag tags[] = {kATSUCGContextTag}; 748 ATSUAttributeTag tags[] = {kATSUCGContextTag};
810 ByteCount sizes[] = {sizeof (CGContextRef)}; 749 ByteCount sizes[] = {sizeof (CGContextRef)};
811 ATSUAttributeValuePtr values[] = {&context}; 750 ATSUAttributeValuePtr values[] = {&context};
812 751
813 GetPort (&port); 752 GetPort (&port);
814 QDBeginCGContext (port, &context); 753 QDBeginCGContext (port, &context);
815 GetPortBounds (port, &rect);
816 port_height = rect.bottom - rect.top;
817 if (gc->n_clip_rects) 754 if (gc->n_clip_rects)
818 { 755 {
819 CGContextTranslateCTM (context, 0, port_height); 756 CGContextTranslateCTM (context, 0, port_height);
@@ -862,7 +799,7 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
862#endif 799#endif
863 800
864 if (mode != srcOr) 801 if (mode != srcOr)
865 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 802 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
866#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 803#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
867 if (!NILP(Vmac_use_core_graphics)) 804 if (!NILP(Vmac_use_core_graphics))
868 SwapQDTextFlags(savedFlags); 805 SwapQDTextFlags(savedFlags);
@@ -873,73 +810,65 @@ mac_draw_string_common (display, w, gc, x, y, buf, nchars, mode,
873/* Mac replacement for XDrawString. */ 810/* Mac replacement for XDrawString. */
874 811
875static void 812static void
876XDrawString (display, w, gc, x, y, buf, nchars) 813mac_draw_string (f, gc, x, y, buf, nchars)
877 Display *display; 814 struct frame *f;
878 WindowPtr w;
879 GC gc; 815 GC gc;
880 int x, y; 816 int x, y;
881 char *buf; 817 char *buf;
882 int nchars; 818 int nchars;
883{ 819{
884 mac_draw_string_common (display, w, gc, x, y, buf, nchars, srcOr, 1); 820 mac_draw_string_common (f, gc, x, y, buf, nchars, srcOr, 1);
885} 821}
886 822
887 823
888/* Mac replacement for XDrawString16. */ 824/* Mac replacement for XDrawString16. */
889 825
890static void 826static void
891XDrawString16 (display, w, gc, x, y, buf, nchars) 827mac_draw_string_16 (f, gc, x, y, buf, nchars)
892 Display *display; 828 struct frame *f;
893 WindowPtr w;
894 GC gc; 829 GC gc;
895 int x, y; 830 int x, y;
896 XChar2b *buf; 831 XChar2b *buf;
897 int nchars; 832 int nchars;
898{ 833{
899 mac_draw_string_common (display, w, gc, x, y, (char *) buf, nchars, srcOr, 834 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcOr, 2);
900 2);
901} 835}
902 836
903 837
904/* Mac replacement for XDrawImageString. */ 838/* Mac replacement for XDrawImageString. */
905 839
906static void 840static void
907XDrawImageString (display, w, gc, x, y, buf, nchars) 841mac_draw_image_string (f, gc, x, y, buf, nchars)
908 Display *display; 842 struct frame *f;
909 WindowPtr w;
910 GC gc; 843 GC gc;
911 int x, y; 844 int x, y;
912 char *buf; 845 char *buf;
913 int nchars; 846 int nchars;
914{ 847{
915 mac_draw_string_common (display, w, gc, x, y, buf, nchars, srcCopy, 1); 848 mac_draw_string_common (f, gc, x, y, buf, nchars, srcCopy, 1);
916} 849}
917 850
918 851
919/* Mac replacement for XDrawString16. */ 852/* Mac replacement for XDrawString16. */
920 853
921static void 854static void
922XDrawImageString16 (display, w, gc, x, y, buf, nchars) 855mac_draw_image_string_16 (f, gc, x, y, buf, nchars)
923 Display *display; 856 struct frame *f;
924 WindowPtr w;
925 GC gc; 857 GC gc;
926 int x, y; 858 int x, y;
927 XChar2b *buf; 859 XChar2b *buf;
928 int nchars; 860 int nchars;
929{ 861{
930 mac_draw_string_common (display, w, gc, x, y, (char *) buf, nchars, srcCopy, 862 mac_draw_string_common (f, gc, x, y, (char *) buf, nchars, srcCopy, 2);
931 2);
932} 863}
933 864
934 865
935/* Mac replacement for XCopyArea: dest must be window. */ 866/* Mac replacement for XCopyArea: dest must be window. */
936 867
937static void 868static void
938mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x, 869mac_copy_area (src, f, gc, src_x, src_y, width, height, dest_x, dest_y)
939 dest_y)
940 Display *display;
941 Pixmap src; 870 Pixmap src;
942 WindowPtr dest; 871 struct frame *f;
943 GC gc; 872 GC gc;
944 int src_x, src_y; 873 int src_x, src_y;
945 unsigned int width, height; 874 unsigned int width, height;
@@ -947,7 +876,7 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
947{ 876{
948 Rect src_r, dest_r; 877 Rect src_r, dest_r;
949 878
950 SetPortWindowPort (dest); 879 SetPortWindowPort (FRAME_MAC_WINDOW (f));
951 880
952 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 881 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
953 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 882 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -958,28 +887,32 @@ mac_copy_area (display, src, dest, gc, src_x, src_y, width, height, dest_x,
958 mac_begin_clip (GC_CLIP_REGION (gc)); 887 mac_begin_clip (GC_CLIP_REGION (gc));
959 LockPixels (GetGWorldPixMap (src)); 888 LockPixels (GetGWorldPixMap (src));
960#if TARGET_API_MAC_CARBON 889#if TARGET_API_MAC_CARBON
961 LockPortBits (GetWindowPort (dest)); 890 {
962 CopyBits (GetPortBitMapForCopyBits (src), 891 CGrafPtr port;
963 GetPortBitMapForCopyBits (GetWindowPort (dest)), 892
964 &src_r, &dest_r, srcCopy, 0); 893 GetPort (&port);
965 UnlockPortBits (GetWindowPort (dest)); 894 LockPortBits (port);
895 CopyBits (GetPortBitMapForCopyBits (src),
896 GetPortBitMapForCopyBits (port),
897 &src_r, &dest_r, srcCopy, 0);
898 UnlockPortBits (port);
899 }
966#else /* not TARGET_API_MAC_CARBON */ 900#else /* not TARGET_API_MAC_CARBON */
967 CopyBits (&(((GrafPtr)src)->portBits), &(dest->portBits), 901 CopyBits (&(((GrafPtr)src)->portBits), &(FRAME_MAC_WINDOW (f)->portBits),
968 &src_r, &dest_r, srcCopy, 0); 902 &src_r, &dest_r, srcCopy, 0);
969#endif /* not TARGET_API_MAC_CARBON */ 903#endif /* not TARGET_API_MAC_CARBON */
970 UnlockPixels (GetGWorldPixMap (src)); 904 UnlockPixels (GetGWorldPixMap (src));
971 mac_end_clip (GC_CLIP_REGION (gc)); 905 mac_end_clip (GC_CLIP_REGION (gc));
972 906
973 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest))); 907 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
974} 908}
975 909
976 910
977static void 911static void
978mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y, 912mac_copy_area_with_mask (src, mask, f, gc, src_x, src_y,
979 width, height, dest_x, dest_y) 913 width, height, dest_x, dest_y)
980 Display *display;
981 Pixmap src, mask; 914 Pixmap src, mask;
982 WindowPtr dest; 915 struct frame *f;
983 GC gc; 916 GC gc;
984 int src_x, src_y; 917 int src_x, src_y;
985 unsigned int width, height; 918 unsigned int width, height;
@@ -987,7 +920,7 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
987{ 920{
988 Rect src_r, dest_r; 921 Rect src_r, dest_r;
989 922
990 SetPortWindowPort (dest); 923 SetPortWindowPort (FRAME_MAC_WINDOW (f));
991 924
992 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 925 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
993 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 926 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
@@ -999,29 +932,33 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
999 LockPixels (GetGWorldPixMap (src)); 932 LockPixels (GetGWorldPixMap (src));
1000 LockPixels (GetGWorldPixMap (mask)); 933 LockPixels (GetGWorldPixMap (mask));
1001#if TARGET_API_MAC_CARBON 934#if TARGET_API_MAC_CARBON
1002 LockPortBits (GetWindowPort (dest)); 935 {
1003 CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask), 936 CGrafPtr port;
1004 GetPortBitMapForCopyBits (GetWindowPort (dest)), 937
1005 &src_r, &src_r, &dest_r); 938 GetPort (&port);
1006 UnlockPortBits (GetWindowPort (dest)); 939 LockPortBits (port);
940 CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask),
941 GetPortBitMapForCopyBits (port),
942 &src_r, &src_r, &dest_r);
943 UnlockPortBits (port);
944 }
1007#else /* not TARGET_API_MAC_CARBON */ 945#else /* not TARGET_API_MAC_CARBON */
1008 CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits), 946 CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits),
1009 &(dest->portBits), &src_r, &src_r, &dest_r); 947 &(FRAME_MAC_WINDOW (f)->portBits), &src_r, &src_r, &dest_r);
1010#endif /* not TARGET_API_MAC_CARBON */ 948#endif /* not TARGET_API_MAC_CARBON */
1011 UnlockPixels (GetGWorldPixMap (mask)); 949 UnlockPixels (GetGWorldPixMap (mask));
1012 UnlockPixels (GetGWorldPixMap (src)); 950 UnlockPixels (GetGWorldPixMap (src));
1013 mac_end_clip (GC_CLIP_REGION (gc)); 951 mac_end_clip (GC_CLIP_REGION (gc));
1014 952
1015 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (dest))); 953 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
1016} 954}
1017 955
1018 956
1019/* Mac replacement for XCopyArea: used only for scrolling. */ 957/* Mac replacement for XCopyArea: used only for scrolling. */
1020 958
1021static void 959static void
1022mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y) 960mac_scroll_area (f, gc, src_x, src_y, width, height, dest_x, dest_y)
1023 Display *display; 961 struct frame *f;
1024 WindowPtr w;
1025 GC gc; 962 GC gc;
1026 int src_x, src_y; 963 int src_x, src_y;
1027 unsigned int width, height; 964 unsigned int width, height;
@@ -1032,11 +969,13 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
1032 RgnHandle dummy = NewRgn (); /* For avoiding update events. */ 969 RgnHandle dummy = NewRgn (); /* For avoiding update events. */
1033 970
1034 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 971 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1035 ScrollWindowRect (w, &src_r, dest_x - src_x, dest_y - src_y, 972 ScrollWindowRect (FRAME_MAC_WINDOW (f),
973 &src_r, dest_x - src_x, dest_y - src_y,
1036 kScrollWindowNoOptions, dummy); 974 kScrollWindowNoOptions, dummy);
1037 DisposeRgn (dummy); 975 DisposeRgn (dummy);
1038#else /* not TARGET_API_MAC_CARBON */ 976#else /* not TARGET_API_MAC_CARBON */
1039 Rect src_r, dest_r; 977 Rect src_r, dest_r;
978 WindowPtr w = FRAME_MAC_WINDOW (f);
1040 979
1041 SetPort (w); 980 SetPort (w);
1042 981
@@ -1051,91 +990,9 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
1051 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0); 990 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
1052 mac_end_clip (GC_CLIP_REGION (gc)); 991 mac_end_clip (GC_CLIP_REGION (gc));
1053 992
1054 RGBBackColor (GC_BACK_COLOR (MAC_WINDOW_NORMAL_GC (w))); 993 RGBBackColor (GC_BACK_COLOR (FRAME_NORMAL_GC (f)));
1055#endif /* not TARGET_API_MAC_CARBON */
1056}
1057
1058
1059#if 0 /* TODO: figure out if we need to do this on Mac. */
1060/* Mac replacement for XCopyArea: dest must be Pixmap. */
1061
1062static void
1063mac_copy_area_to_pixmap (display, src, dest, gc, src_x, src_y, width, height,
1064 dest_x, dest_y)
1065 Display *display;
1066 Pixmap src, dest;
1067 GC gc;
1068 int src_x, src_y;
1069 unsigned int width, height;
1070 int dest_x, dest_y;
1071{
1072 CGrafPtr old_port;
1073 GDHandle old_gdh;
1074 Rect src_r, dest_r;
1075
1076 GetGWorld (&old_port, &old_gdh);
1077 SetGWorld (dest, NULL);
1078 ForeColor (blackColor);
1079 BackColor (whiteColor);
1080
1081 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1082 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
1083
1084 LockPixels (GetGWorldPixMap (src));
1085 LockPixels (GetGWorldPixMap (dest));
1086#if TARGET_API_MAC_CARBON
1087 CopyBits (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (dest),
1088 &src_r, &dest_r, srcCopy, 0);
1089#else /* not TARGET_API_MAC_CARBON */
1090 CopyBits (&(((GrafPtr)src)->portBits), &(((GrafPtr)dest)->portBits),
1091 &src_r, &dest_r, srcCopy, 0);
1092#endif /* not TARGET_API_MAC_CARBON */
1093 UnlockPixels (GetGWorldPixMap (dest));
1094 UnlockPixels (GetGWorldPixMap (src));
1095
1096 SetGWorld (old_port, old_gdh);
1097}
1098
1099
1100static void
1101mac_copy_area_with_mask_to_pixmap (display, src, mask, dest, gc, src_x, src_y,
1102 width, height, dest_x, dest_y)
1103 Display *display;
1104 Pixmap src, mask, dest;
1105 GC gc;
1106 int src_x, src_y;
1107 unsigned int width, height;
1108 int dest_x, dest_y;
1109{
1110 CGrafPtr old_port;
1111 GDHandle old_gdh;
1112 Rect src_r, dest_r;
1113
1114 GetGWorld (&old_port, &old_gdh);
1115 SetGWorld (dest, NULL);
1116 ForeColor (blackColor);
1117 BackColor (whiteColor);
1118
1119 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
1120 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
1121
1122 LockPixels (GetGWorldPixMap (src));
1123 LockPixels (GetGWorldPixMap (mask));
1124 LockPixels (GetGWorldPixMap (dest));
1125#if TARGET_API_MAC_CARBON
1126 CopyMask (GetPortBitMapForCopyBits (src), GetPortBitMapForCopyBits (mask),
1127 GetPortBitMapForCopyBits (dest), &src_r, &src_r, &dest_r);
1128#else /* not TARGET_API_MAC_CARBON */
1129 CopyMask (&(((GrafPtr)src)->portBits), &(((GrafPtr)mask)->portBits),
1130 &(((GrafPtr)dest)->portBits), &src_r, &src_r, &dest_r);
1131#endif /* not TARGET_API_MAC_CARBON */ 994#endif /* not TARGET_API_MAC_CARBON */
1132 UnlockPixels (GetGWorldPixMap (dest));
1133 UnlockPixels (GetGWorldPixMap (mask));
1134 UnlockPixels (GetGWorldPixMap (src));
1135
1136 SetGWorld (old_port, old_gdh);
1137} 995}
1138#endif
1139 996
1140 997
1141/* Mac replacement for XChangeGC. */ 998/* Mac replacement for XChangeGC. */
@@ -1509,8 +1366,7 @@ mac_draw_vertical_window_border (w, x, y0, y1)
1509 XSetForeground (FRAME_MAC_DISPLAY (f), f->output_data.mac->normal_gc, 1366 XSetForeground (FRAME_MAC_DISPLAY (f), f->output_data.mac->normal_gc,
1510 face->foreground); 1367 face->foreground);
1511 1368
1512 XDrawLine (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1369 mac_draw_line (f, f->output_data.mac->normal_gc, x, y0, x, y1);
1513 f->output_data.mac->normal_gc, x, y0, x, y1);
1514} 1370}
1515 1371
1516/* End update of window W (which is equal to updated_window). 1372/* End update of window W (which is equal to updated_window).
@@ -1649,11 +1505,8 @@ x_after_update_window_line (desired_row)
1649 y -= width; 1505 y -= width;
1650 1506
1651 BLOCK_INPUT; 1507 BLOCK_INPUT;
1652 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1508 mac_clear_area (f, 0, y, width, height);
1653 0, y, width, height, 0); 1509 mac_clear_area (f, FRAME_PIXEL_WIDTH (f) - width, y, width, height);
1654 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1655 FRAME_PIXEL_WIDTH (f) - width, y,
1656 width, height, 0);
1657 UNBLOCK_INPUT; 1510 UNBLOCK_INPUT;
1658 } 1511 }
1659} 1512}
@@ -1672,8 +1525,6 @@ x_draw_fringe_bitmap (w, row, p)
1672{ 1525{
1673 struct frame *f = XFRAME (WINDOW_FRAME (w)); 1526 struct frame *f = XFRAME (WINDOW_FRAME (w));
1674 Display *display = FRAME_MAC_DISPLAY (f); 1527 Display *display = FRAME_MAC_DISPLAY (f);
1675 WindowPtr window = FRAME_MAC_WINDOW (f);
1676 GC gc = f->output_data.mac->normal_gc;
1677 struct face *face = p->face; 1528 struct face *face = p->face;
1678 int rowY; 1529 int rowY;
1679 1530
@@ -1687,12 +1538,12 @@ x_draw_fringe_bitmap (w, row, p)
1687 int oldVH = row->visible_height; 1538 int oldVH = row->visible_height;
1688 row->visible_height = p->h; 1539 row->visible_height = p->h;
1689 row->y -= rowY - p->y; 1540 row->y -= rowY - p->y;
1690 x_clip_to_row (w, row, -1, gc); 1541 x_clip_to_row (w, row, -1, face->gc);
1691 row->y = oldY; 1542 row->y = oldY;
1692 row->visible_height = oldVH; 1543 row->visible_height = oldVH;
1693 } 1544 }
1694 else 1545 else
1695 x_clip_to_row (w, row, -1, gc); 1546 x_clip_to_row (w, row, -1, face->gc);
1696 1547
1697 if (p->bx >= 0 && !p->overlay_p) 1548 if (p->bx >= 0 && !p->overlay_p)
1698 { 1549 {
@@ -1707,7 +1558,7 @@ x_draw_fringe_bitmap (w, row, p)
1707 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background); 1558 XSetForeground (FRAME_X_DISPLAY (f), face->gc, face->background);
1708#endif 1559#endif
1709 1560
1710 mac_erase_rectangle (window, face->gc, p->bx, p->by, p->nx, p->ny); 1561 mac_erase_rectangle (f, face->gc, p->bx, p->by, p->nx, p->ny);
1711 1562
1712#if 0 /* MAC_TODO: stipple */ 1563#if 0 /* MAC_TODO: stipple */
1713 if (!face->stipple) 1564 if (!face->stipple)
@@ -1726,12 +1577,12 @@ x_draw_fringe_bitmap (w, row, p)
1726 ? (p->overlay_p ? face->background 1577 ? (p->overlay_p ? face->background
1727 : f->output_data.mac->cursor_pixel) 1578 : f->output_data.mac->cursor_pixel)
1728 : face->foreground)); 1579 : face->foreground));
1729 mac_draw_bitmap (display, window, face->gc, p->x, p->y, 1580 mac_draw_bitmap (f, face->gc, p->x, p->y,
1730 p->wd, p->h, bits, p->overlay_p); 1581 p->wd, p->h, bits, p->overlay_p);
1731 XSetForeground (display, face->gc, gcv.foreground); 1582 XSetForeground (display, face->gc, gcv.foreground);
1732 } 1583 }
1733 1584
1734 mac_reset_clip_rectangles (display, gc); 1585 mac_reset_clip_rectangles (display, face->gc);
1735} 1586}
1736 1587
1737 1588
@@ -2282,7 +2133,7 @@ x_clear_glyph_string_rect (s, x, y, w, h)
2282 struct glyph_string *s; 2133 struct glyph_string *s;
2283 int x, y, w, h; 2134 int x, y, w, h;
2284{ 2135{
2285 mac_erase_rectangle (s->window, s->gc, x, y, w, h); 2136 mac_erase_rectangle (s->f, s->gc, x, y, w, h);
2286} 2137}
2287 2138
2288 2139
@@ -2364,9 +2215,8 @@ x_draw_glyph_string_foreground (s)
2364 for (i = 0; i < s->nchars; ++i) 2215 for (i = 0; i < s->nchars; ++i)
2365 { 2216 {
2366 struct glyph *g = s->first_glyph + i; 2217 struct glyph *g = s->first_glyph + i;
2367 mac_draw_rectangle (s->display, s->window, 2218 mac_draw_rectangle (s->f, s->gc, x, s->y,
2368 s->gc, x, s->y, g->pixel_width - 1, 2219 g->pixel_width - 1, s->height - 1);
2369 s->height - 1);
2370 x += g->pixel_width; 2220 x += g->pixel_width;
2371 } 2221 }
2372 } 2222 }
@@ -2403,21 +2253,21 @@ x_draw_glyph_string_foreground (s)
2403 || GC_FONT (s->gc)->mac_style 2253 || GC_FONT (s->gc)->mac_style
2404#endif 2254#endif
2405 ) 2255 )
2406 XDrawString16 (s->display, s->window, s->gc, x, 2256 mac_draw_string_16 (s->f, s->gc, x, s->ybase - boff,
2407 s->ybase - boff, s->char2b, s->nchars); 2257 s->char2b, s->nchars);
2408 else 2258 else
2409 XDrawString (s->display, s->window, s->gc, x, 2259 mac_draw_string (s->f, s->gc, x, s->ybase - boff,
2410 s->ybase - boff, char1b, s->nchars); 2260 char1b, s->nchars);
2411 } 2261 }
2412#if defined (MAC_OS8) && !USE_ATSUI 2262#if defined (MAC_OS8) && !USE_ATSUI
2413 else 2263 else
2414 { 2264 {
2415 if (s->two_byte_p) 2265 if (s->two_byte_p)
2416 XDrawImageString16 (s->display, s->window, s->gc, x, 2266 mac_draw_image_string_16 (s->f, s->gc, x, s->ybase - boff,
2417 s->ybase - boff, s->char2b, s->nchars); 2267 s->char2b, s->nchars);
2418 else 2268 else
2419 XDrawImageString (s->display, s->window, s->gc, x, 2269 mac_draw_image_string (s->f, s->gc, x, s->ybase - boff,
2420 s->ybase - boff, char1b, s->nchars); 2270 char1b, s->nchars);
2421 } 2271 }
2422#endif 2272#endif
2423 } 2273 }
@@ -2449,16 +2299,16 @@ x_draw_composite_glyph_string_foreground (s)
2449 if (s->font_not_found_p) 2299 if (s->font_not_found_p)
2450 { 2300 {
2451 if (s->gidx == 0) 2301 if (s->gidx == 0)
2452 mac_draw_rectangle (s->display, s->window, s->gc, x, s->y, 2302 mac_draw_rectangle (s->f, s->gc, x, s->y,
2453 s->width - 1, s->height - 1); 2303 s->width - 1, s->height - 1);
2454 } 2304 }
2455 else 2305 else
2456 { 2306 {
2457 for (i = 0; i < s->nchars; i++, ++s->gidx) 2307 for (i = 0; i < s->nchars; i++, ++s->gidx)
2458 XDrawString16 (s->display, s->window, s->gc, 2308 mac_draw_string_16 (s->f, s->gc,
2459 x + s->cmp->offsets[s->gidx * 2], 2309 x + s->cmp->offsets[s->gidx * 2],
2460 s->ybase - s->cmp->offsets[s->gidx * 2 + 1], 2310 s->ybase - s->cmp->offsets[s->gidx * 2 + 1],
2461 s->char2b + i, 1); 2311 s->char2b + i, 1);
2462 } 2312 }
2463} 2313}
2464 2314
@@ -2814,7 +2664,6 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2814 Rect *clip_rect; 2664 Rect *clip_rect;
2815{ 2665{
2816 Display *dpy = FRAME_MAC_DISPLAY (f); 2666 Display *dpy = FRAME_MAC_DISPLAY (f);
2817 Window window = FRAME_MAC_WINDOW (f);
2818 int i; 2667 int i;
2819 GC gc; 2668 GC gc;
2820 2669
@@ -2827,15 +2676,15 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2827 /* Top. */ 2676 /* Top. */
2828 if (top_p) 2677 if (top_p)
2829 for (i = 0; i < width; ++i) 2678 for (i = 0; i < width; ++i)
2830 XDrawLine (dpy, window, gc, 2679 mac_draw_line (f, gc,
2831 left_x + i * left_p, top_y + i, 2680 left_x + i * left_p, top_y + i,
2832 right_x - i * right_p, top_y + i); 2681 right_x - i * right_p, top_y + i);
2833 2682
2834 /* Left. */ 2683 /* Left. */
2835 if (left_p) 2684 if (left_p)
2836 for (i = 0; i < width; ++i) 2685 for (i = 0; i < width; ++i)
2837 XDrawLine (dpy, window, gc, 2686 mac_draw_line (f, gc,
2838 left_x + i, top_y + i, left_x + i, bottom_y - i); 2687 left_x + i, top_y + i, left_x + i, bottom_y - i);
2839 2688
2840 mac_reset_clip_rectangles (dpy, gc); 2689 mac_reset_clip_rectangles (dpy, gc);
2841 if (raised_p) 2690 if (raised_p)
@@ -2847,15 +2696,15 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
2847 /* Bottom. */ 2696 /* Bottom. */
2848 if (bot_p) 2697 if (bot_p)
2849 for (i = 0; i < width; ++i) 2698 for (i = 0; i < width; ++i)
2850 XDrawLine (dpy, window, gc, 2699 mac_draw_line (f, gc,
2851 left_x + i * left_p, bottom_y - i, 2700 left_x + i * left_p, bottom_y - i,
2852 right_x - i * right_p, bottom_y - i); 2701 right_x - i * right_p, bottom_y - i);
2853 2702
2854 /* Right. */ 2703 /* Right. */
2855 if (right_p) 2704 if (right_p)
2856 for (i = 0; i < width; ++i) 2705 for (i = 0; i < width; ++i)
2857 XDrawLine (dpy, window, gc, 2706 mac_draw_line (f, gc,
2858 right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1); 2707 right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1);
2859 2708
2860 mac_reset_clip_rectangles (dpy, gc); 2709 mac_reset_clip_rectangles (dpy, gc);
2861} 2710}
@@ -2882,22 +2731,22 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width,
2882 mac_set_clip_rectangles (s->display, s->gc, clip_rect, 1); 2731 mac_set_clip_rectangles (s->display, s->gc, clip_rect, 1);
2883 2732
2884 /* Top. */ 2733 /* Top. */
2885 XFillRectangle (s->display, s->window, s->gc, 2734 mac_fill_rectangle (s->f, s->gc, left_x, top_y,
2886 left_x, top_y, right_x - left_x + 1, width); 2735 right_x - left_x + 1, width);
2887 2736
2888 /* Left. */ 2737 /* Left. */
2889 if (left_p) 2738 if (left_p)
2890 XFillRectangle (s->display, s->window, s->gc, 2739 mac_fill_rectangle (s->f, s->gc, left_x, top_y,
2891 left_x, top_y, width, bottom_y - top_y + 1); 2740 width, bottom_y - top_y + 1);
2892 2741
2893 /* Bottom. */ 2742 /* Bottom. */
2894 XFillRectangle (s->display, s->window, s->gc, 2743 mac_fill_rectangle (s->f, s->gc, left_x, bottom_y - width + 1,
2895 left_x, bottom_y - width + 1, right_x - left_x + 1, width); 2744 right_x - left_x + 1, width);
2896 2745
2897 /* Right. */ 2746 /* Right. */
2898 if (right_p) 2747 if (right_p)
2899 XFillRectangle (s->display, s->window, s->gc, 2748 mac_fill_rectangle (s->f, s->gc, right_x - width + 1,
2900 right_x - width + 1, top_y, width, bottom_y - top_y + 1); 2749 top_y, width, bottom_y - top_y + 1);
2901 2750
2902 XSetForeground (s->display, s->gc, xgcv.foreground); 2751 XSetForeground (s->display, s->gc, xgcv.foreground);
2903 mac_reset_clip_rectangles (s->display, s->gc); 2752 mac_reset_clip_rectangles (s->display, s->gc);
@@ -2984,13 +2833,13 @@ x_draw_image_foreground (s)
2984 x_set_glyph_string_clipping (s); 2833 x_set_glyph_string_clipping (s);
2985 2834
2986 if (s->img->mask) 2835 if (s->img->mask)
2987 mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask, 2836 mac_copy_area_with_mask (s->img->pixmap, s->img->mask,
2988 s->window, s->gc, s->slice.x, s->slice.y, 2837 s->f, s->gc, s->slice.x, s->slice.y,
2989 s->slice.width, s->slice.height, x, y); 2838 s->slice.width, s->slice.height, x, y);
2990 else 2839 else
2991 { 2840 {
2992 mac_copy_area (s->display, s->img->pixmap, 2841 mac_copy_area (s->img->pixmap,
2993 s->window, s->gc, s->slice.x, s->slice.y, 2842 s->f, s->gc, s->slice.x, s->slice.y,
2994 s->slice.width, s->slice.height, x, y); 2843 s->slice.width, s->slice.height, x, y);
2995 2844
2996 /* When the image has a mask, we can expect that at 2845 /* When the image has a mask, we can expect that at
@@ -3003,8 +2852,7 @@ x_draw_image_foreground (s)
3003 { 2852 {
3004 int r = s->img->relief; 2853 int r = s->img->relief;
3005 if (r < 0) r = -r; 2854 if (r < 0) r = -r;
3006 mac_draw_rectangle (s->display, s->window, s->gc, 2855 mac_draw_rectangle (s->f, s->gc, x - r, y - r,
3007 x - r, y - r,
3008 s->slice.width + r*2 - 1, 2856 s->slice.width + r*2 - 1,
3009 s->slice.height + r*2 - 1); 2857 s->slice.height + r*2 - 1);
3010 } 2858 }
@@ -3012,7 +2860,7 @@ x_draw_image_foreground (s)
3012 } 2860 }
3013 else 2861 else
3014 /* Draw a rectangle if image could not be loaded. */ 2862 /* Draw a rectangle if image could not be loaded. */
3015 mac_draw_rectangle (s->display, s->window, s->gc, x, y, 2863 mac_draw_rectangle (s->f, s->gc, x, y,
3016 s->slice.width - 1, s->slice.height - 1); 2864 s->slice.width - 1, s->slice.height - 1);
3017} 2865}
3018 2866
@@ -3070,70 +2918,6 @@ x_draw_image_relief (s)
3070} 2918}
3071 2919
3072 2920
3073#if 0 /* TODO: figure out if we need to do this on Mac. */
3074/* Draw the foreground of image glyph string S to PIXMAP. */
3075
3076static void
3077x_draw_image_foreground_1 (s, pixmap)
3078 struct glyph_string *s;
3079 Pixmap pixmap;
3080{
3081 int x = 0;
3082 int y = s->ybase - s->y - image_ascent (s->img, s->face, &s->slice);
3083
3084 /* If first glyph of S has a left box line, start drawing it to the
3085 right of that line. */
3086 if (s->face->box != FACE_NO_BOX
3087 && s->first_glyph->left_box_line_p
3088 && s->slice.x == 0)
3089 x += abs (s->face->box_line_width);
3090
3091 /* If there is a margin around the image, adjust x- and y-position
3092 by that margin. */
3093 if (s->slice.x == 0)
3094 x += s->img->hmargin;
3095 if (s->slice.y == 0)
3096 y += s->img->vmargin;
3097
3098 if (s->img->pixmap)
3099 {
3100 if (s->img->mask)
3101 mac_copy_area_with_mask_to_pixmap (s->display, s->img->pixmap,
3102 s->img->mask, pixmap, s->gc,
3103 s->slice.x, s->slice.y,
3104 s->slice.width, s->slice.height,
3105 x, y);
3106 else
3107 {
3108 mac_copy_area_to_pixmap (s->display, s->img->pixmap, pixmap, s->gc,
3109 s->slice.x, s->slice.y,
3110 s->slice.width, s->slice.height,
3111 x, y);
3112
3113 /* When the image has a mask, we can expect that at
3114 least part of a mouse highlight or a block cursor will
3115 be visible. If the image doesn't have a mask, make
3116 a block cursor visible by drawing a rectangle around
3117 the image. I believe it's looking better if we do
3118 nothing here for mouse-face. */
3119 if (s->hl == DRAW_CURSOR)
3120 {
3121 int r = s->img->relief;
3122 if (r < 0) r = -r;
3123 mac_draw_rectangle (s->display, s->window, s->gc, x - r, y - r,
3124 s->slice.width + r*2 - 1,
3125 s->slice.height + r*2 - 1);
3126 }
3127 }
3128 }
3129 else
3130 /* Draw a rectangle if image could not be loaded. */
3131 mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y,
3132 s->slice.width - 1, s->slice.height - 1);
3133}
3134#endif
3135
3136
3137/* Draw part of the background of glyph string S. X, Y, W, and H 2921/* Draw part of the background of glyph string S. X, Y, W, and H
3138 give the rectangle to draw. */ 2922 give the rectangle to draw. */
3139 2923
@@ -3203,62 +2987,13 @@ x_draw_image_glyph_string (s)
3203 if (s->slice.y == 0) 2987 if (s->slice.y == 0)
3204 y += box_line_vwidth; 2988 y += box_line_vwidth;
3205 2989
3206#if 0 /* TODO: figure out if we need to do this on Mac. */ 2990 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
3207 if (s->img->mask)
3208 {
3209 /* Create a pixmap as large as the glyph string. Fill it
3210 with the background color. Copy the image to it, using
3211 its mask. Copy the temporary pixmap to the display. */
3212 int depth = one_mac_display_info.n_planes;
3213
3214 /* Create a pixmap as large as the glyph string. */
3215 pixmap = XCreatePixmap (s->display, s->window,
3216 s->background_width,
3217 s->height, depth);
3218
3219 /* Fill the pixmap with the background color/stipple. */
3220#if 0 /* TODO: stipple */
3221 if (s->stippled_p)
3222 {
3223 /* Fill background with a stipple pattern. */
3224 XSetFillStyle (s->display, s->gc, FillOpaqueStippled);
3225 XFillRectangle (s->display, pixmap, s->gc,
3226 0, 0, s->background_width, s->height);
3227 XSetFillStyle (s->display, s->gc, FillSolid);
3228 }
3229 else
3230#endif
3231 {
3232 XGCValues xgcv;
3233 XGetGCValues (s->display, s->gc, GCForeground | GCBackground,
3234 &xgcv);
3235 XSetForeground (s->display, s->gc, xgcv.background);
3236 mac_fill_rectangle_to_pixmap (s->display, pixmap, s->gc,
3237 0, 0, s->background_width,
3238 s->height);
3239 XSetForeground (s->display, s->gc, xgcv.foreground);
3240 }
3241 }
3242 else
3243#endif
3244 x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height);
3245 2991
3246 s->background_filled_p = 1; 2992 s->background_filled_p = 1;
3247 } 2993 }
3248 2994
3249 /* Draw the foreground. */ 2995 /* Draw the foreground. */
3250#if 0 /* TODO: figure out if we need to do this on Mac. */ 2996 x_draw_image_foreground (s);
3251 if (pixmap != 0)
3252 {
3253 x_draw_image_foreground_1 (s, pixmap);
3254 x_set_glyph_string_clipping (s);
3255 mac_copy_area (s->display, pixmap, s->window, s->gc,
3256 0, 0, s->background_width, s->height, s->x, s->y);
3257 XFreePixmap (s->display, pixmap);
3258 }
3259 else
3260#endif
3261 x_draw_image_foreground (s);
3262 2997
3263 /* If we must draw a relief around the image, do it. */ 2998 /* If we must draw a relief around the image, do it. */
3264 if (s->img->relief 2999 if (s->img->relief
@@ -3317,7 +3052,7 @@ x_draw_stretch_glyph_string (s)
3317 } 3052 }
3318 else 3053 else
3319#endif /* MAC_TODO */ 3054#endif /* MAC_TODO */
3320 mac_erase_rectangle (s->window, gc, x, y, w, h); 3055 mac_erase_rectangle (s->f, gc, x, y, w, h);
3321 } 3056 }
3322 } 3057 }
3323 else if (!s->background_filled_p) 3058 else if (!s->background_filled_p)
@@ -3408,15 +3143,15 @@ x_draw_glyph_string (s)
3408 unsigned long dy = s->height - h; 3143 unsigned long dy = s->height - h;
3409 3144
3410 if (s->face->underline_defaulted_p) 3145 if (s->face->underline_defaulted_p)
3411 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3146 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3412 s->width, h); 3147 s->width, h);
3413 else 3148 else
3414 { 3149 {
3415 XGCValues xgcv; 3150 XGCValues xgcv;
3416 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3151 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3417 XSetForeground (s->display, s->gc, s->face->underline_color); 3152 XSetForeground (s->display, s->gc, s->face->underline_color);
3418 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3153 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3419 s->width, h); 3154 s->width, h);
3420 XSetForeground (s->display, s->gc, xgcv.foreground); 3155 XSetForeground (s->display, s->gc, xgcv.foreground);
3421 } 3156 }
3422 } 3157 }
@@ -3427,15 +3162,15 @@ x_draw_glyph_string (s)
3427 unsigned long dy = 0, h = 1; 3162 unsigned long dy = 0, h = 1;
3428 3163
3429 if (s->face->overline_color_defaulted_p) 3164 if (s->face->overline_color_defaulted_p)
3430 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3165 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3431 s->width, h); 3166 s->width, h);
3432 else 3167 else
3433 { 3168 {
3434 XGCValues xgcv; 3169 XGCValues xgcv;
3435 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3170 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3436 XSetForeground (s->display, s->gc, s->face->overline_color); 3171 XSetForeground (s->display, s->gc, s->face->overline_color);
3437 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3172 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3438 s->width, h); 3173 s->width, h);
3439 XSetForeground (s->display, s->gc, xgcv.foreground); 3174 XSetForeground (s->display, s->gc, xgcv.foreground);
3440 } 3175 }
3441 } 3176 }
@@ -3447,15 +3182,15 @@ x_draw_glyph_string (s)
3447 unsigned long dy = (s->height - h) / 2; 3182 unsigned long dy = (s->height - h) / 2;
3448 3183
3449 if (s->face->strike_through_color_defaulted_p) 3184 if (s->face->strike_through_color_defaulted_p)
3450 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3185 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3451 s->width, h); 3186 s->width, h);
3452 else 3187 else
3453 { 3188 {
3454 XGCValues xgcv; 3189 XGCValues xgcv;
3455 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3190 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3456 XSetForeground (s->display, s->gc, s->face->strike_through_color); 3191 XSetForeground (s->display, s->gc, s->face->strike_through_color);
3457 XFillRectangle (s->display, s->window, s->gc, s->x, s->y + dy, 3192 mac_fill_rectangle (s->f, s->gc, s->x, s->y + dy,
3458 s->width, h); 3193 s->width, h);
3459 XSetForeground (s->display, s->gc, xgcv.foreground); 3194 XSetForeground (s->display, s->gc, xgcv.foreground);
3460 } 3195 }
3461 } 3196 }
@@ -3476,8 +3211,7 @@ mac_shift_glyphs_for_insert (f, x, y, width, height, shift_by)
3476 struct frame *f; 3211 struct frame *f;
3477 int x, y, width, height, shift_by; 3212 int x, y, width, height, shift_by;
3478{ 3213{
3479 mac_scroll_area (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3214 mac_scroll_area (f, f->output_data.mac->normal_gc,
3480 f->output_data.mac->normal_gc,
3481 x, y, width, height, 3215 x, y, width, height,
3482 x + shift_by, y); 3216 x + shift_by, y);
3483} 3217}
@@ -3515,7 +3249,7 @@ x_clear_frame ()
3515 /* We don't set the output cursor here because there will always 3249 /* We don't set the output cursor here because there will always
3516 follow an explicit cursor_to. */ 3250 follow an explicit cursor_to. */
3517 BLOCK_INPUT; 3251 BLOCK_INPUT;
3518 XClearWindow (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f)); 3252 mac_clear_window (f);
3519 3253
3520 /* We have to clear the scroll bars, too. If we have changed 3254 /* We have to clear the scroll bars, too. If we have changed
3521 colors or something like that, then they should be notified. */ 3255 colors or something like that, then they should be notified. */
@@ -3605,21 +3339,18 @@ XTflash (f)
3605 /* If window is tall, flash top and bottom line. */ 3339 /* If window is tall, flash top and bottom line. */
3606 if (height > 3 * FRAME_LINE_HEIGHT (f)) 3340 if (height > 3 * FRAME_LINE_HEIGHT (f))
3607 { 3341 {
3608 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3342 mac_invert_rectangle (f, flash_left,
3609 flash_left,
3610 (FRAME_INTERNAL_BORDER_WIDTH (f) 3343 (FRAME_INTERNAL_BORDER_WIDTH (f)
3611 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)), 3344 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
3612 width, flash_height); 3345 width, flash_height);
3613 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3346 mac_invert_rectangle (f, flash_left,
3614 flash_left,
3615 (height - flash_height 3347 (height - flash_height
3616 - FRAME_INTERNAL_BORDER_WIDTH (f)), 3348 - FRAME_INTERNAL_BORDER_WIDTH (f)),
3617 width, flash_height); 3349 width, flash_height);
3618 } 3350 }
3619 else 3351 else
3620 /* If it is short, flash it all. */ 3352 /* If it is short, flash it all. */
3621 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3353 mac_invert_rectangle (f, flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3622 flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3623 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); 3354 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
3624 3355
3625 x_flush (f); 3356 x_flush (f);
@@ -3659,21 +3390,18 @@ XTflash (f)
3659 /* If window is tall, flash top and bottom line. */ 3390 /* If window is tall, flash top and bottom line. */
3660 if (height > 3 * FRAME_LINE_HEIGHT (f)) 3391 if (height > 3 * FRAME_LINE_HEIGHT (f))
3661 { 3392 {
3662 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3393 mac_invert_rectangle (f, flash_left,
3663 flash_left,
3664 (FRAME_INTERNAL_BORDER_WIDTH (f) 3394 (FRAME_INTERNAL_BORDER_WIDTH (f)
3665 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)), 3395 + FRAME_TOOL_BAR_LINES (f) * FRAME_LINE_HEIGHT (f)),
3666 width, flash_height); 3396 width, flash_height);
3667 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3397 mac_invert_rectangle (f, flash_left,
3668 flash_left,
3669 (height - flash_height 3398 (height - flash_height
3670 - FRAME_INTERNAL_BORDER_WIDTH (f)), 3399 - FRAME_INTERNAL_BORDER_WIDTH (f)),
3671 width, flash_height); 3400 width, flash_height);
3672 } 3401 }
3673 else 3402 else
3674 /* If it is short, flash it all. */ 3403 /* If it is short, flash it all. */
3675 mac_invert_rectangle (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3404 mac_invert_rectangle (f, flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3676 flash_left, FRAME_INTERNAL_BORDER_WIDTH (f),
3677 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f)); 3405 width, height - 2 * FRAME_INTERNAL_BORDER_WIDTH (f));
3678 3406
3679 x_flush (f); 3407 x_flush (f);
@@ -3778,11 +3506,10 @@ x_scroll_run (w, run)
3778 updated_window = w; 3506 updated_window = w;
3779 x_clear_cursor (w); 3507 x_clear_cursor (w);
3780 3508
3781 mac_scroll_area (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 3509 mac_scroll_area (f, f->output_data.mac->normal_gc,
3782 f->output_data.mac->normal_gc, 3510 x, from_y,
3783 x, from_y, 3511 width, height,
3784 width, height, 3512 x, to_y);
3785 x, to_y);
3786 3513
3787 UNBLOCK_INPUT; 3514 UNBLOCK_INPUT;
3788} 3515}
@@ -4829,8 +4556,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
4829 if (NILP (w->vertical_scroll_bar)) 4556 if (NILP (w->vertical_scroll_bar))
4830 { 4557 {
4831 BLOCK_INPUT; 4558 BLOCK_INPUT;
4832 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 4559 mac_clear_area (f, left, top, width, height);
4833 left, top, width, height, 0);
4834 UNBLOCK_INPUT; 4560 UNBLOCK_INPUT;
4835 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height, disp_top, 4561 bar = x_scroll_bar_create (w, top, sb_left, sb_width, height, disp_top,
4836 disp_height); 4562 disp_height);
@@ -4854,14 +4580,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
4854 { 4580 {
4855 /* Since toolkit scroll bars are smaller than the space reserved 4581 /* Since toolkit scroll bars are smaller than the space reserved
4856 for them on the frame, we have to clear "under" them. */ 4582 for them on the frame, we have to clear "under" them. */
4857 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 4583 mac_clear_area (f, left, top, width, height);
4858 left, top, width, height, 0);
4859
4860#if 0
4861 if (sb_left + sb_width >= FRAME_PIXEL_WIDTH (f))
4862 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
4863 sb_left - 1, top, 1, height, 0);
4864#endif
4865 4584
4866 HideControl (ch); 4585 HideControl (ch);
4867 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top); 4586 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top);
@@ -5294,7 +5013,7 @@ x_draw_hollow_cursor (w, row)
5294 5013
5295 /* Set clipping, draw the rectangle, and reset clipping again. */ 5014 /* Set clipping, draw the rectangle, and reset clipping again. */
5296 x_clip_to_row (w, row, TEXT_AREA, gc); 5015 x_clip_to_row (w, row, TEXT_AREA, gc);
5297 mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h); 5016 mac_draw_rectangle (f, gc, x, y, wd, h);
5298 mac_reset_clip_rectangles (dpy, gc); 5017 mac_reset_clip_rectangles (dpy, gc);
5299} 5018}
5300 5019
@@ -5367,17 +5086,17 @@ x_draw_bar_cursor (w, row, width, kind)
5367 x_clip_to_row (w, row, TEXT_AREA, gc); 5086 x_clip_to_row (w, row, TEXT_AREA, gc);
5368 5087
5369 if (kind == BAR_CURSOR) 5088 if (kind == BAR_CURSOR)
5370 XFillRectangle (dpy, window, gc, 5089 mac_fill_rectangle (f, gc,
5371 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x), 5090 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
5372 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y), 5091 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
5373 width, row->height); 5092 width, row->height);
5374 else 5093 else
5375 XFillRectangle (dpy, window, gc, 5094 mac_fill_rectangle (f, gc,
5376 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x), 5095 WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x),
5377 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y + 5096 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y +
5378 row->height - width), 5097 row->height - width),
5379 cursor_glyph->pixel_width, 5098 cursor_glyph->pixel_width,
5380 width); 5099 width);
5381 5100
5382 mac_reset_clip_rectangles (dpy, gc); 5101 mac_reset_clip_rectangles (dpy, gc);
5383 } 5102 }
@@ -5402,8 +5121,7 @@ mac_clear_frame_area (f, x, y, width, height)
5402 struct frame *f; 5121 struct frame *f;
5403 int x, y, width, height; 5122 int x, y, width, height;
5404{ 5123{
5405 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 5124 mac_clear_area (f, x, y, width, height);
5406 x, y, width, height, 0);
5407} 5125}
5408 5126
5409 5127