comparison src/macterm.c @ 83531:a387c138b28e

Merged from emacs@sv.gnu.org Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-305 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-306 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-307 Update from CVS: lispref/display.texi (Forcing Redisplay): Fix typo. * emacs@sv.gnu.org/emacs--devo--0--patch-308 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-309 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-310 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-311 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-312 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-313 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-314 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-315 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-316 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-317 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-318 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-319 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-320 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-321 Merge from gnus--rel--5.10 * emacs@sv.gnu.org/emacs--devo--0--patch-322 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-323 lisp/play/cookie1.el (cookie): Work properly when there's only one entry * emacs@sv.gnu.org/emacs--devo--0--patch-324 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-325 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-326 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-327 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-328 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-329 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-330 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-105 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-106 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-107 Update from CVS * emacs@sv.gnu.org/gnus--rel--5.10--patch-108 Merge from emacs--devo--0 * emacs@sv.gnu.org/gnus--rel--5.10--patch-109 Clean up merge mistakes * emacs@sv.gnu.org/gnus--rel--5.10--patch-110 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-571
author Karoly Lorentey <lorentey@elte.hu>
date Tue, 27 Jun 2006 15:06:36 +0000
parents 46b1096093f5 4df3a065ee9b
children b19aaf4ab0ee
comparison
equal deleted inserted replaced
83530:46b1096093f5 83531:a387c138b28e
8510 static TSMDocumentID tsm_document_id; 8510 static TSMDocumentID tsm_document_id;
8511 static Lisp_Object Qtext_input; 8511 static Lisp_Object Qtext_input;
8512 static Lisp_Object Qupdate_active_input_area, Qunicode_for_key_event; 8512 static Lisp_Object Qupdate_active_input_area, Qunicode_for_key_event;
8513 static Lisp_Object Vmac_ts_active_input_overlay; 8513 static Lisp_Object Vmac_ts_active_input_overlay;
8514 extern Lisp_Object Qbefore_string; 8514 extern Lisp_Object Qbefore_string;
8515 static Lisp_Object Vmac_ts_script_language_on_focus;
8516 static ScriptLanguageRecord saved_ts_language;
8517 static Component saved_ts_component;
8515 #endif 8518 #endif
8516 #endif 8519 #endif
8517 extern int mac_ready_for_apple_events; 8520 extern int mac_ready_for_apple_events;
8518 extern Lisp_Object Qundefined; 8521 extern Lisp_Object Qundefined;
8519 extern void init_apple_event_handler P_ ((void)); 8522 extern void init_apple_event_handler P_ ((void));
8859 return 1; 8862 return 1;
8860 8863
8861 return 0; 8864 return 0;
8862 } 8865 }
8863 8866
8864 static void
8865 do_app_resume ()
8866 {
8867 #if USE_MAC_TSM 8867 #if USE_MAC_TSM
8868 ActivateTSMDocument (tsm_document_id); 8868 static OSStatus
8869 #endif 8869 mac_tsm_resume ()
8870 } 8870 {
8871 8871 OSStatus err;
8872 static void 8872 ScriptLanguageRecord slrec, *slptr = NULL;
8873 do_app_suspend () 8873
8874 { 8874 err = ActivateTSMDocument (tsm_document_id);
8875 #if USE_MAC_TSM 8875
8876 DeactivateTSMDocument (tsm_document_id); 8876 if (err == noErr)
8877 #endif 8877 {
8878 } 8878 if (EQ (Vmac_ts_script_language_on_focus, Qt))
8879 8879 slptr = &saved_ts_language;
8880 else if (CONSP (Vmac_ts_script_language_on_focus)
8881 && INTEGERP (XCAR (Vmac_ts_script_language_on_focus))
8882 && INTEGERP (XCDR (Vmac_ts_script_language_on_focus)))
8883 {
8884 slrec.fScript = XINT (XCAR (Vmac_ts_script_language_on_focus));
8885 slrec.fLanguage = XINT (XCDR (Vmac_ts_script_language_on_focus));
8886 slptr = &slrec;
8887 }
8888 }
8889
8890 if (slptr)
8891 {
8892 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
8893 err = SetDefaultInputMethodOfClass (saved_ts_component, slptr,
8894 kKeyboardInputMethodClass);
8895 #else
8896 err = SetDefaultInputMethod (saved_ts_component, slptr);
8897 #endif
8898 if (err == noErr)
8899 err = SetTextServiceLanguage (slptr);
8900
8901 /* Seems to be needed on Mac OS X 10.2. */
8902 if (err == noErr)
8903 KeyScript (slptr->fScript | smKeyForceKeyScriptMask);
8904 }
8905
8906 return err;
8907 }
8908
8909 static OSStatus
8910 mac_tsm_suspend ()
8911 {
8912 OSStatus err;
8913 ScriptLanguageRecord slrec, *slptr = NULL;
8914
8915 if (EQ (Vmac_ts_script_language_on_focus, Qt))
8916 {
8917 err = GetTextServiceLanguage (&saved_ts_language);
8918 if (err == noErr)
8919 slptr = &saved_ts_language;
8920 }
8921 else if (CONSP (Vmac_ts_script_language_on_focus)
8922 && INTEGERP (XCAR (Vmac_ts_script_language_on_focus))
8923 && INTEGERP (XCDR (Vmac_ts_script_language_on_focus)))
8924 {
8925 slrec.fScript = XINT (XCAR (Vmac_ts_script_language_on_focus));
8926 slrec.fLanguage = XINT (XCDR (Vmac_ts_script_language_on_focus));
8927 slptr = &slrec;
8928 }
8929
8930 if (slptr)
8931 {
8932 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
8933 GetDefaultInputMethodOfClass (&saved_ts_component, slptr,
8934 kKeyboardInputMethodClass);
8935 #else
8936 GetDefaultInputMethod (&saved_ts_component, slptr);
8937 #endif
8938 }
8939
8940 err = DeactivateTSMDocument (tsm_document_id);
8941
8942 return err;
8943 }
8944 #endif
8880 8945
8881 static void 8946 static void
8882 do_apple_menu (SInt16 menu_item) 8947 do_apple_menu (SInt16 menu_item)
8883 { 8948 {
8884 #if !TARGET_API_MAC_CARBON 8949 #if !TARGET_API_MAC_CARBON
9328 #endif 9393 #endif
9329 9394
9330 #if USE_MAC_TSM 9395 #if USE_MAC_TSM
9331 case kEventWindowFocusAcquired: 9396 case kEventWindowFocusAcquired:
9332 result = CallNextEventHandler (next_handler, event); 9397 result = CallNextEventHandler (next_handler, event);
9333 err = ActivateTSMDocument (tsm_document_id); 9398 err = mac_tsm_resume ();
9334 return err == noErr ? noErr : result; 9399 return err == noErr ? noErr : result;
9335 9400
9336 case kEventWindowFocusRelinquish: 9401 case kEventWindowFocusRelinquish:
9337 result = CallNextEventHandler (next_handler, event); 9402 result = CallNextEventHandler (next_handler, event);
9338 err = DeactivateTSMDocument (tsm_document_id); 9403 err = mac_tsm_suspend ();
9339 return err == noErr ? noErr : result; 9404 return err == noErr ? noErr : result;
9340 #endif 9405 #endif
9341 } 9406 }
9342 9407
9343 return eventNotHandledErr; 9408 return eventNotHandledErr;
10392 break; 10457 break;
10393 #endif 10458 #endif
10394 switch ((er.message >> 24) & 0x000000FF) 10459 switch ((er.message >> 24) & 0x000000FF)
10395 { 10460 {
10396 case suspendResumeMessage: 10461 case suspendResumeMessage:
10397 if ((er.message & resumeFlag) == 1) 10462 #if USE_MAC_TSM
10398 do_app_resume (); 10463 if (er.message & resumeFlag)
10464 mac_tsm_resume ();
10399 else 10465 else
10400 do_app_suspend (); 10466 mac_tsm_suspend ();
10467 #endif
10401 break; 10468 break;
10402 10469
10403 case mouseMovedMessage: 10470 case mouseMovedMessage:
10404 #if !USE_CARBON_EVENTS 10471 #if !USE_CARBON_EVENTS
10405 SetRectRgn (mouse_region, er.where.h, er.where.v, 10472 SetRectRgn (mouse_region, er.where.h, er.where.v,
10958 11025
10959 void 11026 void
10960 mac_initialize_display_info () 11027 mac_initialize_display_info ()
10961 { 11028 {
10962 struct mac_display_info *dpyinfo = &one_mac_display_info; 11029 struct mac_display_info *dpyinfo = &one_mac_display_info;
10963 GDHandle main_device_handle;
10964 11030
10965 bzero (dpyinfo, sizeof (*dpyinfo)); 11031 bzero (dpyinfo, sizeof (*dpyinfo));
10966 11032
10967 #ifdef MAC_OSX 11033 #ifdef MAC_OSX
10968 dpyinfo->mac_id_name 11034 dpyinfo->mac_id_name
10974 #else 11040 #else
10975 dpyinfo->mac_id_name = (char *) xmalloc (strlen ("Mac Display") + 1); 11041 dpyinfo->mac_id_name = (char *) xmalloc (strlen ("Mac Display") + 1);
10976 strcpy (dpyinfo->mac_id_name, "Mac Display"); 11042 strcpy (dpyinfo->mac_id_name, "Mac Display");
10977 #endif 11043 #endif
10978 11044
10979 main_device_handle = LMGetMainDevice();
10980
10981 dpyinfo->reference_count = 0; 11045 dpyinfo->reference_count = 0;
10982 dpyinfo->resx = 72.0; 11046 dpyinfo->resx = 72.0;
10983 dpyinfo->resy = 72.0; 11047 dpyinfo->resy = 72.0;
10984 dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType);
10985 #ifdef MAC_OSX 11048 #ifdef MAC_OSX
10986 /* HasDepth returns true if it is possible to have a 32 bit display, 11049 /* HasDepth returns true if it is possible to have a 32 bit display,
10987 but this may not be what is actually used. Mac OSX can do better. 11050 but this may not be what is actually used. Mac OSX can do better. */
10988 CGMainDisplayID is only available on OSX 10.2 and higher, but the 11051 dpyinfo->color_p = 1;
10989 header for CGGetActiveDisplayList says that the first display returned 11052 dpyinfo->n_planes = CGDisplayBitsPerPixel (kCGDirectMainDisplay);
10990 is the active one, so we use that. */ 11053 dpyinfo->height = CGDisplayPixelsHigh (kCGDirectMainDisplay);
11054 dpyinfo->width = CGDisplayPixelsWide (kCGDirectMainDisplay);
11055 #else
10991 { 11056 {
10992 CGDirectDisplayID disp_id[1]; 11057 GDHandle main_device_handle = LMGetMainDevice();
10993 CGDisplayCount disp_count; 11058
10994 CGDisplayErr error_code; 11059 dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType);
10995 11060 for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1)
10996 error_code = CGGetActiveDisplayList (1, disp_id, &disp_count); 11061 if (HasDepth (main_device_handle, dpyinfo->n_planes,
10997 if (error_code != 0) 11062 gdDevType, dpyinfo->color_p))
10998 error ("No display found, CGGetActiveDisplayList error %d", error_code); 11063 break;
10999 11064 dpyinfo->height = (**main_device_handle).gdRect.bottom;
11000 dpyinfo->n_planes = CGDisplayBitsPerPixel (disp_id[0]); 11065 dpyinfo->width = (**main_device_handle).gdRect.right;
11001 } 11066 }
11002 #else 11067 #endif
11003 for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1)
11004 if (HasDepth (main_device_handle, dpyinfo->n_planes,
11005 gdDevType, dpyinfo->color_p))
11006 break;
11007 #endif
11008 dpyinfo->height = (**main_device_handle).gdRect.bottom;
11009 dpyinfo->width = (**main_device_handle).gdRect.right;
11010 dpyinfo->grabbed = 0; 11068 dpyinfo->grabbed = 0;
11011 dpyinfo->root_window = NULL; 11069 dpyinfo->root_window = NULL;
11012 dpyinfo->image_cache = make_image_cache (); 11070 dpyinfo->image_cache = make_image_cache ();
11013 11071
11014 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1; 11072 dpyinfo->mouse_face_beg_row = dpyinfo->mouse_face_beg_col = -1;
11556 #endif 11614 #endif
11557 #if USE_MAC_TSM 11615 #if USE_MAC_TSM
11558 DEFVAR_LISP ("mac-ts-active-input-overlay", &Vmac_ts_active_input_overlay, 11616 DEFVAR_LISP ("mac-ts-active-input-overlay", &Vmac_ts_active_input_overlay,
11559 doc: /* Overlay used to display Mac TSM active input area. */); 11617 doc: /* Overlay used to display Mac TSM active input area. */);
11560 Vmac_ts_active_input_overlay = Qnil; 11618 Vmac_ts_active_input_overlay = Qnil;
11619
11620 DEFVAR_LISP ("mac-ts-script-language-on-focus", &Vmac_ts_script_language_on_focus,
11621 doc: /* *How to change Mac TSM script/language when a frame gets focus.
11622 If the value is t, the input script and language are restored to those
11623 used in the last focus frame. If the value is a pair of integers, the
11624 input script and language codes, which are defined in the Script
11625 Manager, are set to its car and cdr parts, respectively. Otherwise,
11626 Emacs doesn't set them and thus follows the system default behavior. */);
11627 Vmac_ts_script_language_on_focus = Qnil;
11561 #endif 11628 #endif
11562 } 11629 }
11563 11630
11564 /* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b 11631 /* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b
11565 (do not change this comment) */ 11632 (do not change this comment) */