# HG changeset patch # User Steven Tamm # Date 1101794247 0 # Node ID 95d38c47c806ead5feab30585d5b88514a4030ce # Parent 55d668830eed363351c250376a79d74a72692af9 * keyboard.c: Don't undef SIGIO * s/darwin.h (NO_SOCK_SIGIO): Define NO_SOCK_SIGIO on carbon * Makefile.in (mac.o): Depend on blockinput.h and atimer.h. (macfns.o): Don't depend on ccl.h. * macfns.c (mac_frame_parm_handlers): Set handlers for Qleft_fringe and Qright_fringe. * macterm.c (mac_fill_rectangle_to_pixmap) (mac_draw_rectangle_to_pixmap, mac_copy_area_to_pixmap) (mac_copy_area_with_mask_to_pixmap, x_draw_image_foreground_1): Put in #if 0. (mac_scroll_area) [TARGET_API_MAC_CARBON]: Use ScrollWindowRect. (x_flush) [TARGET_API_MAC_CARBON]: Don't traverse frames. (XFlush) [TARGET_API_MAC_CARBON]: Define to an empty replacement. (x_draw_glyph_string_background, x_draw_glyph_string_foreground) [!MAC_OS8]: Added ifdef'd out code for os8. Don't use XDrawImageString. Always draw background and foreground separately. (x_draw_image_foreground): Use clipping instead of computing the intersection rectangle. (x_draw_image_glyph_string): Don't draw an image with mask to a pixmap. (x_redisplay_interface): Set flush_display_optional member to 0. (XTread_socket): Correctly reset the TEConverter object. diff -r 55d668830eed -r 95d38c47c806 src/ChangeLog --- a/src/ChangeLog Tue Nov 30 00:31:38 2004 +0000 +++ b/src/ChangeLog Tue Nov 30 05:57:27 2004 +0000 @@ -1,3 +1,29 @@ +2004-11-30 YAMAMOTO Mitsuharu + + * keyboard.c: Don't undef SIGIO + * s/darwin.h (NO_SOCK_SIGIO): Define NO_SOCK_SIGIO on carbon + * Makefile.in (mac.o): Depend on blockinput.h and atimer.h. + (macfns.o): Don't depend on ccl.h. + * macfns.c (mac_frame_parm_handlers): Set handlers for + Qleft_fringe and Qright_fringe. + * macterm.c (mac_fill_rectangle_to_pixmap) + (mac_draw_rectangle_to_pixmap, mac_copy_area_to_pixmap) + (mac_copy_area_with_mask_to_pixmap, x_draw_image_foreground_1): + Put in #if 0. + (mac_scroll_area) [TARGET_API_MAC_CARBON]: Use ScrollWindowRect. + (x_flush) [TARGET_API_MAC_CARBON]: Don't traverse frames. + (XFlush) [TARGET_API_MAC_CARBON]: Define to an empty replacement. + (x_draw_glyph_string_background, x_draw_glyph_string_foreground) + [!MAC_OS8]: Added ifdef'd out code for os8. Don't use + XDrawImageString. Always draw background and foreground separately. + (x_draw_image_foreground): Use clipping instead of computing the + intersection rectangle. + (x_draw_image_glyph_string): Don't draw an image with mask to a + pixmap. + (x_redisplay_interface): Set flush_display_optional member to 0. + (XTread_socket): Correctly reset the TEConverter + object. + 2004-11-30 Kim F. Storm * lisp.h: New defines to enable buffer overrun checking. diff -r 55d668830eed -r 95d38c47c806 src/Makefile.in --- a/src/Makefile.in Tue Nov 30 00:31:38 2004 +0000 +++ b/src/Makefile.in Tue Nov 30 05:57:27 2004 +0000 @@ -1226,10 +1226,10 @@ fontset.o indent.o insdel.o keyboard.o macros.o minibuf.o msdos.o process.o \ scroll.o sysdep.o term.o widget.o window.o xdisp.o xfaces.o xfns.o xmenu.o \ xterm.o xselect.o sound.o: macgui.h -mac.o: mac.c process.h sysselect.h systime.h $(config_h) +mac.o: mac.c process.h sysselect.h blockinput.h atimer.h systime.h $(config_h) macfns.o: macfns.c charset.h macterm.h macgui.h frame.h window.h buffer.h \ dispextern.h macgui.h fontset.h $(INTERVAL_SRC) keyboard.h blockinput.h \ - atimer.h systime.h epaths.h termhooks.h coding.h ccl.h systime.h $(config_h) + atimer.h systime.h epaths.h termhooks.h coding.h systime.h $(config_h) macmenu.o: macmenu.c termhooks.h frame.h window.h dispextern.h macgui.h \ keyboard.h blockinput.h atimer.h systime.h buffer.h macterm.h $(config_h) macterm.o: blockinput.h atimer.h systime.h syssignal.h macterm.h macgui.h \ diff -r 55d668830eed -r 95d38c47c806 src/keyboard.c --- a/src/keyboard.c Tue Nov 30 00:31:38 2004 +0000 +++ b/src/keyboard.c Tue Nov 30 05:57:27 2004 +0000 @@ -607,7 +607,7 @@ /* We are unable to use interrupts if FIONREAD is not available, so flush SIGIO so we won't try. */ -#if !defined (FIONREAD) || defined(HAVE_CARBON) +#if !defined (FIONREAD) #ifdef SIGIO #undef SIGIO #endif diff -r 55d668830eed -r 95d38c47c806 src/macfns.c --- a/src/macfns.c Tue Nov 30 00:31:38 2004 +0000 +++ b/src/macfns.c Tue Nov 30 05:57:27 2004 +0000 @@ -4415,8 +4415,8 @@ 0, /* MAC_TODO: x_set_scroll_bar_background, */ x_set_screen_gamma, x_set_line_spacing, - 0, /* MAC_TODO: x_set_fringe_width, */ - 0, /* MAC_TODO: x_set_fringe_width, */ + x_set_fringe_width, + x_set_fringe_width, 0, /* x_set_wait_for_wm, */ 0, /* MAC_TODO: x_set_fullscreen, */ }; diff -r 55d668830eed -r 95d38c47c806 src/macterm.c --- a/src/macterm.c Tue Nov 30 00:31:38 2004 +0000 +++ b/src/macterm.c Tue Nov 30 05:57:27 2004 +0000 @@ -567,7 +567,7 @@ Display *display; /* not used */ WindowPtr w; unsigned int width, height; - unsigned int depth; /* not used */ + unsigned int depth; { Pixmap pixmap; Rect r; @@ -643,6 +643,7 @@ } +#if 0 /* TODO: figure out if we need to do this on Mac. */ static void mac_fill_rectangle_to_pixmap (display, p, gc, x, y, width, height) Display *display; @@ -666,6 +667,7 @@ SetGWorld (old_port, old_gdh); } +#endif /* Mac replacement for XDrawRectangle: dest is a window. */ @@ -689,6 +691,7 @@ } +#if 0 /* TODO: figure out if we need to do this on Mac. */ /* Mac replacement for XDrawRectangle: dest is a Pixmap. */ static void @@ -714,6 +717,7 @@ SetGWorld (old_port, old_gdh); } +#endif static void @@ -908,24 +912,13 @@ int dest_x, dest_y; { #if TARGET_API_MAC_CARBON - Rect gw_r, src_r, dest_r; + Rect src_r; + RgnHandle dummy = NewRgn (); /* For avoiding update events. */ SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); - SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); - - SetPortWindowPort (w); - - ForeColor (blackColor); - BackColor (whiteColor); - - LockPortBits (GetWindowPort (w)); - { - const BitMap *bitmap = GetPortBitMapForCopyBits (GetWindowPort (w)); - CopyBits (bitmap, bitmap, &src_r, &dest_r, srcCopy, 0); - } - UnlockPortBits (GetWindowPort (w)); - - mac_set_colors (gc); + ScrollWindowRect (w, &src_r, dest_x - src_x, dest_y - src_y, + kScrollWindowNoOptions, dummy); + DisposeRgn (dummy); #else /* not TARGET_API_MAC_CARBON */ Rect src_r, dest_r; @@ -959,6 +952,7 @@ } +#if 0 /* TODO: figure out if we need to do this on Mac. */ /* Mac replacement for XCopyArea: dest must be Pixmap. */ static void @@ -1037,6 +1031,7 @@ SetGWorld (old_port, old_gdh); } +#endif /* Mac replacement for XChangeGC. */ @@ -1131,6 +1126,23 @@ } +/* Flush display of frame F, or of all frames if F is null. */ + +static void +x_flush (f) + struct frame *f; +{ +#if TARGET_API_MAC_CARBON + BLOCK_INPUT; + if (f) + QDFlushPortBuffer (GetWindowPort (FRAME_MAC_WINDOW (f)), NULL); + else + QDFlushPortBuffer (GetQDGlobalsThePort (), NULL); + UNBLOCK_INPUT; +#endif +} + + /* Remove calls to XFlush by defining XFlush to an empty replacement. Calls to XFlush should be unnecessary because the X output buffer is flushed automatically as needed by calls to XPending, @@ -1138,32 +1150,7 @@ XTread_socket calls XPending. Removing XFlush improves performance. */ -#if TARGET_API_MAC_CARBON -#define XFlush(DISPLAY) QDFlushPortBuffer (GetQDGlobalsThePort (), NULL) -#else #define XFlush(DISPLAY) (void) 0 -#endif - -/* Flush display of frame F, or of all frames if F is null. */ - -void -x_flush (f) - struct frame *f; -{ -#if TARGET_API_MAC_CARBON - BLOCK_INPUT; - if (f == NULL) - { - Lisp_Object rest, frame; - FOR_EACH_FRAME (rest, frame) - x_flush (XFRAME (frame)); - } - else if (FRAME_MAC_P (f)) - XFlush (FRAME_MAC_DISPLAY (f)); - UNBLOCK_INPUT; -#endif /* TARGET_API_MAC_CARBON */ -} - /* Return the struct mac_display_info corresponding to DPY. There's @@ -1957,6 +1944,14 @@ } +/* We prefer not to use XDrawImageString (srcCopy text transfer mode) + on Mac OS X because: + - Screen is double-buffered. (In srcCopy mode, a text is drawn + into an offscreen graphics world first. So performance gain + cannot be expected.) + - It lowers rendering quality. + - Some fonts leave garbage on cursor movement. */ + /* Draw the background of glyph_string S. If S->background_filled_p is non-zero don't draw it. FORCE_P non-zero means draw the background even if it wouldn't be drawn normally. This is used @@ -1988,10 +1983,12 @@ } else #endif +#if 0 /* defined(MAC_OS8)*/ if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width || s->font_not_found_p || s->extends_to_end_of_line_p || force_p) +#endif { x_clear_glyph_string_rect (s, s->x, s->y + box_line_width, s->background_width, @@ -2044,6 +2041,7 @@ for (i = 0; i < s->nchars; ++i) char1b[i] = s->char2b[i].byte2; +#if 0 /* defined(MAC_OS8) */ /* Draw text with XDrawString if background has already been filled. Otherwise, use XDrawImageString. (Note that XDrawImageString is usually faster than XDrawString.) Always @@ -2051,6 +2049,7 @@ no chance that characters under a box cursor are invisible. */ if (s->for_overlaps_p || (s->background_filled_p && s->hl != DRAW_CURSOR)) +#endif { /* Draw characters with 16-bit or 8-bit functions. */ if (s->two_byte_p) @@ -2060,6 +2059,7 @@ XDrawString (s->display, s->window, s->gc, x, s->ybase - boff, char1b, s->nchars); } +#if 0 /* defined(MAC_OS8)*/ else { if (s->two_byte_p) @@ -2069,6 +2069,7 @@ XDrawImageString (s->display, s->window, s->gc, x, s->ybase - boff, char1b, s->nchars); } +#endif } } @@ -2635,38 +2636,17 @@ if (s->img->pixmap) { + x_set_glyph_string_clipping (s); + if (s->img->mask) - { - Rect nr; - XRectangle clip_rect, image_rect, r; - - get_glyph_string_clip_rect (s, &nr); - CONVERT_TO_XRECT (clip_rect, nr); - image_rect.x = x; - image_rect.y = y; - image_rect.width = s->slice.width; - image_rect.height = s->slice.height; - if (x_intersect_rectangles (&clip_rect, &image_rect, &r)) - mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask, - s->window, s->gc, - s->slice.x + r.x - x, s->slice.y + r.y - y, - r.width, r.height, r.x, r.y); - } + mac_copy_area_with_mask (s->display, s->img->pixmap, s->img->mask, + s->window, s->gc, s->slice.x, s->slice.y, + s->slice.width, s->slice.height, x, y); else { - Rect nr; - XRectangle clip_rect, image_rect, r; - - get_glyph_string_clip_rect (s, &nr); - CONVERT_TO_XRECT (clip_rect, nr); - image_rect.x = x; - image_rect.y = y; - image_rect.width = s->slice.width; - image_rect.height = s->slice.height; - if (x_intersect_rectangles (&clip_rect, &image_rect, &r)) - mac_copy_area (s->display, s->img->pixmap, s->window, s->gc, - s->slice.x + r.x - x, s->slice.y + r.y - y, - r.width, r.height, r.x, r.y); + mac_copy_area (s->display, s->img->pixmap, + s->window, s->gc, s->slice.x, s->slice.y, + s->slice.width, s->slice.height, x, y); /* When the image has a mask, we can expect that at least part of a mouse highlight or a block cursor will @@ -2745,6 +2725,7 @@ } +#if 0 /* TODO: figure out if we need to do this on Mac. */ /* Draw the foreground of image glyph string S to PIXMAP. */ static void @@ -2805,6 +2786,7 @@ mac_draw_rectangle_to_pixmap (s->display, pixmap, s->gc, x, y, s->slice.width - 1, s->slice.height - 1); } +#endif /* Draw part of the background of glyph string S. X, Y, W, and H @@ -2876,6 +2858,7 @@ if (s->slice.y == 0) y += box_line_vwidth; +#if 0 /* TODO: figure out if we need to do this on Mac. */ if (s->img->mask) { /* Create a pixmap as large as the glyph string. Fill it @@ -2912,12 +2895,14 @@ } } else +#endif x_draw_glyph_string_bg_rect (s, x, y, s->background_width, height); s->background_filled_p = 1; } /* Draw the foreground. */ +#if 0 /* TODO: figure out if we need to do this on Mac. */ if (pixmap != 0) { x_draw_image_foreground_1 (s, pixmap); @@ -2928,6 +2913,7 @@ XFreePixmap (s->display, pixmap); } else +#endif x_draw_image_foreground (s); /* If we must draw a relief around the image, do it. */ @@ -5899,7 +5885,14 @@ static Lisp_Object Qbig5, Qcn_gb, Qsjis, Qeuc_kr; static void -decode_mac_font_name (char *name, int size, short scriptcode) +decode_mac_font_name (name, size, scriptcode) + char *name; + int size; +#if TARGET_API_MAC_CARBON + int scriptcode; +#else + short scriptcode; +#endif { Lisp_Object coding_system; struct coding_system coding; @@ -5937,7 +5930,15 @@ static char * -mac_to_x_fontname (char *name, int size, Style style, short scriptcode) +mac_to_x_fontname (name, size, style, scriptcode, encoding_base) + char *name; + int size; + Style style; +#if TARGET_API_MAC_CARBON + int scriptcode; +#else + short scriptcode; +#endif { char foundry[32], family[32], cs[32]; char xf[256], *result, *p; @@ -5949,13 +5950,13 @@ switch (scriptcode) { - case smTradChinese: + case smTradChinese: /* == kTextEncodingMacChineseTrad */ strcpy(cs, "big5-0"); break; - case smSimpChinese: + case smSimpChinese: /* == kTextEncodingMacChineseSimp */ strcpy(cs, "gb2312.1980-0"); break; - case smJapanese: + case smJapanese: /* == kTextEncodingMacJapanese */ strcpy(cs, "jisx0208.1983-sjis"); break; case -smJapanese: @@ -5967,12 +5968,24 @@ font is being built. */ strcpy(cs, "jisx0201.1976-0"); break; - case smKorean: + case smKorean: /* == kTextEncodingMacKorean */ strcpy(cs, "ksc5601.1989-0"); break; +#if TARGET_API_MAC_CARBON + case kTextEncodingMacCyrillic: + strcpy(cs, "mac-cyrillic"); + break; + case kTextEncodingMacCentralEurRoman: + strcpy(cs, "mac-centraleuropean"); + break; + case kTextEncodingMacSymbol: + case kTextEncodingMacDingbats: + strcpy(cs, "adobe-fontspecific"); + break; +#endif default: - strcpy(cs, "mac-roman"); - break; + strcpy(cs, "mac-roman"); + break; } } @@ -6019,7 +6032,10 @@ coding_system = Qsjis; else if (strcmp (cs, "ksc5601.1989-0") == 0) coding_system = Qeuc_kr; - else if (strcmp (cs, "mac-roman") == 0) + else if (strcmp (cs, "mac-roman") == 0 + || strcmp (cs, "mac-cyrillic") == 0 + || strcmp (cs, "mac-centraleuropean") == 0 + || strcmp (cs, "adobe-fontspecific") == 0) strcpy (mf, family); else sprintf (mf, "%s-%s-%s", foundry, family, cs); @@ -6091,7 +6107,8 @@ FMFont font; FMFontStyle style; FMFontSize size; - SInt16 sc; + TextEncoding encoding; + TextEncodingBase sc; if (FMGetFontFamilyName (ff, name) != noErr) break; @@ -6099,9 +6116,11 @@ if (*name == '.') continue; - sc = FontToScript (ff); + if (FMGetFontFamilyTextEncoding (ff, &encoding) != noErr) + break; + sc = GetTextEncodingBase (encoding); decode_mac_font_name (name, sizeof (name), sc); - + /* Point the instance iterator at the current font family. */ if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr) break; @@ -8619,17 +8638,30 @@ { unsigned char ch = inev.code; ByteCount actual_input_length, actual_output_length; - unsigned char outch; - - convert_status = TECConvertText (converter, &ch, 1, - &actual_input_length, - &outch, 1, - &actual_output_length); - if (convert_status == noErr - && actual_input_length == 1 - && actual_output_length == 1) - inev.code = outch; - } + unsigned char outbuf[32]; + + convert_status = TECConvertText (converter, &ch, 1, + &actual_input_length, + outbuf, 1, + &actual_output_length); + if (convert_status == noErr + && actual_input_length == 1 + && actual_output_length == 1) + inev.code = *outbuf; + + /* Reset internal states of the converter object. + If it fails, create another one. */ + convert_status = TECFlushText (converter, outbuf, + sizeof (outbuf), + &actual_output_length); + if (convert_status != noErr) + { + TECDisposeConverter (converter); + TECCreateConverter (&converter, + kTextEncodingMacRoman, + mac_keyboard_text_encoding); + } + } } #if USE_CARBON_EVENTS @@ -9148,7 +9180,7 @@ x_update_window_end, x_cursor_to, x_flush, - x_flush, + 0, /* flush_display_optional */ x_clear_window_mouse_face, x_get_glyph_overhangs, x_fix_overlapping_area, diff -r 55d668830eed -r 95d38c47c806 src/s/darwin.h --- a/src/s/darwin.h Tue Nov 30 00:31:38 2004 +0000 +++ b/src/s/darwin.h Tue Nov 30 05:57:27 2004 +0000 @@ -217,6 +217,13 @@ /* Define HAVE_SOCKETS if system supports 4.2-compatible sockets. */ #define HAVE_SOCKETS +/* In Carbon, asynchronous I/O (using SIGIO) can't be used for window + events because they don't come from sockets, even though it works + fine on tty's. */ +#ifdef HAVE_CARBON +#define NO_SOCK_SIGIO +#endif + /* Extra initialization calls in main for Mac OS X system type. */ #ifdef HAVE_CARBON #define SYMS_SYSTEM syms_of_mac()