aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2005-04-18 13:40:23 +0000
committerKaroly Lorentey2005-04-18 13:40:23 +0000
commit6ab9dd8034fcd76f5d2e92a91243f8d8be3a8f98 (patch)
treea40a6371728d46bdfb26b7090612e0ca70e1c057 /src
parent91fd98fc1eff12aa5a46142efabababa7daf77bb (diff)
parentd4127a9a1111805640eaa06e9767a7a6f56351a5 (diff)
downloademacs-6ab9dd8034fcd76f5d2e92a91243f8d8be3a8f98.tar.gz
emacs-6ab9dd8034fcd76f5d2e92a91243f8d8be3a8f98.zip
Merged from miles@gnu.org--gnu-2005 (patch 60-65, 246-265)
Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-246 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-247 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-248 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-249 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-250 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-251 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-252 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-253 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-254 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-255 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-256 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-257 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-258 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-259 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-260 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-261 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-262 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-263 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-264 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-265 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-60 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-61 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-62 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-63 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-64 (mm-string-to-multibyte): Use Gnus trunk definition. * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-65 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-328
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog130
-rw-r--r--src/Makefile.in11
-rw-r--r--src/image.c2
-rw-r--r--src/keyboard.c15
-rw-r--r--src/mac.c82
-rw-r--r--src/macfns.c18
-rw-r--r--src/macterm.c467
-rw-r--r--src/macterm.h11
-rw-r--r--src/term.c21
-rw-r--r--src/termhooks.h9
-rw-r--r--src/window.c19
-rw-r--r--src/xdisp.c37
12 files changed, 508 insertions, 314 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 26b8a9ce5ad..3483a2c5905 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,102 @@
12005-04-16 Dan Nicolaescu <dann@ics.uci.edu>
2
3 * term.c (struct keys): Add support for shifted keys.
4
52005-04-16 Richard M. Stallman <rms@gnu.org>
6
7 * xdisp.c (with_echo_area_buffer): Delete WHICH < 0 case.
8 (set_message): Call with_echo_area_buffer with WHICH = 0.
9 (set_message_1): Erase the echo area buffer first thing.
10 (echo_area_display): Don't clear echo_message_buffer.
11
122005-04-16 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
13
14 * Makefile.in (mac.o): Depend on charset.h and coding.h.
15
16 * mac.c: Include charset.h and coding.h.
17 [TARGET_API_MAC_CARBON] (Qutf_8): Remove extern.
18 [TARGET_API_MAC_CARBON] (cfstring_create_with_string): New
19 function.
20 [TARGET_API_MAC_CARBON] (Fmac_get_preference): Use it.
21
22 * macfns.c [TARGET_API_MAC_CARBON] (Fx_file_dialog): Likewise.
23
24 * image.c [MAC_OSX] (image_load_quartz2d): Likewise.
25
26 * macterm.c (x_autoselect_window_p): Remove variable.
27 (last_window): New variable.
28 (XTreassert_line_highlight, x_change_line_highlight): Remove
29 declarations.
30 (mac_focus_changed, x_detect_focus_change): New functions and
31 declarations.
32 (XTextExtents16, front_emacs_window): Remove function.
33 (mac_focus_frame): New function.
34 (XTmouse_position, do_menu_choice, do_zoom_window, XTread_socket)
35 (mac_check_for_quit_char): Use it instead of front_emacs_window.
36 (x_scroll_bar_report_motion): Obtain window from control owner.
37 (x_make_frame_invisible): Set window manager size hint.
38 (do_mouse_moved): Remove function.
39 (XTread_socket): Move its contents here. Generate select-window
40 event on mouse movement if needed. Use x_detect_focus_change on
41 activate/deactivate events. Don't deiconify frame or invalidate
42 window rectangle when dnd items are dropped. Don't
43 activate/deactivate root control.
44 (frame_highlight, frame_unhighlight): Activate/deactivate root
45 control here.
46 (syms_of_macterm): Delete DEFVAR_BOOL for x_autoselect_window_p.
47
48 * macterm.h (cfstring_create_with_string) [TARGET_API_MAC_CARBON]:
49 New extern.
50
512005-04-15 Luc Teirlinck <teirllm@auburn.edu>
52
53 * Makefile.in: Define new macro TOOLTIP_SUPPORT.
54 (lisp): Use it.
55 (SOME_MACHINE_LISP): Add tooltip.
56
572005-04-14 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
58
59 * mac.c [!TARGET_API_MAC_CARBON]: Include MacLocales.h. Don't
60 include TextEncodingConverter.h.
61 (mac_system_script_code, Vmac_system_locale): New variables.
62 (syms_of_mac): Defvar them.
63 (mac_get_system_locale): New function.
64
65 * macfns.c (x_set_name, x_set_title) [!TARGET_API_MAC_CARBON]: Use
66 ENCODE_SYSTEM to encode title bar string.
67 (x_create_tip_frame): Apply 2005-03-18 change for xfns.c.
68 (Fx_file_dialog) [TARGET_API_MAC_CARBON && !MAC_OSX]: Use
69 CFStringGetSystemEncoding to get system default string encoding.
70
71 * macterm.c [!TARGET_API_MAC_CARBON]: Don't include
72 TextEncodingConverter.h.
73
742005-04-13 Steven Tamm <steventamm@mac.com>
75
76 * macterm.c (syms_of_macterm): Remove redundant definition of
77 mac-pass-control-to-system.
78
792005-04-12 Stefan Monnier <monnier@iro.umontreal.ca>
80
81 * window.c (Fset_window_configuration): Be careful when you choose
82 among several possible points for the new_current_buffer.
83
842005-04-12 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
85
86 * keyboard.c (poll_for_input) [SYNC_INPUT]: Don't call
87 poll_for_input_1. Set interrupt_input_pending to 1 instead.
88 (Qlanguage_change) [MAC_OS]: New variable.
89 (syms_of_keyboard) [MAC_OS]: Intern and staticpro it.
90 (kbd_buffer_get_event) [MAC_OS]: Make event for LANGUAGE_CHANGE_EVENT.
91
92 * macterm.c (mac_keyboard_text_encoding)
93 (current_mac_keyboard_text_encoding): Remove variables.
94 (XTread_socket): Store language-change event if keyboard script change
95 is detected. Don't convert input to `mac_keyboard_text_encoding'.
96 (syms_of_macterm): Delete DEFVAR_INT for mac-keyboard-text-encoding.
97
98 * termhooks.h (enum event_kind) [MAC_OS]: Add LANGUAGE_CHANGE_EVENT.
99
12005-04-10 Richard M. Stallman <rms@gnu.org> 1002005-04-10 Richard M. Stallman <rms@gnu.org>
2 101
3 * emacs.c (standard_args): Rename --bare-bones to --quick. 102 * emacs.c (standard_args): Rename --bare-bones to --quick.
@@ -48,8 +147,8 @@
48 * mac.c (cfdate_to_lisp): Add `const' for variable `epoch_gdate'. 147 * mac.c (cfdate_to_lisp): Add `const' for variable `epoch_gdate'.
49 (Fmac_get_preference): Doc fix. 148 (Fmac_get_preference): Doc fix.
50 149
51 * macfns.c (Fx_create_frame, x_create_tip_frame): Add 150 * macfns.c (Fx_create_frame, x_create_tip_frame):
52 "fontset-mac" to fallback font/fontsets. 151 Add "fontset-mac" to fallback font/fontsets.
53 152
542005-04-04 Kim F. Storm <storm@cua.dk> 1532005-04-04 Kim F. Storm <storm@cua.dk>
55 154
@@ -80,8 +179,8 @@
80 Vascii_downcase_table. 179 Vascii_downcase_table.
81 (fast_string_match_ignore_case): Likewise. 180 (fast_string_match_ignore_case): Likewise.
82 (search_buffer): Fix checking of boyer-moore usability. 181 (search_buffer): Fix checking of boyer-moore usability.
83 (boyer_moore): Calculate translate_prev_byte1/2/3 in advance. No 182 (boyer_moore): Calculate translate_prev_byte1/2/3 in advance.
84 need of tranlating characters in PAT. Fix calculation of 183 No need of tranlating characters in PAT. Fix calculation of
85 simple_translate. 184 simple_translate.
86 185
872005-03-31 Stefan Monnier <monnier@iro.umontreal.ca> 1862005-03-31 Stefan Monnier <monnier@iro.umontreal.ca>
@@ -885,9 +984,9 @@
885 984
8862005-02-02 Steven Tamm <steventamm@mac.com> 9852005-02-02 Steven Tamm <steventamm@mac.com>
887 986
888 * macfns.c (unwind_create_frame): Fixing compile error due to 987 * macfns.c (unwind_create_frame): Fix compile error due to
889 xassert being uncondition, but predicate is. 988 xassert being uncondition, but predicate is.
890 * dispnew.c (update_window): Fixing compile error due to 989 * dispnew.c (update_window): Fix compile error due to
891 xassert being uncondition, but predicate is. 990 xassert being uncondition, but predicate is.
892 991
8932005-02-02 Miles Bader <miles@gnu.org> 9922005-02-02 Miles Bader <miles@gnu.org>
@@ -1031,6 +1130,7 @@
1031 1130
1032 * s/darwin.h: Removed PTY_ITERATION from here. 1131 * s/darwin.h: Removed PTY_ITERATION from here.
1033 (DARWIN): Define. 1132 (DARWIN): Define.
1133
1034 * process.c (init_process): Default process-connection-type to 1134 * process.c (init_process): Default process-connection-type to
1035 nil on darwin 6 or less, t if it is 7 or higher. This way the 1135 nil on darwin 6 or less, t if it is 7 or higher. This way the
1036 broken pty behavior is still allowed on darwin 6 for interactive 1136 broken pty behavior is still allowed on darwin 6 for interactive
@@ -3536,8 +3636,8 @@
35362004-08-26 Steven Tamm <steventamm@mac.com> 36362004-08-26 Steven Tamm <steventamm@mac.com>
3537 3637
3538 * fileio.c (Fread_file_name): Call x_file_dialog on carbon on 3638 * fileio.c (Fread_file_name): Call x_file_dialog on carbon on
3539 tool-bar/menu click 3639 tool-bar/menu click.
3540 * macfns.c (Fx_file_dialog): Implemented using NavServices 3640 * macfns.c (Fx_file_dialog): Implement using NavServices.
3541 3641
35422004-08-24 Jan Dj,Ad(Brv <jan.h.d@swipnet.se> 36422004-08-24 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
3543 3643
@@ -5024,7 +5124,7 @@
5024 5124
50252004-04-26 Steven Tamm <tamm@Steven-Tamms-Computer.local> 51252004-04-26 Steven Tamm <tamm@Steven-Tamms-Computer.local>
5026 5126
5027 * lread.c (init_lread): Fixing typo HAVE_CARBON test logic 5127 * lread.c (init_lread): Fix typo in HAVE_CARBON test logic.
5028 5128
50292004-04-26 Miles Bader <miles@gnu.org> 51292004-04-26 Miles Bader <miles@gnu.org>
5030 5130
@@ -5479,10 +5579,10 @@
5479 5579
54802004-03-11 Steven Tamm <steventamm@mac.com> 55802004-03-11 Steven Tamm <steventamm@mac.com>
5481 5581
5482 * image.c [MAC_OSX]: Include sys/stat.h 5582 * image.c [MAC_OSX]: Include sys/stat.h.
5483 5583
5484 * macfns.c (syms_of_macfns): Remove definitions of things now 5584 * macfns.c (syms_of_macfns): Remove definitions of things now
5485 defined in image.c 5585 defined in image.c.
5486 5586
54872004-03-11 Kim F. Storm <storm@cua.dk> 55872004-03-11 Kim F. Storm <storm@cua.dk>
5488 5588
@@ -6192,7 +6292,7 @@
6192 * macterm.c (Vmac_emulate_three_button_mouse): New variable for 6292 * macterm.c (Vmac_emulate_three_button_mouse): New variable for
6193 controlling emulation of a three button mouse with option and 6293 controlling emulation of a three button mouse with option and
6194 command keys. 6294 command keys.
6195 (Qreverse, mac_get_enumlated_btn): Handle the emulation 6295 (Qreverse, mac_get_enumlated_btn): Handle the emulation.
6196 (mac_event_to_emacs_modifiers, XTread_socket): Ditto. 6296 (mac_event_to_emacs_modifiers, XTread_socket): Ditto.
6197 6297
61982004-02-15 Kim F. Storm <storm@cua.dk> 62982004-02-15 Kim F. Storm <storm@cua.dk>
@@ -11132,7 +11232,7 @@
11132 11232
111332003-01-20 Steven Tamm <steventamm@mac.com> 112332003-01-20 Steven Tamm <steventamm@mac.com>
11134 11234
11135 * macterm.c (XTread_socket): Checks for valid, visible window 11235 * macterm.c (XTread_socket): Check for valid, visible window
11136 before sending a scroll-wheel event. 11236 before sending a scroll-wheel event.
11137 11237
111382003-01-20 Richard M. Stallman <rms@gnu.org> 112382003-01-20 Richard M. Stallman <rms@gnu.org>
@@ -11491,7 +11591,7 @@
11491 11591
114922002-12-28 Steven Tamm <steventamm@mac.com> 115922002-12-28 Steven Tamm <steventamm@mac.com>
11493 11593
11494 * Makefile.in (macosx-bundle): Fixes to Mac OS X/Carbon port to 11594 * Makefile.in (macosx-bundle): Fix Mac OS X/Carbon port to
11495 allow building in a different directory than source. Uses some 11595 allow building in a different directory than source. Uses some
11496 GNU Make extensions, but there is no other make on Mac OS X. 11596 GNU Make extensions, but there is no other make on Mac OS X.
11497 11597
@@ -11534,7 +11634,7 @@
11534 11634
11535 * macterm.c (XTread_socket): Call KeyTranslate for control and 11635 * macterm.c (XTread_socket): Call KeyTranslate for control and
11536 meta to deal correctly shifted non-alpha characters, like C-S-5 11636 meta to deal correctly shifted non-alpha characters, like C-S-5
11537 being treated like C-%. Does not look for shift key to deal 11637 being treated like C-%. Do not look for shift key to deal
11538 with masking off control-key with mac-reverse-ctrl-meta. 11638 with masking off control-key with mac-reverse-ctrl-meta.
11539 11639
115402002-12-21 Richard M. Stallman <rms@gnu.org> 116402002-12-21 Richard M. Stallman <rms@gnu.org>
diff --git a/src/Makefile.in b/src/Makefile.in
index 53725361a80..ec5ff5a4c5f 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -686,6 +686,12 @@ otherobj= $(termcapobj) lastfile.o $(mallocobj) $(allocaobj) $(widgetobj) $(LIBO
686#define WINNT_SUPPORT 686#define WINNT_SUPPORT
687#endif 687#endif
688 688
689#ifdef HAVE_WINDOW_SYSTEM
690#define TOOLTIP_SUPPORT ${lispsource}tooltip.elc
691#else
692#define TOOLTIP_SUPPORT
693#endif
694
689/* List of Lisp files loaded into the dumped Emacs. It's arranged 695/* List of Lisp files loaded into the dumped Emacs. It's arranged
690 like this because it's easier to generate it semi-mechanically from 696 like this because it's easier to generate it semi-mechanically from
691 loadup.el this way. 697 loadup.el this way.
@@ -780,6 +786,7 @@ lisp= \
780 ${lispsource}emacs-lisp/timer.elc \ 786 ${lispsource}emacs-lisp/timer.elc \
781 ${lispsource}vc-hooks.elc \ 787 ${lispsource}vc-hooks.elc \
782 ${lispsource}ediff-hook.elc \ 788 ${lispsource}ediff-hook.elc \
789 TOOLTIP_SUPPORT \
783 VMS_SUPPORT \ 790 VMS_SUPPORT \
784 MSDOS_SUPPORT \ 791 MSDOS_SUPPORT \
785 WINNT_SUPPORT \ 792 WINNT_SUPPORT \
@@ -887,6 +894,7 @@ SOME_MACHINE_LISP = ${dotdot}/lisp/mouse.elc \
887 ${dotdot}/lisp/ls-lisp.elc ${dotdot}/lisp/dos-fns.elc \ 894 ${dotdot}/lisp/ls-lisp.elc ${dotdot}/lisp/dos-fns.elc \
888 ${dotdot}/lisp/w32-fns.elc ${dotdot}/lisp/dos-w32.elc \ 895 ${dotdot}/lisp/w32-fns.elc ${dotdot}/lisp/dos-w32.elc \
889 ${dotdot}/lisp/disp-table.elc ${dotdot}/lisp/dos-vars.elc \ 896 ${dotdot}/lisp/disp-table.elc ${dotdot}/lisp/dos-vars.elc \
897 ${dotdot}/lisp/tooltip.elc \
890 ${dotdot}/lisp/international/ccl.elc \ 898 ${dotdot}/lisp/international/ccl.elc \
891 ${dotdot}/lisp/international/codepage.elc \ 899 ${dotdot}/lisp/international/codepage.elc \
892 ${dotdot}/lisp/mouse.elc ${dotdot}/lisp/international/fontset.elc \ 900 ${dotdot}/lisp/mouse.elc ${dotdot}/lisp/international/fontset.elc \
@@ -1233,7 +1241,8 @@ abbrev.o buffer.o callint.o cmds.o dispnew.o editfns.o fileio.o frame.o \
1233 fontset.o indent.o insdel.o keyboard.o macros.o minibuf.o msdos.o process.o \ 1241 fontset.o indent.o insdel.o keyboard.o macros.o minibuf.o msdos.o process.o \
1234 scroll.o sysdep.o term.o widget.o window.o xdisp.o xfaces.o xfns.o xmenu.o \ 1242 scroll.o sysdep.o term.o widget.o window.o xdisp.o xfaces.o xfns.o xmenu.o \
1235 xterm.o xselect.o sound.o: macgui.h 1243 xterm.o xselect.o sound.o: macgui.h
1236mac.o: mac.c process.h sysselect.h blockinput.h atimer.h systime.h $(config_h) 1244mac.o: mac.c process.h sysselect.h blockinput.h atimer.h systime.h charset.h \
1245 coding.h $(config_h)
1237macfns.o: macfns.c charset.h macterm.h macgui.h frame.h window.h buffer.h \ 1246macfns.o: macfns.c charset.h macterm.h macgui.h frame.h window.h buffer.h \
1238 dispextern.h macgui.h fontset.h $(INTERVAL_SRC) keyboard.h blockinput.h \ 1247 dispextern.h macgui.h fontset.h $(INTERVAL_SRC) keyboard.h blockinput.h \
1239 atimer.h systime.h epaths.h termhooks.h coding.h systime.h $(config_h) 1248 atimer.h systime.h epaths.h termhooks.h coding.h systime.h $(config_h)
diff --git a/src/image.c b/src/image.c
index 0e48b1d2bcb..6a1fc7aa795 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2423,7 +2423,7 @@ image_load_quartz2d (f, img, png_p)
2423 UNGCPRO; 2423 UNGCPRO;
2424 return 0; 2424 return 0;
2425 } 2425 }
2426 path = cfstring_create_with_utf8_cstring (SDATA (file)); 2426 path = cfstring_create_with_string (file);
2427 url = CFURLCreateWithFileSystemPath (NULL, path, 2427 url = CFURLCreateWithFileSystemPath (NULL, path,
2428 kCFURLPOSIXPathStyle, 0); 2428 kCFURLPOSIXPathStyle, 0);
2429 CFRelease (path); 2429 CFRelease (path);
diff --git a/src/keyboard.c b/src/keyboard.c
index 48c47502f85..9afcab10acd 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -521,7 +521,7 @@ Lisp_Object Qmouse_fixup_help_message;
521/* Symbols to denote kinds of events. */ 521/* Symbols to denote kinds of events. */
522Lisp_Object Qfunction_key; 522Lisp_Object Qfunction_key;
523Lisp_Object Qmouse_click; 523Lisp_Object Qmouse_click;
524#ifdef WINDOWSNT 524#if defined (WINDOWSNT) || defined (MAC_OS)
525Lisp_Object Qlanguage_change; 525Lisp_Object Qlanguage_change;
526#endif 526#endif
527Lisp_Object Qdrag_n_drop; 527Lisp_Object Qdrag_n_drop;
@@ -2100,7 +2100,11 @@ poll_for_input (timer)
2100 struct atimer *timer; 2100 struct atimer *timer;
2101{ 2101{
2102 if (poll_suppress_count == 0) 2102 if (poll_suppress_count == 0)
2103#ifdef SYNC_INPUT
2104 interrupt_input_pending = 1;
2105#else
2103 poll_for_input_1 (); 2106 poll_for_input_1 ();
2107#endif
2104} 2108}
2105 2109
2106#endif /* POLL_FOR_INPUT */ 2110#endif /* POLL_FOR_INPUT */
@@ -4026,11 +4030,16 @@ kbd_buffer_get_event (kbp, used_mouse_menu)
4026 x_activate_menubar (XFRAME (event->frame_or_window)); 4030 x_activate_menubar (XFRAME (event->frame_or_window));
4027 } 4031 }
4028#endif 4032#endif
4029#ifdef WINDOWSNT 4033#if defined (WINDOWSNT) || defined (MAC_OS)
4030 else if (event->kind == LANGUAGE_CHANGE_EVENT) 4034 else if (event->kind == LANGUAGE_CHANGE_EVENT)
4031 { 4035 {
4036#ifdef MAC_OS
4037 /* Make an event (language-change (KEY_SCRIPT)). */
4038 obj = Fcons (make_number (event->code), Qnil);
4039#else
4032 /* Make an event (language-change (FRAME CHARSET LCID)). */ 4040 /* Make an event (language-change (FRAME CHARSET LCID)). */
4033 obj = Fcons (event->frame_or_window, Qnil); 4041 obj = Fcons (event->frame_or_window, Qnil);
4042#endif
4034 obj = Fcons (Qlanguage_change, Fcons (obj, Qnil)); 4043 obj = Fcons (Qlanguage_change, Fcons (obj, Qnil));
4035 kbd_fetch_ptr = event + 1; 4044 kbd_fetch_ptr = event + 1;
4036 } 4045 }
@@ -10976,7 +10985,7 @@ syms_of_keyboard ()
10976 staticpro (&Qfunction_key); 10985 staticpro (&Qfunction_key);
10977 Qmouse_click = intern ("mouse-click"); 10986 Qmouse_click = intern ("mouse-click");
10978 staticpro (&Qmouse_click); 10987 staticpro (&Qmouse_click);
10979#ifdef WINDOWSNT 10988#if defined (WINDOWSNT) || defined (MAC_OS)
10980 Qlanguage_change = intern ("language-change"); 10989 Qlanguage_change = intern ("language-change");
10981 staticpro (&Qlanguage_change); 10990 staticpro (&Qlanguage_change);
10982#endif 10991#endif
diff --git a/src/mac.c b/src/mac.c
index da6a61633dc..68e3bdfa065 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -31,6 +31,8 @@ Boston, MA 02111-1307, USA. */
31#include "sysselect.h" 31#include "sysselect.h"
32#include "systime.h" 32#include "systime.h"
33#include "blockinput.h" 33#include "blockinput.h"
34#include "charset.h"
35#include "coding.h"
34 36
35#include "macterm.h" 37#include "macterm.h"
36 38
@@ -49,6 +51,7 @@ Boston, MA 02111-1307, USA. */
49#include <Events.h> 51#include <Events.h>
50#include <Processes.h> 52#include <Processes.h>
51#include <EPPC.h> 53#include <EPPC.h>
54#include <MacLocales.h>
52#endif /* not HAVE_CARBON */ 55#endif /* not HAVE_CARBON */
53 56
54#include <utime.h> 57#include <utime.h>
@@ -67,6 +70,12 @@ Boston, MA 02111-1307, USA. */
67 70
68Lisp_Object QCLIPBOARD; 71Lisp_Object QCLIPBOARD;
69 72
73/* The system script code. */
74static int mac_system_script_code;
75
76/* The system locale identifier string. */
77static Lisp_Object Vmac_system_locale;
78
70/* An instance of the AppleScript component. */ 79/* An instance of the AppleScript component. */
71static ComponentInstance as_scripting_component; 80static ComponentInstance as_scripting_component;
72/* The single script context used for all script executions. */ 81/* The single script context used for all script executions. */
@@ -258,7 +267,6 @@ posix_to_mac_pathname (const char *ufn, char *mfn, int mfnbuflen)
258#if TARGET_API_MAC_CARBON 267#if TARGET_API_MAC_CARBON
259static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata; 268static Lisp_Object Qstring, Qnumber, Qboolean, Qdate, Qdata;
260static Lisp_Object Qarray, Qdictionary; 269static Lisp_Object Qarray, Qdictionary;
261extern Lisp_Object Qutf_8;
262#define DECODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 0) 270#define DECODE_UTF_8(str) code_convert_string_norecord (str, Qutf_8, 0)
263 271
264struct cfdict_context 272struct cfdict_context
@@ -267,7 +275,7 @@ struct cfdict_context
267 int with_tag, hash_bound; 275 int with_tag, hash_bound;
268}; 276};
269 277
270/* C string to CFString. */ 278/* C string to CFString. */
271 279
272CFStringRef 280CFStringRef
273cfstring_create_with_utf8_cstring (c_str) 281cfstring_create_with_utf8_cstring (c_str)
@@ -284,6 +292,37 @@ cfstring_create_with_utf8_cstring (c_str)
284} 292}
285 293
286 294
295/* Lisp string to CFString. */
296
297CFStringRef
298cfstring_create_with_string (s)
299 Lisp_Object s;
300{
301 CFStringRef string = NULL;
302
303 if (STRING_MULTIBYTE (s))
304 {
305 char *p, *end = SDATA (s) + SBYTES (s);
306
307 for (p = SDATA (s); p < end; p++)
308 if (!isascii (*p))
309 {
310 s = ENCODE_UTF_8 (s);
311 break;
312 }
313 string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
314 kCFStringEncodingUTF8, false);
315 }
316
317 if (string == NULL)
318 /* Failed to interpret as UTF 8. Fall back on Mac Roman. */
319 string = CFStringCreateWithBytes (NULL, SDATA (s), SBYTES (s),
320 kCFStringEncodingMacRoman, false);
321
322 return string;
323}
324
325
287/* From CFData to a lisp string. Always returns a unibyte string. */ 326/* From CFData to a lisp string. Always returns a unibyte string. */
288 327
289Lisp_Object 328Lisp_Object
@@ -3704,11 +3743,11 @@ otherwise. */)
3704 app_id = kCFPreferencesCurrentApplication; 3743 app_id = kCFPreferencesCurrentApplication;
3705 if (!NILP (application)) 3744 if (!NILP (application))
3706 { 3745 {
3707 app_id = cfstring_create_with_utf8_cstring (SDATA (application)); 3746 app_id = cfstring_create_with_string (application);
3708 if (app_id == NULL) 3747 if (app_id == NULL)
3709 goto out; 3748 goto out;
3710 } 3749 }
3711 key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key))); 3750 key_str = cfstring_create_with_string (XCAR (key));
3712 if (key_str == NULL) 3751 if (key_str == NULL)
3713 goto out; 3752 goto out;
3714 app_plist = CFPreferencesCopyAppValue (key_str, app_id); 3753 app_plist = CFPreferencesCopyAppValue (key_str, app_id);
@@ -3721,7 +3760,7 @@ otherwise. */)
3721 { 3760 {
3722 if (CFGetTypeID (plist) != CFDictionaryGetTypeID ()) 3761 if (CFGetTypeID (plist) != CFDictionaryGetTypeID ())
3723 break; 3762 break;
3724 key_str = cfstring_create_with_utf8_cstring (SDATA (XCAR (key))); 3763 key_str = cfstring_create_with_string (XCAR (key));
3725 if (key_str == NULL) 3764 if (key_str == NULL)
3726 goto out; 3765 goto out;
3727 plist = CFDictionaryGetValue (plist, key_str); 3766 plist = CFDictionaryGetValue (plist, key_str);
@@ -4167,6 +4206,29 @@ init_mac_osx_environment ()
4167} 4206}
4168#endif /* MAC_OSX */ 4207#endif /* MAC_OSX */
4169 4208
4209
4210static Lisp_Object
4211mac_get_system_locale ()
4212{
4213 OSErr err;
4214 LangCode lang;
4215 RegionCode region;
4216 LocaleRef locale;
4217 Str255 str;
4218
4219 lang = GetScriptVariable (smSystemScript, smScriptLang);
4220 region = GetScriptManagerVariable (smRegionCode);
4221 err = LocaleRefFromLangOrRegionCode (lang, region, &locale);
4222 if (err == noErr)
4223 err = LocaleRefGetPartString (locale, kLocaleAllPartsMask,
4224 sizeof (str), str);
4225 if (err == noErr)
4226 return build_string (str);
4227 else
4228 return Qnil;
4229}
4230
4231
4170void 4232void
4171syms_of_mac () 4233syms_of_mac ()
4172{ 4234{
@@ -4197,6 +4259,16 @@ syms_of_mac ()
4197 defsubr (&Sdo_applescript); 4259 defsubr (&Sdo_applescript);
4198 defsubr (&Smac_file_name_to_posix); 4260 defsubr (&Smac_file_name_to_posix);
4199 defsubr (&Sposix_file_name_to_mac); 4261 defsubr (&Sposix_file_name_to_mac);
4262
4263 DEFVAR_INT ("mac-system-script-code", &mac_system_script_code,
4264 doc: /* The system script code. */);
4265 mac_system_script_code = (ScriptCode) GetScriptManagerVariable (smSysScript);
4266
4267 DEFVAR_LISP ("mac-system-locale", &Vmac_system_locale,
4268 doc: /* The system locale identifier string.
4269This is not a POSIX locale ID, but an ICU locale ID. So encoding
4270information is not included. */);
4271 Vmac_system_locale = mac_get_system_locale ();
4200} 4272}
4201 4273
4202/* arch-tag: 29d30c1f-0c6b-4f88-8a6d-0558d7f9dbff 4274/* arch-tag: 29d30c1f-0c6b-4f88-8a6d-0558d7f9dbff
diff --git a/src/macfns.c b/src/macfns.c
index 357f993b0f9..b85c4f01795 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -1895,7 +1895,7 @@ x_set_name (f, name, explicit)
1895#if TARGET_API_MAC_CARBON 1895#if TARGET_API_MAC_CARBON
1896 name = ENCODE_UTF_8 (name); 1896 name = ENCODE_UTF_8 (name);
1897#else 1897#else
1898 return; 1898 name = ENCODE_SYSTEM (name);
1899#endif 1899#endif
1900 1900
1901 BLOCK_INPUT; 1901 BLOCK_INPUT;
@@ -1977,7 +1977,7 @@ x_set_title (f, name, old_name)
1977#if TARGET_API_MAC_CARBON 1977#if TARGET_API_MAC_CARBON
1978 name = ENCODE_UTF_8 (name); 1978 name = ENCODE_UTF_8 (name);
1979#else 1979#else
1980 return; 1980 name = ENCODE_SYSTEM (name);
1981#endif 1981#endif
1982 1982
1983 BLOCK_INPUT; 1983 BLOCK_INPUT;
@@ -3637,9 +3637,6 @@ x_create_tip_frame (dpyinfo, parms, text)
3637 3637
3638 check_mac (); 3638 check_mac ();
3639 3639
3640 /* Use this general default value to start with until we know if
3641 this frame has a specified name. */
3642 Vx_resource_name = Vinvocation_name;
3643 3640
3644#ifdef MULTI_KBOARD 3641#ifdef MULTI_KBOARD
3645 kb = dpyinfo->kboard; 3642 kb = dpyinfo->kboard;
@@ -3653,7 +3650,6 @@ x_create_tip_frame (dpyinfo, parms, text)
3653 && !EQ (name, Qunbound) 3650 && !EQ (name, Qunbound)
3654 && !NILP (name)) 3651 && !NILP (name))
3655 error ("Invalid frame name--not a string or nil"); 3652 error ("Invalid frame name--not a string or nil");
3656 Vx_resource_name = name;
3657 3653
3658 frame = Qnil; 3654 frame = Qnil;
3659 GCPRO3 (parms, name, frame); 3655 GCPRO3 (parms, name, frame);
@@ -4252,8 +4248,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4252 options.optionFlags |= kNavSelectAllReadableItem; 4248 options.optionFlags |= kNavSelectAllReadableItem;
4253 if (!NILP(prompt)) 4249 if (!NILP(prompt))
4254 { 4250 {
4255 message = 4251 message = cfstring_create_with_string (prompt);
4256 cfstring_create_with_utf8_cstring (SDATA (ENCODE_UTF_8 (prompt)));
4257 options.message = message; 4252 options.message = message;
4258 } 4253 }
4259 /* Don't set the application, let it use default. 4254 /* Don't set the application, let it use default.
@@ -4362,7 +4357,12 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
4362 filename[len++] = '/'; 4357 filename[len++] = '/';
4363 CFStringGetCString(reply.saveFileName, filename+len, 4358 CFStringGetCString(reply.saveFileName, filename+len,
4364 sizeof (filename) - len, 4359 sizeof (filename) - len,
4365 kCFStringEncodingUTF8); 4360#if MAC_OSX
4361 kCFStringEncodingUTF8
4362#else
4363 CFStringGetSystemEncoding ()
4364#endif
4365 );
4366 } 4366 }
4367 file = DECODE_FILE (make_unibyte_string (filename, 4367 file = DECODE_FILE (make_unibyte_string (filename,
4368 strlen (filename))); 4368 strlen (filename)));
diff --git a/src/macterm.c b/src/macterm.c
index 569c728f80e..5aab6ec5364 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -95,6 +95,7 @@ Boston, MA 02111-1307, USA. */
95 : controlKey) 95 : controlKey)
96#define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey) 96#define macAltKey (NILP (Vmac_command_key_is_meta) ? cmdKey : optionKey)
97 97
98#define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
98 99
99 100
100/* Non-nil means Emacs uses toolkit scroll bars. */ 101/* Non-nil means Emacs uses toolkit scroll bars. */
@@ -110,9 +111,8 @@ Lisp_Object Vmac_use_core_graphics;
110 111
111static int any_help_event_p; 112static int any_help_event_p;
112 113
113/* Non-zero means autoselect window with the mouse cursor. */ 114/* Last window where we saw the mouse. Used by mouse-autoselect-window. */
114 115static Lisp_Object last_window;
115int x_autoselect_window_p;
116 116
117/* Non-zero means make use of UNDERLINE_POSITION font properties. */ 117/* Non-zero means make use of UNDERLINE_POSITION font properties. */
118 118
@@ -273,14 +273,16 @@ static void x_font_min_bounds P_ ((XFontStruct *, int *, int *));
273static int x_compute_min_glyph_bounds P_ ((struct frame *)); 273static int x_compute_min_glyph_bounds P_ ((struct frame *));
274static void x_update_end P_ ((struct frame *)); 274static void x_update_end P_ ((struct frame *));
275static void XTframe_up_to_date P_ ((struct frame *)); 275static void XTframe_up_to_date P_ ((struct frame *));
276static void XTreassert_line_highlight P_ ((int, int));
277static void x_change_line_highlight P_ ((int, int, int, int));
278static void XTset_terminal_modes P_ ((void)); 276static void XTset_terminal_modes P_ ((void));
279static void XTreset_terminal_modes P_ ((void)); 277static void XTreset_terminal_modes P_ ((void));
280static void x_clear_frame P_ ((void)); 278static void x_clear_frame P_ ((void));
281static void frame_highlight P_ ((struct frame *)); 279static void frame_highlight P_ ((struct frame *));
282static void frame_unhighlight P_ ((struct frame *)); 280static void frame_unhighlight P_ ((struct frame *));
283static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *)); 281static void x_new_focus_frame P_ ((struct x_display_info *, struct frame *));
282static void mac_focus_changed P_ ((int, struct mac_display_info *,
283 struct frame *, struct input_event *));
284static void x_detect_focus_change P_ ((struct mac_display_info *,
285 EventRecord *, struct input_event *));
284static void XTframe_rehighlight P_ ((struct frame *)); 286static void XTframe_rehighlight P_ ((struct frame *));
285static void x_frame_rehighlight P_ ((struct x_display_info *)); 287static void x_frame_rehighlight P_ ((struct x_display_info *));
286static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *)); 288static void x_draw_hollow_cursor P_ ((struct window *, struct glyph_row *));
@@ -1198,15 +1200,6 @@ XSetFont (display, gc, font)
1198} 1200}
1199 1201
1200 1202
1201static void
1202XTextExtents16 (XFontStruct *font, XChar2b *text, int nchars,
1203 int *direction,int *font_ascent,
1204 int *font_descent, XCharStruct *cs)
1205{
1206 /* MAC_TODO: Use GetTextMetrics to do this and inline it below. */
1207}
1208
1209
1210/* x_sync is a no-op on Mac. */ 1203/* x_sync is a no-op on Mac. */
1211void 1204void
1212x_sync (f) 1205x_sync (f)
@@ -3494,6 +3487,14 @@ static void
3494frame_highlight (f) 3487frame_highlight (f)
3495 struct frame *f; 3488 struct frame *f;
3496{ 3489{
3490 OSErr err;
3491 ControlRef root_control;
3492
3493 BLOCK_INPUT;
3494 err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
3495 if (err == noErr)
3496 ActivateControl (root_control);
3497 UNBLOCK_INPUT;
3497 x_update_cursor (f, 1); 3498 x_update_cursor (f, 1);
3498} 3499}
3499 3500
@@ -3501,6 +3502,14 @@ static void
3501frame_unhighlight (f) 3502frame_unhighlight (f)
3502 struct frame *f; 3503 struct frame *f;
3503{ 3504{
3505 OSErr err;
3506 ControlRef root_control;
3507
3508 BLOCK_INPUT;
3509 err = GetRootControl (FRAME_MAC_WINDOW (f), &root_control);
3510 if (err == noErr)
3511 DeactivateControl (root_control);
3512 UNBLOCK_INPUT;
3504 x_update_cursor (f, 1); 3513 x_update_cursor (f, 1);
3505} 3514}
3506 3515
@@ -3543,6 +3552,68 @@ x_new_focus_frame (dpyinfo, frame)
3543 x_frame_rehighlight (dpyinfo); 3552 x_frame_rehighlight (dpyinfo);
3544} 3553}
3545 3554
3555/* Handle FocusIn and FocusOut state changes for FRAME.
3556 If FRAME has focus and there exists more than one frame, puts
3557 a FOCUS_IN_EVENT into *BUFP. */
3558
3559static void
3560mac_focus_changed (type, dpyinfo, frame, bufp)
3561 int type;
3562 struct mac_display_info *dpyinfo;
3563 struct frame *frame;
3564 struct input_event *bufp;
3565{
3566 if (type == activeFlag)
3567 {
3568 if (dpyinfo->x_focus_event_frame != frame)
3569 {
3570 x_new_focus_frame (dpyinfo, frame);
3571 dpyinfo->x_focus_event_frame = frame;
3572
3573 /* Don't stop displaying the initial startup message
3574 for a switch-frame event we don't need. */
3575 if (GC_NILP (Vterminal_frame)
3576 && GC_CONSP (Vframe_list)
3577 && !GC_NILP (XCDR (Vframe_list)))
3578 {
3579 bufp->kind = FOCUS_IN_EVENT;
3580 XSETFRAME (bufp->frame_or_window, frame);
3581 }
3582 }
3583 }
3584 else
3585 {
3586 if (dpyinfo->x_focus_event_frame == frame)
3587 {
3588 dpyinfo->x_focus_event_frame = 0;
3589 x_new_focus_frame (dpyinfo, 0);
3590 }
3591 }
3592}
3593
3594/* The focus may have changed. Figure out if it is a real focus change,
3595 by checking both FocusIn/Out and Enter/LeaveNotify events.
3596
3597 Returns FOCUS_IN_EVENT event in *BUFP. */
3598
3599static void
3600x_detect_focus_change (dpyinfo, event, bufp)
3601 struct mac_display_info *dpyinfo;
3602 EventRecord *event;
3603 struct input_event *bufp;
3604{
3605 struct frame *frame;
3606
3607 frame = mac_window_to_frame ((WindowPtr) event->message);
3608 if (! frame)
3609 return;
3610
3611 /* On Mac, this is only called from focus events, so no switch needed. */
3612 mac_focus_changed ((event->modifiers & activeFlag),
3613 dpyinfo, frame, bufp);
3614}
3615
3616
3546/* Handle an event saying the mouse has moved out of an Emacs frame. */ 3617/* Handle an event saying the mouse has moved out of an Emacs frame. */
3547 3618
3548void 3619void
@@ -3980,25 +4051,19 @@ remember_mouse_glyph (f1, gx, gy)
3980} 4051}
3981 4052
3982 4053
3983static WindowPtr 4054static struct frame *
3984front_emacs_window () 4055mac_focus_frame (dpyinfo)
4056 struct mac_display_info *dpyinfo;
3985{ 4057{
3986#if TARGET_API_MAC_CARBON 4058 if (dpyinfo->x_focus_frame)
3987 WindowPtr wp = GetFrontWindowOfClass (kDocumentWindowClass, true); 4059 return dpyinfo->x_focus_frame;
3988 4060 else
3989 while (wp && !is_emacs_window (wp)) 4061 /* Mac version may get events, such as a menu bar click, even when
3990 wp = GetNextWindowOfClass (wp, kDocumentWindowClass, true); 4062 all the frames are invisible. In this case, we regard the
3991#else 4063 event came to the selected frame. */
3992 WindowPtr wp = FrontWindow (); 4064 return SELECTED_FRAME ();
3993
3994 while (wp && (wp == tip_window || !is_emacs_window (wp)))
3995 wp = GetNextWindow (wp);
3996#endif
3997
3998 return wp;
3999} 4065}
4000 4066
4001#define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
4002 4067
4003/* Return the current position of the mouse. 4068/* Return the current position of the mouse.
4004 *fp should be a frame which indicates which display to ask about. 4069 *fp should be a frame which indicates which display to ask about.
@@ -4031,13 +4096,10 @@ XTmouse_position (fp, insist, bar_window, part, x, y, time)
4031{ 4096{
4032 Point mouse_pos; 4097 Point mouse_pos;
4033 int ignore1, ignore2; 4098 int ignore1, ignore2;
4034 WindowPtr wp = front_emacs_window (); 4099 struct frame *f = mac_focus_frame (FRAME_MAC_DISPLAY_INFO (*fp));
4035 struct frame *f; 4100 WindowPtr wp = FRAME_MAC_WINDOW (f);
4036 Lisp_Object frame, tail; 4101 Lisp_Object frame, tail;
4037 4102
4038 if (is_emacs_window(wp))
4039 f = mac_window_to_frame (wp);
4040
4041 BLOCK_INPUT; 4103 BLOCK_INPUT;
4042 4104
4043 if (! NILP (last_mouse_scroll_bar) && insist == 0) 4105 if (! NILP (last_mouse_scroll_bar) && insist == 0)
@@ -4604,7 +4666,12 @@ x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
4604 unsigned long *time; 4666 unsigned long *time;
4605{ 4667{
4606 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar); 4668 struct scroll_bar *bar = XSCROLL_BAR (last_mouse_scroll_bar);
4607 WindowPtr wp = front_emacs_window (); 4669 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
4670#if TARGET_API_MAC_CARBON
4671 WindowPtr wp = GetControlOwner (ch);
4672#else
4673 WindowPtr wp = (*ch)->contrlOwner;
4674#endif
4608 Point mouse_pos; 4675 Point mouse_pos;
4609 struct frame *f = mac_window_to_frame (wp); 4676 struct frame *f = mac_window_to_frame (wp);
4610 int win_y, top_range; 4677 int win_y, top_range;
@@ -5050,7 +5117,7 @@ x_new_fontset (f, fontsetname)
5050 return Qnil; 5117 return Qnil;
5051 5118
5052 /* Since x_new_font doesn't update any fontset information, do it now. */ 5119 /* Since x_new_font doesn't update any fontset information, do it now. */
5053 FRAME_FONTSET(f) = fontset; 5120 FRAME_FONTSET (f) = fontset;
5054 5121
5055 return build_string (fontsetname); 5122 return build_string (fontsetname);
5056} 5123}
@@ -5498,6 +5565,13 @@ x_make_frame_invisible (f)
5498 5565
5499 BLOCK_INPUT; 5566 BLOCK_INPUT;
5500 5567
5568 /* Before unmapping the window, update the WM_SIZE_HINTS property to claim
5569 that the current position of the window is user-specified, rather than
5570 program-specified, so that when the window is mapped again, it will be
5571 placed at the same location, without forcing the user to position it
5572 by hand again (they have already done that once for this window.) */
5573 x_wm_set_size_hint (f, (long) 0, 1);
5574
5501 HideWindow (FRAME_MAC_WINDOW (f)); 5575 HideWindow (FRAME_MAC_WINDOW (f));
5502 5576
5503 /* We can't distinguish this from iconification 5577 /* We can't distinguish this from iconification
@@ -7070,7 +7144,6 @@ x_find_ccl_program (fontp)
7070#include <Dialogs.h> 7144#include <Dialogs.h>
7071#include <Script.h> 7145#include <Script.h>
7072#include <Types.h> 7146#include <Types.h>
7073#include <TextEncodingConverter.h>
7074#include <Resources.h> 7147#include <Resources.h>
7075 7148
7076#if __MWERKS__ 7149#if __MWERKS__
@@ -7146,11 +7219,6 @@ Lisp_Object Vmac_pass_command_to_system;
7146Lisp_Object Vmac_pass_control_to_system; 7219Lisp_Object Vmac_pass_control_to_system;
7147#endif 7220#endif
7148 7221
7149/* convert input from Mac keyboard (assumed to be in Mac Roman coding)
7150 to this text encoding */
7151int mac_keyboard_text_encoding;
7152int current_mac_keyboard_text_encoding = kTextEncodingMacRoman;
7153
7154/* Set in term/mac-win.el to indicate that event loop can now generate 7222/* Set in term/mac-win.el to indicate that event loop can now generate
7155 drag and drop events. */ 7223 drag and drop events. */
7156Lisp_Object Qmac_ready_for_drag_n_drop; 7224Lisp_Object Qmac_ready_for_drag_n_drop;
@@ -7460,21 +7528,6 @@ do_app_resume ()
7460{ 7528{
7461 /* Window-activate events will do the job. */ 7529 /* Window-activate events will do the job. */
7462#if 0 7530#if 0
7463 WindowPtr wp;
7464 struct frame *f;
7465
7466 wp = front_emacs_window ();
7467 if (wp)
7468 {
7469 f = mac_window_to_frame (wp);
7470
7471 if (f)
7472 {
7473 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), f);
7474 activate_scroll_bars (f);
7475 }
7476 }
7477
7478 app_is_suspended = false; 7531 app_is_suspended = false;
7479 app_sleep_time = WNE_SLEEP_AT_RESUME; 7532 app_sleep_time = WNE_SLEEP_AT_RESUME;
7480#endif 7533#endif
@@ -7485,21 +7538,6 @@ do_app_suspend ()
7485{ 7538{
7486 /* Window-deactivate events will do the job. */ 7539 /* Window-deactivate events will do the job. */
7487#if 0 7540#if 0
7488 WindowPtr wp;
7489 struct frame *f;
7490
7491 wp = front_emacs_window ();
7492 if (wp)
7493 {
7494 f = mac_window_to_frame (wp);
7495
7496 if (f == FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame)
7497 {
7498 x_new_focus_frame (FRAME_MAC_DISPLAY_INFO (f), 0);
7499 deactivate_scroll_bars (f);
7500 }
7501 }
7502
7503 app_is_suspended = true; 7541 app_is_suspended = true;
7504 app_sleep_time = WNE_SLEEP_AT_SUSPEND; 7542 app_sleep_time = WNE_SLEEP_AT_SUSPEND;
7505#endif 7543#endif
@@ -7507,40 +7545,6 @@ do_app_suspend ()
7507 7545
7508 7546
7509static void 7547static void
7510do_mouse_moved (mouse_pos, f)
7511 Point mouse_pos;
7512 FRAME_PTR *f;
7513{
7514 WindowPtr wp = front_emacs_window ();
7515 struct x_display_info *dpyinfo;
7516
7517 if (wp)
7518 {
7519 *f = mac_window_to_frame (wp);
7520 dpyinfo = FRAME_MAC_DISPLAY_INFO (*f);
7521
7522 if (dpyinfo->mouse_face_hidden)
7523 {
7524 dpyinfo->mouse_face_hidden = 0;
7525 clear_mouse_face (dpyinfo);
7526 }
7527
7528 SetPortWindowPort (wp);
7529
7530 GlobalToLocal (&mouse_pos);
7531
7532 if (dpyinfo->grabbed && tracked_scroll_bar)
7533 x_scroll_bar_note_movement (tracked_scroll_bar,
7534 mouse_pos.v
7535 - XINT (tracked_scroll_bar->top),
7536 TickCount() * (1000 / 60));
7537 else
7538 note_mouse_movement (*f, &mouse_pos);
7539 }
7540}
7541
7542
7543static void
7544do_apple_menu (SInt16 menu_item) 7548do_apple_menu (SInt16 menu_item)
7545{ 7549{
7546#if !TARGET_API_MAC_CARBON 7550#if !TARGET_API_MAC_CARBON
@@ -7576,7 +7580,7 @@ do_menu_choice (SInt32 menu_choice)
7576 7580
7577 default: 7581 default:
7578 { 7582 {
7579 struct frame *f = mac_window_to_frame (front_emacs_window ()); 7583 struct frame *f = mac_focus_frame (&one_mac_display_info);
7580 MenuHandle menu = GetMenuHandle (menu_id); 7584 MenuHandle menu = GetMenuHandle (menu_id);
7581 if (menu) 7585 if (menu)
7582 { 7586 {
@@ -7654,13 +7658,14 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
7654 Point top_left; 7658 Point top_left;
7655 int w_title_height, columns, rows, width, height; 7659 int w_title_height, columns, rows, width, height;
7656 struct frame *f = mac_window_to_frame (w); 7660 struct frame *f = mac_window_to_frame (w);
7661 struct mac_display_info *dpyinfo = FRAME_MAC_DISPLAY_INFO (f);
7657 7662
7658#if TARGET_API_MAC_CARBON 7663#if TARGET_API_MAC_CARBON
7659 { 7664 {
7660 Point standard_size; 7665 Point standard_size;
7661 7666
7662 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS); 7667 standard_size.h = FRAME_TEXT_COLS_TO_PIXEL_WIDTH (f, DEFAULT_NUM_COLS);
7663 standard_size.v = FRAME_MAC_DISPLAY_INFO (f)->height; 7668 standard_size.v = dpyinfo->height;
7664 7669
7665 if (IsWindowInStandardState (w, &standard_size, &zoom_rect)) 7670 if (IsWindowInStandardState (w, &standard_size, &zoom_rect))
7666 zoom_in_or_out = inZoomIn; 7671 zoom_in_or_out = inZoomIn;
@@ -7716,7 +7721,7 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
7716 = zoom_rect; 7721 = zoom_rect;
7717 } 7722 }
7718 7723
7719 ZoomWindow (w, zoom_in_or_out, w == front_emacs_window ()); 7724 ZoomWindow (w, zoom_in_or_out, f == mac_focus_frame (dpyinfo));
7720 7725
7721 SetPort (save_port); 7726 SetPort (save_port);
7722#endif /* not TARGET_API_MAC_CARBON */ 7727#endif /* not TARGET_API_MAC_CARBON */
@@ -8582,10 +8587,13 @@ XTread_socket (sd, expected, hold_quit)
8582 { 8587 {
8583 SInt32 delta; 8588 SInt32 delta;
8584 Point point; 8589 Point point;
8585 WindowPtr window_ptr = front_emacs_window (); 8590 struct frame *f = mac_focus_frame (dpyinfo);
8591 WindowPtr window_ptr;
8586 8592
8587 if (!IsValidWindowPtr (window_ptr)) 8593 if (!f)
8588 { 8594 {
8595 /* Beep if wheel move occurs when all the frames
8596 are invisible. */
8589 SysBeep(1); 8597 SysBeep(1);
8590 break; 8598 break;
8591 } 8599 }
@@ -8601,6 +8609,7 @@ XTread_socket (sd, expected, hold_quit)
8601 inev.modifiers = (mac_event_to_emacs_modifiers (eventRef) 8609 inev.modifiers = (mac_event_to_emacs_modifiers (eventRef)
8602 | ((delta < 0) ? down_modifier 8610 | ((delta < 0) ? down_modifier
8603 : up_modifier)); 8611 : up_modifier));
8612 window_ptr = FRAME_MAC_WINDOW (f);
8604 SetPortWindowPort (window_ptr); 8613 SetPortWindowPort (window_ptr);
8605 GlobalToLocal (&point); 8614 GlobalToLocal (&point);
8606 XSETINT (inev.x, point.h); 8615 XSETINT (inev.x, point.h);
@@ -8659,14 +8668,14 @@ XTread_socket (sd, expected, hold_quit)
8659 switch (part_code) 8668 switch (part_code)
8660 { 8669 {
8661 case inMenuBar: 8670 case inMenuBar:
8662 f = mac_window_to_frame (front_emacs_window ()); 8671 f = mac_focus_frame (dpyinfo);
8663 saved_menu_event_location = er.where; 8672 saved_menu_event_location = er.where;
8664 inev.kind = MENU_BAR_ACTIVATE_EVENT; 8673 inev.kind = MENU_BAR_ACTIVATE_EVENT;
8665 XSETFRAME (inev.frame_or_window, f); 8674 XSETFRAME (inev.frame_or_window, f);
8666 break; 8675 break;
8667 8676
8668 case inContent: 8677 case inContent:
8669 if (window_ptr != front_emacs_window ()) 8678 if (window_ptr != FRAME_MAC_WINDOW (mac_focus_frame (dpyinfo)))
8670 SelectWindow (window_ptr); 8679 SelectWindow (window_ptr);
8671 else 8680 else
8672 { 8681 {
@@ -8857,7 +8866,61 @@ XTread_socket (sd, expected, hold_quit)
8857 help_echo_string = help_echo_object = help_echo_window = Qnil; 8866 help_echo_string = help_echo_object = help_echo_window = Qnil;
8858 help_echo_pos = -1; 8867 help_echo_pos = -1;
8859 8868
8860 do_mouse_moved (er.where, &f); 8869 if (dpyinfo->grabbed && last_mouse_frame
8870 && FRAME_LIVE_P (last_mouse_frame))
8871 f = last_mouse_frame;
8872 else
8873 f = dpyinfo->x_focus_frame;
8874
8875 if (dpyinfo->mouse_face_hidden)
8876 {
8877 dpyinfo->mouse_face_hidden = 0;
8878 clear_mouse_face (dpyinfo);
8879 }
8880
8881 if (f)
8882 {
8883 WindowPtr wp = FRAME_MAC_WINDOW (f);
8884 Point mouse_pos = er.where;
8885
8886 SetPortWindowPort (wp);
8887
8888 GlobalToLocal (&mouse_pos);
8889
8890 if (dpyinfo->grabbed && tracked_scroll_bar)
8891 x_scroll_bar_note_movement (tracked_scroll_bar,
8892 mouse_pos.v
8893 - XINT (tracked_scroll_bar->top),
8894 TickCount() * (1000 / 60));
8895 else
8896 {
8897 /* Generate SELECT_WINDOW_EVENTs when needed. */
8898 if (mouse_autoselect_window)
8899 {
8900 Lisp_Object window;
8901
8902 window = window_from_coordinates (f,
8903 mouse_pos.h,
8904 mouse_pos.v,
8905 0, 0, 0, 0);
8906
8907 /* Window will be selected only when it is
8908 not selected now and last mouse movement
8909 event was not in it. Minibuffer window
8910 will be selected iff it is active. */
8911 if (WINDOWP (window)
8912 && !EQ (window, last_window)
8913 && !EQ (window, selected_window))
8914 {
8915 inev.kind = SELECT_WINDOW_EVENT;
8916 inev.frame_or_window = window;
8917 }
8918
8919 last_window=window;
8920 }
8921 note_mouse_movement (f, &mouse_pos);
8922 }
8923 }
8861 8924
8862 /* If the contents of the global variable 8925 /* If the contents of the global variable
8863 help_echo_string has changed, generate a 8926 help_echo_string has changed, generate a
@@ -8871,7 +8934,6 @@ XTread_socket (sd, expected, hold_quit)
8871 case activateEvt: 8934 case activateEvt:
8872 { 8935 {
8873 WindowPtr window_ptr = (WindowPtr) er.message; 8936 WindowPtr window_ptr = (WindowPtr) er.message;
8874 ControlRef root_control;
8875 8937
8876#if USE_CARBON_EVENTS 8938#if USE_CARBON_EVENTS
8877 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) 8939 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
@@ -8887,16 +8949,12 @@ XTread_socket (sd, expected, hold_quit)
8887 if (!is_emacs_window (window_ptr)) 8949 if (!is_emacs_window (window_ptr))
8888 break; 8950 break;
8889 8951
8890 f = mac_window_to_frame (window_ptr);
8891 GetRootControl (window_ptr, &root_control);
8892
8893 if ((er.modifiers & activeFlag) != 0) 8952 if ((er.modifiers & activeFlag) != 0)
8894 { 8953 {
8895 /* A window has been activated */ 8954 /* A window has been activated */
8896 Point mouse_loc = er.where; 8955 Point mouse_loc = er.where;
8897 8956
8898 x_new_focus_frame (dpyinfo, f); 8957 x_detect_focus_change (dpyinfo, &er, &inev);
8899 ActivateControl (root_control);
8900 8958
8901 SetPortWindowPort (window_ptr); 8959 SetPortWindowPort (window_ptr);
8902 GlobalToLocal (&mouse_loc); 8960 GlobalToLocal (&mouse_loc);
@@ -8910,13 +8968,9 @@ XTread_socket (sd, expected, hold_quit)
8910 /* A window has been deactivated */ 8968 /* A window has been deactivated */
8911 dpyinfo->grabbed = 0; 8969 dpyinfo->grabbed = 0;
8912 8970
8913 if (f == dpyinfo->x_focus_frame) 8971 x_detect_focus_change (dpyinfo, &er, &inev);
8914 {
8915 x_new_focus_frame (dpyinfo, 0);
8916 DeactivateControl (root_control);
8917 }
8918
8919 8972
8973 f = mac_window_to_frame (window_ptr);
8920 if (f == dpyinfo->mouse_face_mouse_frame) 8974 if (f == dpyinfo->mouse_face_mouse_frame)
8921 { 8975 {
8922 /* If we move outside the frame, then we're 8976 /* If we move outside the frame, then we're
@@ -8957,13 +9011,31 @@ XTread_socket (sd, expected, hold_quit)
8957 break; 9011 break;
8958#endif 9012#endif
8959 9013
8960#if TARGET_API_MAC_CARBON 9014 if (dpyinfo->x_focus_frame == NULL)
8961 if (!IsValidWindowPtr (front_emacs_window ()))
8962 { 9015 {
9016 /* Beep if keyboard input occurs when all the frames
9017 are invisible. */
8963 SysBeep (1); 9018 SysBeep (1);
8964 break; 9019 break;
8965 } 9020 }
8966#endif 9021
9022 {
9023 static SInt16 last_key_script = -1;
9024 SInt16 current_key_script = GetScriptManagerVariable (smKeyScript);
9025
9026 if (last_key_script != current_key_script)
9027 {
9028 struct input_event event;
9029
9030 EVENT_INIT (event);
9031 event.kind = LANGUAGE_CHANGE_EVENT;
9032 event.arg = Qnil;
9033 event.code = current_key_script;
9034 kbd_buffer_store_event (&event);
9035 count++;
9036 }
9037 last_key_script = current_key_script;
9038 }
8967 9039
8968 ObscureCursor (); 9040 ObscureCursor ();
8969 9041
@@ -8998,95 +9070,32 @@ XTread_socket (sd, expected, hold_quit)
8998 unsigned long some_state = 0; 9070 unsigned long some_state = 0;
8999 inev.code = KeyTranslate (kchr_ptr, new_keycode, 9071 inev.code = KeyTranslate (kchr_ptr, new_keycode,
9000 &some_state) & 0xff; 9072 &some_state) & 0xff;
9001 } else if (!NILP(Vmac_option_modifier) && (er.modifiers & optionKey)) 9073 }
9002 { 9074 else if (!NILP (Vmac_option_modifier)
9003 /* When using the option key as an emacs modifier, convert 9075 && (er.modifiers & optionKey))
9004 the pressed key code back to one without the Mac option 9076 {
9005 modifier applied. */ 9077 /* When using the option key as an emacs modifier,
9006 int new_modifiers = er.modifiers & ~optionKey; 9078 convert the pressed key code back to one
9007 int new_keycode = keycode | new_modifiers; 9079 without the Mac option modifier applied. */
9008 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); 9080 int new_modifiers = er.modifiers & ~optionKey;
9009 unsigned long some_state = 0; 9081 int new_keycode = keycode | new_modifiers;
9010 inev.code = KeyTranslate (kchr_ptr, new_keycode, 9082 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
9011 &some_state) & 0xff; 9083 unsigned long some_state = 0;
9012 } 9084 inev.code = KeyTranslate (kchr_ptr, new_keycode,
9085 &some_state) & 0xff;
9086 }
9013 else 9087 else
9014 inev.code = er.message & charCodeMask; 9088 inev.code = er.message & charCodeMask;
9015 inev.kind = ASCII_KEYSTROKE_EVENT; 9089 inev.kind = ASCII_KEYSTROKE_EVENT;
9016 } 9090 }
9017 } 9091 }
9018 9092
9019 /* If variable mac-convert-keyboard-input-to-latin-1 is
9020 non-nil, convert non-ASCII characters typed at the Mac
9021 keyboard (presumed to be in the Mac Roman encoding) to
9022 iso-latin-1 encoding before they are passed to Emacs.
9023 This enables the Mac keyboard to be used to enter
9024 non-ASCII iso-latin-1 characters directly. */
9025 if (mac_keyboard_text_encoding != kTextEncodingMacRoman
9026 && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128)
9027 {
9028 static TECObjectRef converter = NULL;
9029 OSStatus the_err = noErr;
9030 OSStatus convert_status = noErr;
9031
9032 if (converter == NULL)
9033 {
9034 the_err = TECCreateConverter (&converter,
9035 kTextEncodingMacRoman,
9036 mac_keyboard_text_encoding);
9037 current_mac_keyboard_text_encoding
9038 = mac_keyboard_text_encoding;
9039 }
9040 else if (mac_keyboard_text_encoding
9041 != current_mac_keyboard_text_encoding)
9042 {
9043 /* Free the converter for the current encoding
9044 before creating a new one. */
9045 TECDisposeConverter (converter);
9046 the_err = TECCreateConverter (&converter,
9047 kTextEncodingMacRoman,
9048 mac_keyboard_text_encoding);
9049 current_mac_keyboard_text_encoding
9050 = mac_keyboard_text_encoding;
9051 }
9052
9053 if (the_err == noErr)
9054 {
9055 unsigned char ch = inev.code;
9056 ByteCount actual_input_length, actual_output_length;
9057 unsigned char outbuf[32];
9058
9059 convert_status = TECConvertText (converter, &ch, 1,
9060 &actual_input_length,
9061 outbuf, 1,
9062 &actual_output_length);
9063 if (convert_status == noErr
9064 && actual_input_length == 1
9065 && actual_output_length == 1)
9066 inev.code = *outbuf;
9067
9068 /* Reset internal states of the converter object.
9069 If it fails, create another one. */
9070 convert_status = TECFlushText (converter, outbuf,
9071 sizeof (outbuf),
9072 &actual_output_length);
9073 if (convert_status != noErr)
9074 {
9075 TECDisposeConverter (converter);
9076 TECCreateConverter (&converter,
9077 kTextEncodingMacRoman,
9078 mac_keyboard_text_encoding);
9079 }
9080 }
9081 }
9082
9083#if USE_CARBON_EVENTS 9093#if USE_CARBON_EVENTS
9084 inev.modifiers = mac_event_to_emacs_modifiers (eventRef); 9094 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
9085#else 9095#else
9086 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); 9096 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
9087#endif 9097#endif
9088 XSETFRAME (inev.frame_or_window, 9098 XSETFRAME (inev.frame_or_window, mac_focus_frame (dpyinfo));
9089 mac_window_to_frame (front_emacs_window ()));
9090 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */ 9099 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
9091 break; 9100 break;
9092 9101
@@ -9099,22 +9108,10 @@ XTread_socket (sd, expected, hold_quit)
9099 constuct_drag_n_drop in w32term.c. */ 9108 constuct_drag_n_drop in w32term.c. */
9100 if (!NILP (drag_and_drop_file_list)) 9109 if (!NILP (drag_and_drop_file_list))
9101 { 9110 {
9102 struct frame *f = NULL; 9111 struct frame *f = mac_focus_frame (dpyinfo);
9103 WindowPtr wp; 9112 WindowPtr wp;
9104 Lisp_Object frame; 9113 Lisp_Object frame;
9105 9114
9106 wp = front_emacs_window ();
9107
9108 if (!wp)
9109 {
9110 struct frame *f = XFRAME (XCAR (Vframe_list));
9111 CollapseWindow (FRAME_MAC_WINDOW (f), false);
9112 wp = front_emacs_window ();
9113 }
9114
9115 if (wp)
9116 f = mac_window_to_frame (wp);
9117
9118 inev.kind = DRAG_N_DROP_EVENT; 9115 inev.kind = DRAG_N_DROP_EVENT;
9119 inev.code = 0; 9116 inev.code = 0;
9120 inev.timestamp = er.when * (1000 / 60); 9117 inev.timestamp = er.when * (1000 / 60);
@@ -9131,10 +9128,12 @@ XTread_socket (sd, expected, hold_quit)
9131 XSETFRAME (frame, f); 9128 XSETFRAME (frame, f);
9132 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list); 9129 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
9133 9130
9131#if 0
9134 /* Regardless of whether Emacs was suspended or in the 9132 /* Regardless of whether Emacs was suspended or in the
9135 foreground, ask it to redraw its entire screen. 9133 foreground, ask it to redraw its entire screen.
9136 Otherwise parts of the screen can be left in an 9134 Otherwise parts of the screen can be left in an
9137 inconsistent state. */ 9135 inconsistent state. */
9136 wp = FRAME_MAC_WINDOW (f);
9138 if (wp) 9137 if (wp)
9139#if TARGET_API_MAC_CARBON 9138#if TARGET_API_MAC_CARBON
9140 { 9139 {
@@ -9146,6 +9145,7 @@ XTread_socket (sd, expected, hold_quit)
9146#else /* not TARGET_API_MAC_CARBON */ 9145#else /* not TARGET_API_MAC_CARBON */
9147 InvalRect (&(wp->portRect)); 9146 InvalRect (&(wp->portRect));
9148#endif /* not TARGET_API_MAC_CARBON */ 9147#endif /* not TARGET_API_MAC_CARBON */
9148#endif
9149 } 9149 }
9150 default: 9150 default:
9151 break; 9151 break;
@@ -9625,7 +9625,7 @@ mac_check_for_quit_char ()
9625 e.arg = Qnil; 9625 e.arg = Qnil;
9626 e.modifiers = NULL; 9626 e.modifiers = NULL;
9627 e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60); 9627 e.timestamp = EventTimeToTicks (GetEventTime (event)) * (1000/60);
9628 XSETFRAME (e.frame_or_window, mac_window_to_frame (front_emacs_window ())); 9628 XSETFRAME (e.frame_or_window, mac_focus_frame (&one_mac_display_info));
9629 /* Remove event from queue to prevent looping. */ 9629 /* Remove event from queue to prevent looping. */
9630 RemoveEventFromQueue (GetMainEventQueue (), event); 9630 RemoveEventFromQueue (GetMainEventQueue (), event);
9631 ReleaseEvent (event); 9631 ReleaseEvent (event);
@@ -9819,10 +9819,6 @@ syms_of_macterm ()
9819 Qeuc_kr = intern ("euc-kr"); 9819 Qeuc_kr = intern ("euc-kr");
9820 staticpro (&Qeuc_kr); 9820 staticpro (&Qeuc_kr);
9821 9821
9822 DEFVAR_BOOL ("x-autoselect-window", &x_autoselect_window_p,
9823 doc: /* *Non-nil means autoselect window with mouse pointer. */);
9824 x_autoselect_window_p = 0;
9825
9826 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, 9822 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
9827 doc: /* If not nil, Emacs uses toolkit scroll bars. */); 9823 doc: /* If not nil, Emacs uses toolkit scroll bars. */);
9828 Vx_toolkit_scroll_bars = Qt; 9824 Vx_toolkit_scroll_bars = Qt;
@@ -9882,10 +9878,6 @@ Toolbox for processing before Emacs sees it. */);
9882Toolbox for processing before Emacs sees it. */); 9878Toolbox for processing before Emacs sees it. */);
9883 Vmac_pass_control_to_system = Qt; 9879 Vmac_pass_control_to_system = Qt;
9884 9880
9885 DEFVAR_LISP ("mac-pass-control-to-system", &Vmac_pass_control_to_system,
9886 doc: /* If non-nil, the Mac \"Control\" key is passed on to the Mac
9887Toolbox for processing before Emacs sees it. */);
9888 Vmac_pass_control_to_system = Qt;
9889#endif 9881#endif
9890 9882
9891 DEFVAR_LISP ("mac-allow-anti-aliasing", &Vmac_use_core_graphics, 9883 DEFVAR_LISP ("mac-allow-anti-aliasing", &Vmac_use_core_graphics,
@@ -9893,21 +9885,6 @@ Toolbox for processing before Emacs sees it. */);
9893The text will be rendered using Core Graphics text rendering which 9885The text will be rendered using Core Graphics text rendering which
9894may anti-alias the text. */); 9886may anti-alias the text. */);
9895 Vmac_use_core_graphics = Qnil; 9887 Vmac_use_core_graphics = Qnil;
9896
9897 DEFVAR_INT ("mac-keyboard-text-encoding", &mac_keyboard_text_encoding,
9898 doc: /* One of the Text Encoding Base constant values defined in the
9899Basic Text Constants section of Inside Macintosh - Text Encoding
9900Conversion Manager. Its value determines the encoding characters
9901typed at the Mac keyboard (presumed to be in the MacRoman encoding)
9902will convert into. E.g., if it is set to kTextEncodingMacRoman (0),
9903its default value, no conversion takes place. If it is set to
9904kTextEncodingISOLatin1 (0x201) or kTextEncodingISOLatin2 (0x202),
9905characters typed on Mac keyboard are first converted into the
9906ISO Latin-1 or ISO Latin-2 encoding, respectively before being
9907passed to Emacs. Together with Emacs's set-keyboard-coding-system
9908command, this enables the Mac keyboard to be used to enter non-ASCII
9909characters directly. */);
9910 mac_keyboard_text_encoding = kTextEncodingMacRoman;
9911} 9888}
9912 9889
9913/* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b 9890/* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b
diff --git a/src/macterm.h b/src/macterm.h
index 3ce3e08947a..705e5d7ac3b 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -195,14 +195,14 @@ struct mac_display_info
195 int bitmaps_last; 195 int bitmaps_last;
196 196
197 /* The frame (if any) which has the window that has keyboard focus. 197 /* The frame (if any) which has the window that has keyboard focus.
198 Zero if none. This is examined by Ffocus_frame in w32fns.c. Note 198 Zero if none. This is examined by Ffocus_frame in macfns.c. Note
199 that a mere EnterNotify event can set this; if you need to know the 199 that a mere EnterNotify event can set this; if you need to know the
200 last frame specified in a FocusIn or FocusOut event, use 200 last frame specified in a FocusIn or FocusOut event, use
201 w32_focus_event_frame. */ 201 x_focus_event_frame. */
202 struct frame *x_focus_frame; 202 struct frame *x_focus_frame;
203 203
204 /* The last frame mentioned in a FocusIn or FocusOut event. This is 204 /* The last frame mentioned in a FocusIn or FocusOut event. This is
205 separate from w32_focus_frame, because whether or not LeaveNotify 205 separate from x_focus_frame, because whether or not LeaveNotify
206 events cause us to lose focus depends on whether or not we have 206 events cause us to lose focus depends on whether or not we have
207 received a FocusIn event for it. */ 207 received a FocusIn event for it. */
208 struct frame *x_focus_event_frame; 208 struct frame *x_focus_event_frame;
@@ -210,7 +210,7 @@ struct mac_display_info
210 /* The frame which currently has the visual highlight, and should get 210 /* The frame which currently has the visual highlight, and should get
211 keyboard input (other sorts of input have the frame encoded in the 211 keyboard input (other sorts of input have the frame encoded in the
212 event). It points to the focus frame's selected window's 212 event). It points to the focus frame's selected window's
213 frame. It differs from w32_focus_frame when we're using a global 213 frame. It differs from x_focus_frame when we're using a global
214 minibuffer. */ 214 minibuffer. */
215 struct frame *x_highlight_frame; 215 struct frame *x_highlight_frame;
216 216
@@ -418,7 +418,7 @@ typedef struct mac_output mac_output;
418 418
419#define FRAME_SIZE_HINTS(f) ((f)->output_data.mac->size_hints) 419#define FRAME_SIZE_HINTS(f) ((f)->output_data.mac->size_hints)
420 420
421/* This gives the w32_display_info structure for the display F is on. */ 421/* This gives the mac_display_info structure for the display F is on. */
422#define FRAME_MAC_DISPLAY_INFO(f) (&one_mac_display_info) 422#define FRAME_MAC_DISPLAY_INFO(f) (&one_mac_display_info)
423#define FRAME_X_DISPLAY_INFO(f) (&one_mac_display_info) 423#define FRAME_X_DISPLAY_INFO(f) (&one_mac_display_info)
424 424
@@ -624,6 +624,7 @@ extern OSErr fsspec_to_posix_pathname P_ ((const FSSpec *, char *, int));
624extern void mac_clear_font_name_table P_ ((void)); 624extern void mac_clear_font_name_table P_ ((void));
625#if TARGET_API_MAC_CARBON 625#if TARGET_API_MAC_CARBON
626extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *)); 626extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *));
627extern CFStringRef cfstring_create_with_string P_ ((Lisp_Object));
627extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef)); 628extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef));
628extern Lisp_Object cfstring_to_lisp P_ ((CFStringRef)); 629extern Lisp_Object cfstring_to_lisp P_ ((CFStringRef));
629extern Lisp_Object cfnumber_to_lisp P_ ((CFNumberRef)); 630extern Lisp_Object cfnumber_to_lisp P_ ((CFNumberRef));
diff --git a/src/term.c b/src/term.c
index 274e453a9d8..bc30e3fb0d8 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1289,7 +1289,26 @@ static struct fkey_table keys[] =
1289 {"k6", "f6"}, 1289 {"k6", "f6"},
1290 {"k7", "f7"}, 1290 {"k7", "f7"},
1291 {"k8", "f8"}, 1291 {"k8", "f8"},
1292 {"k9", "f9"} 1292 {"k9", "f9"},
1293
1294 {"&0", "S-cancel"}, /*shifted cancel key*/
1295 {"&9", "S-begin"}, /*shifted begin key*/
1296 {"*0", "S-find"}, /*shifted find key*/
1297 {"*1", "S-execute"}, /*shifted execute? actually shifted command key*/
1298 {"*4", "S-delete"}, /*shifted delete-character key*/
1299 {"*7", "S-end"}, /*shifted end key*/
1300 {"*8", "S-clearline"}, /*shifted clear-to end-of-line key*/
1301 {"#1", "S-help"}, /*shifted help key*/
1302 {"#2", "S-home"}, /*shifted home key*/
1303 {"#3", "S-insert"}, /*shifted insert-character key*/
1304 {"#4", "S-left"}, /*shifted left-arrow key*/
1305 {"%d", "S-menu"}, /*shifted menu? actually shifted options key*/
1306 {"%c", "S-next"}, /*shifted next key*/
1307 {"%e", "S-prior"}, /*shifted previous key*/
1308 {"%f", "S-print"}, /*shifted print key*/
1309 {"%g", "S-redo"}, /*shifted redo key*/
1310 {"%i", "S-right"}, /*shifted right-arrow key*/
1311 {"!3", "S-undo"} /*shifted undo key*/
1293 }; 1312 };
1294 1313
1295static char **term_get_fkeys_arg; 1314static char **term_get_fkeys_arg;
diff --git a/src/termhooks.h b/src/termhooks.h
index 9aedede55bf..d424ad75e4a 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -103,10 +103,11 @@ enum event_kind
103 the wheel event occurred in. 103 the wheel event occurred in.
104 .timestamp gives a timestamp (in 104 .timestamp gives a timestamp (in
105 milliseconds) for the event. */ 105 milliseconds) for the event. */
106#ifdef WINDOWSNT 106#if defined (WINDOWSNT) || defined (MAC_OS)
107 LANGUAGE_CHANGE_EVENT, /* A LANGUAGE_CHANGE_EVENT is generated 107 LANGUAGE_CHANGE_EVENT, /* A LANGUAGE_CHANGE_EVENT is
108 on WINDOWSNT when the keyboard layout 108 generated on WINDOWSNT or Mac OS
109 or input language is changed by the 109 when the keyboard layout or input
110 language is changed by the
110 user. */ 111 user. */
111#endif 112#endif
112 SCROLL_BAR_CLICK_EVENT, /* .code gives the number of the mouse button 113 SCROLL_BAR_CLICK_EVENT, /* .code gives the number of the mouse button
diff --git a/src/window.c b/src/window.c
index e16416d6fb2..a1b3c879bb5 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,7 +1,7 @@
1/* Window creation, deletion and examination for GNU Emacs. 1/* Window creation, deletion and examination for GNU Emacs.
2 Does not include redisplay. 2 Does not include redisplay.
3 Copyright (C) 1985,86,87, 1993,94,95,96,97,98, 2000,01,02,03,04 3 Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1996, 1997, 1998, 2000,
4 Free Software Foundation, Inc. 4 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -5596,7 +5596,20 @@ the return value is nil. Otherwise the value is t. */)
5596 if (XBUFFER (new_current_buffer) == current_buffer) 5596 if (XBUFFER (new_current_buffer) == current_buffer)
5597 old_point = PT; 5597 old_point = PT;
5598 else 5598 else
5599 old_point = BUF_PT (XBUFFER (new_current_buffer)); 5599 /* BUF_PT (XBUFFER (new_current_buffer)) gives us the position of
5600 point in new_current_buffer as of the last time this buffer was
5601 used. This can be non-deterministic since it can be changed by
5602 things like jit-lock by mere temporary selection of some random
5603 window that happens to show this buffer.
5604 So if possible we want this arbitrary choice of "which point" to
5605 be the one from the to-be-selected-window so as to prevent this
5606 window's cursor from being copied from another window. */
5607 if (EQ (XWINDOW (data->current_window)->buffer, new_current_buffer)
5608 /* If current_window = selected_window, its point is in BUF_PT. */
5609 && !EQ (selected_window, data->current_window))
5610 old_point = XMARKER (XWINDOW (data->current_window)->pointm)->charpos;
5611 else
5612 old_point = BUF_PT (XBUFFER (new_current_buffer));
5600 } 5613 }
5601 5614
5602 frame = XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame; 5615 frame = XWINDOW (SAVED_WINDOW_N (saved_windows, 0)->window)->frame;
diff --git a/src/xdisp.c b/src/xdisp.c
index c545b6b2bc2..c832f1fa5e0 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -567,12 +567,21 @@ Lisp_Object Vmessage_log_max;
567 567
568static Lisp_Object Vmessages_buffer_name; 568static Lisp_Object Vmessages_buffer_name;
569 569
570/* Current, index 0, and last displayed echo area message. Either 570/* Index 0 is the buffer that holds the current (desired) echo area message,
571 buffers from echo_buffers, or nil to indicate no message. */ 571 or nil if none is desired right now.
572
573 Index 1 is the buffer that holds the previously displayed echo area message,
574 or nil to indicate no message. This is normally what's on the screen now.
575
576 These two can point to the same buffer. That happens when the last
577 message output by the user (or made by echoing) has been displayed. */
572 578
573Lisp_Object echo_area_buffer[2]; 579Lisp_Object echo_area_buffer[2];
574 580
575/* The buffers referenced from echo_area_buffer. */ 581/* Permanent pointers to the two buffers that are used for echo area
582 purposes. Once the two buffers are made, and their pointers are
583 placed here, these two slots remain unchanged unless those buffers
584 need to be created afresh. */
576 585
577static Lisp_Object echo_buffer[2]; 586static Lisp_Object echo_buffer[2];
578 587
@@ -7213,10 +7222,6 @@ ensure_echo_area_buffers ()
7213 WHICH > 0 means use echo_area_buffer[1]. If that is nil, choose a 7222 WHICH > 0 means use echo_area_buffer[1]. If that is nil, choose a
7214 suitable buffer from echo_buffer[] and clear it. 7223 suitable buffer from echo_buffer[] and clear it.
7215 7224
7216 If WHICH < 0, set echo_area_buffer[1] to echo_area_buffer[0], so
7217 that the current message becomes the last displayed one, make
7218 choose a suitable buffer for echo_area_buffer[0], and clear it.
7219
7220 Value is what FN returns. */ 7225 Value is what FN returns. */
7221 7226
7222static int 7227static int
@@ -7241,17 +7246,6 @@ with_echo_area_buffer (w, which, fn, a1, a2, a3, a4)
7241 this_one = 0, the_other = 1; 7246 this_one = 0, the_other = 1;
7242 else if (which > 0) 7247 else if (which > 0)
7243 this_one = 1, the_other = 0; 7248 this_one = 1, the_other = 0;
7244 else
7245 {
7246 this_one = 0, the_other = 1;
7247 clear_buffer_p = 1;
7248
7249 /* We need a fresh one in case the current echo buffer equals
7250 the one containing the last displayed echo area message. */
7251 if (!NILP (echo_area_buffer[this_one])
7252 && EQ (echo_area_buffer[this_one], echo_area_buffer[the_other]))
7253 echo_area_buffer[this_one] = Qnil;
7254 }
7255 7249
7256 /* Choose a suitable buffer from echo_buffer[] is we don't 7250 /* Choose a suitable buffer from echo_buffer[] is we don't
7257 have one. */ 7251 have one. */
@@ -7871,7 +7865,7 @@ set_message (s, string, nbytes, multibyte_p)
7871 = ((s && multibyte_p) 7865 = ((s && multibyte_p)
7872 || (STRINGP (string) && STRING_MULTIBYTE (string))); 7866 || (STRINGP (string) && STRING_MULTIBYTE (string)));
7873 7867
7874 with_echo_area_buffer (0, -1, set_message_1, 7868 with_echo_area_buffer (0, 0, set_message_1,
7875 (EMACS_INT) s, string, nbytes, multibyte_p); 7869 (EMACS_INT) s, string, nbytes, multibyte_p);
7876 message_buf_print = 0; 7870 message_buf_print = 0;
7877 help_echo_showing_p = 0; 7871 help_echo_showing_p = 0;
@@ -7903,6 +7897,7 @@ set_message_1 (a1, a2, nbytes, multibyte_p)
7903 7897
7904 /* Insert new message at BEG. */ 7898 /* Insert new message at BEG. */
7905 TEMP_SET_PT_BOTH (BEG, BEG_BYTE); 7899 TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
7900 Ferase_buffer ();
7906 7901
7907 if (STRINGP (string)) 7902 if (STRINGP (string))
7908 { 7903 {
@@ -8118,10 +8113,8 @@ echo_area_display (update_frame_p)
8118 else if (!EQ (mini_window, selected_window)) 8113 else if (!EQ (mini_window, selected_window))
8119 windows_or_buffers_changed++; 8114 windows_or_buffers_changed++;
8120 8115
8121 /* Last displayed message is now the current message. */ 8116 /* The current message is now also the last one displayed. */
8122 echo_area_buffer[1] = echo_area_buffer[0]; 8117 echo_area_buffer[1] = echo_area_buffer[0];
8123 /* Inform read_char that we're not echoing. */
8124 echo_message_buffer = Qnil;
8125 8118
8126 /* Prevent redisplay optimization in redisplay_internal by resetting 8119 /* Prevent redisplay optimization in redisplay_internal by resetting
8127 this_line_start_pos. This is done because the mini-buffer now 8120 this_line_start_pos. This is done because the mini-buffer now