diff options
| author | YAMAMOTO Mitsuharu | 2006-06-16 08:08:59 +0000 |
|---|---|---|
| committer | YAMAMOTO Mitsuharu | 2006-06-16 08:08:59 +0000 |
| commit | b4c515960ff17093ed7c499b1d1435b02a5e57b3 (patch) | |
| tree | 9f3cd322f229fdcebb6e089950c180e0b79e1563 /src | |
| parent | e2da5e42129173a6544ec29ceeaafc2b9a7946f0 (diff) | |
| download | emacs-b4c515960ff17093ed7c499b1d1435b02a5e57b3.tar.gz emacs-b4c515960ff17093ed7c499b1d1435b02a5e57b3.zip | |
(do_app_resume, do_app_suspend): Remove functions.
(mac_tsm_resume, mac_tsm_suspend) [USE_MAC_TSM]: New functions.
(mac_handle_window_event, XTread_socket) [USE_MAC_TSM]: Use them.
(Vmac_ts_script_language_on_focus) [USE_MAC_TSM]: New variable.
(syms_of_macterm) [USE_MAC_TSM]: Defvar it.
(saved_ts_language, saved_ts_component) [USE_MAC_TSM]: New variables.
(mac_initialize_display_info) [MAC_OSX]: Use Quartz Display
Services functions to get size of main display in pixels.
Diffstat (limited to 'src')
| -rw-r--r-- | src/macterm.c | 141 |
1 files changed, 104 insertions, 37 deletions
diff --git a/src/macterm.c b/src/macterm.c index 007cc14888e..e1fc7dbff66 100644 --- a/src/macterm.c +++ b/src/macterm.c | |||
| @@ -8512,6 +8512,9 @@ 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; |
| @@ -8861,22 +8864,84 @@ is_emacs_window (WindowPtr win) | |||
| 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 | mac_tsm_resume () | ||
| 8870 | { | ||
| 8871 | OSStatus err; | ||
| 8872 | ScriptLanguageRecord slrec, *slptr = NULL; | ||
| 8873 | |||
| 8874 | err = ActivateTSMDocument (tsm_document_id); | ||
| 8875 | |||
| 8876 | if (err == noErr) | ||
| 8877 | { | ||
| 8878 | if (EQ (Vmac_ts_script_language_on_focus, Qt)) | ||
| 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); | ||
| 8869 | #endif | 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; | ||
| 8870 | } | 8907 | } |
| 8871 | 8908 | ||
| 8872 | static void | 8909 | static OSStatus |
| 8873 | do_app_suspend () | 8910 | mac_tsm_suspend () |
| 8874 | { | 8911 | { |
| 8875 | #if USE_MAC_TSM | 8912 | OSStatus err; |
| 8876 | DeactivateTSMDocument (tsm_document_id); | 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); | ||
| 8877 | #endif | 8937 | #endif |
| 8878 | } | 8938 | } |
| 8879 | 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) |
| @@ -9330,12 +9395,12 @@ mac_handle_window_event (next_handler, event, data) | |||
| 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 | } |
| @@ -10394,10 +10459,12 @@ XTread_socket (sd, expected, hold_quit) | |||
| 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: |
| @@ -10960,7 +11027,6 @@ 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 | ||
| @@ -10976,37 +11042,29 @@ mac_initialize_display_info () | |||
| 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; | ||
| 10994 | CGDisplayErr error_code; | ||
| 10995 | |||
| 10996 | error_code = CGGetActiveDisplayList (1, disp_id, &disp_count); | ||
| 10997 | if (error_code != 0) | ||
| 10998 | error ("No display found, CGGetActiveDisplayList error %d", error_code); | ||
| 10999 | 11058 | ||
| 11000 | dpyinfo->n_planes = CGDisplayBitsPerPixel (disp_id[0]); | 11059 | dpyinfo->color_p = TestDeviceAttribute (main_device_handle, gdDevType); |
| 11060 | for (dpyinfo->n_planes = 32; dpyinfo->n_planes > 0; dpyinfo->n_planes >>= 1) | ||
| 11061 | if (HasDepth (main_device_handle, dpyinfo->n_planes, | ||
| 11062 | gdDevType, dpyinfo->color_p)) | ||
| 11063 | break; | ||
| 11064 | dpyinfo->height = (**main_device_handle).gdRect.bottom; | ||
| 11065 | dpyinfo->width = (**main_device_handle).gdRect.right; | ||
| 11001 | } | 11066 | } |
| 11002 | #else | ||
| 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 | 11067 | #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 (); |
| @@ -11557,6 +11615,15 @@ order. */); | |||
| 11557 | DEFVAR_LISP ("mac-ts-active-input-overlay", &Vmac_ts_active_input_overlay, | 11615 | DEFVAR_LISP ("mac-ts-active-input-overlay", &Vmac_ts_active_input_overlay, |
| 11558 | doc: /* Overlay used to display Mac TSM active input area. */); | 11616 | doc: /* Overlay used to display Mac TSM active input area. */); |
| 11559 | Vmac_ts_active_input_overlay = Qnil; | 11617 | Vmac_ts_active_input_overlay = Qnil; |
| 11618 | |||
| 11619 | DEFVAR_LISP ("mac-ts-script-language-on-focus", &Vmac_ts_script_language_on_focus, | ||
| 11620 | doc: /* *How to change Mac TSM script/language when a frame gets focus. | ||
| 11621 | If the value is t, the input script and language are restored to those | ||
| 11622 | used in the last focus frame. If the value is a pair of integers, the | ||
| 11623 | input script and language codes, which are defined in the Script | ||
| 11624 | Manager, are set to its car and cdr parts, respectively. Otherwise, | ||
| 11625 | Emacs doesn't set them and thus follows the system default behavior. */); | ||
| 11626 | Vmac_ts_script_language_on_focus = Qnil; | ||
| 11560 | #endif | 11627 | #endif |
| 11561 | } | 11628 | } |
| 11562 | 11629 | ||