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 |
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); |
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. |
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. |
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; |
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. |
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 |
|
|
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 |
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 |
|
|
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); |
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 |
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)) |
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. |
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); |
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); |
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. */) |
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 |
} |
} |
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 |
|
|
4228 |
|
|
4229 |
|
|
4230 |
|
|
4231 |
#ifdef TARGET_API_MAC_CARBON |
#if TARGET_API_MAC_CARBON |
4232 |
/*********************************************************************** |
/*********************************************************************** |
4233 |
File selection dialog |
File selection dialog |
4234 |
***********************************************************************/ |
***********************************************************************/ |
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. */ |
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 |
|
|