comparison src/macterm.c @ 71504:2b4e59cd1121

(Qeql): Add extern. (x_set_mouse_pixel_position) [MAC_OSX]: Use CGWarpMouseCursorPosition. (fm_style_face_attributes_alist) [USE_ATSUI]: New variable. (syms_of_macterm) [USE_ATSUI]: Initialize and staticpro it. Change keys of Vmac_atsu_font_table from strings to numbers. (fm_style_to_face_attributes) [USE_ATSUI]: New function. (init_font_name_table) [USE_ATSUI]: Use it. (saved_ts_script_language_on_focus) [USE_MAC_TSM]: New variable. (syms_of_macterm) [USE_MAC_TSM]: Initialize and staticpro it. [USE_MAC_TSM] (mac_tsm_resume): Restore script and language codes only when saved_ts_script_language_on_focus coincides with Vmac_ts_script_language_on_focus. [USE_MAC_TSM] (mac_tsm_suspend): Save value of Vmac_ts_script_language_on_focus to saved_ts_script_language_on_focus. (XTread_socket) [USE_MAC_TSM]: Add Mac OS Classic support. [USE_MAC_TSM] (mac_handle_text_input_event, init_tsm): Likewise.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Wed, 28 Jun 2006 08:31:32 +0000
parents 4df3a065ee9b
children a6c0f6b0c790 b19aaf4ab0ee 138ce2701550
comparison
equal deleted inserted replaced
71503:fa67beba36e1 71504:2b4e59cd1121
193 #else 193 #else
194 static int input_signal_count; 194 static int input_signal_count;
195 #endif 195 #endif
196 196
197 extern Lisp_Object Vsystem_name; 197 extern Lisp_Object Vsystem_name;
198
199 extern Lisp_Object Qeql;
198 200
199 /* A mask of extra modifier bits to put into every keyboard char. */ 201 /* A mask of extra modifier bits to put into every keyboard char. */
200 202
201 extern EMACS_INT extra_keyboard_modifiers; 203 extern EMACS_INT extra_keyboard_modifiers;
202 204
6029 void 6031 void
6030 x_set_mouse_pixel_position (f, pix_x, pix_y) 6032 x_set_mouse_pixel_position (f, pix_x, pix_y)
6031 struct frame *f; 6033 struct frame *f;
6032 int pix_x, pix_y; 6034 int pix_x, pix_y;
6033 { 6035 {
6034 #if 0 /* MAC_TODO: CursorDeviceMoveTo is non-Carbon */ 6036 #ifdef MAC_OSX
6037 Point p;
6038 CGPoint point;
6039
6040 BLOCK_INPUT;
6041 SetPortWindowPort (FRAME_MAC_WINDOW (f));
6042 p.h = pix_x;
6043 p.v = pix_y;
6044 LocalToGlobal (&p);
6045 point.x = p.h;
6046 point.y = p.v;
6047 CGWarpMouseCursorPosition (point);
6048 UNBLOCK_INPUT;
6049 #else
6050 #if 0 /* MAC_TODO: LMSetMouseLocation and CursorDeviceMoveTo are non-Carbon */
6035 BLOCK_INPUT; 6051 BLOCK_INPUT;
6036 6052
6037 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f), 6053 XWarpPointer (FRAME_X_DISPLAY (f), None, FRAME_X_WINDOW (f),
6038 0, 0, 0, 0, pix_x, pix_y); 6054 0, 0, 0, 0, pix_x, pix_y);
6039 UNBLOCK_INPUT; 6055 UNBLOCK_INPUT;
6056 #endif
6040 #endif 6057 #endif
6041 } 6058 }
6042 6059
6043 /* focus shifting, raising and lowering. */ 6060 /* focus shifting, raising and lowering. */
6044 6061
6895 for Mac OS Classic is created. */ 6912 for Mac OS Classic is created. */
6896 static Lisp_Object fm_font_family_alist; 6913 static Lisp_Object fm_font_family_alist;
6897 #if USE_ATSUI 6914 #if USE_ATSUI
6898 /* Hash table linking font family names to ATSU font IDs. */ 6915 /* Hash table linking font family names to ATSU font IDs. */
6899 static Lisp_Object atsu_font_id_hash; 6916 static Lisp_Object atsu_font_id_hash;
6917 /* Alist linking Font Manager style to face attributes. */
6918 static Lisp_Object fm_style_face_attributes_alist;
6900 static Lisp_Object Vmac_atsu_font_table; 6919 static Lisp_Object Vmac_atsu_font_table;
6901 extern Lisp_Object QCfamily, QCweight, QCslant, Qnormal, Qbold, Qitalic; 6920 extern Lisp_Object QCfamily, QCweight, QCslant, Qnormal, Qbold, Qitalic;
6902 #endif 6921 #endif
6903 6922
6904 /* Alist linking character set strings to Mac text encoding and Emacs 6923 /* Alist linking character set strings to Mac text encoding and Emacs
7129 add_font_name_table_entry (mac_to_x_fontname (name, 0, bold, charset)); 7148 add_font_name_table_entry (mac_to_x_fontname (name, 0, bold, charset));
7130 add_font_name_table_entry (mac_to_x_fontname (name, 0, italic | bold, 7149 add_font_name_table_entry (mac_to_x_fontname (name, 0, italic | bold,
7131 charset)); 7150 charset));
7132 } 7151 }
7133 } 7152 }
7153
7154 #if USE_ATSUI
7155 static Lisp_Object
7156 fm_style_to_face_attributes (fm_style)
7157 FMFontStyle fm_style;
7158 {
7159 Lisp_Object tem;
7160
7161 fm_style &= (bold | italic);
7162 tem = assq_no_quit (make_number (fm_style),
7163 fm_style_face_attributes_alist);
7164 if (!NILP (tem))
7165 return XCDR (tem);
7166
7167 tem = list4 (QCweight, fm_style & bold ? Qbold : Qnormal,
7168 QCslant, fm_style & italic ? Qitalic : Qnormal);
7169 fm_style_face_attributes_alist =
7170 Fcons (Fcons (make_number (fm_style), tem),
7171 fm_style_face_attributes_alist);
7172
7173 return tem;
7174 }
7175 #endif
7134 7176
7135 /* Sets up the table font_name_table to contain the list of all fonts 7177 /* Sets up the table font_name_table to contain the list of all fonts
7136 in the system the first time the table is used so that the Resource 7178 in the system the first time the table is used so that the Resource
7137 Manager need not be accessed every time this information is 7179 Manager need not be accessed every time this information is
7138 needed. */ 7180 needed. */
7198 FMFontStyle style = normal; 7240 FMFontStyle style = normal;
7199 7241
7200 decode_mac_font_name (name, name_len + 1, Qnil); 7242 decode_mac_font_name (name, name_len + 1, Qnil);
7201 family = make_unibyte_string (name, name_len); 7243 family = make_unibyte_string (name, name_len);
7202 FMGetFontFamilyInstanceFromFont (font_ids[i], &ff, &style); 7244 FMGetFontFamilyInstanceFromFont (font_ids[i], &ff, &style);
7203 Fputhash (make_unibyte_string ((char *)(font_ids + i), 7245 Fputhash ((font_ids[i] > MOST_POSITIVE_FIXNUM
7204 sizeof (ATSUFontID)), 7246 ? make_float (font_ids[i])
7247 : make_number (font_ids[i])),
7205 Fcons (QCfamily, 7248 Fcons (QCfamily,
7206 list5 (family, 7249 Fcons (family,
7207 QCweight, 7250 fm_style_to_face_attributes (style))),
7208 style & bold ? Qbold : Qnormal,
7209 QCslant,
7210 style & italic ? Qitalic : Qnormal)),
7211 Vmac_atsu_font_table); 7251 Vmac_atsu_font_table);
7212 if (*name != '.' 7252 if (*name != '.'
7213 && hash_lookup (h, family, &hash_code) < 0) 7253 && hash_lookup (h, family, &hash_code) < 0)
7214 { 7254 {
7215 add_mac_font_name (name, 0, normal, "iso10646-1"); 7255 add_mac_font_name (name, 0, normal, "iso10646-1");
8511 static Lisp_Object Qtext_input; 8551 static Lisp_Object Qtext_input;
8512 static Lisp_Object Qupdate_active_input_area, Qunicode_for_key_event; 8552 static Lisp_Object Qupdate_active_input_area, Qunicode_for_key_event;
8513 static Lisp_Object Vmac_ts_active_input_overlay; 8553 static Lisp_Object Vmac_ts_active_input_overlay;
8514 extern Lisp_Object Qbefore_string; 8554 extern Lisp_Object Qbefore_string;
8515 static Lisp_Object Vmac_ts_script_language_on_focus; 8555 static Lisp_Object Vmac_ts_script_language_on_focus;
8556 static Lisp_Object saved_ts_script_language_on_focus;
8516 static ScriptLanguageRecord saved_ts_language; 8557 static ScriptLanguageRecord saved_ts_language;
8517 static Component saved_ts_component; 8558 static Component saved_ts_component;
8518 #endif 8559 #endif
8519 #endif 8560 #endif
8520 extern int mac_ready_for_apple_events; 8561 extern int mac_ready_for_apple_events;
8873 8914
8874 err = ActivateTSMDocument (tsm_document_id); 8915 err = ActivateTSMDocument (tsm_document_id);
8875 8916
8876 if (err == noErr) 8917 if (err == noErr)
8877 { 8918 {
8878 if (EQ (Vmac_ts_script_language_on_focus, Qt)) 8919 if (EQ (Vmac_ts_script_language_on_focus, Qt)
8920 && EQ (saved_ts_script_language_on_focus, Qt))
8879 slptr = &saved_ts_language; 8921 slptr = &saved_ts_language;
8880 else if (CONSP (Vmac_ts_script_language_on_focus) 8922 else if (CONSP (Vmac_ts_script_language_on_focus)
8881 && INTEGERP (XCAR (Vmac_ts_script_language_on_focus)) 8923 && INTEGERP (XCAR (Vmac_ts_script_language_on_focus))
8882 && INTEGERP (XCDR (Vmac_ts_script_language_on_focus))) 8924 && INTEGERP (XCDR (Vmac_ts_script_language_on_focus))
8925 && CONSP (saved_ts_script_language_on_focus)
8926 && EQ (XCAR (saved_ts_script_language_on_focus),
8927 XCAR (Vmac_ts_script_language_on_focus))
8928 && EQ (XCDR (saved_ts_script_language_on_focus),
8929 XCDR (Vmac_ts_script_language_on_focus)))
8883 { 8930 {
8884 slrec.fScript = XINT (XCAR (Vmac_ts_script_language_on_focus)); 8931 slrec.fScript = XINT (XCAR (Vmac_ts_script_language_on_focus));
8885 slrec.fLanguage = XINT (XCDR (Vmac_ts_script_language_on_focus)); 8932 slrec.fLanguage = XINT (XCDR (Vmac_ts_script_language_on_focus));
8886 slptr = &slrec; 8933 slptr = &slrec;
8887 } 8934 }
8909 static OSStatus 8956 static OSStatus
8910 mac_tsm_suspend () 8957 mac_tsm_suspend ()
8911 { 8958 {
8912 OSStatus err; 8959 OSStatus err;
8913 ScriptLanguageRecord slrec, *slptr = NULL; 8960 ScriptLanguageRecord slrec, *slptr = NULL;
8961
8962 saved_ts_script_language_on_focus = Vmac_ts_script_language_on_focus;
8914 8963
8915 if (EQ (Vmac_ts_script_language_on_focus, Qt)) 8964 if (EQ (Vmac_ts_script_language_on_focus, Qt))
8916 { 8965 {
8917 err = GetTextServiceLanguage (&saved_ts_language); 8966 err = GetTextServiceLanguage (&saved_ts_language);
8918 if (err == noErr) 8967 if (err == noErr)
9558 static EventParamType types_uaia[] = 9607 static EventParamType types_uaia[] =
9559 {typeComponentInstance, 9608 {typeComponentInstance,
9560 typeLongInteger, 9609 typeLongInteger,
9561 typeIntlWritingCode, 9610 typeIntlWritingCode,
9562 typeLongInteger, 9611 typeLongInteger,
9612 #ifdef MAC_OSX
9563 typeUnicodeText, 9613 typeUnicodeText,
9614 #else
9615 typeChar,
9616 #endif
9564 typeTextRangeArray, 9617 typeTextRangeArray,
9565 typeTextRangeArray, 9618 typeTextRangeArray,
9566 typeOffsetArray, 9619 typeOffsetArray,
9567 typeTextRange, 9620 typeTextRange,
9568 typeUInt32, 9621 typeUInt32,
10644 typeUInt32, NULL, 10697 typeUInt32, NULL,
10645 sizeof (UInt32), NULL, &modifiers); 10698 sizeof (UInt32), NULL, &modifiers);
10646 #endif 10699 #endif
10647 mapped_modifiers &= modifiers; 10700 mapped_modifiers &= modifiers;
10648 10701
10649 #if USE_CARBON_EVENTS && defined (MAC_OSX) 10702 #if USE_CARBON_EVENTS && (defined (MAC_OSX) || USE_MAC_TSM)
10650 /* When using Carbon Events, we need to pass raw keyboard 10703 /* When using Carbon Events, we need to pass raw keyboard
10651 events to the TSM ourselves. If TSM handles it, it 10704 events to the TSM ourselves. If TSM handles it, it
10652 will pass back noErr, otherwise it will pass back 10705 will pass back noErr, otherwise it will pass back
10653 "eventNotHandledErr" and we can process it 10706 "eventNotHandledErr" and we can process it
10654 normally. */ 10707 normally. */
11300 11353
11301 #if USE_MAC_TSM 11354 #if USE_MAC_TSM
11302 static void 11355 static void
11303 init_tsm () 11356 init_tsm ()
11304 { 11357 {
11358 #ifdef MAC_OSX
11305 static InterfaceTypeList types = {kUnicodeDocument}; 11359 static InterfaceTypeList types = {kUnicodeDocument};
11360 #else
11361 static InterfaceTypeList types = {kTextService};
11362 #endif
11306 11363
11307 NewTSMDocument (sizeof (types) / sizeof (types[0]), types, 11364 NewTSMDocument (sizeof (types) / sizeof (types[0]), types,
11308 &tsm_document_id, 0); 11365 &tsm_document_id, 0);
11309 } 11366 }
11310 #endif 11367 #endif
11488 fm_font_family_alist = Qnil; 11545 fm_font_family_alist = Qnil;
11489 11546
11490 #if USE_ATSUI 11547 #if USE_ATSUI
11491 staticpro (&atsu_font_id_hash); 11548 staticpro (&atsu_font_id_hash);
11492 atsu_font_id_hash = Qnil; 11549 atsu_font_id_hash = Qnil;
11550
11551 staticpro (&fm_style_face_attributes_alist);
11552 fm_style_face_attributes_alist = Qnil;
11553 #endif
11554
11555 #if USE_MAC_TSM
11556 staticpro (&saved_ts_script_language_on_focus);
11557 saved_ts_script_language_on_focus = Qnil;
11493 #endif 11558 #endif
11494 11559
11495 /* We don't yet support this, but defining this here avoids whining 11560 /* We don't yet support this, but defining this here avoids whining
11496 from cus-start.el and other places, like "M-x set-variable". */ 11561 from cus-start.el and other places, like "M-x set-variable". */
11497 DEFVAR_BOOL ("x-use-underline-position-properties", 11562 DEFVAR_BOOL ("x-use-underline-position-properties",
11600 Fcons (list3 (build_string ("mac-roman"), 11665 Fcons (list3 (build_string ("mac-roman"),
11601 make_number (smRoman), Qnil), Qnil); 11666 make_number (smRoman), Qnil), Qnil);
11602 11667
11603 #if USE_ATSUI 11668 #if USE_ATSUI
11604 DEFVAR_LISP ("mac-atsu-font-table", &Vmac_atsu_font_table, 11669 DEFVAR_LISP ("mac-atsu-font-table", &Vmac_atsu_font_table,
11605 doc: /* Hash table of ATSU font IDs vs plist of attributes and values. 11670 doc: /* Hash table of ATSU font IDs vs plist of attributes and values. */);
11606 Each font ID is represented as a four-byte string in native byte
11607 order. */);
11608 Vmac_atsu_font_table = 11671 Vmac_atsu_font_table =
11609 make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), 11672 make_hash_table (Qeql, make_number (DEFAULT_HASH_SIZE),
11610 make_float (DEFAULT_REHASH_SIZE), 11673 make_float (DEFAULT_REHASH_SIZE),
11611 make_float (DEFAULT_REHASH_THRESHOLD), 11674 make_float (DEFAULT_REHASH_THRESHOLD),
11612 Qnil, Qnil, Qnil); 11675 Qnil, Qnil, Qnil);
11613 #endif 11676 #endif
11614 #if USE_MAC_TSM 11677 #if USE_MAC_TSM