comparison src/macfns.c @ 59146:9bde7721ad0f

* dispextern.h: Change HAVE_CARBON to MAC_OS. (struct glyph_string): Likewise. * emacs.c (main) [MAC_OS8]: Call mac_term_init instead of mac_initialize. * fileio.c (Fnext_read_file_uses_dialog_p, Fread_file_name): Change TARGET_API_MAC_CARBON to HAVE_CARBON. * fns.c (vector): Change MAC_OSX to MAC_OS. * frame.c (x_set_frame_parameters, x_report_frame_params) (x_set_fullscreen): Remove #ifndef HAVE_CARBON. (x_set_border_width, Vdefault_frame_scroll_bars): Change HAVE_CARBON to MAC_OS. * image.c [MAC_OS]: Include sys/stat.h. [MAC_OS && !MAC_OSX]: Include sys/param.h, ImageCompression.h, and QuickTimeComponents.h. * mac.c [!MAC_OSX] (mac_wait_next_event): Add extern. [!MAC_OSX] (select): Use mac_wait_next_event. [!MAC_OSX] (run_mac_command): Change EXEC_SUFFIXES to Vexec_suffixes. [!MAC_OSX] (select, run_mac_command): Change `#ifdef TARGET_API_MAC_CARBON' to `#if TARGET_API_MAC_CARBON'. (mac_clear_font_name_table): Add extern. (Fmac_clear_font_name_table): New defun. (syms_of_mac): Defsubr it. [MAC_OSX] (SELECT_POLLING_PERIOD_USEC): New define. [MAC_OSX] (select_and_poll_event): New function. [MAC_OSX] (sys_select): Use it. [MAC_OSX && SELECT_USE_CFSOCKET] (socket_callback): New function. [MAC_OSX && SELECT_USE_CFSOCKET] (SELECT_TIMEOUT_THRESHOLD_RUNLOOP, EVENT_CLASS_SOCK): New defines. [MAC_OSX] (sys_select) [SELECT_USE_CFSOCKET]: Use CFSocket and RunLoop for simultaneously monitoring two kinds of inputs, window events and process outputs, without periodically polling. * macfns.c (mac_initialized): Remove extern. (stricmp): Put in #if 0. All callers changed to use xstricmp in xfaces.c. (strnicmp): Decrement `n' at the end of each loop, not the beginning. (check_mac): Use the term "Mac native windows" instead of "Mac OS". (check_x_display_info, x_display_info_for_name): Sync with xfns.c. (mac_get_rdb_resource): New function (from w32reg.c). (x_get_string_resource): Use it. (install_window_handler): Add extern. (mac_window): New function. (Fx_create_frame): Use it instead of make_mac_frame. Set parameter for Qfullscreen. Call x_wm_set_size_hint. (Fx_open_connection, Fx_close_connection): New defuns. (syms_of_macfns): Defsubr them. (x_create_tip_frame) [TARGET_API_MAC_CARBON]: Add kWindowNoUpdatesAttribute to the window attribute. (x_create_tip_frame) [!TARGET_API_MAC_CARBON]: Use NewCWindow. (x_create_tip_frame): Don't call ShowWindow. (Fx_show_tip): Call ShowWindow. (Fx_file_dialog): Change `#ifdef TARGET_API_MAC_CARBON' to `#if TARGET_API_MAC_CARBON'. (mac_frame_parm_handlers): Set handlers for Qfullscreen. (syms_of_macfns) [MAC_OSX]: Initialize mac_in_use to 0. * macgui.h [!MAC_OSX]: Don't include Controls.h. Include Windows.h. (Window): Typedef to WindowPtr and move outside `#if TARGET_API_MAC_CARBON'. (XSizeHints): New struct. * macterm.c (x_update_begin, x_update_end) [TARGET_API_MAC_CARBON]: Disable screen updates during update of a frame. (x_draw_glyph_string_background, x_draw_glyph_string_foreground) [MAC_OS8]: Use XDrawImageString/XDrawImageString16. (construct_mouse_click): Put in #if 0. (x_check_fullscreen, x_check_fullscreen_move): Remove decls. (x_scroll_bar_create, x_scroll_bar_handle_click): Change `#ifdef TARGET_API_MAC_CARBON' to `#if TARGET_API_MAC_CARBON'. (activate_scroll_bars, deactivate_scroll_bars) [!TARGET_API_MAC_CARBON]: Use ActivateControl/DeactivateControl. (x_make_frame_visible) [TARGET_API_MAC_CARBON]: Reposition window if the position is neither user-specified nor program-specified. (x_free_frame_resources): Free size_hints. (x_wm_set_size_hint): Allocate size_hints if needed. Set size_hints. (mac_clear_font_name_table): New function. (mac_do_list_fonts): Initialize font_name_table if needed. (x_list_fonts): Don't initialize font_name_table. Add BLOCK_INPUT around mac_do_list_fonts. (mac_unload_font): New function. (x_load_font): Add BLOCK_INPUT around XLoadQueryFont. (init_mac_drag_n_drop, mac_do_receive_drag): Enclose declarations and definitions with #if TARGET_API_MAC_CARBON. [USE_CARBON_EVENTS] (mac_handle_window_event): Add decl. (install_window_handler): Add decl. (do_window_update): Add BeginUpdate/EndUpdate for the tooltip window. Use UpdateControls. Get the rectangle that should be updated and restrict the target of expose_frame to it. (do_grow_window): Set minimum height/width according to size_hints. (do_grow_window) [TARGET_API_MAC_CARBON]: Use ResizeWindow. (do_zoom_window): Don't use x_set_window_size. [USE_CARBON_EVENTS] (mac_handle_window_event): New function. (install_window_handler): New function. [!USE_CARBON_EVENTS] (mouse_region): New variable. [!USE_CARBON_EVENTS] (mac_wait_next_event): New function. (XTread_socket) [USE_CARBON_EVENTS]: Move call to GetEventDispatcherTarget inside BLOCK_INPUT. (XTread_socket) [!USE_CARBON_EVENTS]: Use mac_wait_next_event. Update mouse_region when mouse is moved. (make_mac_frame): Remove. (make_mac_terminal_frame): Put in #ifdef MAC_OS8. Initialize mouse pointer shapes. Change values of f->left_pos and f->top_pos. Don't use make_mac_frame. Use NewCWindow. Don't call ShowWindow. (mac_initialize_display_info) [MAC_OSX]: Create mac_id_name from Vinvocation_name and Vsystem_name. (mac_make_rdb): New function (from w32term.c). (mac_term_init): Use it. Add BLOCK_INPUT. Error if display has already been opened. Don't pass argument to mac_initialize_display_info. Don't set dpyinfo->height/width. Add entries to x_display_list and x_display_name_list. (x_delete_display): New function. (mac_initialize): Don't call mac_initialize_display_info. (syms_of_macterm) [!MAC_OSX]: Don't call Fprovide. * macterm.h (check_mac): Add extern. (struct mac_output): New member size_hints. (FRAME_SIZE_HINTS): New macro. (mac_unload_font): Add extern. * xdisp.c (expose_window, expose_frame): Remove kludges for Mac. * xfaces.c (clear_font_table) [MAC_OS]: call mac_unload_font.
author Steven Tamm <steventamm@mac.com>
date Mon, 27 Dec 2004 17:27:30 +0000
parents 4ad0594e1ac4
children 60ffced08532
comparison
equal deleted inserted replaced
59145:c331d9c412f2 59146:9bde7721ad0f
156 Lisp_Object Qcontrol; 156 Lisp_Object Qcontrol;
157 Lisp_Object Qshift; 157 Lisp_Object Qshift;
158 158
159 extern Lisp_Object Vwindow_system_version; 159 extern Lisp_Object Vwindow_system_version;
160 160
161 extern 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
166 static int 164 static int
167 stricmp (const char *s, const char *t) 165 stricmp (const char *s, const char *t)
168 { 166 {
169 for ( ; tolower (*s) == tolower (*t); s++, t++) 167 for ( ; tolower (*s) == tolower (*t); s++, t++)
170 if (*s == '\0') 168 if (*s == '\0')
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
177 static int 176 static int
178 strnicmp (const char *s, const char *t, unsigned int n) 177 strnicmp (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);
184 } 183 }
185 184
188 187
189 void 188 void
190 check_mac () 189 check_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.
197 You should not call this unless HAVE_MENUS is defined. */ 196 You should not call this unless HAVE_MENUS is defined. */
198 197
226 225
227 struct mac_display_info * 226 struct mac_display_info *
228 check_x_display_info (frame) 227 check_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); 249 }
253 f = XFRAME (frame); 250
254 if (! FRAME_MAC_P (f)) 251 return dpyinfo;
255 error ("non-mac frame used");
256 return FRAME_MAC_DISPLAY_INFO (f);
257 }
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.
261 It could be the frame's main window or an icon window. */ 255 It could be the frame's main window or an icon window. */
262 256
1107 int i; 1101 int i;
1108 1102
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;
1116 } 1110 }
1117 1111
2057 } 2051 }
2058 2052
2059 2053
2060 /* Subroutines of creating a frame. */ 2054 /* Subroutines of creating a frame. */
2061 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
2062 char * 2078 char *
2063 x_get_string_resource (rdb, name, class) 2079 x_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.
2072 2102
2073 First search ALIST, then Vdefault_frame_alist, then the X defaults 2103 First search ALIST, then Vdefault_frame_alist, then the X defaults
2227 *height = tempHeight; 2257 *height = tempHeight;
2228 return (mask); 2258 return (mask);
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
2264 extern install_window_handler (WindowPtr);
2265
2235 static void 2266 static void
2236 mac_window (f, window_prompting, minibuffer_only) 2267 mac_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
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 2273
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
2265 /* x_set_name normally ignores requests to set the name if the 2297 /* x_set_name normally ignores requests to set the name if the
2266 requested name is the same as the current name. This is the one 2298 requested name is the same as the current name. This is the one
2274 name = f->name; 2306 name = f->name;
2275 f->name = Qnil; 2307 f->name = Qnil;
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
2283 if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
2284 initialize_frame_menubar (f);
2285 2312
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
2293 well. */ 2319 well. */
2294 2320
2701 "toolBar", "ToolBar", RES_TYPE_NUMBER); 2727 "toolBar", "ToolBar", RES_TYPE_NUMBER);
2702 x_default_parameter (f, parms, Qbuffer_predicate, Qnil, 2728 x_default_parameter (f, parms, Qbuffer_predicate, Qnil,
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
2709 #if TARGET_API_MAC_CARBON 2737 #if TARGET_API_MAC_CARBON
2710 f->output_data.mac->text_cursor = kThemeIBeamCursor; 2738 f->output_data.mac->text_cursor = kThemeIBeamCursor;
2726 window_prompting = x_figure_window_size (f, parms, 1); 2754 window_prompting = x_figure_window_size (f, parms, 1);
2727 2755
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);
2736 2763
2737 /* Now consider the frame official. */ 2764 /* Now consider the frame official. */
2761 2788
2762 SET_FRAME_COLS (f, 0); 2789 SET_FRAME_COLS (f, 0);
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
2777 cannot control visibility, so don't try. */ 2802 cannot control visibility, so don't try. */
2778 if (! f->output_data.mac->explicit_parent) 2803 if (! f->output_data.mac->explicit_parent)
3142 Lisp_Object names; 3167 Lisp_Object names;
3143 struct mac_display_info *dpyinfo; 3168 struct mac_display_info *dpyinfo;
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))
3150 { 3178 {
3151 Lisp_Object tem; 3179 Lisp_Object tem;
3169 XSETFASTINT (Vwindow_system_version, 3); 3197 XSETFASTINT (Vwindow_system_version, 3);
3170 3198
3171 return dpyinfo; 3199 return dpyinfo;
3172 } 3200 }
3173 3201
3174 #if 0 /* MAC_TODO: implement network support */
3175 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection, 3202 DEFUN ("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.
3178 DISPLAY is the name of the display to connect to. 3205 DISPLAY is the name of the display to connect to.
3179 Optional second arg XRM-STRING is a string of resources in xrdb format. 3206 Optional second arg XRM-STRING is a string of resources in xrdb format.
3188 CHECK_STRING (display); 3215 CHECK_STRING (display);
3189 if (! NILP (xrm_string)) 3216 if (! NILP (xrm_string))
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);
3197 else 3224 else
3198 xrm_option = (unsigned char *) 0; 3225 xrm_option = (unsigned char *) 0;
3236 BLOCK_INPUT; 3263 BLOCK_INPUT;
3237 /* Free the fonts in the font table. */ 3264 /* Free the fonts in the font table. */
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);
3249 UNBLOCK_INPUT; 3274 UNBLOCK_INPUT;
3250 3275
3251 return Qnil; 3276 return Qnil;
3252 } 3277 }
3253 #endif /* 0 */
3254 3278
3255 DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, 3279 DEFUN ("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. */)
3257 () 3281 ()
3258 { 3282 {
3811 { 3835 {
3812 Rect r; 3836 Rect r;
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 }
3831 3860
3832 x_make_gc (f); 3861 x_make_gc (f);
4138 compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y); 4167 compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y);
4139 4168
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
4146 /* Draw into the window. */ 4176 /* Draw into the window. */
4147 w->must_be_updated_p = 1; 4177 w->must_be_updated_p = 1;
4196 return unbind_to (count, deleted); 4226 return unbind_to (count, deleted);
4197 } 4227 }
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 ***********************************************************************/
4205 4235
4206 /** 4236 /**
4403 x_set_screen_gamma, 4433 x_set_screen_gamma,
4404 x_set_line_spacing, 4434 x_set_line_spacing,
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
4411 void 4441 void
4412 syms_of_macfns () 4442 syms_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. */
4419 /*&&& init symbols here &&&*/ 4454 /*&&& init symbols here &&&*/
4420 Qnone = intern ("none"); 4455 Qnone = intern ("none");
4534 defsubr (&Sx_display_color_cells); 4569 defsubr (&Sx_display_color_cells);
4535 defsubr (&Sx_display_visual_class); 4570 defsubr (&Sx_display_visual_class);
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
4546 /* Setting callback functions for fontset handler. */ 4579 /* Setting callback functions for fontset handler. */
4547 get_font_info_func = x_get_font_info; 4580 get_font_info_func = x_get_font_info;