aboutsummaryrefslogtreecommitdiffstats
path: root/src/macfns.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/macfns.c')
-rw-r--r--src/macfns.c157
1 files changed, 95 insertions, 62 deletions
diff --git a/src/macfns.c b/src/macfns.c
index fdfe7a52416..dfbc5dacd5e 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -158,9 +158,7 @@ Lisp_Object Qshift;
158 158
159extern Lisp_Object Vwindow_system_version; 159extern Lisp_Object Vwindow_system_version;
160 160
161extern int mac_initialized; 161#if 0 /* Use xstricmp instead. */
162
163
164/* compare two strings ignoring case */ 162/* compare two strings ignoring case */
165 163
166static int 164static int
@@ -171,13 +169,14 @@ stricmp (const char *s, const char *t)
171 return 0; 169 return 0;
172 return tolower (*s) - tolower (*t); 170 return tolower (*s) - tolower (*t);
173} 171}
172#endif
174 173
175/* compare two strings up to n characters, ignoring case */ 174/* compare two strings up to n characters, ignoring case */
176 175
177static int 176static int
178strnicmp (const char *s, const char *t, unsigned int n) 177strnicmp (const char *s, const char *t, unsigned int n)
179{ 178{
180 for ( ; n-- > 0 && tolower (*s) == tolower (*t); s++, t++) 179 for ( ; n > 0 && tolower (*s) == tolower (*t); n--, s++, t++)
181 if (*s == '\0') 180 if (*s == '\0')
182 return 0; 181 return 0;
183 return n == 0 ? 0 : tolower (*s) - tolower (*t); 182 return n == 0 ? 0 : tolower (*s) - tolower (*t);
@@ -190,7 +189,7 @@ void
190check_mac () 189check_mac ()
191{ 190{
192 if (! mac_in_use) 191 if (! mac_in_use)
193 error ("Mac OS not in use or not initialized"); 192 error ("Mac native windows not in use or not initialized");
194} 193}
195 194
196/* Nonzero if we can use mouse menus. 195/* Nonzero if we can use mouse menus.
@@ -228,33 +227,28 @@ struct mac_display_info *
228check_x_display_info (frame) 227check_x_display_info (frame)
229 Lisp_Object frame; 228 Lisp_Object frame;
230{ 229{
231 if (!mac_initialized) 230 struct mac_display_info *dpyinfo = NULL;
232 {
233 mac_initialize ();
234 mac_initialized = 1;
235 }
236 231
237 if (NILP (frame)) 232 if (NILP (frame))
238 { 233 {
239 struct frame *sf = XFRAME (selected_frame); 234 struct frame *sf = XFRAME (selected_frame);
240 235
241 if (FRAME_MAC_P (sf) && FRAME_LIVE_P (sf)) 236 if (FRAME_MAC_P (sf) && FRAME_LIVE_P (sf))
242 return FRAME_MAC_DISPLAY_INFO (sf); 237 dpyinfo = FRAME_MAC_DISPLAY_INFO (sf);
238 else if (x_display_list != 0)
239 dpyinfo = x_display_list;
243 else 240 else
244 return &one_mac_display_info; 241 error ("Mac native windows are not in use or not initialized");
245 } 242 }
246 else if (STRINGP (frame)) 243 else if (STRINGP (frame))
247 return x_display_info_for_name (frame); 244 dpyinfo = x_display_info_for_name (frame);
248 else 245 else
249 { 246 {
250 FRAME_PTR f; 247 FRAME_PTR f = check_x_frame (frame);
251 248 dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
252 CHECK_LIVE_FRAME (frame);
253 f = XFRAME (frame);
254 if (! FRAME_MAC_P (f))
255 error ("non-mac frame used");
256 return FRAME_MAC_DISPLAY_INFO (f);
257 } 249 }
250
251 return dpyinfo;
258} 252}
259 253
260/* Return the Emacs frame-object corresponding to a mac window. 254/* Return the Emacs frame-object corresponding to a mac window.
@@ -1109,7 +1103,7 @@ mac_color_map_lookup (colorname)
1109 BLOCK_INPUT; 1103 BLOCK_INPUT;
1110 1104
1111 for (i = 0; i < sizeof (mac_color_map) / sizeof (mac_color_map[0]); i++) 1105 for (i = 0; i < sizeof (mac_color_map) / sizeof (mac_color_map[0]); i++)
1112 if (stricmp (colorname, mac_color_map[i].name) == 0) 1106 if (xstricmp (colorname, mac_color_map[i].name) == 0)
1113 { 1107 {
1114 ret = make_number (mac_color_map[i].color); 1108 ret = make_number (mac_color_map[i].color);
1115 break; 1109 break;
@@ -2059,13 +2053,49 @@ x_set_scroll_bar_default_width (f)
2059 2053
2060/* Subroutines of creating a frame. */ 2054/* Subroutines of creating a frame. */
2061 2055
2056static char *
2057mac_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
2062char * 2078char *
2063x_get_string_resource (rdb, name, class) 2079x_get_string_resource (rdb, name, class)
2064 XrmDatabase rdb; 2080 XrmDatabase rdb;
2065 char *name, *class; 2081 char *name, *class;
2066{ 2082{
2067 /* MAC_TODO: implement resource strings */ 2083 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
2068 return (char *)0; 2097 return (char *)0;
2098#endif
2069} 2099}
2070 2100
2071/* Return the value of parameter PARAM. 2101/* Return the value of parameter PARAM.
@@ -2229,36 +2259,38 @@ XParseGeometry (string, x, y, width, height)
2229} 2259}
2230 2260
2231 2261
2232#if 0 /* MAC_TODO */
2233/* Create and set up the Mac window for frame F. */ 2262/* Create and set up the Mac window for frame F. */
2234 2263
2264extern install_window_handler (WindowPtr);
2265
2235static void 2266static void
2236mac_window (f, window_prompting, minibuffer_only) 2267mac_window (f)
2237 struct frame *f; 2268 struct frame *f;
2238 long window_prompting;
2239 int minibuffer_only;
2240{ 2269{
2241 Rect r; 2270 Rect r;
2242 2271
2243 BLOCK_INPUT; 2272 BLOCK_INPUT;
2244 2273
2245 /* Use the resource name as the top-level window name
2246 for looking up resources. Make a non-Lisp copy
2247 for the window manager, so GC relocation won't bother it.
2248
2249 Elsewhere we specify the window name for the window manager. */
2250
2251 {
2252 char *str = (char *) SDATA (Vx_resource_name);
2253 f->namebuf = (char *) xmalloc (strlen (str) + 1);
2254 strcpy (f->namebuf, str);
2255 }
2256
2257 SetRect (&r, f->left_pos, f->top_pos, 2274 SetRect (&r, f->left_pos, f->top_pos,
2258 f->left_pos + FRAME_PIXEL_WIDTH (f), 2275 f->left_pos + FRAME_PIXEL_WIDTH (f),
2259 f->top_pos + FRAME_PIXEL_HEIGHT (f)); 2276 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
2260 FRAME_MAC_WINDOW (f) 2288 FRAME_MAC_WINDOW (f)
2261 = NewCWindow (NULL, &r, "\p", 1, zoomDocProc, (WindowPtr) -1, 1, (long) f->output_data.mac); 2289 = 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 */
2262 2294
2263 validate_x_resource_name (); 2295 validate_x_resource_name ();
2264 2296
@@ -2276,17 +2308,11 @@ mac_window (f, window_prompting, minibuffer_only)
2276 x_set_name (f, name, explicit); 2308 x_set_name (f, name, explicit);
2277 } 2309 }
2278 2310
2279 ShowWindow (FRAME_MAC_WINDOW (f));
2280
2281 UNBLOCK_INPUT; 2311 UNBLOCK_INPUT;
2282 2312
2283 if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
2284 initialize_frame_menubar (f);
2285
2286 if (FRAME_MAC_WINDOW (f) == 0) 2313 if (FRAME_MAC_WINDOW (f) == 0)
2287 error ("Unable to create window"); 2314 error ("Unable to create window");
2288} 2315}
2289#endif /* MAC_TODO */
2290 2316
2291/* Handle the icon stuff for this window. Perhaps later we might 2317/* Handle the icon stuff for this window. Perhaps later we might
2292 want an x_set_icon_position which can be called interactively as 2318 want an x_set_icon_position which can be called interactively as
@@ -2703,6 +2729,8 @@ This function is an internal primitive--use `make-frame' instead. */)
2703 "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL); 2729 "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL);
2704 x_default_parameter (f, parms, Qtitle, Qnil, 2730 x_default_parameter (f, parms, Qtitle, Qnil,
2705 "title", "Title", RES_TYPE_STRING); 2731 "title", "Title", RES_TYPE_STRING);
2732 x_default_parameter (f, parms, Qfullscreen, Qnil,
2733 "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
2706 2734
2707 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; 2735 f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window;
2708 2736
@@ -2728,8 +2756,7 @@ This function is an internal primitive--use `make-frame' instead. */)
2728 tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); 2756 tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
2729 f->no_split = minibuffer_only || EQ (tem, Qt); 2757 f->no_split = minibuffer_only || EQ (tem, Qt);
2730 2758
2731 /* mac_window (f, window_prompting, minibuffer_only); */ 2759 mac_window (f);
2732 make_mac_frame (f);
2733 2760
2734 x_icon (f, parms); 2761 x_icon (f, parms);
2735 x_make_gc (f); 2762 x_make_gc (f);
@@ -2763,14 +2790,12 @@ This function is an internal primitive--use `make-frame' instead. */)
2763 FRAME_LINES (f) = 0; 2790 FRAME_LINES (f) = 0;
2764 change_frame_size (f, height, width, 1, 0, 0); 2791 change_frame_size (f, height, width, 1, 0, 0);
2765 2792
2766#if 0 /* MAC_TODO: when we have window manager hints */
2767 /* Tell the server what size and position, etc, we want, and how 2793 /* Tell the server what size and position, etc, we want, and how
2768 badly we want them. This should be done after we have the menu 2794 badly we want them. This should be done after we have the menu
2769 bar so that its size can be taken into account. */ 2795 bar so that its size can be taken into account. */
2770 BLOCK_INPUT; 2796 BLOCK_INPUT;
2771 x_wm_set_size_hint (f, window_prompting, 0); 2797 x_wm_set_size_hint (f, window_prompting, 0);
2772 UNBLOCK_INPUT; 2798 UNBLOCK_INPUT;
2773#endif
2774 2799
2775 /* Make the window appear on the frame and enable display, unless 2800 /* Make the window appear on the frame and enable display, unless
2776 the caller says not to. However, with explicit parent, Emacs 2801 the caller says not to. However, with explicit parent, Emacs
@@ -3144,6 +3169,9 @@ x_display_info_for_name (name)
3144 3169
3145 CHECK_STRING (name); 3170 CHECK_STRING (name);
3146 3171
3172 if (! EQ (Vwindow_system, intern ("mac")))
3173 error ("Not using Mac native windows");
3174
3147 for (dpyinfo = &one_mac_display_info, names = x_display_name_list; 3175 for (dpyinfo = &one_mac_display_info, names = x_display_name_list;
3148 dpyinfo; 3176 dpyinfo;
3149 dpyinfo = dpyinfo->next, names = XCDR (names)) 3177 dpyinfo = dpyinfo->next, names = XCDR (names))
@@ -3171,7 +3199,6 @@ x_display_info_for_name (name)
3171 return dpyinfo; 3199 return dpyinfo;
3172} 3200}
3173 3201
3174#if 0 /* MAC_TODO: implement network support */
3175DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection, 3202DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
3176 1, 3, 0, 3203 1, 3, 0,
3177 doc: /* Open a connection to a server. 3204 doc: /* Open a connection to a server.
@@ -3190,7 +3217,7 @@ terminate Emacs if we can't open the connection. */)
3190 CHECK_STRING (xrm_string); 3217 CHECK_STRING (xrm_string);
3191 3218
3192 if (! EQ (Vwindow_system, intern ("mac"))) 3219 if (! EQ (Vwindow_system, intern ("mac")))
3193 error ("Not using Mac OS"); 3220 error ("Not using Mac native windows");
3194 3221
3195 if (! NILP (xrm_string)) 3222 if (! NILP (xrm_string))
3196 xrm_option = (unsigned char *) SDATA (xrm_string); 3223 xrm_option = (unsigned char *) SDATA (xrm_string);
@@ -3238,11 +3265,9 @@ If DISPLAY is nil, that stands for the selected frame's display. */)
3238 for (i = 0; i < dpyinfo->n_fonts; i++) 3265 for (i = 0; i < dpyinfo->n_fonts; i++)
3239 if (dpyinfo->font_table[i].name) 3266 if (dpyinfo->font_table[i].name)
3240 { 3267 {
3241 if (dpyinfo->font_table[i].name != dpyinfo->font_table[i].full_name) 3268 mac_unload_font (dpyinfo, dpyinfo->font_table[i].font);
3242 xfree (dpyinfo->font_table[i].full_name);
3243 xfree (dpyinfo->font_table[i].name);
3244 x_unload_font (dpyinfo, dpyinfo->font_table[i].font);
3245 } 3269 }
3270
3246 x_destroy_all_bitmaps (dpyinfo); 3271 x_destroy_all_bitmaps (dpyinfo);
3247 3272
3248 x_delete_display (dpyinfo); 3273 x_delete_display (dpyinfo);
@@ -3250,7 +3275,6 @@ If DISPLAY is nil, that stands for the selected frame's display. */)
3250 3275
3251 return Qnil; 3276 return Qnil;
3252} 3277}
3253#endif /* 0 */
3254 3278
3255DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, 3279DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
3256 doc: /* Return the list of display names that Emacs has connections to. */) 3280 doc: /* Return the list of display names that Emacs has connections to. */)
@@ -3813,18 +3837,23 @@ x_create_tip_frame (dpyinfo, parms, text)
3813 3837
3814 BLOCK_INPUT; 3838 BLOCK_INPUT;
3815 SetRect (&r, 0, 0, 1, 1); 3839 SetRect (&r, 0, 0, 1, 1);
3840#if TARGET_API_MAC_CARBON
3816 if (CreateNewWindow (kHelpWindowClass, 3841 if (CreateNewWindow (kHelpWindowClass,
3817#ifdef MAC_OS_X_VERSION_10_2 3842#ifdef MAC_OS_X_VERSION_10_2
3818 kWindowIgnoreClicksAttribute | 3843 kWindowIgnoreClicksAttribute |
3819#endif 3844#endif
3845 kWindowNoUpdatesAttribute |
3820 kWindowNoActivatesAttribute, 3846 kWindowNoActivatesAttribute,
3821 &r, &tip_window) == noErr) 3847 &r, &tip_window) == noErr)
3848#else
3849 if (tip_window = NewCWindow (NULL, &r, "\p", false, plainDBox,
3850 NULL, false, 0L))
3851#endif
3822 { 3852 {
3823 FRAME_MAC_WINDOW (f) = tip_window; 3853 FRAME_MAC_WINDOW (f) = tip_window;
3824 SetWRefCon (tip_window, (long) f->output_data.mac); 3854 SetWRefCon (tip_window, (long) f->output_data.mac);
3825 /* so that update events can find this mac_output struct */ 3855 /* so that update events can find this mac_output struct */
3826 f->output_data.mac->mFP = f; 3856 f->output_data.mac->mFP = f;
3827 ShowWindow (tip_window);
3828 } 3857 }
3829 UNBLOCK_INPUT; 3858 UNBLOCK_INPUT;
3830 } 3859 }
@@ -4140,6 +4169,7 @@ Text larger than the specified size is clipped. */)
4140 BLOCK_INPUT; 4169 BLOCK_INPUT;
4141 MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false); 4170 MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false);
4142 SizeWindow (FRAME_MAC_WINDOW (f), width, height, true); 4171 SizeWindow (FRAME_MAC_WINDOW (f), width, height, true);
4172 ShowWindow (FRAME_MAC_WINDOW (f));
4143 BringToFront (FRAME_MAC_WINDOW (f)); 4173 BringToFront (FRAME_MAC_WINDOW (f));
4144 UNBLOCK_INPUT; 4174 UNBLOCK_INPUT;
4145 4175
@@ -4198,7 +4228,7 @@ Value is t if tooltip was open, nil otherwise. */)
4198 4228
4199 4229
4200 4230
4201#ifdef TARGET_API_MAC_CARBON 4231#if TARGET_API_MAC_CARBON
4202/*********************************************************************** 4232/***********************************************************************
4203 File selection dialog 4233 File selection dialog
4204 ***********************************************************************/ 4234 ***********************************************************************/
@@ -4405,14 +4435,19 @@ frame_parm_handler mac_frame_parm_handlers[] =
4405 x_set_fringe_width, 4435 x_set_fringe_width,
4406 x_set_fringe_width, 4436 x_set_fringe_width,
4407 0, /* x_set_wait_for_wm, */ 4437 0, /* x_set_wait_for_wm, */
4408 0, /* MAC_TODO: x_set_fullscreen, */ 4438 x_set_fullscreen,
4409}; 4439};
4410 4440
4411void 4441void
4412syms_of_macfns () 4442syms_of_macfns ()
4413{ 4443{
4414 /* Certainly running on Mac. */ 4444#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. */
4415 mac_in_use = 1; 4449 mac_in_use = 1;
4450#endif
4416 4451
4417 /* The section below is built by the lisp expression at the top of the file, 4452 /* The section below is built by the lisp expression at the top of the file,
4418 just above where these variables are declared. */ 4453 just above where these variables are declared. */
@@ -4536,10 +4571,8 @@ Chinese, Japanese, and Korean. */);
4536 defsubr (&Sx_display_backing_store); 4571 defsubr (&Sx_display_backing_store);
4537 defsubr (&Sx_display_save_under); 4572 defsubr (&Sx_display_save_under);
4538 defsubr (&Sx_create_frame); 4573 defsubr (&Sx_create_frame);
4539#if 0 /* MAC_TODO: implement network support */
4540 defsubr (&Sx_open_connection); 4574 defsubr (&Sx_open_connection);
4541 defsubr (&Sx_close_connection); 4575 defsubr (&Sx_close_connection);
4542#endif
4543 defsubr (&Sx_display_list); 4576 defsubr (&Sx_display_list);
4544 defsubr (&Sx_synchronize); 4577 defsubr (&Sx_synchronize);
4545 4578