diff options
Diffstat (limited to 'src/macterm.c')
| -rw-r--r-- | src/macterm.c | 119 |
1 files changed, 98 insertions, 21 deletions
diff --git a/src/macterm.c b/src/macterm.c index 6c47e2f932f..45bc533893c 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -389,16 +389,37 @@ mac_draw_line (f, gc, x1, y1, x2, y2) | |||
| 389 | { | 389 | { |
| 390 | #if USE_CG_DRAWING | 390 | #if USE_CG_DRAWING |
| 391 | CGContextRef context; | 391 | CGContextRef context; |
| 392 | float gx1 = x1, gy1 = y1, gx2 = x2, gy2 = y2; | ||
| 393 | |||
| 394 | if (y1 != y2) | ||
| 395 | gx1 += 0.5f, gx2 += 0.5f; | ||
| 396 | if (x1 != x2) | ||
| 397 | gy1 += 0.5f, gy2 += 0.5f; | ||
| 392 | 398 | ||
| 393 | context = mac_begin_cg_clip (f, gc); | 399 | context = mac_begin_cg_clip (f, gc); |
| 394 | CG_SET_STROKE_COLOR (context, gc->xgcv.foreground); | 400 | CG_SET_STROKE_COLOR (context, gc->xgcv.foreground); |
| 395 | CGContextBeginPath (context); | 401 | CGContextBeginPath (context); |
| 396 | CGContextMoveToPoint (context, x1 + 0.5f, y1 + 0.5f); | 402 | CGContextMoveToPoint (context, gx1, gy1); |
| 397 | CGContextAddLineToPoint (context, x2 + 0.5f, y2 + 0.5f); | 403 | CGContextAddLineToPoint (context, gx2, gy2); |
| 398 | CGContextClosePath (context); | 404 | CGContextClosePath (context); |
| 399 | CGContextStrokePath (context); | 405 | CGContextStrokePath (context); |
| 400 | mac_end_cg_clip (f); | 406 | mac_end_cg_clip (f); |
| 401 | #else | 407 | #else |
| 408 | if (x1 == x2) | ||
| 409 | { | ||
| 410 | if (y1 > y2) | ||
| 411 | y1--; | ||
| 412 | else if (y2 > y1) | ||
| 413 | y2--; | ||
| 414 | } | ||
| 415 | else if (y1 == y2) | ||
| 416 | { | ||
| 417 | if (x1 > x2) | ||
| 418 | x1--; | ||
| 419 | else | ||
| 420 | x2--; | ||
| 421 | } | ||
| 422 | |||
| 402 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); | 423 | SetPortWindowPort (FRAME_MAC_WINDOW (f)); |
| 403 | 424 | ||
| 404 | RGBForeColor (GC_FORE_COLOR (gc)); | 425 | RGBForeColor (GC_FORE_COLOR (gc)); |
| @@ -420,6 +441,21 @@ mac_draw_line_to_pixmap (display, p, gc, x1, y1, x2, y2) | |||
| 420 | CGrafPtr old_port; | 441 | CGrafPtr old_port; |
| 421 | GDHandle old_gdh; | 442 | GDHandle old_gdh; |
| 422 | 443 | ||
| 444 | if (x1 == x2) | ||
| 445 | { | ||
| 446 | if (y1 > y2) | ||
| 447 | y1--; | ||
| 448 | else if (y2 > y1) | ||
| 449 | y2--; | ||
| 450 | } | ||
| 451 | else if (y1 == y2) | ||
| 452 | { | ||
| 453 | if (x1 > x2) | ||
| 454 | x1--; | ||
| 455 | else | ||
| 456 | x2--; | ||
| 457 | } | ||
| 458 | |||
| 423 | GetGWorld (&old_port, &old_gdh); | 459 | GetGWorld (&old_port, &old_gdh); |
| 424 | SetGWorld (p, NULL); | 460 | SetGWorld (p, NULL); |
| 425 | 461 | ||
| @@ -1625,7 +1661,7 @@ mac_set_clip_rectangles (display, gc, rectangles, n) | |||
| 1625 | DisposeRgn (region); | 1661 | DisposeRgn (region); |
| 1626 | } | 1662 | } |
| 1627 | } | 1663 | } |
| 1628 | #if defined (MAC_OSX) && USE_ATSUI | 1664 | #if defined (MAC_OSX) && (USE_ATSUI || USE_CG_DRAWING) |
| 1629 | for (i = 0; i < n; i++) | 1665 | for (i = 0; i < n; i++) |
| 1630 | { | 1666 | { |
| 1631 | Rect *rect = rectangles + i; | 1667 | Rect *rect = rectangles + i; |
| @@ -2136,6 +2172,29 @@ static XCharStruct *x_per_char_metric P_ ((XFontStruct *, XChar2b *)); | |||
| 2136 | static int mac_encode_char P_ ((int, XChar2b *, struct font_info *, int *)); | 2172 | static int mac_encode_char P_ ((int, XChar2b *, struct font_info *, int *)); |
| 2137 | 2173 | ||
| 2138 | 2174 | ||
| 2175 | static void | ||
| 2176 | pcm_init (pcm, count) | ||
| 2177 | XCharStruct *pcm; | ||
| 2178 | int count; | ||
| 2179 | { | ||
| 2180 | bzero (pcm, sizeof (XCharStruct) * count); | ||
| 2181 | while (--count >= 0) | ||
| 2182 | { | ||
| 2183 | pcm->descent = PCM_INVALID; | ||
| 2184 | pcm++; | ||
| 2185 | } | ||
| 2186 | } | ||
| 2187 | |||
| 2188 | static enum pcm_status | ||
| 2189 | pcm_get_status (pcm) | ||
| 2190 | XCharStruct *pcm; | ||
| 2191 | { | ||
| 2192 | int height = pcm->ascent + pcm->descent; | ||
| 2193 | |||
| 2194 | /* Negative height means some special status. */ | ||
| 2195 | return height >= 0 ? PCM_VALID : height; | ||
| 2196 | } | ||
| 2197 | |||
| 2139 | /* Get metrics of character CHAR2B in FONT. Value is null if CHAR2B | 2198 | /* Get metrics of character CHAR2B in FONT. Value is null if CHAR2B |
| 2140 | is not contained in the font. */ | 2199 | is not contained in the font. */ |
| 2141 | 2200 | ||
| @@ -2152,22 +2211,21 @@ x_per_char_metric (font, char2b) | |||
| 2152 | #if USE_ATSUI | 2211 | #if USE_ATSUI |
| 2153 | if (font->mac_style) | 2212 | if (font->mac_style) |
| 2154 | { | 2213 | { |
| 2155 | XCharStructRow **row = font->bounds.rows + char2b->byte1; | 2214 | XCharStruct **row = font->bounds.rows + char2b->byte1; |
| 2156 | 2215 | ||
| 2157 | if (*row == NULL) | 2216 | if (*row == NULL) |
| 2158 | { | 2217 | { |
| 2159 | *row = xmalloc (sizeof (XCharStructRow)); | 2218 | *row = xmalloc (sizeof (XCharStruct) * 0x100); |
| 2160 | bzero (*row, sizeof (XCharStructRow)); | 2219 | pcm_init (*row, 0x100); |
| 2161 | } | 2220 | } |
| 2162 | pcm = (*row)->per_char + char2b->byte2; | 2221 | pcm = *row + char2b->byte2; |
| 2163 | if (!XCHARSTRUCTROW_CHAR_VALID_P (*row, char2b->byte2)) | 2222 | if (pcm_get_status (pcm) != PCM_VALID) |
| 2164 | { | 2223 | { |
| 2165 | BLOCK_INPUT; | 2224 | BLOCK_INPUT; |
| 2166 | mac_query_char_extents (font->mac_style, | 2225 | mac_query_char_extents (font->mac_style, |
| 2167 | (char2b->byte1 << 8) + char2b->byte2, | 2226 | (char2b->byte1 << 8) + char2b->byte2, |
| 2168 | NULL, NULL, pcm, NULL); | 2227 | NULL, NULL, pcm, NULL); |
| 2169 | UNBLOCK_INPUT; | 2228 | UNBLOCK_INPUT; |
| 2170 | XCHARSTRUCTROW_SET_CHAR_VALID (*row, char2b->byte2); | ||
| 2171 | } | 2229 | } |
| 2172 | } | 2230 | } |
| 2173 | else | 2231 | else |
| @@ -3122,13 +3180,13 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, | |||
| 3122 | for (i = 0; i < width; ++i) | 3180 | for (i = 0; i < width; ++i) |
| 3123 | mac_draw_line (f, gc, | 3181 | mac_draw_line (f, gc, |
| 3124 | left_x + i * left_p, top_y + i, | 3182 | left_x + i * left_p, top_y + i, |
| 3125 | right_x - i * right_p, top_y + i); | 3183 | right_x + 1 - i * right_p, top_y + i); |
| 3126 | 3184 | ||
| 3127 | /* Left. */ | 3185 | /* Left. */ |
| 3128 | if (left_p) | 3186 | if (left_p) |
| 3129 | for (i = 0; i < width; ++i) | 3187 | for (i = 0; i < width; ++i) |
| 3130 | mac_draw_line (f, gc, | 3188 | mac_draw_line (f, gc, |
| 3131 | left_x + i, top_y + i, left_x + i, bottom_y - i); | 3189 | left_x + i, top_y + i, left_x + i, bottom_y - i + 1); |
| 3132 | 3190 | ||
| 3133 | mac_reset_clip_rectangles (dpy, gc); | 3191 | mac_reset_clip_rectangles (dpy, gc); |
| 3134 | if (raised_p) | 3192 | if (raised_p) |
| @@ -3142,13 +3200,13 @@ x_draw_relief_rect (f, left_x, top_y, right_x, bottom_y, width, | |||
| 3142 | for (i = 0; i < width; ++i) | 3200 | for (i = 0; i < width; ++i) |
| 3143 | mac_draw_line (f, gc, | 3201 | mac_draw_line (f, gc, |
| 3144 | left_x + i * left_p, bottom_y - i, | 3202 | left_x + i * left_p, bottom_y - i, |
| 3145 | right_x - i * right_p, bottom_y - i); | 3203 | right_x + 1 - i * right_p, bottom_y - i); |
| 3146 | 3204 | ||
| 3147 | /* Right. */ | 3205 | /* Right. */ |
| 3148 | if (right_p) | 3206 | if (right_p) |
| 3149 | for (i = 0; i < width; ++i) | 3207 | for (i = 0; i < width; ++i) |
| 3150 | mac_draw_line (f, gc, | 3208 | mac_draw_line (f, gc, |
| 3151 | right_x - i, top_y + i + 1, right_x - i, bottom_y - i - 1); | 3209 | right_x - i, top_y + i + 1, right_x - i, bottom_y - i); |
| 3152 | 3210 | ||
| 3153 | mac_reset_clip_rectangles (dpy, gc); | 3211 | mac_reset_clip_rectangles (dpy, gc); |
| 3154 | } | 3212 | } |
| @@ -6300,6 +6358,11 @@ x_free_frame_resources (f) | |||
| 6300 | if (FRAME_SIZE_HINTS (f)) | 6358 | if (FRAME_SIZE_HINTS (f)) |
| 6301 | xfree (FRAME_SIZE_HINTS (f)); | 6359 | xfree (FRAME_SIZE_HINTS (f)); |
| 6302 | 6360 | ||
| 6361 | #if TARGET_API_MAC_CARBON | ||
| 6362 | if (FRAME_FILE_NAME (f)) | ||
| 6363 | xfree (FRAME_FILE_NAME (f)); | ||
| 6364 | #endif | ||
| 6365 | |||
| 6303 | xfree (f->output_data.mac); | 6366 | xfree (f->output_data.mac); |
| 6304 | f->output_data.mac = NULL; | 6367 | f->output_data.mac = NULL; |
| 6305 | 6368 | ||
| @@ -7746,10 +7809,10 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 7746 | font->min_char_or_byte2 = 0; | 7809 | font->min_char_or_byte2 = 0; |
| 7747 | font->max_char_or_byte2 = 0xff; | 7810 | font->max_char_or_byte2 = 0xff; |
| 7748 | 7811 | ||
| 7749 | font->bounds.rows = xmalloc (sizeof (XCharStructRow *) * 0x100); | 7812 | font->bounds.rows = xmalloc (sizeof (XCharStruct *) * 0x100); |
| 7750 | bzero (font->bounds.rows, sizeof (XCharStructRow *) * 0x100); | 7813 | bzero (font->bounds.rows, sizeof (XCharStruct *) * 0x100); |
| 7751 | font->bounds.rows[0] = xmalloc (sizeof (XCharStructRow)); | 7814 | font->bounds.rows[0] = xmalloc (sizeof (XCharStruct) * 0x100); |
| 7752 | bzero (font->bounds.rows[0], sizeof (XCharStructRow)); | 7815 | pcm_init (font->bounds.rows[0], 0x100); |
| 7753 | 7816 | ||
| 7754 | #if USE_CG_TEXT_DRAWING | 7817 | #if USE_CG_TEXT_DRAWING |
| 7755 | { | 7818 | { |
| @@ -7775,7 +7838,7 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 7775 | bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100); | 7838 | bzero (font->cg_glyphs, sizeof (CGGlyph) * 0x100); |
| 7776 | } | 7839 | } |
| 7777 | #endif | 7840 | #endif |
| 7778 | space_bounds = font->bounds.rows[0]->per_char + 0x20; | 7841 | space_bounds = font->bounds.rows[0] + 0x20; |
| 7779 | err = mac_query_char_extents (font->mac_style, 0x20, | 7842 | err = mac_query_char_extents (font->mac_style, 0x20, |
| 7780 | &font->ascent, &font->descent, | 7843 | &font->ascent, &font->descent, |
| 7781 | space_bounds, | 7844 | space_bounds, |
| @@ -7791,9 +7854,8 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 7791 | mac_unload_font (&one_mac_display_info, font); | 7854 | mac_unload_font (&one_mac_display_info, font); |
| 7792 | return NULL; | 7855 | return NULL; |
| 7793 | } | 7856 | } |
| 7794 | XCHARSTRUCTROW_SET_CHAR_VALID (font->bounds.rows[0], 0x20); | ||
| 7795 | 7857 | ||
| 7796 | pcm = font->bounds.rows[0]->per_char; | 7858 | pcm = font->bounds.rows[0]; |
| 7797 | for (c = 0x21; c <= 0xff; c++) | 7859 | for (c = 0x21; c <= 0xff; c++) |
| 7798 | { | 7860 | { |
| 7799 | if (c == 0xad) | 7861 | if (c == 0xad) |
| @@ -7813,7 +7875,6 @@ XLoadQueryFont (Display *dpy, char *fontname) | |||
| 7813 | NULL | 7875 | NULL |
| 7814 | #endif | 7876 | #endif |
| 7815 | ); | 7877 | ); |
| 7816 | XCHARSTRUCTROW_SET_CHAR_VALID (font->bounds.rows[0], c); | ||
| 7817 | 7878 | ||
| 7818 | #if USE_CG_TEXT_DRAWING | 7879 | #if USE_CG_TEXT_DRAWING |
| 7819 | if (font->cg_glyphs && font->cg_glyphs[c] == 0) | 7880 | if (font->cg_glyphs && font->cg_glyphs[c] == 0) |
| @@ -9997,8 +10058,20 @@ XTread_socket (sd, expected, hold_quit) | |||
| 9997 | } | 10058 | } |
| 9998 | break; | 10059 | break; |
| 9999 | 10060 | ||
| 10061 | #if TARGET_API_MAC_CARBON | ||
| 10062 | case inProxyIcon: | ||
| 10063 | if (TrackWindowProxyDrag (window_ptr, er.where) | ||
| 10064 | != errUserWantsToDragWindow) | ||
| 10065 | break; | ||
| 10066 | /* fall through */ | ||
| 10067 | #endif | ||
| 10000 | case inDrag: | 10068 | case inDrag: |
| 10001 | #if TARGET_API_MAC_CARBON | 10069 | #if TARGET_API_MAC_CARBON |
| 10070 | if (IsWindowPathSelectClick (window_ptr, &er)) | ||
| 10071 | { | ||
| 10072 | WindowPathSelect (window_ptr, NULL, NULL); | ||
| 10073 | break; | ||
| 10074 | } | ||
| 10002 | DragWindow (window_ptr, er.where, NULL); | 10075 | DragWindow (window_ptr, er.where, NULL); |
| 10003 | #else /* not TARGET_API_MAC_CARBON */ | 10076 | #else /* not TARGET_API_MAC_CARBON */ |
| 10004 | DragWindow (window_ptr, er.where, &qd.screenBits.bounds); | 10077 | DragWindow (window_ptr, er.where, &qd.screenBits.bounds); |
| @@ -11050,7 +11123,11 @@ button will be mouse-3. */); | |||
| 11050 | doc: /* *If non-nil, allow anti-aliasing. | 11123 | doc: /* *If non-nil, allow anti-aliasing. |
| 11051 | The text will be rendered using Core Graphics text rendering which | 11124 | The text will be rendered using Core Graphics text rendering which |
| 11052 | may anti-alias the text. */); | 11125 | may anti-alias the text. */); |
| 11126 | #if USE_CG_DRAWING | ||
| 11127 | mac_use_core_graphics = 1; | ||
| 11128 | #else | ||
| 11053 | mac_use_core_graphics = 0; | 11129 | mac_use_core_graphics = 0; |
| 11130 | #endif | ||
| 11054 | 11131 | ||
| 11055 | /* Register an entry for `mac-roman' so that it can be used when | 11132 | /* Register an entry for `mac-roman' so that it can be used when |
| 11056 | creating the terminal frame on Mac OS 9 before loading | 11133 | creating the terminal frame on Mac OS 9 before loading |