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

Diff of /emacs/src/macfns.c

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

revision 1.44 by tamm, Fri Dec 3 17:00:11 2004 UTC revision 1.45 by tamm, Mon Dec 27 17:27:30 2004 UTC
# Line 158  Lisp_Object Qshift; Line 158  Lisp_Object Qshift;
158    
159  extern Lisp_Object Vwindow_system_version;  extern Lisp_Object Vwindow_system_version;
160    
161  extern int mac_initialized;  #if 0 /* Use xstricmp instead. */
   
   
162  /* compare two strings ignoring case */  /* compare two strings ignoring case */
163    
164  static int  static int
# Line 171  stricmp (const char *s, const char *t) Line 169  stricmp (const char *s, const char *t)
169        return 0;        return 0;
170    return tolower (*s) - tolower (*t);    return tolower (*s) - tolower (*t);
171  }  }
172    #endif
173    
174  /* compare two strings up to n characters, ignoring case */  /* compare two strings up to n characters, ignoring case */
175    
176  static int  static int
177  strnicmp (const char *s, const char *t, unsigned int n)  strnicmp (const char *s, const char *t, unsigned int n)
178  {  {
179    for ( ; n-- > 0 && tolower (*s) == tolower (*t); s++, t++)    for ( ; n > 0 && tolower (*s) == tolower (*t); n--, s++, t++)
180      if (*s == '\0')      if (*s == '\0')
181        return 0;        return 0;
182    return n == 0 ? 0 : tolower (*s) - tolower (*t);    return n == 0 ? 0 : tolower (*s) - tolower (*t);
# Line 190  void Line 189  void
189  check_mac ()  check_mac ()
190  {  {
191    if (! mac_in_use)    if (! mac_in_use)
192      error ("Mac OS not in use or not initialized");      error ("Mac native windows not in use or not initialized");
193  }  }
194    
195  /* Nonzero if we can use mouse menus.  /* Nonzero if we can use mouse menus.
# Line 228  struct mac_display_info * Line 227  struct mac_display_info *
227  check_x_display_info (frame)  check_x_display_info (frame)
228       Lisp_Object frame;       Lisp_Object frame;
229  {  {
230    if (!mac_initialized)    struct mac_display_info *dpyinfo = NULL;
     {  
       mac_initialize ();  
       mac_initialized = 1;  
     }  
231    
232    if (NILP (frame))    if (NILP (frame))
233      {      {
234        struct frame *sf = XFRAME (selected_frame);        struct frame *sf = XFRAME (selected_frame);
235    
236        if (FRAME_MAC_P (sf) && FRAME_LIVE_P (sf))        if (FRAME_MAC_P (sf) && FRAME_LIVE_P (sf))
237          return FRAME_MAC_DISPLAY_INFO (sf);          dpyinfo = FRAME_MAC_DISPLAY_INFO (sf);
238          else if (x_display_list != 0)
239            dpyinfo = x_display_list;
240        else        else
241          return &one_mac_display_info;          error ("Mac native windows are not in use or not initialized");
242      }      }
243    else if (STRINGP (frame))    else if (STRINGP (frame))
244      return x_display_info_for_name (frame);      dpyinfo = x_display_info_for_name (frame);
245    else    else
246      {      {
247        FRAME_PTR f;        FRAME_PTR f = check_x_frame (frame);
248          dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
       CHECK_LIVE_FRAME (frame);  
       f = XFRAME (frame);  
       if (! FRAME_MAC_P (f))  
         error ("non-mac frame used");  
       return FRAME_MAC_DISPLAY_INFO (f);  
249      }      }
250    
251      return dpyinfo;
252  }  }
253    
254  /* Return the Emacs frame-object corresponding to a mac window.  /* Return the Emacs frame-object corresponding to a mac window.
# Line 1109  mac_color_map_lookup (colorname) Line 1103  mac_color_map_lookup (colorname)
1103    BLOCK_INPUT;    BLOCK_INPUT;
1104    
1105    for (i = 0; i < sizeof (mac_color_map) / sizeof (mac_color_map[0]); i++)    for (i = 0; i < sizeof (mac_color_map) / sizeof (mac_color_map[0]); i++)
1106      if (stricmp (colorname, mac_color_map[i].name) == 0)      if (xstricmp (colorname, mac_color_map[i].name) == 0)
1107        {        {
1108          ret = make_number (mac_color_map[i].color);          ret = make_number (mac_color_map[i].color);
1109          break;          break;
# Line 2059  x_set_scroll_bar_default_width (f) Line 2053  x_set_scroll_bar_default_width (f)
2053    
2054  /* Subroutines of creating a frame.  */  /* Subroutines of creating a frame.  */
2055    
2056    static char *
2057    mac_get_rdb_resource (rdb, resource)
2058         char *rdb;
2059         char *resource;
2060    {
2061      char *value = rdb;
2062      int len = strlen (resource);
2063    
2064      while (*value)
2065        {
2066          if ((strncmp (value, resource, len) == 0) && (value[len] == ':'))
2067            return xstrdup (&value[len + 1]);
2068    
2069          value = strchr (value, '\0') + 1;
2070        }
2071    
2072      return NULL;
2073    }
2074    
2075    /* Retrieve the string resource specified by NAME with CLASS from
2076       database RDB. */
2077    
2078  char *  char *
2079  x_get_string_resource (rdb, name, class)  x_get_string_resource (rdb, name, class)
2080       XrmDatabase rdb;       XrmDatabase rdb;
2081       char *name, *class;       char *name, *class;
2082  {  {
2083    /* MAC_TODO: implement resource strings */    if (rdb)
2084        {
2085          char *resource;
2086    
2087          if (resource = mac_get_rdb_resource (rdb, name))
2088            return resource;
2089          if (resource = mac_get_rdb_resource (rdb, class))
2090            return resource;
2091        }
2092    
2093      /* MAC_TODO: implement resource strings.  (Maybe Property Lists?)  */
2094    #if 0
2095      return mac_get_string_resource (name, class);
2096    #else
2097    return (char *)0;    return (char *)0;
2098    #endif
2099  }  }
2100    
2101  /* Return the value of parameter PARAM.  /* Return the value of parameter PARAM.
# Line 2229  XParseGeometry (string, x, y, width, hei Line 2259  XParseGeometry (string, x, y, width, hei
2259  }  }
2260    
2261    
 #if 0 /* MAC_TODO */  
2262  /* Create and set up the Mac window for frame F.  */  /* Create and set up the Mac window for frame F.  */
2263    
2264    extern install_window_handler (WindowPtr);
2265    
2266  static void  static void
2267  mac_window (f, window_prompting, minibuffer_only)  mac_window (f)
2268       struct frame *f;       struct frame *f;
      long window_prompting;  
      int minibuffer_only;  
2269  {  {
2270    Rect r;    Rect r;
2271    
2272    BLOCK_INPUT;    BLOCK_INPUT;
2273    
   /* Use the resource name as the top-level window name  
      for looking up resources.  Make a non-Lisp copy  
      for the window manager, so GC relocation won't bother it.  
   
      Elsewhere we specify the window name for the window manager.  */  
   
   {  
     char *str = (char *) SDATA (Vx_resource_name);  
     f->namebuf = (char *) xmalloc (strlen (str) + 1);  
     strcpy (f->namebuf, str);  
   }  
   
2274    SetRect (&r, f->left_pos, f->top_pos,    SetRect (&r, f->left_pos, f->top_pos,
2275             f->left_pos + FRAME_PIXEL_WIDTH (f),             f->left_pos + FRAME_PIXEL_WIDTH (f),
2276             f->top_pos + FRAME_PIXEL_HEIGHT (f));             f->top_pos + FRAME_PIXEL_HEIGHT (f));
2277    #if TARGET_API_MAC_CARBON
2278      CreateNewWindow (kDocumentWindowClass,
2279                       kWindowStandardDocumentAttributes
2280                       /* | kWindowToolbarButtonAttribute */,
2281                       &r, &FRAME_MAC_WINDOW (f));
2282      if (FRAME_MAC_WINDOW (f))
2283        {
2284          SetWRefCon (FRAME_MAC_WINDOW (f), (long) f->output_data.mac);
2285          install_window_handler (FRAME_MAC_WINDOW (f));
2286        }
2287    #else
2288    FRAME_MAC_WINDOW (f)    FRAME_MAC_WINDOW (f)
2289      = NewCWindow (NULL, &r, "\p", 1, zoomDocProc, (WindowPtr) -1, 1, (long) f->output_data.mac);      = NewCWindow (NULL, &r, "\p", false, zoomDocProc,
2290                      (WindowPtr) -1, 1, (long) f->output_data.mac);
2291    #endif
2292      /* so that update events can find this mac_output struct */
2293      f->output_data.mac->mFP = f;  /* point back to emacs frame */
2294    
2295    validate_x_resource_name ();    validate_x_resource_name ();
2296    
# Line 2276  mac_window (f, window_prompting, minibuf Line 2308  mac_window (f, window_prompting, minibuf
2308      x_set_name (f, name, explicit);      x_set_name (f, name, explicit);
2309    }    }
2310    
   ShowWindow (FRAME_MAC_WINDOW (f));  
   
2311    UNBLOCK_INPUT;    UNBLOCK_INPUT;
2312    
   if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))  
     initialize_frame_menubar (f);  
   
2313    if (FRAME_MAC_WINDOW (f) == 0)    if (FRAME_MAC_WINDOW (f) == 0)
2314      error ("Unable to create window");      error ("Unable to create window");
2315  }  }
 #endif /* MAC_TODO */  
2316    
2317  /* Handle the icon stuff for this window.  Perhaps later we might  /* Handle the icon stuff for this window.  Perhaps later we might
2318     want an x_set_icon_position which can be called interactively as     want an x_set_icon_position which can be called interactively as
# Line 2703  This function is an internal primitive-- Line 2729  This function is an internal primitive--
2729                         "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);                         "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
2730    x_default_parameter (f, parms, Qtitle, Qnil,    x_default_parameter (f, parms, Qtitle, Qnil,
2731                         "title", "Title", RES_TYPE_STRING);                         "title", "Title", RES_TYPE_STRING);
2732      x_default_parameter (f, parms, Qfullscreen, Qnil,
2733                           "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
2734    
2735    f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;    f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
2736    
# Line 2728  This function is an internal primitive-- Line 2756  This function is an internal primitive--
2756    tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);    tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
2757    f->no_split = minibuffer_only || EQ (tem, Qt);    f->no_split = minibuffer_only || EQ (tem, Qt);
2758    
2759    /* mac_window (f, window_prompting, minibuffer_only); */    mac_window (f);
   make_mac_frame (f);  
2760    
2761    x_icon (f, parms);    x_icon (f, parms);
2762    x_make_gc (f);    x_make_gc (f);
# Line 2763  This function is an internal primitive-- Line 2790  This function is an internal primitive--
2790    FRAME_LINES (f) = 0;    FRAME_LINES (f) = 0;
2791    change_frame_size (f, height, width, 1, 0, 0);    change_frame_size (f, height, width, 1, 0, 0);
2792    
 #if 0 /* MAC_TODO: when we have window manager hints */  
2793    /* Tell the server what size and position, etc, we want, and how    /* Tell the server what size and position, etc, we want, and how
2794       badly we want them.  This should be done after we have the menu       badly we want them.  This should be done after we have the menu
2795       bar so that its size can be taken into account.  */       bar so that its size can be taken into account.  */
2796    BLOCK_INPUT;    BLOCK_INPUT;
2797    x_wm_set_size_hint (f, window_prompting, 0);    x_wm_set_size_hint (f, window_prompting, 0);
2798    UNBLOCK_INPUT;    UNBLOCK_INPUT;
 #endif  
2799    
2800    /* Make the window appear on the frame and enable display, unless    /* Make the window appear on the frame and enable display, unless
2801       the caller says not to.  However, with explicit parent, Emacs       the caller says not to.  However, with explicit parent, Emacs
# Line 3144  x_display_info_for_name (name) Line 3169  x_display_info_for_name (name)
3169    
3170    CHECK_STRING (name);    CHECK_STRING (name);
3171    
3172      if (! EQ (Vwindow_system, intern ("mac")))
3173        error ("Not using Mac native windows");
3174    
3175    for (dpyinfo = &one_mac_display_info, names = x_display_name_list;    for (dpyinfo = &one_mac_display_info, names = x_display_name_list;
3176         dpyinfo;         dpyinfo;
3177         dpyinfo = dpyinfo->next, names = XCDR (names))         dpyinfo = dpyinfo->next, names = XCDR (names))
# Line 3171  x_display_info_for_name (name) Line 3199  x_display_info_for_name (name)
3199    return dpyinfo;    return dpyinfo;
3200  }  }
3201    
 #if 0 /* MAC_TODO: implement network support */  
3202  DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,  DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
3203         1, 3, 0,         1, 3, 0,
3204         doc: /* Open a connection to a server.         doc: /* Open a connection to a server.
# Line 3190  terminate Emacs if we can't open the con Line 3217  terminate Emacs if we can't open the con
3217      CHECK_STRING (xrm_string);      CHECK_STRING (xrm_string);
3218    
3219    if (! EQ (Vwindow_system, intern ("mac")))    if (! EQ (Vwindow_system, intern ("mac")))
3220      error ("Not using Mac OS");      error ("Not using Mac native windows");
3221    
3222    if (! NILP (xrm_string))    if (! NILP (xrm_string))
3223      xrm_option = (unsigned char *) SDATA (xrm_string);      xrm_option = (unsigned char *) SDATA (xrm_string);
# Line 3238  If DISPLAY is nil, that stands for the s Line 3265  If DISPLAY is nil, that stands for the s
3265    for (i = 0; i < dpyinfo->n_fonts; i++)    for (i = 0; i < dpyinfo->n_fonts; i++)
3266      if (dpyinfo->font_table[i].name)      if (dpyinfo->font_table[i].name)
3267        {        {
3268          if (dpyinfo->font_table[i].name != dpyinfo->font_table[i].full_name)          mac_unload_font (dpyinfo, dpyinfo->font_table[i].font);
           xfree (dpyinfo->font_table[i].full_name);  
         xfree (dpyinfo->font_table[i].name);  
         x_unload_font (dpyinfo, dpyinfo->font_table[i].font);  
3269        }        }
3270    
3271    x_destroy_all_bitmaps (dpyinfo);    x_destroy_all_bitmaps (dpyinfo);
3272    
3273    x_delete_display (dpyinfo);    x_delete_display (dpyinfo);
# Line 3250  If DISPLAY is nil, that stands for the s Line 3275  If DISPLAY is nil, that stands for the s
3275    
3276    return Qnil;    return Qnil;
3277  }  }
 #endif /* 0 */  
3278    
3279  DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,  DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
3280         doc: /* Return the list of display names that Emacs has connections to.  */)         doc: /* Return the list of display names that Emacs has connections to.  */)
# Line 3813  x_create_tip_frame (dpyinfo, parms, text Line 3837  x_create_tip_frame (dpyinfo, parms, text
3837    
3838      BLOCK_INPUT;      BLOCK_INPUT;
3839      SetRect (&r, 0, 0, 1, 1);      SetRect (&r, 0, 0, 1, 1);
3840    #if TARGET_API_MAC_CARBON
3841      if (CreateNewWindow (kHelpWindowClass,      if (CreateNewWindow (kHelpWindowClass,
3842  #ifdef MAC_OS_X_VERSION_10_2  #ifdef MAC_OS_X_VERSION_10_2
3843                           kWindowIgnoreClicksAttribute |                           kWindowIgnoreClicksAttribute |
3844  #endif  #endif
3845                             kWindowNoUpdatesAttribute |
3846                           kWindowNoActivatesAttribute,                           kWindowNoActivatesAttribute,
3847                           &r, &tip_window) == noErr)                           &r, &tip_window) == noErr)
3848    #else
3849        if (tip_window = NewCWindow (NULL, &r, "\p", false, plainDBox,
3850                                     NULL, false, 0L))
3851    #endif
3852        {        {
3853          FRAME_MAC_WINDOW (f) = tip_window;          FRAME_MAC_WINDOW (f) = tip_window;
3854          SetWRefCon (tip_window, (long) f->output_data.mac);          SetWRefCon (tip_window, (long) f->output_data.mac);
3855          /* so that update events can find this mac_output struct */          /* so that update events can find this mac_output struct */
3856          f->output_data.mac->mFP = f;          f->output_data.mac->mFP = f;
         ShowWindow (tip_window);  
3857        }        }
3858      UNBLOCK_INPUT;      UNBLOCK_INPUT;
3859    }    }
# Line 4140  Text larger than the specified size is c Line 4169  Text larger than the specified size is c
4169    BLOCK_INPUT;    BLOCK_INPUT;
4170    MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);    MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
4171    SizeWindow (FRAME_MAC_WINDOW (f), width, height, true);    SizeWindow (FRAME_MAC_WINDOW (f), width, height, true);
4172      ShowWindow (FRAME_MAC_WINDOW (f));
4173    BringToFront (FRAME_MAC_WINDOW (f));    BringToFront (FRAME_MAC_WINDOW (f));
4174    UNBLOCK_INPUT;    UNBLOCK_INPUT;
4175    
# Line 4198  Value is t if tooltip was open, nil othe Line 4228  Value is t if tooltip was open, nil othe
4228    
4229    
4230    
4231  #ifdef TARGET_API_MAC_CARBON  #if TARGET_API_MAC_CARBON
4232  /***********************************************************************  /***********************************************************************
4233                          File selection dialog                          File selection dialog
4234   ***********************************************************************/   ***********************************************************************/
# Line 4405  frame_parm_handler mac_frame_parm_handle Line 4435  frame_parm_handler mac_frame_parm_handle
4435    x_set_fringe_width,    x_set_fringe_width,
4436    x_set_fringe_width,    x_set_fringe_width,
4437    0, /* x_set_wait_for_wm, */    0, /* x_set_wait_for_wm, */
4438    0, /* MAC_TODO: x_set_fullscreen, */    x_set_fullscreen,
4439  };  };
4440    
4441  void  void
4442  syms_of_macfns ()  syms_of_macfns ()
4443  {  {
4444    /* Certainly running on Mac.  */  #ifdef MAC_OSX
4445      /* This is zero if not using Mac native windows.  */
4446      mac_in_use = 0;
4447    #else
4448      /* Certainly running on Mac native windows.  */
4449    mac_in_use = 1;    mac_in_use = 1;
4450    #endif
4451    
4452    /* The section below is built by the lisp expression at the top of the file,    /* The section below is built by the lisp expression at the top of the file,
4453       just above where these variables are declared.  */       just above where these variables are declared.  */
# Line 4536  Chinese, Japanese, and Korean.  */); Line 4571  Chinese, Japanese, and Korean.  */);
4571    defsubr (&Sx_display_backing_store);    defsubr (&Sx_display_backing_store);
4572    defsubr (&Sx_display_save_under);    defsubr (&Sx_display_save_under);
4573    defsubr (&Sx_create_frame);    defsubr (&Sx_create_frame);
 #if 0 /* MAC_TODO: implement network support */  
4574    defsubr (&Sx_open_connection);    defsubr (&Sx_open_connection);
4575    defsubr (&Sx_close_connection);    defsubr (&Sx_close_connection);
 #endif  
4576    defsubr (&Sx_display_list);    defsubr (&Sx_display_list);
4577    defsubr (&Sx_synchronize);    defsubr (&Sx_synchronize);
4578    

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45

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