/[emacs]/emacs/src/macterm.c
ViewVC logotype

Diff of /emacs/src/macterm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.85 by tamm, Mon Dec 20 16:46:17 2004 UTC revision 1.86 by tamm, Mon Dec 27 17:27:30 2004 UTC
# Line 1178  static void Line 1178  static void
1178  x_update_begin (f)  x_update_begin (f)
1179       struct frame *f;       struct frame *f;
1180  {  {
1181    /* Nothing to do.  */  #if TARGET_API_MAC_CARBON
1182      /* During update of a frame, availability of input events is
1183         periodically checked with ReceiveNextEvent if
1184         redisplay-dont-pause is nil.  That normally flushes window buffer
1185         changes for every check, and thus screen update looks waving even
1186         if no input is available.  So we disable screen updates during
1187         update of a frame.  */
1188      BLOCK_INPUT;
1189      DisableScreenUpdates ();
1190      UNBLOCK_INPUT;
1191    #endif
1192  }  }
1193    
1194    
# Line 1263  mac_draw_vertical_window_border (w, x, y Line 1273  mac_draw_vertical_window_border (w, x, y
1273     make sure that the mouse-highlight is properly redrawn.     make sure that the mouse-highlight is properly redrawn.
1274    
1275     W may be a menu bar pseudo-window in case we don't have X toolkit     W may be a menu bar pseudo-window in case we don't have X toolkit
1276     support. Such windows don't have a cursor, so don't display it     support.  Such windows don't have a cursor, so don't display it
1277     here. */     here. */
1278    
1279  static void  static void
# Line 1327  x_update_end (f) Line 1337  x_update_end (f)
1337    
1338    mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));    mac_set_backcolor (FRAME_BACKGROUND_PIXEL (f));
1339    
1340    #if TARGET_API_MAC_CARBON
1341      EnableScreenUpdates ();
1342    #endif
1343    XFlush (FRAME_MAC_DISPLAY (f));    XFlush (FRAME_MAC_DISPLAY (f));
1344    UNBLOCK_INPUT;    UNBLOCK_INPUT;
1345  }  }
# Line 1983  x_draw_glyph_string_background (s, force Line 1996  x_draw_glyph_string_background (s, force
1996          }          }
1997        else        else
1998  #endif  #endif
1999  #if 0 /* defined(MAC_OS8)*/  #ifdef MAC_OS8
2000          if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width          if (FONT_HEIGHT (s->font) < s->height - 2 * box_line_width
2001                 || s->font_not_found_p                 || s->font_not_found_p
2002                 || s->extends_to_end_of_line_p                 || s->extends_to_end_of_line_p
# Line 2041  x_draw_glyph_string_foreground (s) Line 2054  x_draw_glyph_string_foreground (s)
2054          for (i = 0; i < s->nchars; ++i)          for (i = 0; i < s->nchars; ++i)
2055            char1b[i] = s->char2b[i].byte2;            char1b[i] = s->char2b[i].byte2;
2056    
2057  #if 0 /* defined(MAC_OS8) */  #ifdef MAC_OS8
2058        /* Draw text with XDrawString if background has already been        /* Draw text with XDrawString if background has already been
2059           filled.  Otherwise, use XDrawImageString.  (Note that           filled.  Otherwise, use XDrawImageString.  (Note that
2060           XDrawImageString is usually faster than XDrawString.)  Always           XDrawImageString is usually faster than XDrawString.)  Always
# Line 2059  x_draw_glyph_string_foreground (s) Line 2072  x_draw_glyph_string_foreground (s)
2072              XDrawString (s->display, s->window, s->gc, x,              XDrawString (s->display, s->window, s->gc, x,
2073                           s->ybase - boff, char1b, s->nchars);                           s->ybase - boff, char1b, s->nchars);
2074          }          }
2075  #if 0 /* defined(MAC_OS8)*/  #ifdef MAC_OS8
2076        else        else
2077          {          {
2078            if (s->two_byte_p)            if (s->two_byte_p)
# Line 3652  x_get_keysym_name (keysym) Line 3665  x_get_keysym_name (keysym)
3665    
3666    
3667    
3668    #if 0
3669  /* Mouse clicks and mouse movement.  Rah.  */  /* Mouse clicks and mouse movement.  Rah.  */
3670    
3671  /* Prepare a mouse-event in *RESULT for placement in the input queue.  /* Prepare a mouse-event in *RESULT for placement in the input queue.
# Line 3685  construct_mouse_click (result, event, f) Line 3699  construct_mouse_click (result, event, f)
3699    result->arg = Qnil;    result->arg = Qnil;
3700    return Qnil;    return Qnil;
3701  }  }
3702    #endif
3703    
3704    
3705  /* Function to report a mouse movement to the mainstream Emacs code.  /* Function to report a mouse movement to the mainstream Emacs code.
# Line 3754  int disable_mouse_highlight; Line 3769  int disable_mouse_highlight;
3769    
3770  static struct scroll_bar *x_window_to_scroll_bar ();  static struct scroll_bar *x_window_to_scroll_bar ();
3771  static void x_scroll_bar_report_motion ();  static void x_scroll_bar_report_motion ();
 static void x_check_fullscreen P_ ((struct frame *));  
 static void x_check_fullscreen_move P_ ((struct frame *));  
3772  static int glyph_rect P_ ((struct frame *f, int, int, Rect *));  static int glyph_rect P_ ((struct frame *f, int, int, Rect *));
3773    
3774    
# Line 4017  x_scroll_bar_create (w, top, left, width Line 4030  x_scroll_bar_create (w, top, left, width
4030    r.right = left + width;    r.right = left + width;
4031    r.bottom = disp_top + disp_height;    r.bottom = disp_top + disp_height;
4032    
4033  #ifdef TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
4034    ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0,    ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0,
4035                     kControlScrollBarProc, 0L);                     kControlScrollBarProc, 0L);
4036  #else  #else
# Line 4395  activate_scroll_bars (frame) Line 4408  activate_scroll_bars (frame)
4408    while (! NILP (bar))    while (! NILP (bar))
4409      {      {
4410        ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));        ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));
4411  #ifdef TARGET_API_MAC_CARBON  #if 1 /* TARGET_API_MAC_CARBON */
4412        ActivateControl (ch);        ActivateControl (ch);
4413  #else  #else
4414        SetControlMaximum (ch,        SetControlMaximum (ch,
# Line 4419  deactivate_scroll_bars (frame) Line 4432  deactivate_scroll_bars (frame)
4432    while (! NILP (bar))    while (! NILP (bar))
4433      {      {
4434        ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));        ch = SCROLL_BAR_CONTROL_HANDLE (XSCROLL_BAR (bar));
4435  #ifdef TARGET_API_MAC_CARBON  #if 1 /* TARGET_API_MAC_CARBON */
4436        DeactivateControl (ch);        DeactivateControl (ch);
4437  #else  #else
4438        SetControlMaximum (ch, XINT (-1));        SetControlMaximum (ch, -1);
4439  #endif  #endif
4440        bar = XSCROLL_BAR (bar)->next;        bar = XSCROLL_BAR (bar)->next;
4441      }      }
# Line 4466  x_scroll_bar_handle_click (bar, part_cod Line 4479  x_scroll_bar_handle_click (bar, part_cod
4479      case kControlPageDownPart:      case kControlPageDownPart:
4480        bufp->part = scroll_bar_below_handle;        bufp->part = scroll_bar_below_handle;
4481        break;        break;
4482  #ifdef TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
4483      default:      default:
4484  #else  #else
4485      case kControlIndicatorPart:      case kControlIndicatorPart:
# Line 4974  x_new_font (f, fontname) Line 4987  x_new_font (f, fontname)
4987        XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->cursor_gc,        XSetFont (FRAME_MAC_DISPLAY (f), f->output_data.mac->cursor_gc,
4988                  FRAME_FONT (f));                  FRAME_FONT (f));
4989    
4990          /* Don't change the size of a tip frame; there's no point in
4991             doing it because it's done in Fx_show_tip, and it leads to
4992             problems because the tip frame has no widget.  */
4993        if (NILP (tip_frame) || XFRAME (tip_frame) != f)        if (NILP (tip_frame) || XFRAME (tip_frame) != f)
4994          x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));          x_set_window_size (f, 0, FRAME_COLS (f), FRAME_LINES (f));
4995      }      }
4996    
4997    return build_string (fontp->full_name);    return build_string (fontp->full_name);
4998  }  }
4999    
5000  /* Give frame F the fontset named FONTSETNAME as its default font, and  /* Give frame F the fontset named FONTSETNAME as its default font, and
5001     return the full name of that fontset.  FONTSETNAME may be a wildcard     return the full name of that fontset.  FONTSETNAME may be a wildcard
5002     pattern; in that case, we choose some fontset that fits the pattern.     pattern; in that case, we choose some fontset that fits the pattern.
# Line 5369  x_make_frame_visible (f) Line 5385  x_make_frame_visible (f)
5385    
5386        f->output_data.mac->asked_for_visible = 1;        f->output_data.mac->asked_for_visible = 1;
5387    
5388    #if TARGET_API_MAC_CARBON
5389          if (!(FRAME_SIZE_HINTS (f)->flags & (USPosition | PPosition)))
5390            {
5391              struct frame *sf = SELECTED_FRAME ();
5392              if (!FRAME_MAC_P (sf))
5393                RepositionWindow (FRAME_MAC_WINDOW (f), NULL,
5394                                  kWindowCenterOnMainScreen);
5395              else
5396                RepositionWindow (FRAME_MAC_WINDOW (f),
5397                                  FRAME_MAC_WINDOW (sf),
5398    #ifdef MAC_OS_X_VERSION_10_2
5399                                  kWindowCascadeStartAtParentWindowScreen
5400    #else
5401                                  kWindowCascadeOnParentWindowScreen
5402    #endif
5403                                  );
5404              x_real_positions (f, &f->left_pos, &f->top_pos);
5405            }
5406    #endif
5407        ShowWindow (FRAME_MAC_WINDOW (f));        ShowWindow (FRAME_MAC_WINDOW (f));
5408      }      }
5409    
# Line 5496  x_free_frame_resources (f) Line 5531  x_free_frame_resources (f)
5531    
5532    x_free_gcs (f);    x_free_gcs (f);
5533    
5534      if (FRAME_SIZE_HINTS (f))
5535        xfree (FRAME_SIZE_HINTS (f));
5536    
5537    xfree (f->output_data.mac);    xfree (f->output_data.mac);
5538    f->output_data.mac = NULL;    f->output_data.mac = NULL;
5539    
# Line 5548  x_wm_set_size_hint (f, flags, user_posit Line 5586  x_wm_set_size_hint (f, flags, user_posit
5586       long flags;       long flags;
5587       int user_position;       int user_position;
5588  {  {
5589  #if 0 /* MAC_TODO: connect this to the Appearance Manager */    int base_width, base_height, width_inc, height_inc;
5590    XSizeHints size_hints;    int min_rows = 0, min_cols = 0;
5591      XSizeHints *size_hints;
5592  #ifdef USE_X_TOOLKIT  
5593    Arg al[2];    base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);
5594    int ac = 0;    base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);
5595    Dimension widget_width, widget_height;    width_inc = FRAME_COLUMN_WIDTH (f);
5596    Window window = XtWindow (f->output_data.x->widget);    height_inc = FRAME_LINE_HEIGHT (f);
5597  #else /* not USE_X_TOOLKIT */  
5598    Window window = FRAME_X_WINDOW (f);    check_frame_size (f, &min_rows, &min_cols);
5599  #endif /* not USE_X_TOOLKIT */  
5600      size_hints = FRAME_SIZE_HINTS (f);
5601    /* Setting PMaxSize caused various problems.  */    if (size_hints == NULL)
5602    size_hints.flags = PResizeInc | PMinSize /* | PMaxSize */;      {
5603          size_hints = FRAME_SIZE_HINTS (f) = xmalloc (sizeof (XSizeHints));
5604    size_hints.x = f->left_pos;        bzero (size_hints, sizeof (XSizeHints));
5605    size_hints.y = f->top_pos;      }
5606    
5607  #ifdef USE_X_TOOLKIT    size_hints->flags |= PResizeInc | PMinSize | PBaseSize ;
5608    XtSetArg (al[ac], XtNwidth, &widget_width); ac++;    size_hints->width_inc  = width_inc;
5609    XtSetArg (al[ac], XtNheight, &widget_height); ac++;    size_hints->height_inc = height_inc;
5610    XtGetValues (f->output_data.x->widget, al, ac);    size_hints->min_width  = base_width + min_cols * width_inc;
5611    size_hints.height = widget_height;    size_hints->min_height = base_height + min_rows * height_inc;
5612    size_hints.width = widget_width;    size_hints->base_width  = base_width;
5613  #else /* not USE_X_TOOLKIT */    size_hints->base_height = base_height;
   size_hints.height = FRAME_PIXEL_HEIGHT (f);  
   size_hints.width = FRAME_PIXEL_WIDTH (f);  
 #endif /* not USE_X_TOOLKIT */  
   
   size_hints.width_inc = FRAME_COLUMN_WIDTH (f);  
   size_hints.height_inc = FRAME_LINE_HEIGHT (f);  
   size_hints.max_width  
     = FRAME_X_DISPLAY_INFO (f)->width - FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);  
   size_hints.max_height  
     = FRAME_X_DISPLAY_INFO (f)->height - FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);  
   
   /* Calculate the base and minimum sizes.  
   
      (When we use the X toolkit, we don't do it here.  
      Instead we copy the values that the widgets are using, below.)  */  
 #ifndef USE_X_TOOLKIT  
   {  
     int base_width, base_height;  
     int min_rows = 0, min_cols = 0;  
   
     base_width = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, 0);  
     base_height = FRAME_TEXT_LINES_TO_PIXEL_HEIGHT (f, 0);  
5614    
     check_frame_size (f, &min_rows, &min_cols);  
   
     /* The window manager uses the base width hints to calculate the  
        current number of rows and columns in the frame while  
        resizing; min_width and min_height aren't useful for this  
        purpose, since they might not give the dimensions for a  
        zero-row, zero-column frame.  
   
        We use the base_width and base_height members if we have  
        them; otherwise, we set the min_width and min_height members  
        to the size for a zero x zero frame.  */  
   
 #ifdef HAVE_X11R4  
     size_hints.flags |= PBaseSize;  
     size_hints.base_width = base_width;  
     size_hints.base_height = base_height;  
     size_hints.min_width  = base_width + min_cols * size_hints.width_inc;  
     size_hints.min_height = base_height + min_rows * size_hints.height_inc;  
 #else  
     size_hints.min_width = base_width;  
     size_hints.min_height = base_height;  
 #endif  
   }  
   
   /* If we don't need the old flags, we don't need the old hint at all.  */  
5615    if (flags)    if (flags)
5616        size_hints->flags = flags;
5617      else if (user_position)
5618      {      {
5619        size_hints.flags |= flags;        size_hints->flags &= ~ PPosition;
5620        goto no_read;        size_hints->flags |= USPosition;
     }  
 #endif /* not USE_X_TOOLKIT */  
   
   {  
     XSizeHints hints;           /* Sometimes I hate X Windows... */  
     long supplied_return;  
     int value;  
   
 #ifdef HAVE_X11R4  
     value = XGetWMNormalHints (FRAME_X_DISPLAY (f), window, &hints,  
                                &supplied_return);  
 #else  
     value = XGetNormalHints (FRAME_X_DISPLAY (f), window, &hints);  
 #endif  
   
 #ifdef USE_X_TOOLKIT  
     size_hints.base_height = hints.base_height;  
     size_hints.base_width = hints.base_width;  
     size_hints.min_height = hints.min_height;  
     size_hints.min_width = hints.min_width;  
 #endif  
   
     if (flags)  
       size_hints.flags |= flags;  
     else  
       {  
         if (value == 0)  
           hints.flags = 0;  
         if (hints.flags & PSize)  
           size_hints.flags |= PSize;  
         if (hints.flags & PPosition)  
           size_hints.flags |= PPosition;  
         if (hints.flags & USPosition)  
           size_hints.flags |= USPosition;  
         if (hints.flags & USSize)  
           size_hints.flags |= USSize;  
       }  
   }  
   
 #ifndef USE_X_TOOLKIT  
  no_read:  
 #endif  
   
 #ifdef PWinGravity  
   size_hints.win_gravity = f->win_gravity;  
   size_hints.flags |= PWinGravity;  
   
   if (user_position)  
     {  
       size_hints.flags &= ~ PPosition;  
       size_hints.flags |= USPosition;  
5621      }      }
 #endif /* PWinGravity */  
   
 #ifdef HAVE_X11R4  
   XSetWMNormalHints (FRAME_X_DISPLAY (f), window, &size_hints);  
 #else  
   XSetNormalHints (FRAME_X_DISPLAY (f), window, &size_hints);  
 #endif  
 #endif /* MAC_TODO */  
5622  }  }
5623    
5624  #if 0 /* MAC_TODO: hide application instead of iconify? */  #if 0 /* MAC_TODO: hide application instead of iconify? */
# Line 6120  init_font_name_table () Line 6054  init_font_name_table ()
6054              break;              break;
6055            sc = GetTextEncodingBase (encoding);            sc = GetTextEncodingBase (encoding);
6056            decode_mac_font_name (name, sizeof (name), sc);            decode_mac_font_name (name, sizeof (name), sc);
6057                                          
6058            /* Point the instance iterator at the current font family.  */            /* Point the instance iterator at the current font family.  */
6059            if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)            if (FMResetFontFamilyInstanceIterator (ff, &ffii) != noErr)
6060              break;              break;
# Line 6259  init_font_name_table () Line 6193  init_font_name_table ()
6193  }  }
6194    
6195    
6196    void
6197    mac_clear_font_name_table ()
6198    {
6199      int i;
6200    
6201      for (i = 0; i < font_name_count; i++)
6202        xfree (font_name_table[i]);
6203      xfree (font_name_table);
6204      font_name_table = NULL;
6205      font_name_table_size = font_name_count = 0;
6206    }
6207    
6208    
6209  enum xlfd_scalable_field_index  enum xlfd_scalable_field_index
6210    {    {
6211      XLFD_SCL_PIXEL_SIZE,      XLFD_SCL_PIXEL_SIZE,
# Line 6311  mac_do_list_fonts (pattern, maxnames) Line 6258  mac_do_list_fonts (pattern, maxnames)
6258    char *longest_start, *cur_start, *nonspecial;    char *longest_start, *cur_start, *nonspecial;
6259    int longest_len, cur_len, exact;    int longest_len, cur_len, exact;
6260    
6261      if (font_name_table == NULL)  /* Initialize when first used.  */
6262        init_font_name_table ();
6263    
6264    for (i = 0; i < XLFD_SCL_LAST; i++)    for (i = 0; i < XLFD_SCL_LAST; i++)
6265      scl_val[i] = -1;      scl_val[i] = -1;
6266    
# Line 6471  x_list_fonts (struct frame *f, Line 6421  x_list_fonts (struct frame *f,
6421    Lisp_Object newlist = Qnil, tem, key;    Lisp_Object newlist = Qnil, tem, key;
6422    struct mac_display_info *dpyinfo = f ? FRAME_MAC_DISPLAY_INFO (f) : NULL;    struct mac_display_info *dpyinfo = f ? FRAME_MAC_DISPLAY_INFO (f) : NULL;
6423    
   if (font_name_table == NULL)  /* Initialize when first used.  */  
     init_font_name_table ();  
   
6424    if (dpyinfo)    if (dpyinfo)
6425      {      {
6426        tem = XCDR (dpyinfo->name_list_element);        tem = XCDR (dpyinfo->name_list_element);
# Line 6487  x_list_fonts (struct frame *f, Line 6434  x_list_fonts (struct frame *f,
6434          }          }
6435      }      }
6436    
6437      BLOCK_INPUT;
6438    newlist = mac_do_list_fonts (SDATA (pattern), maxnames);    newlist = mac_do_list_fonts (SDATA (pattern), maxnames);
6439      UNBLOCK_INPUT;
6440    
6441    /* MAC_TODO: add code for matching outline fonts here */    /* MAC_TODO: add code for matching outline fonts here */
6442    
# Line 6791  XLoadQueryFont (Display *dpy, char *font Line 6740  XLoadQueryFont (Display *dpy, char *font
6740  }  }
6741    
6742    
6743    void
6744    mac_unload_font (dpyinfo, font)
6745         struct mac_display_info *dpyinfo;
6746         XFontStruct *font;
6747    {
6748      xfree (font->fontname);
6749      if (font->per_char)
6750        xfree (font->per_char);
6751      xfree (font);
6752    }
6753    
6754    
6755  /* Load font named FONTNAME of the size SIZE for frame F, and return a  /* Load font named FONTNAME of the size SIZE for frame F, and return a
6756     pointer to the structure font_info while allocating it dynamically.     pointer to the structure font_info while allocating it dynamically.
6757     If SIZE is 0, load any size of font.     If SIZE is 0, load any size of font.
# Line 6841  x_load_font (f, fontname, size) Line 6802  x_load_font (f, fontname, size)
6802      if (size > 0 && !NILP (font_names))      if (size > 0 && !NILP (font_names))
6803        fontname = (char *) SDATA (XCAR (font_names));        fontname = (char *) SDATA (XCAR (font_names));
6804    
6805        BLOCK_INPUT;
6806      font = (MacFontStruct *) XLoadQueryFont (FRAME_MAC_DISPLAY (f), fontname);      font = (MacFontStruct *) XLoadQueryFont (FRAME_MAC_DISPLAY (f), fontname);
6807        UNBLOCK_INPUT;
6808      if (!font)      if (!font)
6809        return NULL;        return NULL;
6810    
# Line 7121  do_ae_print_documents (const AppleEvent Line 7084  do_ae_print_documents (const AppleEvent
7084  static pascal OSErr do_ae_open_documents (AppleEvent *, AppleEvent *, long);  static pascal OSErr do_ae_open_documents (AppleEvent *, AppleEvent *, long);
7085  static pascal OSErr do_ae_quit_application (AppleEvent *, AppleEvent *, long);  static pascal OSErr do_ae_quit_application (AppleEvent *, AppleEvent *, long);
7086    
7087    #if TARGET_API_MAC_CARBON
7088  /* Drag and Drop */  /* Drag and Drop */
7089  static OSErr init_mac_drag_n_drop ();  static OSErr init_mac_drag_n_drop ();
7090  static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference);  static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference);
7091    #endif
7092    
7093  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
7094  /* Preliminary Support for the OSX Services Menu */  /* Preliminary Support for the OSX Services Menu */
7095  static OSStatus mac_handle_service_event (EventHandlerCallRef,EventRef,void*);  static OSStatus mac_handle_service_event (EventHandlerCallRef,EventRef,void*);
7096  static void init_service_handler ();  static void init_service_handler ();
7097    /* Window Event Handler */
7098    static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
7099                                                    EventRef, void *);
7100  #endif  #endif
7101    void install_window_handler (WindowPtr);
7102    
7103  extern void init_emacs_passwd_dir ();  extern void init_emacs_passwd_dir ();
7104  extern int emacs_main (int, char **, char **);  extern int emacs_main (int, char **, char **);
# Line 7336  do_window_update (WindowPtr win) Line 7305  do_window_update (WindowPtr win)
7305  {  {
7306    struct frame *f = mac_window_to_frame (win);    struct frame *f = mac_window_to_frame (win);
7307    
7308    if (win == tip_window)    BeginUpdate (win);
     /* The tooltip has been drawn already.  Avoid the  
        SET_FRAME_GARBAGED below.  */  
     return;  
7309    
7310    if (f)    /* The tooltip has been drawn already.  Avoid the SET_FRAME_GARBAGED
7311         below.  */
7312      if (win != tip_window)
7313      {      {
7314        if (f->async_visible == 0)        if (f->async_visible == 0)
7315          {          {
# Line 7358  do_window_update (WindowPtr win) Line 7326  do_window_update (WindowPtr win)
7326          }          }
7327        else        else
7328          {          {
7329            BeginUpdate (win);            Rect r;
7330    
7331            handling_window_update = 1;            handling_window_update = 1;
7332    
7333            XClearWindow (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f));  #if TARGET_API_MAC_CARBON
7334              {
7335                RgnHandle region = NewRgn ();
7336    
7337            expose_frame (f, 0, 0, 0, 0);              GetPortVisibleRegion (GetWindowPort (win), region);
7338                UpdateControls (win, region);
7339                GetRegionBounds (region, &r);
7340                DisposeRgn (region);
7341              }
7342    #else
7343              UpdateControls (win, win->visRgn);
7344              r = (*win->visRgn)->rgnBBox;
7345    #endif
7346              expose_frame (f, r.left, r.top, r.right - r.left, r.bottom - r.top);
7347    
7348            handling_window_update = 0;            handling_window_update = 0;
           EndUpdate (win);  
7349          }          }
7350      }      }
7351    
7352      EndUpdate (win);
7353  }  }
7354    
7355  static int  static int
# Line 7530  do_menu_choice (SInt32 menu_choice) Line 7511  do_menu_choice (SInt32 menu_choice)
7511  static void  static void
7512  do_grow_window (WindowPtr w, EventRecord *e)  do_grow_window (WindowPtr w, EventRecord *e)
7513  {  {
   long grow_size;  
7514    Rect limit_rect;    Rect limit_rect;
7515    int rows, columns;    int rows, columns, width, height;
7516    struct frame *f = mac_window_to_frame (w);    struct frame *f = mac_window_to_frame (w);
7517      XSizeHints *size_hints = FRAME_SIZE_HINTS (f);
7518      int min_width = MIN_DOC_SIZE, min_height = MIN_DOC_SIZE;
7519    #if TARGET_API_MAC_CARBON
7520      Rect new_rect;
7521    #else
7522      long grow_size;
7523    #endif
7524    
7525    SetRect(&limit_rect, MIN_DOC_SIZE, MIN_DOC_SIZE, MAX_DOC_SIZE, MAX_DOC_SIZE);    if (size_hints->flags & PMinSize)
7526        {
7527          min_width  = size_hints->min_width;
7528          min_height = size_hints->min_height;
7529        }
7530      SetRect (&limit_rect, min_width, min_height, MAX_DOC_SIZE, MAX_DOC_SIZE);
7531    
7532    #if TARGET_API_MAC_CARBON
7533      if (!ResizeWindow (w, e->where, &limit_rect, &new_rect))
7534        return;
7535      height = new_rect.bottom - new_rect.top;
7536      width = new_rect.right - new_rect.left;
7537    #else
7538    grow_size = GrowWindow (w, e->where, &limit_rect);    grow_size = GrowWindow (w, e->where, &limit_rect);
   
7539    /* see if it really changed size */    /* see if it really changed size */
7540    if (grow_size != 0)    if (grow_size == 0)
7541        return;
7542      height = HiWord (grow_size);
7543      width = LoWord (grow_size);
7544    #endif
7545    
7546      if (width != FRAME_PIXEL_WIDTH (f)
7547          || height != FRAME_PIXEL_HEIGHT (f))
7548      {      {
7549        rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, HiWord (grow_size));        rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
7550        columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, LoWord (grow_size));        columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
7551    
7552        x_set_window_size (f, 0, columns, rows);        x_set_window_size (f, 0, columns, rows);
7553      }      }
# Line 7561  do_zoom_window (WindowPtr w, int zoom_in Line 7565  do_zoom_window (WindowPtr w, int zoom_in
7565    GrafPtr save_port;    GrafPtr save_port;
7566    Rect zoom_rect, port_rect;    Rect zoom_rect, port_rect;
7567    Point top_left;    Point top_left;
7568    int w_title_height, columns, rows;    int w_title_height, columns, rows, width, height;
7569    struct frame *f = mac_window_to_frame (w);    struct frame *f = mac_window_to_frame (w);
7570    
7571  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
# Line 7636  do_zoom_window (WindowPtr w, int zoom_in Line 7640  do_zoom_window (WindowPtr w, int zoom_in
7640  #else  #else
7641    port_rect = w->portRect;    port_rect = w->portRect;
7642  #endif  #endif
7643    rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, port_rect.bottom - port_rect.top);    height = port_rect.bottom - port_rect.top;
7644    columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, port_rect.right - port_rect.left);    width = port_rect.right - port_rect.left;
7645    x_set_window_size (f, 0, columns, rows);  
7646      if (width != FRAME_PIXEL_WIDTH (f)
7647          || height != FRAME_PIXEL_HEIGHT (f))
7648        {
7649          rows = FRAME_PIXEL_HEIGHT_TO_TEXT_LINES (f, height);
7650          columns = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (f, width);
7651    
7652          change_frame_size (f, rows, columns, 0, 1, 0);
7653          SET_FRAME_GARBAGED (f);
7654          cancel_mouse_face (f);
7655    
7656          FRAME_PIXEL_WIDTH (f) = width;
7657          FRAME_PIXEL_HEIGHT (f) = height;
7658        }
7659    x_real_positions (f, &f->left_pos, &f->top_pos);    x_real_positions (f, &f->left_pos, &f->top_pos);
7660  }  }
7661    
7662    #if TARGET_API_MAC_CARBON
7663  /* Initialize Drag And Drop to allow files to be dropped onto emacs frames */  /* Initialize Drag And Drop to allow files to be dropped onto emacs frames */
7664  static OSErr  static OSErr
7665  init_mac_drag_n_drop ()  init_mac_drag_n_drop ()
# Line 7649  init_mac_drag_n_drop () Line 7667  init_mac_drag_n_drop ()
7667    OSErr result = InstallReceiveHandler (mac_do_receive_drag, 0L, NULL);    OSErr result = InstallReceiveHandler (mac_do_receive_drag, 0L, NULL);
7668    return result;    return result;
7669  }  }
7670    #endif
7671    
7672  /* Intialize AppleEvent dispatcher table for the required events.  */  /* Intialize AppleEvent dispatcher table for the required events.  */
7673  void  void
# Line 7819  mac_handle_service_event (EventHandlerCa Line 7838  mac_handle_service_event (EventHandlerCa
7838      }      }
7839    return err;    return err;
7840  }  }
7841    
7842    
7843    static pascal OSStatus
7844    mac_handle_window_event (next_handler, event, data)
7845         EventHandlerCallRef next_handler;
7846         EventRef event;
7847         void *data;
7848    {
7849      extern Lisp_Object Qcontrol;
7850    
7851      WindowPtr wp;
7852      OSStatus result;
7853      UInt32 attributes;
7854      XSizeHints *size_hints;
7855    
7856      GetEventParameter (event, kEventParamDirectObject, typeWindowRef,
7857                         NULL, sizeof (WindowPtr), NULL, &wp);
7858    
7859      switch (GetEventKind (event))
7860        {
7861        case kEventWindowBoundsChanging:
7862          result = CallNextEventHandler (next_handler, event);
7863          if (result != eventNotHandledErr)
7864            return result;
7865    
7866          GetEventParameter (event, kEventParamAttributes, typeUInt32,
7867                             NULL, sizeof (UInt32), NULL, &attributes);
7868          size_hints = FRAME_SIZE_HINTS (mac_window_to_frame (wp));
7869          if ((attributes & kWindowBoundsChangeUserResize)
7870              && ((size_hints->flags & (PResizeInc | PBaseSize | PMinSize))
7871                  == (PResizeInc | PBaseSize | PMinSize)))
7872            {
7873              Rect bounds;
7874              int width, height;
7875    
7876              GetEventParameter (event, kEventParamCurrentBounds,
7877                                 typeQDRectangle,
7878                                 NULL, sizeof (Rect), NULL, &bounds);
7879              width = bounds.right - bounds.left;
7880              height = bounds.bottom - bounds.top;
7881    
7882              if (width < size_hints->min_width)
7883                width = size_hints->min_width;
7884              else
7885                width = size_hints->base_width
7886                  + (int) ((width - size_hints->base_width)
7887                           / (float) size_hints->width_inc + .5)
7888                  * size_hints->width_inc;
7889    
7890              if (height < size_hints->min_height)
7891                height = size_hints->min_height;
7892              else
7893                height = size_hints->base_height
7894                  + (int) ((height - size_hints->base_height)
7895                           / (float) size_hints->height_inc + .5)
7896                  * size_hints->height_inc;
7897    
7898              bounds.right = bounds.left + width;
7899              bounds.bottom = bounds.top + height;
7900              SetEventParameter (event, kEventParamCurrentBounds,
7901                                 typeQDRectangle, sizeof (Rect), &bounds);
7902              return noErr;
7903            }
7904          break;
7905        }
7906    
7907      return eventNotHandledErr;
7908    }
7909    #endif  /* USE_CARBON_EVENTS */
7910    
7911    
7912    void
7913    install_window_handler (window)
7914         WindowPtr window;
7915    {
7916    #if USE_CARBON_EVENTS
7917      EventTypeSpec specs[] = {{kEventClassWindow, kEventWindowBoundsChanging}};
7918      static EventHandlerUPP handle_window_event_UPP = NULL;
7919    
7920      if (handle_window_event_UPP == NULL)
7921        handle_window_event_UPP = NewEventHandlerUPP (mac_handle_window_event);
7922    
7923      InstallWindowEventHandler (window, handle_window_event_UPP,
7924                                 GetEventTypeCount (specs), specs, NULL, NULL);
7925  #endif  #endif
7926    }
7927    
7928    
7929  /* Open Application Apple Event */  /* Open Application Apple Event */
7930  static pascal OSErr  static pascal OSErr
# Line 7915  descriptor_error_exit: Line 8020  descriptor_error_exit:
8020  }  }
8021    
8022    
8023    #if TARGET_API_MAC_CARBON
8024  static pascal OSErr  static pascal OSErr
8025  mac_do_receive_drag (WindowPtr window, void *handlerRefCon,  mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
8026                       DragReference theDrag)                       DragReference theDrag)
# Line 7991  mac_do_receive_drag (WindowPtr window, v Line 8097  mac_do_receive_drag (WindowPtr window, v
8097        }        }
8098      }      }
8099  }  }
8100    #endif
8101    
8102    
8103  /* Print Document Apple Event */  /* Print Document Apple Event */
# Line 8140  keycode_to_xkeysym (int keyCode, int *xK Line 8247  keycode_to_xkeysym (int keyCode, int *xK
8247    return *xKeySym != 0;    return *xKeySym != 0;
8248  }  }
8249    
8250    #if !USE_CARBON_EVENTS
8251    static RgnHandle mouse_region = NULL;
8252    
8253    Boolean
8254    mac_wait_next_event (er, sleep_time, dequeue)
8255         EventRecord *er;
8256         UInt32 sleep_time;
8257         Boolean dequeue;
8258    {
8259      static EventRecord er_buf = {nullEvent};
8260      UInt32 target_tick, current_tick;
8261      EventMask event_mask;
8262    
8263      if (mouse_region == NULL)
8264        mouse_region = NewRgn ();
8265    
8266      event_mask = everyEvent;
8267      if (NILP (Fboundp (Qmac_ready_for_drag_n_drop)))
8268        event_mask -= highLevelEventMask;
8269    
8270      current_tick = TickCount ();
8271      target_tick = current_tick + sleep_time;
8272    
8273      if (er_buf.what == nullEvent)
8274        while (!WaitNextEvent (event_mask, &er_buf,
8275                               target_tick - current_tick, mouse_region))
8276          {
8277            current_tick = TickCount ();
8278            if (target_tick <= current_tick)
8279              return false;
8280          }
8281    
8282      *er = er_buf;
8283      if (dequeue)
8284        er_buf.what = nullEvent;
8285      return true;
8286    }
8287    #endif /* not USE_CARBON_EVENTS */
8288    
8289  /* Emacs calls this whenever it wants to read an input event from the  /* Emacs calls this whenever it wants to read an input event from the
8290     user. */     user. */
8291  int  int
# Line 8151  XTread_socket (sd, expected, hold_quit) Line 8297  XTread_socket (sd, expected, hold_quit)
8297    int count = 0;    int count = 0;
8298  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8299    EventRef eventRef;    EventRef eventRef;
8300    EventTargetRef toolbox_dispatcher = GetEventDispatcherTarget ();    EventTargetRef toolbox_dispatcher;
 #else  
   EventMask event_mask;  
8301  #endif  #endif
8302    EventRecord er;    EventRecord er;
8303    struct mac_display_info *dpyinfo = &one_mac_display_info;    struct mac_display_info *dpyinfo = &one_mac_display_info;
# Line 8184  XTread_socket (sd, expected, hold_quit) Line 8328  XTread_socket (sd, expected, hold_quit)
8328    if (terminate_flag)    if (terminate_flag)
8329      Fkill_emacs (make_number (1));      Fkill_emacs (make_number (1));
8330    
8331  #if !USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
8332    event_mask = everyEvent;    toolbox_dispatcher = GetEventDispatcherTarget ();
   if (NILP (Fboundp (Qmac_ready_for_drag_n_drop)))  
     event_mask -= highLevelEventMask;  
8333    
   while (WaitNextEvent (event_mask, &er, 0L, NULL))  
 #else /* USE_CARBON_EVENTS */  
8334    while (!ReceiveNextEvent (0, NULL, kEventDurationNoWait,    while (!ReceiveNextEvent (0, NULL, kEventDurationNoWait,
8335                              kEventRemoveFromQueue, &eventRef))                              kEventRemoveFromQueue, &eventRef))
8336  #endif /* USE_CARBON_EVENTS */  #else /* !USE_CARBON_EVENTS */
8337      while (mac_wait_next_event (&er, 0, true))
8338    #endif /* !USE_CARBON_EVENTS */
8339      {      {
8340        int do_help = 0;        int do_help = 0;
8341        struct frame *f;        struct frame *f;
# Line 8260  XTread_socket (sd, expected, hold_quit) Line 8402  XTread_socket (sd, expected, hold_quit)
8402                SendEventToEventTarget (eventRef, toolbox_dispatcher);                SendEventToEventTarget (eventRef, toolbox_dispatcher);
8403    
8404              break;              break;
8405    
8406            default:            default:
8407              /* Send the event to the appropriate receiver.  */              /* Send the event to the appropriate receiver.  */
8408              SendEventToEventTarget (eventRef, toolbox_dispatcher);              SendEventToEventTarget (eventRef, toolbox_dispatcher);
# Line 8497  XTread_socket (sd, expected, hold_quit) Line 8640  XTread_socket (sd, expected, hold_quit)
8640                break;                break;
8641    
8642              case mouseMovedMessage:              case mouseMovedMessage:
8643    #if !USE_CARBON_EVENTS
8644                  SetRectRgn (mouse_region, er.where.h, er.where.v,
8645                              er.where.h + 1, er.where.v + 1);
8646    #endif
8647                previous_help_echo_string = help_echo_string;                previous_help_echo_string = help_echo_string;
8648                help_echo_string = help_echo_object = help_echo_window = Qnil;                help_echo_string = help_echo_object = help_echo_window = Qnil;
8649                help_echo_pos = -1;                help_echo_pos = -1;
# Line 8697  XTread_socket (sd, expected, hold_quit) Line 8844  XTread_socket (sd, expected, hold_quit)
8844                    unsigned char ch = inev.code;                    unsigned char ch = inev.code;
8845                    ByteCount actual_input_length, actual_output_length;                    ByteCount actual_input_length, actual_output_length;
8846                    unsigned char outbuf[32];                    unsigned char outbuf[32];
8847                      
8848                    convert_status = TECConvertText (converter, &ch, 1,                    convert_status = TECConvertText (converter, &ch, 1,
8849                                                     &actual_input_length,                                                     &actual_input_length,
8850                                                     outbuf, 1,                                                     outbuf, 1,
8851                                                     &actual_output_length);                                                     &actual_output_length);
8852                    if (convert_status == noErr                    if (convert_status == noErr
8853                        && actual_input_length == 1                        && actual_input_length == 1
8854                        && actual_output_length == 1)                        && actual_output_length == 1)
8855                      inev.code = *outbuf;                      inev.code = *outbuf;
8856                      
8857                    /* Reset internal states of the converter object.                    /* Reset internal states of the converter object.
8858                     If it fails, create another one. */                       If it fails, create another one. */
8859                    convert_status = TECFlushText (converter, outbuf,                    convert_status = TECFlushText (converter, outbuf,
8860                                                   sizeof (outbuf),                                                   sizeof (outbuf),
8861                                                 &actual_output_length);                                                   &actual_output_length);
8862                    if (convert_status != noErr)                    if (convert_status != noErr)
8863                      {                      {
8864                        TECDisposeConverter (converter);                        TECDisposeConverter (converter);
# Line 8719  XTread_socket (sd, expected, hold_quit) Line 8866  XTread_socket (sd, expected, hold_quit)
8866                                            kTextEncodingMacRoman,                                            kTextEncodingMacRoman,
8867                                            mac_keyboard_text_encoding);                                            mac_keyboard_text_encoding);
8868                      }                      }
8869                  }                  }
8870              }              }
8871    
8872  #if USE_CARBON_EVENTS  #if USE_CARBON_EVENTS
# Line 8864  __convert_from_newlines (unsigned char * Line 9011  __convert_from_newlines (unsigned char *
9011  }  }
9012  #endif  #endif
9013    
9014    #ifdef MAC_OS8
 /* Initialize the struct pointed to by MW to represent a new COLS x  
    ROWS Macintosh window, using font with name FONTNAME and size  
    FONTSIZE.  */  
 void  
 make_mac_frame (FRAME_PTR fp)  
 {  
   mac_output *mwp;  
 #if TARGET_API_MAC_CARBON  
   static int making_terminal_window = 0;  
 #else  
   static int making_terminal_window = 1;  
 #endif  
   
   mwp = fp->output_data.mac;  
   
   BLOCK_INPUT;  
   if (making_terminal_window)  
     {  
       if (!(mwp->mWP = GetNewCWindow (TERM_WINDOW_RESOURCE, NULL,  
                                       (WindowPtr) -1)))  
         abort ();  
       making_terminal_window = 0;  
     }  
   else  
     {  
 #if TARGET_API_MAC_CARBON  
       Rect r;  
   
       SetRect (&r, 0, 0, 1, 1);  
       if (CreateNewWindow (kDocumentWindowClass,  
                            kWindowStandardDocumentAttributes  
                            /* | kWindowToolbarButtonAttribute */,  
                            &r, &mwp->mWP) != noErr)  
 #else  
       if (!(mwp->mWP = GetNewCWindow (WINDOW_RESOURCE, NULL, (WindowPtr) -1)))  
 #endif  
         abort ();  
     }  
   
   SetWRefCon (mwp->mWP, (long) mwp);  
     /* so that update events can find this mac_output struct */  
   mwp->mFP = fp;  /* point back to emacs frame */  
   
   SizeWindow (mwp->mWP, FRAME_PIXEL_WIDTH (fp), FRAME_PIXEL_HEIGHT (fp), false);  
   UNBLOCK_INPUT;  
 }  
   
   
9015  void  void
9016  make_mac_terminal_frame (struct frame *f)  make_mac_terminal_frame (struct frame *f)
9017  {  {
9018    Lisp_Object frame;    Lisp_Object frame;
9019      Rect r;
9020    
9021    XSETFRAME (frame, f);    XSETFRAME (frame, f);
9022    
# Line 8940  make_mac_terminal_frame (struct frame *f Line 9040  make_mac_terminal_frame (struct frame *f
9040    f->output_data.mac->mouse_pixel = 0xff00ff;    f->output_data.mac->mouse_pixel = 0xff00ff;
9041    f->output_data.mac->cursor_foreground_pixel = 0x0000ff;    f->output_data.mac->cursor_foreground_pixel = 0x0000ff;
9042    
9043      f->output_data.mac->text_cursor = GetCursor (iBeamCursor);
9044      f->output_data.mac->nontext_cursor = &arrow_cursor;
9045      f->output_data.mac->modeline_cursor = &arrow_cursor;
9046      f->output_data.mac->hand_cursor = &arrow_cursor;
9047      f->output_data.mac->hourglass_cursor = GetCursor (watchCursor);
9048      f->output_data.mac->horizontal_drag_cursor = &arrow_cursor;
9049    
9050    FRAME_FONTSET (f) = -1;    FRAME_FONTSET (f) = -1;
9051    f->output_data.mac->explicit_parent = 0;    f->output_data.mac->explicit_parent = 0;
9052    f->left_pos = 4;    f->left_pos = 8;
9053    f->top_pos = 4;    f->top_pos = 32;
9054    f->border_width = 0;    f->border_width = 0;
9055    
9056    f->internal_border_width = 0;    f->internal_border_width = 0;
# Line 8954  make_mac_terminal_frame (struct frame *f Line 9061  make_mac_terminal_frame (struct frame *f
9061    f->new_text_cols = 0;    f->new_text_cols = 0;
9062    f->new_text_lines = 0;    f->new_text_lines = 0;
9063    
9064    make_mac_frame (f);    SetRect (&r, f->left_pos, f->top_pos,
9065               f->left_pos + FRAME_PIXEL_WIDTH (f),
9066               f->top_pos + FRAME_PIXEL_HEIGHT (f));
9067    
9068      BLOCK_INPUT;
9069    
9070      if (!(FRAME_MAC_WINDOW (f) =
9071            NewCWindow (NULL, &r, "\p", true, dBoxProc,
9072                        (WindowPtr) -1, 1, (long) f->output_data.mac)))
9073        abort ();
9074      /* so that update events can find this mac_output struct */
9075      f->output_data.mac->mFP = f;  /* point back to emacs frame */
9076    
9077      UNBLOCK_INPUT;
9078    
9079    x_make_gc (f);    x_make_gc (f);
9080    
# Line 8970  make_mac_terminal_frame (struct frame *f Line 9090  make_mac_terminal_frame (struct frame *f
9090    Fmodify_frame_parameters (frame,    Fmodify_frame_parameters (frame,
9091                              Fcons (Fcons (Qbackground_color,                              Fcons (Fcons (Qbackground_color,
9092                                            build_string ("white")), Qnil));                                            build_string ("white")), Qnil));
   
   ShowWindow (f->output_data.mac->mWP);  
9093  }  }
9094    #endif
9095    
9096    
9097  /***********************************************************************  /***********************************************************************
# Line 8989  mac_initialize_display_info () Line 9108  mac_initialize_display_info ()
9108    
9109    bzero (dpyinfo, sizeof (*dpyinfo));    bzero (dpyinfo, sizeof (*dpyinfo));
9110    
9111    /* Put it on x_display_name_list.  */  #ifdef MAC_OSX
   x_display_name_list = Fcons (Fcons (build_string ("Mac"), Qnil),  
                                x_display_name_list);  
   dpyinfo->name_list_element = XCAR (x_display_name_list);  
   
 #if 0  
9112    dpyinfo->mac_id_name    dpyinfo->mac_id_name
9113      = (char *) xmalloc (SCHARS (Vinvocation_name)      = (char *) xmalloc (SCHARS (Vinvocation_name)
9114                          + SCHARS (Vsystem_name)                          + SCHARS (Vsystem_name)
# Line 9049  mac_initialize_display_info () Line 9163  mac_initialize_display_info ()
9163    dpyinfo->mouse_face_hidden = 0;    dpyinfo->mouse_face_hidden = 0;
9164  }  }
9165    
9166    /* Create an xrdb-style database of resources to supercede registry settings.
9167       The database is just a concatenation of C strings, finished by an additional
9168       \0.  The string are submitted to some basic normalization, so
9169    
9170         [ *]option[ *]:[ *]value...
9171    
9172       becomes
9173    
9174         option:value...
9175    
9176       but any whitespace following value is not removed.  */
9177    
9178    static char *
9179    mac_make_rdb (xrm_option)
9180         char *xrm_option;
9181    {
9182      char *buffer = xmalloc (strlen (xrm_option) + 2);
9183      char *current = buffer;
9184      char ch;
9185      int in_option = 1;
9186      int before_value = 0;
9187    
9188      do {
9189        ch = *xrm_option++;
9190    
9191        if (ch == '\n')
9192          {
9193            *current++ = '\0';
9194            in_option = 1;
9195            before_value = 0;
9196          }
9197        else if (ch != ' ')
9198          {
9199            *current++ = ch;
9200            if (in_option && (ch == ':'))
9201              {
9202                in_option = 0;
9203                before_value = 1;
9204              }
9205            else if (before_value)
9206              {
9207                before_value = 0;
9208              }
9209          }
9210        else if (!(in_option || before_value))
9211          {
9212            *current++ = ch;
9213          }
9214      } while (ch);
9215    
9216      *current = '\0';
9217    
9218      return buffer;
9219    }
9220    
9221  struct mac_display_info *  struct mac_display_info *
9222  mac_term_init (display_name, xrm_option, resource_name)  mac_term_init (display_name, xrm_option, resource_name)
9223       Lisp_Object display_name;       Lisp_Object display_name;
# Line 9056  mac_term_init (display_name, xrm_option, Line 9225  mac_term_init (display_name, xrm_option,
9225       char *resource_name;       char *resource_name;
9226  {  {
9227    struct mac_display_info *dpyinfo;    struct mac_display_info *dpyinfo;
9228    GDHandle main_device_handle;  
9229      BLOCK_INPUT;
9230    
9231    if (!mac_initialized)    if (!mac_initialized)
9232      {      {
# Line 9064  mac_term_init (display_name, xrm_option, Line 9234  mac_term_init (display_name, xrm_option,
9234        mac_initialized = 1;        mac_initialized = 1;
9235      }      }
9236    
9237    mac_initialize_display_info (display_name);    if (x_display_list)
9238        error ("Sorry, this version can only handle one display");
9239    
9240      mac_initialize_display_info ();
9241    
9242    dpyinfo = &one_mac_display_info;    dpyinfo = &one_mac_display_info;
9243    
9244    main_device_handle = LMGetMainDevice();    dpyinfo->xrdb = xrm_option ? mac_make_rdb (xrm_option) : NULL;
9245    
9246    dpyinfo->height = (**main_device_handle).gdRect.bottom;    /* Put this display on the chain.  */
9247    dpyinfo->width = (**main_device_handle).gdRect.right;    dpyinfo->next = x_display_list;
9248      x_display_list = dpyinfo;
9249    
9250      /* Put it on x_display_name_list.  */
9251      x_display_name_list = Fcons (Fcons (display_name, Qnil),
9252                                   x_display_name_list);
9253      dpyinfo->name_list_element = XCAR (x_display_name_list);
9254    
9255      UNBLOCK_INPUT;
9256    
9257    return dpyinfo;    return dpyinfo;
9258  }  }
9259    /* Get rid of display DPYINFO, assuming all frames are already gone.  */
9260    
9261    void
9262    x_delete_display (dpyinfo)
9263         struct mac_display_info *dpyinfo;
9264    {
9265      int i;
9266    
9267      /* Discard this display from x_display_name_list and x_display_list.
9268         We can't use Fdelq because that can quit.  */
9269      if (! NILP (x_display_name_list)
9270          && EQ (XCAR (x_display_name_list), dpyinfo->name_list_element))
9271        x_display_name_list = XCDR (x_display_name_list);
9272      else
9273        {
9274          Lisp_Object tail;
9275    
9276          tail = x_display_name_list;
9277          while (CONSP (tail) && CONSP (XCDR (tail)))
9278            {
9279              if (EQ (XCAR (XCDR (tail)), dpyinfo->name_list_element))
9280                {
9281                  XSETCDR (tail, XCDR (XCDR (tail)));
9282                  break;
9283                }
9284              tail = XCDR (tail);
9285            }
9286        }
9287    
9288      if (x_display_list == dpyinfo)
9289        x_display_list = dpyinfo->next;
9290      else
9291        {
9292          struct x_display_info *tail;
9293    
9294          for (tail = x_display_list; tail; tail = tail->next)
9295            if (tail->next == dpyinfo)
9296              tail->next = tail->next->next;
9297        }
9298    
9299      /* Free the font names in the font table.  */
9300      for (i = 0; i < dpyinfo->n_fonts; i++)
9301        if (dpyinfo->font_table[i].name)
9302          {
9303            if (dpyinfo->font_table[i].name != dpyinfo->font_table[i].full_name)
9304              xfree (dpyinfo->font_table[i].full_name);
9305            xfree (dpyinfo->font_table[i].name);
9306          }
9307    
9308      if (dpyinfo->font_table->font_encoder)
9309        xfree (dpyinfo->font_table->font_encoder);
9310    
9311      xfree (dpyinfo->font_table);
9312      xfree (dpyinfo->mac_id_name);
9313    
9314      if (x_display_list == 0)
9315        {
9316          mac_clear_font_name_table ();
9317          bzero (dpyinfo, sizeof (*dpyinfo));
9318        }
9319    }
9320    
9321    
9322  #ifdef MAC_OSX  #ifdef MAC_OSX
9323  void  void
# Line 9333  mac_initialize () Line 9576  mac_initialize ()
9576  #endif  #endif
9577    
9578    BLOCK_INPUT;    BLOCK_INPUT;
   mac_initialize_display_info ();  
9579    
9580  #if TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
9581    init_required_apple_events ();    init_required_apple_events ();
# Line 9371  syms_of_macterm () Line 9613  syms_of_macterm ()
9613    Qsuper = intern ("super");    Qsuper = intern ("super");
9614    Fput (Qsuper, Qmodifier_value, make_number (super_modifier));    Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
9615    
9616    #ifdef MAC_OSX
9617    Fprovide (intern ("mac-carbon"), Qnil);    Fprovide (intern ("mac-carbon"), Qnil);
9618    #endif
9619    
9620    staticpro (&Qreverse);    staticpro (&Qreverse);
9621    Qreverse = intern ("reverse");    Qreverse = intern ("reverse");

Legend:
Removed from v.1.85  
changed lines
  Added in v.1.86

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26