comparison src/macterm.c @ 72545:171c891be45d

(mac_draw_string_common, mac_query_char_extents) (x_iconify_frame, XLoadQueryFont, install_window_handler) (mac_handle_command_event, init_command_handler, init_menu_bar): Use OSStatus instead of OSErr. (x_free_frame_resources) [TARGET_API_MAC_CARBON]: Don't use FRAME_FILE_NAME. (x_query_font): Apply 2006-08-04 change for xterm.c. (Qhi_command): Rename from Qhicommand. All uses changed.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Sun, 27 Aug 2006 07:09:52 +0000
parents 759e19ea81e5
children 3f73353559c2 694bbb62a75d 6823a91487f2
comparison
equal deleted inserted replaced
72544:f8ade754466c 72545:171c891be45d
900 SetPortWindowPort (FRAME_MAC_WINDOW (f)); 900 SetPortWindowPort (FRAME_MAC_WINDOW (f));
901 901
902 #if USE_ATSUI 902 #if USE_ATSUI
903 if (GC_FONT (gc)->mac_style) 903 if (GC_FONT (gc)->mac_style)
904 { 904 {
905 OSErr err; 905 OSStatus err;
906 ATSUTextLayout text_layout; 906 ATSUTextLayout text_layout;
907 907
908 xassert (bytes_per_char == 2); 908 xassert (bytes_per_char == 2);
909 909
910 #ifndef WORDS_BIG_ENDIAN 910 #ifndef WORDS_BIG_ENDIAN
1127 /* Mac replacement for XQueryTextExtents, but takes a character. If 1127 /* Mac replacement for XQueryTextExtents, but takes a character. If
1128 STYLE is NULL, measurement is done by QuickDraw Text routines for 1128 STYLE is NULL, measurement is done by QuickDraw Text routines for
1129 the font of the current graphics port. If CG_GLYPH is not NULL, 1129 the font of the current graphics port. If CG_GLYPH is not NULL,
1130 *CG_GLYPH is set to the glyph ID or 0 if it cannot be obtained. */ 1130 *CG_GLYPH is set to the glyph ID or 0 if it cannot be obtained. */
1131 1131
1132 static OSErr 1132 static OSStatus
1133 mac_query_char_extents (style, c, 1133 mac_query_char_extents (style, c,
1134 font_ascent_return, font_descent_return, 1134 font_ascent_return, font_descent_return,
1135 overall_return, cg_glyph) 1135 overall_return, cg_glyph)
1136 #if USE_ATSUI 1136 #if USE_ATSUI
1137 ATSUStyle style; 1137 ATSUStyle style;
1145 CGGlyph *cg_glyph; 1145 CGGlyph *cg_glyph;
1146 #else 1146 #else
1147 void *cg_glyph; 1147 void *cg_glyph;
1148 #endif 1148 #endif
1149 { 1149 {
1150 OSErr err = noErr; 1150 OSStatus err = noErr;
1151 int width; 1151 int width;
1152 Rect char_bounds; 1152 Rect char_bounds;
1153 1153
1154 #if USE_ATSUI 1154 #if USE_ATSUI
1155 if (style) 1155 if (style)
1191 if (err == noErr) 1191 if (err == noErr)
1192 STORE_XCHARSTRUCT (*overall_return, width, char_bounds); 1192 STORE_XCHARSTRUCT (*overall_return, width, char_bounds);
1193 #if USE_CG_TEXT_DRAWING 1193 #if USE_CG_TEXT_DRAWING
1194 if (err == noErr && cg_glyph) 1194 if (err == noErr && cg_glyph)
1195 { 1195 {
1196 OSErr err1; 1196 OSStatus err1;
1197 ATSUGlyphInfoArray glyph_info_array; 1197 ATSUGlyphInfoArray glyph_info_array;
1198 ByteCount count = sizeof (ATSUGlyphInfoArray); 1198 ByteCount count = sizeof (ATSUGlyphInfoArray);
1199 1199
1200 err1 = ATSUMatchFontsToText (text_layout, kATSUFromTextBeginning, 1200 err1 = ATSUMatchFontsToText (text_layout, kATSUFromTextBeginning,
1201 kATSUToTextEnd, NULL, NULL, NULL); 1201 kATSUToTextEnd, NULL, NULL, NULL);
6312 6312
6313 void 6313 void
6314 x_iconify_frame (f) 6314 x_iconify_frame (f)
6315 struct frame *f; 6315 struct frame *f;
6316 { 6316 {
6317 OSErr err; 6317 OSStatus err;
6318 6318
6319 /* A deactivate event does not occur when the last visible frame is 6319 /* A deactivate event does not occur when the last visible frame is
6320 iconified. So if we clear the highlight here, it will not be 6320 iconified. So if we clear the highlight here, it will not be
6321 rehighlighted when it is deiconified. */ 6321 rehighlighted when it is deiconified. */
6322 #if 0 6322 #if 0
6375 6375
6376 x_free_gcs (f); 6376 x_free_gcs (f);
6377 6377
6378 if (FRAME_SIZE_HINTS (f)) 6378 if (FRAME_SIZE_HINTS (f))
6379 xfree (FRAME_SIZE_HINTS (f)); 6379 xfree (FRAME_SIZE_HINTS (f));
6380
6381 #if TARGET_API_MAC_CARBON
6382 if (FRAME_FILE_NAME (f))
6383 xfree (FRAME_FILE_NAME (f));
6384 #endif
6385 6380
6386 xfree (f->output_data.mac); 6381 xfree (f->output_data.mac);
6387 f->output_data.mac = NULL; 6382 f->output_data.mac = NULL;
6388 6383
6389 if (f == dpyinfo->x_focus_frame) 6384 if (f == dpyinfo->x_focus_frame)
7198 init_cg_text_anti_aliasing_threshold (); 7193 init_cg_text_anti_aliasing_threshold ();
7199 #endif 7194 #endif
7200 if (!NILP (assq_no_quit (make_number (kTextEncodingMacUnicode), 7195 if (!NILP (assq_no_quit (make_number (kTextEncodingMacUnicode),
7201 text_encoding_info_alist))) 7196 text_encoding_info_alist)))
7202 { 7197 {
7203 OSErr err; 7198 OSStatus err;
7204 struct Lisp_Hash_Table *h; 7199 struct Lisp_Hash_Table *h;
7205 unsigned hash_code; 7200 unsigned hash_code;
7206 ItemCount nfonts, i; 7201 ItemCount nfonts, i;
7207 ATSUFontID *font_ids = NULL; 7202 ATSUFontID *font_ids = NULL;
7208 Ptr name; 7203 Ptr name;
7780 return NULL; 7775 return NULL;
7781 7776
7782 #if USE_ATSUI 7777 #if USE_ATSUI
7783 if (strcmp (charset, "iso10646-1") == 0) /* XXX */ 7778 if (strcmp (charset, "iso10646-1") == 0) /* XXX */
7784 { 7779 {
7785 OSErr err; 7780 OSStatus err;
7786 ATSUAttributeTag tags[] = {kATSUFontTag, kATSUSizeTag, 7781 ATSUAttributeTag tags[] = {kATSUFontTag, kATSUSizeTag,
7787 kATSUQDBoldfaceTag, kATSUQDItalicTag}; 7782 kATSUQDBoldfaceTag, kATSUQDItalicTag};
7788 ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed), 7783 ByteCount sizes[] = {sizeof (ATSUFontID), sizeof (Fixed),
7789 sizeof (Boolean), sizeof (Boolean)}; 7784 sizeof (Boolean), sizeof (Boolean)};
7790 static Fixed size_fixed; 7785 static Fixed size_fixed;
7863 font->full_name = mac_to_x_fontname (family, size, fontface, charset); 7858 font->full_name = mac_to_x_fontname (family, size, fontface, charset);
7864 7859
7865 #if USE_ATSUI 7860 #if USE_ATSUI
7866 if (font->mac_style) 7861 if (font->mac_style)
7867 { 7862 {
7868 OSErr err; 7863 OSStatus err;
7869 UniChar c; 7864 UniChar c;
7870 7865
7871 font->min_byte1 = 0; 7866 font->min_byte1 = 0;
7872 font->max_byte1 = 0xff; 7867 font->max_byte1 = 0xff;
7873 font->min_char_or_byte2 = 0; 7868 font->min_char_or_byte2 = 0;
8342 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f); 8337 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
8343 int i; 8338 int i;
8344 8339
8345 for (i = 0; i < dpyinfo->n_fonts; i++) 8340 for (i = 0; i < dpyinfo->n_fonts; i++)
8346 if (dpyinfo->font_table[i].name 8341 if (dpyinfo->font_table[i].name
8347 && (!strcmp (dpyinfo->font_table[i].name, fontname) 8342 && (!xstricmp (dpyinfo->font_table[i].name, fontname)
8348 || !strcmp (dpyinfo->font_table[i].full_name, fontname))) 8343 || !xstricmp (dpyinfo->font_table[i].full_name, fontname)))
8349 return (dpyinfo->font_table + i); 8344 return (dpyinfo->font_table + i);
8350 return NULL; 8345 return NULL;
8351 } 8346 }
8352 8347
8353 8348
8537 8532
8538 Point saved_menu_event_location; 8533 Point saved_menu_event_location;
8539 8534
8540 /* Apple Events */ 8535 /* Apple Events */
8541 #if USE_CARBON_EVENTS 8536 #if USE_CARBON_EVENTS
8542 static Lisp_Object Qhicommand; 8537 static Lisp_Object Qhi_command;
8543 #ifdef MAC_OSX 8538 #ifdef MAC_OSX
8544 extern Lisp_Object Qwindow; 8539 extern Lisp_Object Qwindow;
8545 static Lisp_Object Qtoolbar_switch_mode; 8540 static Lisp_Object Qtoolbar_switch_mode;
8546 #endif 8541 #endif
8547 #if USE_MAC_FONT_PANEL 8542 #if USE_MAC_FONT_PANEL
8579 #endif 8574 #endif
8580 /* Window Event Handler */ 8575 /* Window Event Handler */
8581 static pascal OSStatus mac_handle_window_event (EventHandlerCallRef, 8576 static pascal OSStatus mac_handle_window_event (EventHandlerCallRef,
8582 EventRef, void *); 8577 EventRef, void *);
8583 #endif 8578 #endif
8584 OSErr install_window_handler (WindowPtr); 8579 OSStatus install_window_handler (WindowPtr);
8585 8580
8586 extern void init_emacs_passwd_dir (); 8581 extern void init_emacs_passwd_dir ();
8587 extern int emacs_main (int, char **, char **); 8582 extern int emacs_main (int, char **, char **);
8588 8583
8589 extern void initialize_applescript(); 8584 extern void initialize_applescript();
9380 NULL, sizeof (HICommand), NULL, &command); 9375 NULL, sizeof (HICommand), NULL, &command);
9381 9376
9382 if (err != noErr || command.commandID == 0) 9377 if (err != noErr || command.commandID == 0)
9383 return eventNotHandledErr; 9378 return eventNotHandledErr;
9384 9379
9385 /* A HICommand event is mapped to an Apple event whose event class 9380 /* A HI command event is mapped to an Apple event whose event class
9386 symbol is `hicommand' and event ID is its command ID. */ 9381 symbol is `hi-command' and event ID is its command ID. */
9387 err = mac_store_event_ref_as_apple_event (0, command.commandID, 9382 err = mac_store_event_ref_as_apple_event (0, command.commandID,
9388 Qhicommand, Qnil, 9383 Qhi_command, Qnil,
9389 event, num_params, names, types); 9384 event, num_params, names, types);
9390 return err == noErr ? noErr : eventNotHandledErr; 9385 return err == noErr ? noErr : eventNotHandledErr;
9391 } 9386 }
9392 9387
9393 static OSErr 9388 static OSStatus
9394 init_command_handler () 9389 init_command_handler ()
9395 { 9390 {
9396 EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}}; 9391 EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}};
9397 static EventHandlerUPP handle_command_eventUPP = NULL; 9392 static EventHandlerUPP handle_command_eventUPP = NULL;
9398 9393
9889 } 9884 }
9890 #endif /* MAC_OSX */ 9885 #endif /* MAC_OSX */
9891 #endif /* USE_CARBON_EVENTS */ 9886 #endif /* USE_CARBON_EVENTS */
9892 9887
9893 9888
9894 OSErr 9889 OSStatus
9895 install_window_handler (window) 9890 install_window_handler (window)
9896 WindowPtr window; 9891 WindowPtr window;
9897 { 9892 {
9898 OSErr err = noErr; 9893 OSStatus err = noErr;
9899 #if USE_CARBON_EVENTS 9894 #if USE_CARBON_EVENTS
9900 EventTypeSpec specs_window[] = 9895 EventTypeSpec specs_window[] =
9901 {{kEventClassWindow, kEventWindowUpdate}, 9896 {{kEventClassWindow, kEventWindowUpdate},
9902 {kEventClassWindow, kEventWindowBoundsChanging}, 9897 {kEventClassWindow, kEventWindowBoundsChanging},
9903 {kEventClassWindow, kEventWindowShown}, 9898 {kEventClassWindow, kEventWindowShown},
11327 11322
11328 static void 11323 static void
11329 init_menu_bar () 11324 init_menu_bar ()
11330 { 11325 {
11331 #ifdef MAC_OSX 11326 #ifdef MAC_OSX
11332 OSErr err; 11327 OSStatus err;
11333 MenuRef menu; 11328 MenuRef menu;
11334 MenuItemIndex menu_index; 11329 MenuItemIndex menu_index;
11335 11330
11336 err = GetIndMenuItemWithCommandID (NULL, kHICommandQuit, 1, 11331 err = GetIndMenuItemWithCommandID (NULL, kHICommandQuit, 1,
11337 &menu, &menu_index); 11332 &menu, &menu_index);
11510 Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); 11505 Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
11511 Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); 11506 Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier));
11512 Fput (Qsuper, Qmodifier_value, make_number (super_modifier)); 11507 Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
11513 11508
11514 #if USE_CARBON_EVENTS 11509 #if USE_CARBON_EVENTS
11515 Qhicommand = intern ("hicommand"); staticpro (&Qhicommand); 11510 Qhi_command = intern ("hi-command"); staticpro (&Qhi_command);
11516 #ifdef MAC_OSX 11511 #ifdef MAC_OSX
11517 Qtoolbar_switch_mode = intern ("toolbar-switch-mode"); 11512 Qtoolbar_switch_mode = intern ("toolbar-switch-mode");
11518 staticpro (&Qtoolbar_switch_mode); 11513 staticpro (&Qtoolbar_switch_mode);
11519 #if USE_MAC_FONT_PANEL 11514 #if USE_MAC_FONT_PANEL
11520 Qpanel_closed = intern ("panel-closed"); staticpro (&Qpanel_closed); 11515 Qpanel_closed = intern ("panel-closed"); staticpro (&Qpanel_closed);