emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/macterm.c [lexbind]


From: Miles Bader
Subject: [Emacs-diffs] Changes to emacs/src/macterm.c [lexbind]
Date: Wed, 08 Dec 2004 18:56:51 -0500

Index: emacs/src/macterm.c
diff -c emacs/src/macterm.c:1.3.2.21 emacs/src/macterm.c:1.3.2.22
*** emacs/src/macterm.c:1.3.2.21        Fri Oct 29 02:05:10 2004
--- emacs/src/macterm.c Wed Dec  8 23:36:22 2004
***************
*** 279,285 ****
  static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
                                   enum text_cursor_kinds));
  
! static void x_clip_to_row P_ ((struct window *, struct glyph_row *, GC));
  static void x_flush P_ ((struct frame *f));
  static void x_update_begin P_ ((struct frame *));
  static void x_update_window_begin P_ ((struct window *));
--- 279,285 ----
  static void x_draw_bar_cursor P_ ((struct window *, struct glyph_row *, int,
                                   enum text_cursor_kinds));
  
! static void x_clip_to_row P_ ((struct window *, struct glyph_row *, int, GC));
  static void x_flush P_ ((struct frame *f));
  static void x_update_begin P_ ((struct frame *));
  static void x_update_window_begin P_ ((struct window *));
***************
*** 567,573 ****
       Display *display;                /* not used */
       WindowPtr w;
       unsigned int width, height;
!      unsigned int depth;      /* not used */
  {
    Pixmap pixmap;
    Rect r;
--- 567,573 ----
       Display *display;                /* not used */
       WindowPtr w;
       unsigned int width, height;
!      unsigned int depth;
  {
    Pixmap pixmap;
    Rect r;
***************
*** 643,648 ****
--- 643,649 ----
  }
  
  
+ #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,671 ****
--- 667,673 ----
  
    SetGWorld (old_port, old_gdh);
  }
+ #endif
  
  
  /* Mac replacement for XDrawRectangle: dest is a window.  */
***************
*** 689,694 ****
--- 691,697 ----
  }
  
  
+ #if 0 /* TODO: figure out if we need to do this on Mac.  */
  /* Mac replacement for XDrawRectangle: dest is a Pixmap.  */
  
  static void
***************
*** 714,719 ****
--- 717,723 ----
  
    SetGWorld (old_port, old_gdh);
  }
+ #endif
  
  
  static void
***************
*** 908,931 ****
       int dest_x, dest_y;
  {
  #if TARGET_API_MAC_CARBON
!   Rect gw_r, src_r, dest_r;
  
    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);
  #else /* not TARGET_API_MAC_CARBON */
    Rect src_r, dest_r;
  
--- 912,924 ----
       int dest_x, dest_y;
  {
  #if TARGET_API_MAC_CARBON
!   Rect src_r;
!   RgnHandle dummy = NewRgn ();        /* For avoiding update events.  */
  
    SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
!   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,964 ****
--- 952,958 ----
  }
  
  
+ #if 0 /* TODO: figure out if we need to do this on Mac.  */
  /* Mac replacement for XCopyArea: dest must be Pixmap.  */
  
  static void
***************
*** 1037,1042 ****
--- 1031,1037 ----
  
    SetGWorld (old_port, old_gdh);
  }
+ #endif
  
  
  /* Mac replacement for XChangeGC.  */
***************
*** 1131,1170 ****
  }
  
  
- /* 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,
-    XNextEvent, or XWindowEvent according to the XFlush man page.
-    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
     only one.  */
--- 1126,1157 ----
  }
  
  
  /* 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,
+    XNextEvent, or XWindowEvent according to the XFlush man page.
+    XTread_socket calls XPending.  Removing XFlush improves
+    performance.  */
+ 
+ #define XFlush(DISPLAY)       (void) 0
+ 
  
  /* Return the struct mac_display_info corresponding to DPY.  There's
     only one.  */
***************
*** 1454,1465 ****
        int oldVH = row->visible_height;
        row->visible_height = p->h;
        row->y -= rowY - p->y;
!       x_clip_to_row (w, row, gc);
        row->y = oldY;
        row->visible_height = oldVH;
      }
    else
!     x_clip_to_row (w, row, gc);
  
    if (p->bx >= 0 && !p->overlay_p)
      {
--- 1441,1452 ----
        int oldVH = row->visible_height;
        row->visible_height = p->h;
        row->y -= rowY - p->y;
!       x_clip_to_row (w, row, -1, gc);
        row->y = oldY;
        row->visible_height = oldVH;
      }
    else
!     x_clip_to_row (w, row, -1, gc);
  
    if (p->bx >= 0 && !p->overlay_p)
      {
***************
*** 1957,1962 ****
--- 1944,1957 ----
  }
  
  
+ /* 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,1997 ****
--- 1983,1994 ----
        }
        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,2049 ****
--- 2041,2047 ----
        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,2056 ****
--- 2049,2055 ----
         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,2065 ****
--- 2059,2065 ----
            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,2074 ****
--- 2069,2075 ----
            XDrawImageString (s->display, s->window, s->gc, x,
                              s->ybase - boff, char1b, s->nchars);
        }
+ #endif
      }
  }
  
***************
*** 2635,2672 ****
  
    if (s->img->pixmap)
      {
!       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);
!       }
        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);
  
          /* When the image has a mask, we can expect that at
             least part of a mouse highlight or a block cursor will
--- 2636,2652 ----
  
    if (s->img->pixmap)
      {
!       x_set_glyph_string_clipping (s);
  
!       if (s->img->mask)
!       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
        {
!         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,2750 ****
--- 2725,2731 ----
  }
  
  
+ #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,2810 ****
--- 2786,2792 ----
      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,2881 ****
--- 2858,2864 ----
        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,2923 ****
--- 2895,2908 ----
            }
        }
        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,2933 ****
--- 2913,2919 ----
        XFreePixmap (s->display, pixmap);
      }
    else
+ #endif
      x_draw_image_foreground (s);
  
    /* If we must draw a relief around the image, do it.  */
***************
*** 4615,4632 ****
     mode lines must be clipped to the whole window.  */
  
  static void
! x_clip_to_row (w, row, gc)
       struct window *w;
       struct glyph_row *row;
       GC gc;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    Rect clip_rect;
!   int window_y, window_width;
  
!   window_box (w, -1, 0, &window_y, &window_width, 0);
  
!   clip_rect.left = WINDOW_TO_FRAME_PIXEL_X (w, 0);
    clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
    clip_rect.top = max (clip_rect.top, window_y);
    clip_rect.right = clip_rect.left + window_width;
--- 4601,4619 ----
     mode lines must be clipped to the whole window.  */
  
  static void
! x_clip_to_row (w, row, area, gc)
       struct window *w;
       struct glyph_row *row;
+      int area;
       GC gc;
  {
    struct frame *f = XFRAME (WINDOW_FRAME (w));
    Rect clip_rect;
!   int window_x, window_y, window_width;
  
!   window_box (w, area, &window_x, &window_y, &window_width, 0);
  
!   clip_rect.left = window_x;
    clip_rect.top = WINDOW_TO_FRAME_PIXEL_Y (w, row->y);
    clip_rect.top = max (clip_rect.top, window_y);
    clip_rect.right = clip_rect.left + window_width;
***************
*** 4692,4698 ****
    gc = dpyinfo->scratch_cursor_gc;
  
    /* Set clipping, draw the rectangle, and reset clipping again.  */
!   x_clip_to_row (w, row, gc);
    mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h);
    mac_reset_clipping (dpy, FRAME_MAC_WINDOW (f));
  }
--- 4679,4685 ----
    gc = dpyinfo->scratch_cursor_gc;
  
    /* Set clipping, draw the rectangle, and reset clipping again.  */
!   x_clip_to_row (w, row, TEXT_AREA, gc);
    mac_draw_rectangle (dpy, FRAME_MAC_WINDOW (f), gc, x, y, wd, h);
    mac_reset_clipping (dpy, FRAME_MAC_WINDOW (f));
  }
***************
*** 4763,4769 ****
        width = min (cursor_glyph->pixel_width, width);
  
        w->phys_cursor_width = width;
!       x_clip_to_row (w, row, gc);
  
        if (kind == BAR_CURSOR)
        XFillRectangle (dpy, window, gc,
--- 4750,4756 ----
        width = min (cursor_glyph->pixel_width, width);
  
        w->phys_cursor_width = width;
!       x_clip_to_row (w, row, TEXT_AREA, gc);
  
        if (kind == BAR_CURSOR)
        XFillRectangle (dpy, window, gc,
***************
*** 5898,5904 ****
  static Lisp_Object Qbig5, Qcn_gb, Qsjis, Qeuc_kr;
  
  static void
! decode_mac_font_name (char *name, int size, short scriptcode)
  {
    Lisp_Object coding_system;
    struct coding_system coding;
--- 5885,5898 ----
  static Lisp_Object Qbig5, Qcn_gb, Qsjis, Qeuc_kr;
  
  static void
! 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;
***************
*** 5936,5942 ****
  
  
  static char *
! mac_to_x_fontname (char *name, int size, Style style, short scriptcode)
  {
    char foundry[32], family[32], cs[32];
    char xf[256], *result, *p;
--- 5930,5944 ----
  
  
  static char *
! 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;
***************
*** 5948,5960 ****
  
        switch (scriptcode)
        {
!       case smTradChinese:
          strcpy(cs, "big5-0");
          break;
!       case smSimpChinese:
          strcpy(cs, "gb2312.1980-0");
          break;
!       case smJapanese:
          strcpy(cs, "jisx0208.1983-sjis");
          break;
        case -smJapanese:
--- 5950,5962 ----
  
        switch (scriptcode)
        {
!       case smTradChinese:     /* == kTextEncodingMacChineseTrad */
          strcpy(cs, "big5-0");
          break;
!       case smSimpChinese:     /* == kTextEncodingMacChineseSimp */
          strcpy(cs, "gb2312.1980-0");
          break;
!       case smJapanese:                /* == kTextEncodingMacJapanese */
          strcpy(cs, "jisx0208.1983-sjis");
          break;
        case -smJapanese:
***************
*** 5966,5977 ****
           font is being built.  */
        strcpy(cs, "jisx0201.1976-0");
        break;
!       case smKorean:
          strcpy(cs, "ksc5601.1989-0");
          break;
        default:
!         strcpy(cs, "mac-roman");
!         break;
        }
      }
  
--- 5968,5991 ----
           font is being built.  */
        strcpy(cs, "jisx0201.1976-0");
        break;
!       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;
        }
      }
  
***************
*** 6018,6024 ****
      coding_system = Qsjis;
    else if (strcmp (cs, "ksc5601.1989-0") == 0)
      coding_system = Qeuc_kr;
!   else if (strcmp (cs, "mac-roman") == 0)
      strcpy (mf, family);
    else
      sprintf (mf, "%s-%s-%s", foundry, family, cs);
--- 6032,6041 ----
      coding_system = Qsjis;
    else if (strcmp (cs, "ksc5601.1989-0") == 0)
      coding_system = Qeuc_kr;
!   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);
***************
*** 6090,6096 ****
          FMFont font;
          FMFontStyle style;
          FMFontSize size;
!         SInt16 sc;
  
          if (FMGetFontFamilyName (ff, name) != noErr)
            break;
--- 6107,6114 ----
          FMFont font;
          FMFontStyle style;
          FMFontSize size;
!         TextEncoding encoding;
!         TextEncodingBase sc;
  
          if (FMGetFontFamilyName (ff, name) != noErr)
            break;
***************
*** 6098,6106 ****
          if (*name == '.')
            continue;
  
!         sc = FontToScript (ff);
          decode_mac_font_name (name, sizeof (name), sc);
! 
          /* Point the instance iterator at the current font family.  */
          if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
            break;
--- 6116,6126 ----
          if (*name == '.')
            continue;
  
!         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;
***************
*** 8618,8634 ****
                {
                  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;
!               }
            }
  
  #if USE_CARBON_EVENTS
--- 8638,8667 ----
                {
                  unsigned char ch = inev.code;
                  ByteCount actual_input_length, actual_output_length;
!                 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
***************
*** 9147,9153 ****
    x_update_window_end,
    x_cursor_to,
    x_flush,
!   x_flush,
    x_clear_window_mouse_face,
    x_get_glyph_overhangs,
    x_fix_overlapping_area,
--- 9180,9186 ----
    x_update_window_end,
    x_cursor_to,
    x_flush,
!   0, /* flush_display_optional */
    x_clear_window_mouse_face,
    x_get_glyph_overhangs,
    x_fix_overlapping_area,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]