aboutsummaryrefslogtreecommitdiffstats
path: root/src/macterm.c
diff options
context:
space:
mode:
authorMiles Bader2008-04-23 05:55:42 +0000
committerMiles Bader2008-04-23 05:55:42 +0000
commita113b3ca322fd73d97d0d9d69c9f48dc13fb326a (patch)
tree37b3ad22a198a83f68738ef86aec187bb6d926d9 /src/macterm.c
parente96a8d6dc0ffc35cf6c02924de2453c69fa8f6fe (diff)
parent81fe843b5a3cc7708e0800aeb5bc0dbe448e800a (diff)
downloademacs-a113b3ca322fd73d97d0d9d69c9f48dc13fb326a.tar.gz
emacs-a113b3ca322fd73d97d0d9d69c9f48dc13fb326a.zip
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1121
Diffstat (limited to 'src/macterm.c')
-rw-r--r--src/macterm.c122
1 files changed, 67 insertions, 55 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 842e1844f50..f4715c7f772 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -351,7 +351,7 @@ init_cg_color ()
351 if (CGColorGetTypeID != NULL) 351 if (CGColorGetTypeID != NULL)
352#endif 352#endif
353 { 353 {
354 float rgba[] = {0.0f, 0.0f, 0.0f, 1.0f}; 354 CGFloat rgba[] = {0.0f, 0.0f, 0.0f, 1.0f};
355 355
356 mac_cg_color_black = CGColorCreate (mac_cg_color_space_rgb, rgba); 356 mac_cg_color_black = CGColorCreate (mac_cg_color_space_rgb, rgba);
357 } 357 }
@@ -460,7 +460,7 @@ mac_draw_line (f, gc, x1, y1, x2, y2)
460{ 460{
461#if USE_CG_DRAWING 461#if USE_CG_DRAWING
462 CGContextRef context; 462 CGContextRef context;
463 float gx1 = x1, gy1 = y1, gx2 = x2, gy2 = y2; 463 CGFloat gx1 = x1, gy1 = y1, gx2 = x2, gy2 = y2;
464 464
465 if (y1 != y2) 465 if (y1 != y2)
466 gx1 += 0.5f, gx2 += 0.5f; 466 gx1 += 0.5f, gx2 += 0.5f;
@@ -553,7 +553,7 @@ mac_erase_rectangle (f, gc, x, y, width, height)
553 553
554 context = mac_begin_cg_clip (f, gc); 554 context = mac_begin_cg_clip (f, gc);
555 CG_SET_FILL_COLOR_WITH_GC_BACKGROUND (context, gc); 555 CG_SET_FILL_COLOR_WITH_GC_BACKGROUND (context, gc);
556 CGContextFillRect (context, CGRectMake (x, y, width, height)); 556 CGContextFillRect (context, mac_rect_make (f, x, y, width, height));
557 mac_end_cg_clip (f); 557 mac_end_cg_clip (f);
558 } 558 }
559#else 559#else
@@ -632,8 +632,8 @@ mac_draw_cg_image (image, f, gc, src_x, src_y, width, height,
632 int dest_x, dest_y, overlay_p; 632 int dest_x, dest_y, overlay_p;
633{ 633{
634 CGContextRef context; 634 CGContextRef context;
635 float port_height = FRAME_PIXEL_HEIGHT (f); 635 CGFloat port_height = FRAME_PIXEL_HEIGHT (f);
636 CGRect dest_rect = CGRectMake (dest_x, dest_y, width, height); 636 CGRect dest_rect = mac_rect_make (f, dest_x, dest_y, width, height);
637 637
638 context = mac_begin_cg_clip (f, gc); 638 context = mac_begin_cg_clip (f, gc);
639 if (!overlay_p) 639 if (!overlay_p)
@@ -647,11 +647,11 @@ mac_draw_cg_image (image, f, gc, src_x, src_y, width, height,
647 if (CGImageIsMask (image)) 647 if (CGImageIsMask (image))
648 CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc); 648 CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc);
649 CGContextDrawImage (context, 649 CGContextDrawImage (context,
650 CGRectMake (dest_x - src_x, 650 mac_rect_make (f, dest_x - src_x,
651 port_height - (dest_y - src_y 651 port_height - (dest_y - src_y
652 + CGImageGetHeight (image)), 652 + CGImageGetHeight (image)),
653 CGImageGetWidth (image), 653 CGImageGetWidth (image),
654 CGImageGetHeight (image)), 654 CGImageGetHeight (image)),
655 image); 655 image);
656 mac_end_cg_clip (f); 656 mac_end_cg_clip (f);
657} 657}
@@ -744,7 +744,7 @@ mac_free_bitmap (bitmap)
744Pixmap 744Pixmap
745XCreatePixmap (display, w, width, height, depth) 745XCreatePixmap (display, w, width, height, depth)
746 Display *display; 746 Display *display;
747 WindowRef w; 747 Window w;
748 unsigned int width, height; 748 unsigned int width, height;
749 unsigned int depth; 749 unsigned int depth;
750{ 750{
@@ -752,8 +752,9 @@ XCreatePixmap (display, w, width, height, depth)
752 Rect r; 752 Rect r;
753 QDErr err; 753 QDErr err;
754 754
755#ifdef MAC_OS8
755 SetPortWindowPort (w); 756 SetPortWindowPort (w);
756 757#endif
757 SetRect (&r, 0, 0, width, height); 758 SetRect (&r, 0, 0, width, height);
758#if !defined (WORDS_BIG_ENDIAN) && USE_CG_DRAWING 759#if !defined (WORDS_BIG_ENDIAN) && USE_CG_DRAWING
759 if (depth == 1) 760 if (depth == 1)
@@ -773,7 +774,7 @@ XCreatePixmap (display, w, width, height, depth)
773Pixmap 774Pixmap
774XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth) 775XCreatePixmapFromBitmapData (display, w, data, width, height, fg, bg, depth)
775 Display *display; 776 Display *display;
776 WindowRef w; 777 Window w;
777 char *data; 778 char *data;
778 unsigned int width, height; 779 unsigned int width, height;
779 unsigned long fg, bg; 780 unsigned long fg, bg;
@@ -838,7 +839,7 @@ mac_fill_rectangle (f, gc, x, y, width, height)
838 839
839 context = mac_begin_cg_clip (f, gc); 840 context = mac_begin_cg_clip (f, gc);
840 CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc); 841 CG_SET_FILL_COLOR_WITH_GC_FOREGROUND (context, gc);
841 CGContextFillRect (context, CGRectMake (x, y, width, height)); 842 CGContextFillRect (context, mac_rect_make (f, x, y, width, height));
842 mac_end_cg_clip (f); 843 mac_end_cg_clip (f);
843#else 844#else
844 Rect r; 845 Rect r;
@@ -887,7 +888,26 @@ mac_invert_rectangle (f, x, y, width, height)
887 int x, y; 888 int x, y;
888 unsigned int width, height; 889 unsigned int width, height;
889{ 890{
890 Rect r; 891#if USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1040
892#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 && MAC_OS_X_VERSION_MIN_REQUIRED >= 1020
893 if (CGContextSetBlendMode != NULL)
894#endif
895 {
896 CGContextRef context;
897
898 context = mac_begin_cg_clip (f, NULL);
899 CGContextSetRGBFillColor (context, 1.0f, 1.0f, 1.0f, 1.0f);
900 CGContextSetBlendMode (context, kCGBlendModeDifference);
901 CGContextFillRect (context, mac_rect_make (f, x, y, width, height));
902 mac_end_cg_clip (f);
903 }
904#if MAC_OS_X_VERSION_MIN_REQUIRED < 1040 && MAC_OS_X_VERSION_MIN_REQUIRED >= 1020
905 else /* CGContextSetBlendMode == NULL */
906#endif
907#endif /* USE_CG_DRAWING && MAC_OS_X_VERSION_MAX_ALLOWED >= 1040 */
908#if !USE_CG_DRAWING || MAC_OS_X_VERSION_MAX_ALLOWED < 1040 || (MAC_OS_X_VERSION_MIN_REQUIRED < 1040 && MAC_OS_X_VERSION_MIN_REQUIRED >= 1020)
909 {
910 Rect r;
891 911
892#if USE_CG_DRAWING 912#if USE_CG_DRAWING
893 mac_prepare_for_quickdraw (f); 913 mac_prepare_for_quickdraw (f);
@@ -1018,7 +1038,7 @@ mac_draw_image_string_atsui (f, gc, x, y, buf, nchars, bg_width,
1018 else 1038 else
1019 { 1039 {
1020 static CGContextRef context; 1040 static CGContextRef context;
1021 float port_height = FRAME_PIXEL_HEIGHT (f); 1041 CGFloat port_height = FRAME_PIXEL_HEIGHT (f);
1022 static const ATSUAttributeTag tags[] = {kATSUCGContextTag}; 1042 static const ATSUAttributeTag tags[] = {kATSUCGContextTag};
1023 static const ByteCount sizes[] = {sizeof (CGContextRef)}; 1043 static const ByteCount sizes[] = {sizeof (CGContextRef)};
1024 static const ATSUAttributeValuePtr values[] = {&context}; 1044 static const ATSUAttributeValuePtr values[] = {&context};
@@ -1042,9 +1062,10 @@ mac_draw_image_string_atsui (f, gc, x, y, buf, nchars, bg_width,
1042 { 1062 {
1043 CG_SET_FILL_COLOR_WITH_GC_BACKGROUND (context, gc); 1063 CG_SET_FILL_COLOR_WITH_GC_BACKGROUND (context, gc);
1044 CGContextFillRect (context, 1064 CGContextFillRect (context,
1045 CGRectMake (x, y - FONT_BASE (GC_FONT (gc)), 1065 mac_rect_make (f,
1046 bg_width, 1066 x, y - FONT_BASE (GC_FONT (gc)),
1047 FONT_HEIGHT (GC_FONT (gc)))); 1067 bg_width,
1068 FONT_HEIGHT (GC_FONT (gc))));
1048 } 1069 }
1049 CGContextScaleCTM (context, 1, -1); 1070 CGContextScaleCTM (context, 1, -1);
1050 CGContextTranslateCTM (context, 0, -port_height); 1071 CGContextTranslateCTM (context, 0, -port_height);
@@ -1388,7 +1409,7 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width, overstrike_p)
1388 XChar2b *buf; 1409 XChar2b *buf;
1389 int nchars, bg_width, overstrike_p; 1410 int nchars, bg_width, overstrike_p;
1390{ 1411{
1391 float port_height, gx, gy; 1412 CGFloat port_height, gx, gy;
1392 int i; 1413 int i;
1393 CGContextRef context; 1414 CGContextRef context;
1394 CGGlyph *glyphs; 1415 CGGlyph *glyphs;
@@ -1430,8 +1451,8 @@ mac_draw_image_string_cg (f, gc, x, y, buf, nchars, bg_width, overstrike_p)
1430 CG_SET_FILL_COLOR_WITH_GC_BACKGROUND (context, gc); 1451 CG_SET_FILL_COLOR_WITH_GC_BACKGROUND (context, gc);
1431 CGContextFillRect 1452 CGContextFillRect
1432 (context, 1453 (context,
1433 CGRectMake (gx, y - FONT_BASE (GC_FONT (gc)), 1454 mac_rect_make (f, gx, y - FONT_BASE (GC_FONT (gc)),
1434 bg_width, FONT_HEIGHT (GC_FONT (gc)))); 1455 bg_width, FONT_HEIGHT (GC_FONT (gc))));
1435 } 1456 }
1436 CGContextScaleCTM (context, 1, -1); 1457 CGContextScaleCTM (context, 1, -1);
1437 CGContextTranslateCTM (context, 0, -port_height); 1458 CGContextTranslateCTM (context, 0, -port_height);
@@ -1733,7 +1754,7 @@ XSetForeground (display, gc, color)
1733 } 1754 }
1734 else 1755 else
1735 { 1756 {
1736 float rgba[4]; 1757 CGFloat rgba[4];
1737 1758
1738 rgba[0] = gc->fore_color.red / 65535.0f; 1759 rgba[0] = gc->fore_color.red / 65535.0f;
1739 rgba[1] = gc->fore_color.green / 65535.0f; 1760 rgba[1] = gc->fore_color.green / 65535.0f;
@@ -1774,7 +1795,7 @@ XSetBackground (display, gc, color)
1774 } 1795 }
1775 else 1796 else
1776 { 1797 {
1777 float rgba[4]; 1798 CGFloat rgba[4];
1778 1799
1779 rgba[0] = gc->back_color.red / 65535.0f; 1800 rgba[0] = gc->back_color.red / 65535.0f;
1780 rgba[1] = gc->back_color.green / 65535.0f; 1801 rgba[1] = gc->back_color.green / 65535.0f;
@@ -1803,8 +1824,8 @@ XSetFont (display, gc, font)
1803/* Mac replacement for XSetClipRectangles. */ 1824/* Mac replacement for XSetClipRectangles. */
1804 1825
1805static void 1826static void
1806mac_set_clip_rectangles (display, gc, rectangles, n) 1827mac_set_clip_rectangles (f, gc, rectangles, n)
1807 Display *display; 1828 struct frame *f;
1808 GC gc; 1829 GC gc;
1809 Rect *rectangles; 1830 Rect *rectangles;
1810 int n; 1831 int n;
@@ -1836,9 +1857,9 @@ mac_set_clip_rectangles (display, gc, rectangles, n)
1836 { 1857 {
1837 Rect *rect = rectangles + i; 1858 Rect *rect = rectangles + i;
1838 1859
1839 gc->clip_rects[i] = CGRectMake (rect->left, rect->top, 1860 gc->clip_rects[i] = mac_rect_make (f, rect->left, rect->top,
1840 rect->right - rect->left, 1861 rect->right - rect->left,
1841 rect->bottom - rect->top); 1862 rect->bottom - rect->top);
1842 } 1863 }
1843#endif 1864#endif
1844} 1865}
@@ -1847,8 +1868,8 @@ mac_set_clip_rectangles (display, gc, rectangles, n)
1847/* Mac replacement for XSetClipMask. */ 1868/* Mac replacement for XSetClipMask. */
1848 1869
1849static INLINE void 1870static INLINE void
1850mac_reset_clip_rectangles (display, gc) 1871mac_reset_clip_rectangles (f, gc)
1851 Display *display; 1872 struct frame *f;
1852 GC gc; 1873 GC gc;
1853{ 1874{
1854 gc->n_clip_rects = 0; 1875 gc->n_clip_rects = 0;
@@ -2338,7 +2359,7 @@ x_draw_fringe_bitmap (w, row, p)
2338 XSetForeground (display, face->gc, gcv.foreground); 2359 XSetForeground (display, face->gc, gcv.foreground);
2339 } 2360 }
2340 2361
2341 mac_reset_clip_rectangles (display, face->gc); 2362 mac_reset_clip_rectangles (f, face->gc);
2342} 2363}
2343 2364
2344#if USE_CG_DRAWING 2365#if USE_CG_DRAWING
@@ -2852,7 +2873,7 @@ x_set_glyph_string_clipping (s)
2852 int n; 2873 int n;
2853 2874
2854 n = get_glyph_string_clip_rects (s, rects, MAX_CLIP_RECTS); 2875 n = get_glyph_string_clip_rects (s, rects, MAX_CLIP_RECTS);
2855 mac_set_clip_rectangles (s->display, s->gc, rects, n); 2876 mac_set_clip_rectangles (s->f, s->gc, rects, n);
2856} 2877}
2857 2878
2858 2879
@@ -3442,7 +3463,7 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
3442 gc = f->output_data.mac->white_relief.gc; 3463 gc = f->output_data.mac->white_relief.gc;
3443 else 3464 else
3444 gc = f->output_data.mac->black_relief.gc; 3465 gc = f->output_data.mac->black_relief.gc;
3445 mac_set_clip_rectangles (dpy, gc, clip_rect, 1); 3466 mac_set_clip_rectangles (f, gc, clip_rect, 1);
3446 3467
3447 /* Top. */ 3468 /* Top. */
3448 if (top_p) 3469 if (top_p)
@@ -3457,12 +3478,12 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
3457 mac_draw_line (f, gc, 3478 mac_draw_line (f, gc,
3458 left_x + i, top_y + i, left_x + i, bottom_y - i + 1); 3479 left_x + i, top_y + i, left_x + i, bottom_y - i + 1);
3459 3480
3460 mac_reset_clip_rectangles (dpy, gc); 3481 mac_reset_clip_rectangles (f, gc);
3461 if (raised_p) 3482 if (raised_p)
3462 gc = f->output_data.mac->black_relief.gc; 3483 gc = f->output_data.mac->black_relief.gc;
3463 else 3484 else
3464 gc = f->output_data.mac->white_relief.gc; 3485 gc = f->output_data.mac->white_relief.gc;
3465 mac_set_clip_rectangles (dpy, gc, clip_rect, 1); 3486 mac_set_clip_rectangles (f, gc, clip_rect, 1);
3466 3487
3467 /* Bottom. */ 3488 /* Bottom. */
3468 if (bot_p) 3489 if (bot_p)
@@ -3477,7 +3498,7 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width,
3477 mac_draw_line (f, gc, 3498 mac_draw_line (f, gc,
3478 right_x - i, top_y + i + 1, right_x - i, bottom_y - i); 3499 right_x - i, top_y + i + 1, right_x - i, bottom_y - i);
3479 3500
3480 mac_reset_clip_rectangles (dpy, gc); 3501 mac_reset_clip_rectangles (f, gc);
3481} 3502}
3482 3503
3483 3504
@@ -3499,7 +3520,7 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width,
3499 3520
3500 XGetGCValues (s->display, s->gc, GCForeground, &xgcv); 3521 XGetGCValues (s->display, s->gc, GCForeground, &xgcv);
3501 XSetForeground (s->display, s->gc, s->face->box_color); 3522 XSetForeground (s->display, s->gc, s->face->box_color);
3502 mac_set_clip_rectangles (s->display, s->gc, clip_rect, 1); 3523 mac_set_clip_rectangles (s->f, s->gc, clip_rect, 1);
3503 3524
3504 /* Top. */ 3525 /* Top. */
3505 mac_fill_rectangle (s->f, s->gc, left_x, top_y, 3526 mac_fill_rectangle (s->f, s->gc, left_x, top_y,
@@ -3520,7 +3541,7 @@ x_draw_box_rect (s, left_x, top_y, right_x, bottom_y, width,
3520 top_y, width, bottom_y - top_y + 1); 3541 top_y, width, bottom_y - top_y + 1);
3521 3542
3522 XSetForeground (s->display, s->gc, xgcv.foreground); 3543 XSetForeground (s->display, s->gc, xgcv.foreground);
3523 mac_reset_clip_rectangles (s->display, s->gc); 3544 mac_reset_clip_rectangles (s->f, s->gc);
3524} 3545}
3525 3546
3526 3547
@@ -3829,7 +3850,7 @@ x_draw_stretch_glyph_string (s)
3829 gc = s->face->gc; 3850 gc = s->face->gc;
3830 3851
3831 get_glyph_string_clip_rect (s, &r); 3852 get_glyph_string_clip_rect (s, &r);
3832 mac_set_clip_rectangles (s->display, gc, &r, 1); 3853 mac_set_clip_rectangles (s->f, gc, &r, 1);
3833 3854
3834#if 0 /* MAC_TODO: stipple */ 3855#if 0 /* MAC_TODO: stipple */
3835 if (s->face->stipple) 3856 if (s->face->stipple)
@@ -4029,7 +4050,7 @@ x_draw_glyph_string (s)
4029 } 4050 }
4030 4051
4031 /* Reset clipping. */ 4052 /* Reset clipping. */
4032 mac_reset_clip_rectangles (s->display, s->gc); 4053 mac_reset_clip_rectangles (s->f, s->gc);
4033} 4054}
4034 4055
4035/* Shift display to make room for inserted glyphs. */ 4056/* Shift display to make room for inserted glyphs. */
@@ -6409,7 +6430,7 @@ x_draw_bar_cursor (w, row, width, kind)
6409 cursor_glyph->pixel_width, 6430 cursor_glyph->pixel_width,
6410 width); 6431 width);
6411 6432
6412 mac_reset_clip_rectangles (dpy, gc); 6433 mac_reset_clip_rectangles (f, gc);
6413 } 6434 }
6414} 6435}
6415 6436
@@ -6739,7 +6760,6 @@ mac_handle_size_change (f, pixelwidth, pixelheight)
6739 change_frame_size (f, rows, cols, 0, 1, 0); 6760 change_frame_size (f, rows, cols, 0, 1, 0);
6740 FRAME_PIXEL_WIDTH (f) = pixelwidth; 6761 FRAME_PIXEL_WIDTH (f) = pixelwidth;
6741 FRAME_PIXEL_HEIGHT (f) = pixelheight; 6762 FRAME_PIXEL_HEIGHT (f) = pixelheight;
6742 SET_FRAME_GARBAGED (f);
6743 6763
6744 /* If cursor was outside the new size, mark it as off. */ 6764 /* If cursor was outside the new size, mark it as off. */
6745 mark_window_cursors_off (XWINDOW (f->root_window)); 6765 mark_window_cursors_off (XWINDOW (f->root_window));
@@ -6772,7 +6792,6 @@ void
6772x_calc_absolute_position (f) 6792x_calc_absolute_position (f)
6773 struct frame *f; 6793 struct frame *f;
6774{ 6794{
6775 int width_diff = 0, height_diff = 0;
6776 int flags = f->size_hint_flags; 6795 int flags = f->size_hint_flags;
6777 Rect inner, outer; 6796 Rect inner, outer;
6778 6797
@@ -6787,22 +6806,15 @@ x_calc_absolute_position (f)
6787 mac_get_window_bounds (f, &inner, &outer); 6806 mac_get_window_bounds (f, &inner, &outer);
6788 UNBLOCK_INPUT; 6807 UNBLOCK_INPUT;
6789 6808
6790 width_diff = (outer.right - outer.left) - (inner.right - inner.left);
6791 height_diff = (outer.bottom - outer.top) - (inner.bottom - inner.top);
6792
6793 /* Treat negative positions as relative to the leftmost bottommost 6809 /* Treat negative positions as relative to the leftmost bottommost
6794 position that fits on the screen. */ 6810 position that fits on the screen. */
6795 if (flags & XNegative) 6811 if (flags & XNegative)
6796 f->left_pos = (FRAME_MAC_DISPLAY_INFO (f)->width 6812 f->left_pos += (FRAME_MAC_DISPLAY_INFO (f)->width
6797 - width_diff 6813 - (outer.right - outer.left));
6798 - FRAME_PIXEL_WIDTH (f)
6799 + f->left_pos);
6800 6814
6801 if (flags & YNegative) 6815 if (flags & YNegative)
6802 f->top_pos = (FRAME_MAC_DISPLAY_INFO (f)->height 6816 f->top_pos += (FRAME_MAC_DISPLAY_INFO (f)->height
6803 - height_diff 6817 - (outer.bottom - outer.top));
6804 - FRAME_PIXEL_HEIGHT (f)
6805 + f->top_pos);
6806 6818
6807 /* The left_pos and top_pos 6819 /* The left_pos and top_pos
6808 are now relative to the top and left screen edges, 6820 are now relative to the top and left screen edges,