aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2006-05-10 15:04:01 +0000
committerKaroly Lorentey2006-05-10 15:04:01 +0000
commit8dadeb1e1f78c7be07db5ae78aa9eed58d272a4e (patch)
tree6262988e87d6b347a8c90fcc3c5b49f9bb5b36e1 /src
parentf6cf85ac95e469835a2643024f995b471a4c5d52 (diff)
parent9a4d87c8d5f4503d67d5155eae6d543cc31f86d0 (diff)
downloademacs-8dadeb1e1f78c7be07db5ae78aa9eed58d272a4e.tar.gz
emacs-8dadeb1e1f78c7be07db5ae78aa9eed58d272a4e.zip
Merged from emacs@sv.gnu.org
Patches applied: * emacs@sv.gnu.org/emacs--devo--0--patch-266 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-267 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-268 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-269 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-270 Update from CVS * emacs@sv.gnu.org/emacs--devo--0--patch-271 Rename "field-at-point" to "field-at-pos" * emacs@sv.gnu.org/emacs--devo--0--patch-272 (comint-insert-input): Remove redundant calls to setq and goto-char git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-556
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit155
-rw-r--r--src/ChangeLog152
-rw-r--r--src/callproc.c2
-rw-r--r--src/coding.c19
-rw-r--r--src/coding.h3
-rw-r--r--src/fileio.c2
-rw-r--r--src/image.c21
-rw-r--r--src/keyboard.c3
-rw-r--r--src/keymap.c16
-rw-r--r--src/mac.c125
-rw-r--r--src/macfns.c67
-rw-r--r--src/macgui.h7
-rw-r--r--src/macmenu.c2
-rw-r--r--src/macselect.c216
-rw-r--r--src/macterm.c653
-rw-r--r--src/macterm.h8
-rw-r--r--src/minibuf.c2
-rw-r--r--src/process.c12
-rw-r--r--src/termhooks.h6
-rw-r--r--src/xdisp.c18
20 files changed, 1115 insertions, 374 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index ea9bf3f6092..54d68dc123d 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -211,6 +211,7 @@ define pitx
211 printf "vpos=%d hpos=%d", $it->vpos, $it->hpos, 211 printf "vpos=%d hpos=%d", $it->vpos, $it->hpos,
212 printf " y=%d lvy=%d", $it->current_y, $it->last_visible_y 212 printf " y=%d lvy=%d", $it->current_y, $it->last_visible_y
213 printf " x=%d vx=%d-%d", $it->current_x, $it->first_visible_x, $it->last_visible_x 213 printf " x=%d vx=%d-%d", $it->current_x, $it->first_visible_x, $it->last_visible_x
214 printf " w=%d", $it->pixel_width
214 printf " a+d=%d+%d=%d", $it->ascent, $it->descent, $it->ascent+$it->descent 215 printf " a+d=%d+%d=%d", $it->ascent, $it->descent, $it->ascent+$it->descent
215 printf " max=%d+%d=%d", $it->max_ascent, $it->max_descent, $it->max_ascent+$it->max_descent 216 printf " max=%d+%d=%d", $it->max_ascent, $it->max_descent, $it->max_ascent+$it->max_descent
216 printf "\n" 217 printf "\n"
@@ -544,6 +545,10 @@ end
544define xframe 545define xframe
545 xgetptr $ 546 xgetptr $
546 print (struct frame *) $ptr 547 print (struct frame *) $ptr
548 xgetptr $->name
549 set $ptr = (struct Lisp_String *) $ptr
550 xprintstr $ptr
551 echo \n
547end 552end
548document xframe 553document xframe
549Print $ as a frame pointer, assuming it is an Emacs Lisp frame value. 554Print $ as a frame pointer, assuming it is an Emacs Lisp frame value.
@@ -676,6 +681,31 @@ document xcdr
676Print the cdr of $, assuming it is an Emacs Lisp pair. 681Print the cdr of $, assuming it is an Emacs Lisp pair.
677end 682end
678 683
684define xlist
685 xgetptr $
686 set $cons = (struct Lisp_Cons *) $ptr
687 xgetptr Qnil
688 set $nil = $ptr
689 set $i = 0
690 while $cons != $nil && $i < 10
691 p/x $cons->car
692 xpr
693 xgetptr $cons->u.cdr
694 set $cons = (struct Lisp_Cons *) $ptr
695 set $i = $i + 1
696 printf "---\n"
697 end
698 if $cons == $nil
699 printf "nil\n"
700 else
701 printf "...\n"
702 p $ptr
703 end
704end
705document xlist
706Print $ assuming it is a list.
707end
708
679define xfloat 709define xfloat
680 xgetptr $ 710 xgetptr $
681 print ((struct Lisp_Float *) $ptr)->u.data 711 print ((struct Lisp_Float *) $ptr)->u.data
@@ -694,6 +724,108 @@ document xscrollbar
694Print $ as a scrollbar pointer. 724Print $ as a scrollbar pointer.
695end 725end
696 726
727define xpr
728 xtype
729 if $type == Lisp_Int
730 xint
731 end
732 if $type == Lisp_Symbol
733 xsymbol
734 end
735 if $type == Lisp_String
736 xstring
737 end
738 if $type == Lisp_Cons
739 xcons
740 end
741 if $type == Lisp_Float
742 xfloat
743 end
744 if $type == Lisp_Misc
745 set $misc = (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type)
746 if $misc == Lisp_Misc_Free
747 xmiscfree
748 end
749 if $misc == Lisp_Misc_Boolfwd
750 xboolfwd
751 end
752 if $misc == Lisp_Misc_Marker
753 xmarker
754 end
755 if $misc == Lisp_Misc_Intfwd
756 xintfwd
757 end
758 if $misc == Lisp_Misc_Boolfwd
759 xboolfwd
760 end
761 if $misc == Lisp_Misc_Objfwd
762 xobjfwd
763 end
764 if $misc == Lisp_Misc_Buffer_Objfwd
765 xbufobjfwd
766 end
767 if $misc == Lisp_Misc_Buffer_Local_Value
768 xbuflocal
769 end
770# if $misc == Lisp_Misc_Some_Buffer_Local_Value
771# xvalue
772# end
773 if $misc == Lisp_Misc_Overlay
774 xoverlay
775 end
776 if $misc == Lisp_Misc_Kboard_Objfwd
777 xkbobjfwd
778 end
779# if $misc == Lisp_Misc_Save_Value
780# xsavevalue
781# end
782 end
783 if $type == Lisp_Vectorlike
784 set $size = ((struct Lisp_Vector *) $ptr)->size
785 if ($size & PVEC_FLAG)
786 set $vec = (enum pvec_type) ($size & PVEC_TYPE_MASK)
787 if $vec == PVEC_NORMAL_VECTOR
788 xvector
789 end
790 if $vec == PVEC_PROCESS
791 xprocess
792 end
793 if $vec == PVEC_FRAME
794 xframe
795 end
796 if $vec == PVEC_COMPILED
797 xcompiled
798 end
799 if $vec == PVEC_WINDOW
800 xwindow
801 end
802 if $vec == PVEC_WINDOW_CONFIGURATION
803 xwinconfig
804 end
805 if $vec == PVEC_SUBR
806 xsubr
807 end
808 if $vec == PVEC_CHAR_TABLE
809 xchartable
810 end
811 if $vec == PVEC_BOOL_VECTOR
812 xboolvector
813 end
814 if $vec == PVEC_BUFFER
815 xbuffer
816 end
817 if $vec == PVEC_HASH_TABLE
818 xhashtable
819 end
820 else
821 xvector
822 end
823 end
824end
825document xpr
826Print $ as a lisp object of any type.
827end
828
697define xprintstr 829define xprintstr
698 set $data = $arg0->data 830 set $data = $arg0->data
699 output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte) 831 output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte)
@@ -716,7 +848,7 @@ define xbacktrace
716 xgettype (*$bt->function) 848 xgettype (*$bt->function)
717 if $type == Lisp_Symbol 849 if $type == Lisp_Symbol
718 xprintsym (*$bt->function) 850 xprintsym (*$bt->function)
719 echo \n 851 printf " (0x%x)\n", *$bt->args
720 else 852 else
721 printf "0x%x ", *$bt->function 853 printf "0x%x ", *$bt->function
722 if $type == Lisp_Vectorlike 854 if $type == Lisp_Vectorlike
@@ -737,6 +869,27 @@ document xbacktrace
737 an error was signaled. 869 an error was signaled.
738end 870end
739 871
872define which
873 set debug_print (which_symbols ($arg0))
874end
875document which
876 Print symbols which references a given lisp object,
877 either as its symbol value or symbol function.
878end
879
880define xbytecode
881 set $bt = byte_stack_list
882 while $bt
883 xgettype ($bt->byte_string)
884 printf "0x%x => ", $bt->byte_string
885 which $bt->byte_string
886 set $bt = $bt->next
887 end
888end
889document xbytecode
890 Print a backtrace of the byte code stack.
891end
892
740# Show Lisp backtrace after normal backtrace. 893# Show Lisp backtrace after normal backtrace.
741define hookpost-backtrace 894define hookpost-backtrace
742 set $bt = backtrace_list 895 set $bt = backtrace_list
diff --git a/src/ChangeLog b/src/ChangeLog
index c0e8f035a17..89147db983f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,155 @@
12006-05-09 Kenichi Handa <handa@m17n.org>
2
3 * keymap.c (push_key_description): Handle invalid character key.
4
52006-05-08 Kenichi Handa <handa@m17n.org>
6
7 * callproc.c (Fcall_process): Use system_eol_type for encoding
8 arguments if eol_type is not yet decided.
9
10 * coding.h (system_eol_type): Extern it.
11
12 * coding.c (setup_coding_system): For invalid coding-system, set
13 coding->eol_type to CODING_EOL_UNDECIDED.
14 (encode_coding): Cancel previous change.
15 (shrink_encoding_region): Likewise.
16 (code_convert_region1): Likewise.
17 (code_convert_string1): Likewise.
18 (code_convert_string_norecord): Likewise.
19
20 * fileio.c (choose_write_coding_system): Use system_eol_type for
21 encoding if eol_type is not yet decided.
22
23 * process.c (setup_process_coding_systems): Use system_eol_type
24 for encoding if eol_type is not yet decided.
25 (read_process_output): Likewise.
26 (send_process): Likewise.
27
282006-05-07 Juanma Barranquero <lekktu@gmail.com>
29
30 * minibuf.c (syms_of_minibuf) <history-length>: Fix typo in doc.
31
322006-05-07 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
33
34 * mac.c (Fmac_clear_font_name_table): Move defun to macfns.c.
35 (syms_of_mac): Likewise for defsubr.
36
37 * macfns.c (mac_set_font): New function.
38 (mac_frame_parm_handlers, syms_of_macfns): Replace x_set_font with it.
39 (mac_window) [TARGET_API_MAC_CARBON && MAC_OSX]: Specify
40 kWindowToolbarButtonAttribute when creating window.
41 (Fmac_clear_font_name_table): Move from macfns.c.
42 (syms_of_macfns): Likewise for defsubr.
43 [USE_MAC_FONT_PANEL] (Fmac_set_font_panel_visibility): New defun.
44 (syms_of_macfns) [USE_MAC_FONT_PANEL]: Defsubr it.
45
46 * macgui.h (USE_MAC_FONT_PANEL): Define to 1 if USE_ATSUI is set
47 and build is done on Mac OS X 10.2 and later.
48
49 * macselect.c (mac_do_receive_drag): Remove unused variable `index'.
50 (mac_store_services_event): Change return type in extern.
51
52 * macterm.c (XLoadQueryFont) [USE_ATSUI]: Set FMFontFamily value
53 to font->mac_fontnum.
54 [USE_MAC_FONT_PANEL] (mac_set_font_info_for_selection): New function.
55 (x_new_focus_frame) [USE_MAC_FONT_PANEL]: Use it.
56 (QCfamily, QCweight, QCslant, Qnormal, Qbold, Qitalic): Add extern.
57 (QWindow) [MAC_OSX]: Likewise.
58 (Qfont) [USE_MAC_FONT_PANEL]: Likewise.
59 (Vmac_atsu_font_table) [USE_ATSUI]: New variable.
60 (syms_of_macterm) [USE_ATSUI]: Defvar it.
61 (Qtoolbar_switch_mode) [MAC_OSX]: New variable.
62 (Qpanel_closed, Qselection) [USE_MAC_FONT_PANEL]: Likewise.
63 (syms_of_macterm): Intern and staticpro them.
64 (init_font_name_table) [USE_ATSUI]: Set data to Vmac_atsu_font_table.
65 [TARGET_API_MAC_CARBON] (mac_store_event_ref_as_apple_event): New
66 function.
67 [USE_CARBON_EVENTS] (mac_handle_command_event): Use it.
68 [MAC_OSX] (mac_store_services_event): Likewise.
69 [USE_CARBON_EVENTS] (mac_handle_window_event) [MAC_OSX]: Handle
70 kEventWindowToolbarSwitchMode event.
71 (install_window_handler) [USE_CARBON_EVENTS && MAC_OSX]: Register it.
72 [MAC_OSX] (mac_store_services_event): Change return type to OSStatus.
73 [USE_MAC_FONT_PANEL] (mac_handle_font_event): New function.
74 (install_window_handler) [USE_MAC_FONT_PANEL]: Install it.
75 (XTread_socket): Select window on mouse click if x_focus_frame is NULL.
76
77 * macterm.h (mac_set_font_info_for_selection): Add extern.
78
792006-05-06 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
80
81 * image.c (Qduration) [MAC_OS]: New variable.
82 (syms_of_image) [MAC_OS]: Intern and staticpro it.
83 [MAC_OS] (gif_load): Save image extension data in img->data.lisp_val.
84 [MAC_OSX] (image_load_quartz2d): Use cfstring_create_with_utf8_cstring
85 instead of cfstring_create_with_string.
86
872006-05-06 Kim F. Storm <storm@cua.dk>
88
89 * .gdbinit (xframe): Print frame name.
90 (xlist): New command to print a list (max 10 elements).
91 (xpr): Print lisp object of any type.
92 (pitx): Print it->pixel_width.
93
942006-05-05 Kenichi Handa <handa@m17n.org>
95
96 * xdisp.c (handle_composition_prop): Fix for the case of empty
97 composition component.
98
992006-05-05 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
100
101 * keyboard.c (make_lispy_event) [MAC_OS]: Get Apple event info
102 from event->arg.
103
104 * termhooks.h (enum event_kind) [MAC_OS]: Update comment for
105 MAC_APPLE_EVENT.
106
107 * macterm.h (mac_make_lispy_event_code): Remove extern.
108 (mac_post_mouse_moved_event): Add extern.
109 (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
110 `const AEDesc *' in externs.
111 (create_apple_event_from_drag_ref) [TARGET_API_MAC_CARBON]: New extern.
112
113 * mac.c (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to
114 `const AEDesc *'.
115 [TARGET_API_MAC_CARBON] (create_apple_event): New function.
116 [TARGET_API_MAC_CARBON] (create_apple_event_from_event_ref): Use it.
117 Use xrealloc instead of repeated xmalloc/xfree.
118 [TARGET_API_MAC_CARBON] (create_apple_event_from_drag_ref): New
119 function.
120
121 * macmenu.c (restore_menu_items, cleanup_popup_menu): Return a value.
122
123 * macselect.c: Update copyright year.
124 (mac_store_apple_event): Change return type to void in extern.
125 (mac_handle_apple_event): Don't get return value from
126 mac_store_apple_event.
127 [TARGET_API_MAC_CARBON] (Vmac_dnd_known_types): New variable.
128 (syms_of_macselect) [TARGET_API_MAC_CARBON]: Defvar it.
129 [TARGET_API_MAC_CARBON] (mac_do_track_drag): Move function from
130 macterm.c. Use Vmac_dnd_known_types as acceptable flavors.
131 [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Likewise. New
132 implementation using create_apple_event_from_drag_ref.
133 [TARGET_API_MAC_CARBON] (mac_do_track_dragUPP)
134 (mac_do_receive_dragUPP): Move variables from macterm.c.
135 (install_drag_handler, remove_drag_handler): New functions.
136
137 * macterm.c (XTread_socket) [TARGET_API_MAC_CARBON]: Try window
138 path select also for proxy icon click.
139 [TARGET_API_MAC_CARBON] (mac_post_mouse_moved_event): New function.
140 [USE_TOOLKIT_SCROLL_BARS] (scroll_bar_timer_callback): Use it.
141 (xlfdpat_create): Remove unused label `error' and trailing sentences.
142 (mac_do_track_drag, mac_do_receive_drag): Move functions to macselect.c.
143 (mac_do_track_dragUPP, mac_do_receive_dragUPP): Move variables to
144 macselect.c.
145 (install_drag_handler, remove_drag_handler): Add extern.
146 (mac_store_apple_event): Change return type to void. All uses changed.
147 Create Lisp object from Apple event and store it into input event.
148 (mac_make_lispy_event_code): Remove function.
149 [TARGET_API_MAC_CARBON] (mac_store_drag_event): New function.
150 (install_window_handler): Call install_drag_handler.
151 (remove_window_handler): Call remove_drag_handler.
152
12006-05-03 Richard Stallman <rms@gnu.org> 1532006-05-03 Richard Stallman <rms@gnu.org>
2 154
3 * sound.c (Fplay_sound_internal): Dynamically allocate 155 * sound.c (Fplay_sound_internal): Dynamically allocate
diff --git a/src/callproc.c b/src/callproc.c
index a6841317e63..25c79bf926c 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -302,6 +302,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
302 val = Qnil; 302 val = Qnil;
303 } 303 }
304 setup_coding_system (Fcheck_coding_system (val), &argument_coding); 304 setup_coding_system (Fcheck_coding_system (val), &argument_coding);
305 if (argument_coding.eol_type == CODING_EOL_UNDECIDED)
306 argument_coding.eol_type = system_eol_type;
305 } 307 }
306 } 308 }
307 309
diff --git a/src/coding.c b/src/coding.c
index d261418def5..a83aadfd468 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -386,7 +386,9 @@ Lisp_Object eol_mnemonic_unix, eol_mnemonic_dos, eol_mnemonic_mac;
386Lisp_Object eol_mnemonic_undecided; 386Lisp_Object eol_mnemonic_undecided;
387 387
388/* Format of end-of-line decided by system. This is CODING_EOL_LF on 388/* Format of end-of-line decided by system. This is CODING_EOL_LF on
389 Unix, CODING_EOL_CRLF on DOS/Windows, and CODING_EOL_CR on Mac. */ 389 Unix, CODING_EOL_CRLF on DOS/Windows, and CODING_EOL_CR on Mac.
390 This has an effect only for external encoding (i.e. for output to
391 file and process), not for in-buffer or Lisp string encoding. */
390int system_eol_type; 392int system_eol_type;
391 393
392#ifdef emacs 394#ifdef emacs
@@ -3920,10 +3922,7 @@ setup_coding_system (coding_system, coding)
3920 coding->type = coding_type_no_conversion; 3922 coding->type = coding_type_no_conversion;
3921 coding->category_idx = CODING_CATEGORY_IDX_BINARY; 3923 coding->category_idx = CODING_CATEGORY_IDX_BINARY;
3922 coding->common_flags = 0; 3924 coding->common_flags = 0;
3923 coding->eol_type = NILP (coding_system) ? system_eol_type : CODING_EOL_LF; 3925 coding->eol_type = CODING_EOL_UNDECIDED;
3924 if (coding->eol_type != CODING_EOL_LF)
3925 coding->common_flags
3926 |= CODING_REQUIRE_DECODING_MASK | CODING_REQUIRE_ENCODING_MASK;
3927 coding->pre_write_conversion = coding->post_read_conversion = Qnil; 3926 coding->pre_write_conversion = coding->post_read_conversion = Qnil;
3928 return NILP (coding_system) ? 0 : -1; 3927 return NILP (coding_system) ? 0 : -1;
3929} 3928}
@@ -5000,7 +4999,7 @@ encode_coding (coding, source, destination, src_bytes, dst_bytes)
5000 coding->errors = 0; 4999 coding->errors = 0;
5001 coding->result = CODING_FINISH_NORMAL; 5000 coding->result = CODING_FINISH_NORMAL;
5002 if (coding->eol_type == CODING_EOL_UNDECIDED) 5001 if (coding->eol_type == CODING_EOL_UNDECIDED)
5003 coding->eol_type = system_eol_type; 5002 coding->eol_type = CODING_EOL_LF;
5004 5003
5005 switch (coding->type) 5004 switch (coding->type)
5006 { 5005 {
@@ -5257,8 +5256,6 @@ shrink_encoding_region (beg, end, coding, str)
5257 if (coding->type == coding_type_ccl 5256 if (coding->type == coding_type_ccl
5258 || coding->eol_type == CODING_EOL_CRLF 5257 || coding->eol_type == CODING_EOL_CRLF
5259 || coding->eol_type == CODING_EOL_CR 5258 || coding->eol_type == CODING_EOL_CR
5260 || (coding->eol_type == CODING_EOL_UNDECIDED
5261 && system_eol_type != CODING_EOL_LF)
5262 || (coding->cmp_data && coding->cmp_data->used > 0)) 5259 || (coding->cmp_data && coding->cmp_data->used > 0))
5263 { 5260 {
5264 /* We can't skip any data. */ 5261 /* We can't skip any data. */
@@ -7114,7 +7111,7 @@ code_convert_region1 (start, end, coding_system, encodep)
7114 from = XFASTINT (start); 7111 from = XFASTINT (start);
7115 to = XFASTINT (end); 7112 to = XFASTINT (end);
7116 7113
7117 if (NILP (coding_system) && system_eol_type == CODING_EOL_LF) 7114 if (NILP (coding_system))
7118 return make_number (to - from); 7115 return make_number (to - from);
7119 7116
7120 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) 7117 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
@@ -7169,7 +7166,7 @@ code_convert_string1 (string, coding_system, nocopy, encodep)
7169 CHECK_STRING (string); 7166 CHECK_STRING (string);
7170 CHECK_SYMBOL (coding_system); 7167 CHECK_SYMBOL (coding_system);
7171 7168
7172 if (NILP (coding_system) && system_eol_type == CODING_EOL_LF) 7169 if (NILP (coding_system))
7173 return (NILP (nocopy) ? Fcopy_sequence (string) : string); 7170 return (NILP (nocopy) ? Fcopy_sequence (string) : string);
7174 7171
7175 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) 7172 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
@@ -7228,7 +7225,7 @@ code_convert_string_norecord (string, coding_system, encodep)
7228 CHECK_STRING (string); 7225 CHECK_STRING (string);
7229 CHECK_SYMBOL (coding_system); 7226 CHECK_SYMBOL (coding_system);
7230 7227
7231 if (NILP (coding_system) && system_eol_type == CODING_EOL_LF) 7228 if (NILP (coding_system))
7232 return string; 7229 return string;
7233 7230
7234 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0) 7231 if (setup_coding_system (Fcheck_coding_system (coding_system), &coding) < 0)
diff --git a/src/coding.h b/src/coding.h
index 5d649fbf9ff..cac11d1514c 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -666,6 +666,9 @@ extern Lisp_Object eol_mnemonic_unix, eol_mnemonic_dos, eol_mnemonic_mac;
666/* Mnemonic string to indicate type of end-of-line is not yet decided. */ 666/* Mnemonic string to indicate type of end-of-line is not yet decided. */
667extern Lisp_Object eol_mnemonic_undecided; 667extern Lisp_Object eol_mnemonic_undecided;
668 668
669/* Format of end-of-line decided by system. */
670extern int system_eol_type;
671
669#ifdef emacs 672#ifdef emacs
670extern Lisp_Object Qfile_coding_system; 673extern Lisp_Object Qfile_coding_system;
671extern Lisp_Object Qcall_process, Qcall_process_region; 674extern Lisp_Object Qcall_process, Qcall_process_region;
diff --git a/src/fileio.c b/src/fileio.c
index 2248963102a..7bfcc98541b 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4940,6 +4940,8 @@ choose_write_coding_system (start, end, filename,
4940 setup_coding_system (Fcheck_coding_system (val), coding); 4940 setup_coding_system (Fcheck_coding_system (val), coding);
4941 4941
4942 done_setup_coding: 4942 done_setup_coding:
4943 if (coding->eol_type == CODING_EOL_UNDECIDED)
4944 coding->eol_type = system_eol_type;
4943 if (!STRINGP (start) && !NILP (current_buffer->selective_display)) 4945 if (!STRINGP (start) && !NILP (current_buffer->selective_display))
4944 coding->mode |= CODING_MODE_SELECTIVE_DISPLAY; 4946 coding->mode |= CODING_MODE_SELECTIVE_DISPLAY;
4945} 4947}
diff --git a/src/image.c b/src/image.c
index eae25fdb02e..98e44be9d44 100644
--- a/src/image.c
+++ b/src/image.c
@@ -2630,7 +2630,7 @@ image_load_quartz2d (f, img, png_p)
2630 UNGCPRO; 2630 UNGCPRO;
2631 return 0; 2631 return 0;
2632 } 2632 }
2633 path = cfstring_create_with_string (file); 2633 path = cfstring_create_with_utf8_cstring (SDATA (file));
2634 url = CFURLCreateWithFileSystemPath (NULL, path, 2634 url = CFURLCreateWithFileSystemPath (NULL, path,
2635 kCFURLPOSIXPathStyle, 0); 2635 kCFURLPOSIXPathStyle, 0);
2636 CFRelease (path); 2636 CFRelease (path);
@@ -7901,6 +7901,8 @@ gif_load (f, img)
7901#else /* !HAVE_GIF */ 7901#else /* !HAVE_GIF */
7902 7902
7903#ifdef MAC_OS 7903#ifdef MAC_OS
7904static Lisp_Object Qduration;
7905
7904static int 7906static int
7905gif_load (f, img) 7907gif_load (f, img)
7906 struct frame *f; 7908 struct frame *f;
@@ -7922,7 +7924,8 @@ gif_load (f, img)
7922 RGBColor bg_color; 7924 RGBColor bg_color;
7923 int width, height; 7925 int width, height;
7924 XImagePtr ximg; 7926 XImagePtr ximg;
7925 TimeValue time; 7927 TimeScale time_scale;
7928 TimeValue time, duration;
7926 int ino; 7929 int ino;
7927 CGrafPtr old_port; 7930 CGrafPtr old_port;
7928 GDHandle old_gdh; 7931 GDHandle old_gdh;
@@ -8030,6 +8033,7 @@ gif_load (f, img)
8030 image, img->spec); 8033 image, img->spec);
8031 goto error; 8034 goto error;
8032 } 8035 }
8036 time_scale = GetMediaTimeScale (media);
8033 8037
8034 specified_bg = image_spec_value (img->spec, QCbackground, NULL); 8038 specified_bg = image_spec_value (img->spec, QCbackground, NULL);
8035 if (!STRINGP (specified_bg) || 8039 if (!STRINGP (specified_bg) ||
@@ -8055,7 +8059,7 @@ gif_load (f, img)
8055 SetGWorld (old_port, old_gdh); 8059 SetGWorld (old_port, old_gdh);
8056 SetMovieActive (movie, 1); 8060 SetMovieActive (movie, 1);
8057 SetMovieGWorld (movie, ximg, NULL); 8061 SetMovieGWorld (movie, ximg, NULL);
8058 SampleNumToMediaTime (media, ino + 1, &time, NULL); 8062 SampleNumToMediaTime (media, ino + 1, &time, &duration);
8059 SetMovieTimeValue (movie, time); 8063 SetMovieTimeValue (movie, time);
8060 MoviesTask (movie, 0L); 8064 MoviesTask (movie, 0L);
8061 DisposeTrackMedia (media); 8065 DisposeTrackMedia (media);
@@ -8063,6 +8067,12 @@ gif_load (f, img)
8063 DisposeMovie (movie); 8067 DisposeMovie (movie);
8064 if (dh) 8068 if (dh)
8065 DisposeHandle (dh); 8069 DisposeHandle (dh);
8070
8071 /* Save GIF image extension data for `image-extension-data'.
8072 Format is (count IMAGES duration DURATION). */
8073 img->data.lisp_val = list4 (Qcount, make_number (nsamples), Qduration,
8074 make_float ((double)duration / time_scale));
8075
8066 /* Maybe fill in the background field while we have ximg handy. */ 8076 /* Maybe fill in the background field while we have ximg handy. */
8067 if (NILP (image_spec_value (img->spec, QCbackground, NULL))) 8077 if (NILP (image_spec_value (img->spec, QCbackground, NULL)))
8068 IMAGE_BACKGROUND (img, f, ximg); 8078 IMAGE_BACKGROUND (img, f, ximg);
@@ -8618,6 +8628,11 @@ non-numeric, there is no explicit limit on the size of images. */);
8618 ADD_IMAGE_TYPE(Qgif); 8628 ADD_IMAGE_TYPE(Qgif);
8619#endif 8629#endif
8620 8630
8631#ifdef MAC_OS
8632 Qduration = intern ("duration");
8633 staticpro (&Qduration);
8634#endif
8635
8621#if defined (HAVE_PNG) || defined (MAC_OS) 8636#if defined (HAVE_PNG) || defined (MAC_OS)
8622 Qpng = intern ("png"); 8637 Qpng = intern ("png");
8623 staticpro (&Qpng); 8638 staticpro (&Qpng);
diff --git a/src/keyboard.c b/src/keyboard.c
index 1ad852c819a..5dcd2f8f5ae 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5992,8 +5992,7 @@ make_lispy_event (event)
5992 spec[1] = event->y; 5992 spec[1] = event->y;
5993 return Fcons (Qmac_apple_event, 5993 return Fcons (Qmac_apple_event,
5994 Fcons (Fvector (2, spec), 5994 Fcons (Fvector (2, spec),
5995 Fcons (mac_make_lispy_event_code (event->code), 5995 Fcons (event->arg, Qnil)));
5996 Qnil)));
5997 } 5996 }
5998#endif 5997#endif
5999 5998
diff --git a/src/keymap.c b/src/keymap.c
index c609ed6c4e4..31b9378d3ad 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -2083,12 +2083,21 @@ push_key_description (c, p, force_multibyte)
2083 int force_multibyte; 2083 int force_multibyte;
2084{ 2084{
2085 unsigned c2; 2085 unsigned c2;
2086 int valid_p;
2086 2087
2087 /* Clear all the meaningless bits above the meta bit. */ 2088 /* Clear all the meaningless bits above the meta bit. */
2088 c &= meta_modifier | ~ - meta_modifier; 2089 c &= meta_modifier | ~ - meta_modifier;
2089 c2 = c & ~(alt_modifier | ctrl_modifier | hyper_modifier 2090 c2 = c & ~(alt_modifier | ctrl_modifier | hyper_modifier
2090 | meta_modifier | shift_modifier | super_modifier); 2091 | meta_modifier | shift_modifier | super_modifier);
2091 2092
2093 valid_p = SINGLE_BYTE_CHAR_P (c2) || char_valid_p (c2, 0);
2094 if (! valid_p)
2095 {
2096 /* KEY_DESCRIPTION_SIZE is large enough for this. */
2097 p += sprintf (p, "[%d]", c);
2098 return p;
2099 }
2100
2092 if (c & alt_modifier) 2101 if (c & alt_modifier)
2093 { 2102 {
2094 *p++ = 'A'; 2103 *p++ = 'A';
@@ -2176,16 +2185,13 @@ push_key_description (c, p, force_multibyte)
2176 } 2185 }
2177 else 2186 else
2178 { 2187 {
2179 int valid_p = SINGLE_BYTE_CHAR_P (c) || char_valid_p (c, 0); 2188 if (force_multibyte)
2180
2181 if (force_multibyte && valid_p)
2182 { 2189 {
2183 if (SINGLE_BYTE_CHAR_P (c)) 2190 if (SINGLE_BYTE_CHAR_P (c))
2184 c = unibyte_char_to_multibyte (c); 2191 c = unibyte_char_to_multibyte (c);
2185 p += CHAR_STRING (c, p); 2192 p += CHAR_STRING (c, p);
2186 } 2193 }
2187 else if (NILP (current_buffer->enable_multibyte_characters) 2194 else if (NILP (current_buffer->enable_multibyte_characters))
2188 || valid_p)
2189 { 2195 {
2190 int bit_offset; 2196 int bit_offset;
2191 *p++ = '\\'; 2197 *p++ = '\\';
diff --git a/src/mac.c b/src/mac.c
index 444320322c3..f7fcbe9ac88 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -272,7 +272,7 @@ static Lisp_Object Qundecoded_file_name;
272 272
273static Lisp_Object 273static Lisp_Object
274mac_aelist_to_lisp (desc_list) 274mac_aelist_to_lisp (desc_list)
275 AEDescList *desc_list; 275 const AEDescList *desc_list;
276{ 276{
277 OSErr err; 277 OSErr err;
278 long count; 278 long count;
@@ -337,7 +337,7 @@ mac_aelist_to_lisp (desc_list)
337 337
338Lisp_Object 338Lisp_Object
339mac_aedesc_to_lisp (desc) 339mac_aedesc_to_lisp (desc)
340 AEDesc *desc; 340 const AEDesc *desc;
341{ 341{
342 OSErr err = noErr; 342 OSErr err = noErr;
343 DescType desc_type = desc->descriptorType; 343 DescType desc_type = desc->descriptorType;
@@ -665,33 +665,46 @@ init_coercion_handler ()
665} 665}
666 666
667#if TARGET_API_MAC_CARBON 667#if TARGET_API_MAC_CARBON
668OSErr 668static OSErr
669create_apple_event_from_event_ref (event, num_params, names, types, result) 669create_apple_event (class, id, result)
670 EventRef event; 670 AEEventClass class;
671 UInt32 num_params; 671 AEEventID id;
672 EventParamName *names;
673 EventParamType *types;
674 AppleEvent *result; 672 AppleEvent *result;
675{ 673{
676 OSErr err; 674 OSErr err;
677 static const ProcessSerialNumber psn = {0, kCurrentProcess}; 675 static const ProcessSerialNumber psn = {0, kCurrentProcess};
678 AEAddressDesc address_desc; 676 AEAddressDesc address_desc;
679 UInt32 i, size;
680 CFStringRef string;
681 CFDataRef data;
682 char *buf;
683 677
684 err = AECreateDesc (typeProcessSerialNumber, &psn, 678 err = AECreateDesc (typeProcessSerialNumber, &psn,
685 sizeof (ProcessSerialNumber), &address_desc); 679 sizeof (ProcessSerialNumber), &address_desc);
686 if (err == noErr) 680 if (err == noErr)
687 { 681 {
688 err = AECreateAppleEvent (0, 0, /* Dummy class and ID. */ 682 err = AECreateAppleEvent (class, id,
689 &address_desc, /* NULL is not allowed 683 &address_desc, /* NULL is not allowed
690 on Mac OS Classic. */ 684 on Mac OS Classic. */
691 kAutoGenerateReturnID, 685 kAutoGenerateReturnID,
692 kAnyTransactionID, result); 686 kAnyTransactionID, result);
693 AEDisposeDesc (&address_desc); 687 AEDisposeDesc (&address_desc);
694 } 688 }
689
690 return err;
691}
692
693OSErr
694create_apple_event_from_event_ref (event, num_params, names, types, result)
695 EventRef event;
696 UInt32 num_params;
697 EventParamName *names;
698 EventParamType *types;
699 AppleEvent *result;
700{
701 OSErr err;
702 UInt32 i, size;
703 CFStringRef string;
704 CFDataRef data;
705 char *buf = NULL;
706
707 err = create_apple_event (0, 0, result); /* Dummy class and ID. */
695 if (err != noErr) 708 if (err != noErr)
696 return err; 709 return err;
697 710
@@ -721,19 +734,88 @@ create_apple_event_from_event_ref (event, num_params, names, types, result)
721 0, &size, NULL); 734 0, &size, NULL);
722 if (err != noErr) 735 if (err != noErr)
723 break; 736 break;
724 buf = xmalloc (size); 737 buf = xrealloc (buf, size);
725 err = GetEventParameter (event, names[i], types[i], NULL, 738 err = GetEventParameter (event, names[i], types[i], NULL,
726 size, NULL, buf); 739 size, NULL, buf);
727 if (err == noErr) 740 if (err == noErr)
728 AEPutParamPtr (result, names[i], types[i], buf, size); 741 AEPutParamPtr (result, names[i], types[i], buf, size);
729 xfree (buf);
730 break; 742 break;
731 } 743 }
744 if (buf)
745 xfree (buf);
732 746
733 return noErr; 747 return noErr;
734} 748}
735#endif
736 749
750OSErr
751create_apple_event_from_drag_ref (drag, num_types, types, result)
752 DragRef drag;
753 UInt32 num_types;
754 FlavorType *types;
755 AppleEvent *result;
756{
757 OSErr err;
758 UInt16 num_items;
759 AppleEvent items;
760 long index;
761 char *buf = NULL;
762
763 err = CountDragItems (drag, &num_items);
764 if (err != noErr)
765 return err;
766 err = AECreateList (NULL, 0, false, &items);
767 if (err != noErr)
768 return err;
769
770 for (index = 1; index <= num_items; index++)
771 {
772 ItemReference item;
773 DescType desc_type = typeNull;
774 Size size;
775
776 err = GetDragItemReferenceNumber (drag, index, &item);
777 if (err == noErr)
778 {
779 int i;
780
781 for (i = 0; i < num_types; i++)
782 {
783 err = GetFlavorDataSize (drag, item, types[i], &size);
784 if (err == noErr)
785 {
786 buf = xrealloc (buf, size);
787 err = GetFlavorData (drag, item, types[i], buf, &size, 0);
788 }
789 if (err == noErr)
790 {
791 desc_type = types[i];
792 break;
793 }
794 }
795 }
796 err = AEPutPtr (&items, index, desc_type,
797 desc_type != typeNull ? buf : NULL,
798 desc_type != typeNull ? size : 0);
799 if (err != noErr)
800 break;
801 }
802 if (buf)
803 xfree (buf);
804
805 if (err == noErr)
806 {
807 err = create_apple_event (0, 0, result); /* Dummy class and ID. */
808 if (err == noErr)
809 err = AEPutParamDesc (result, keyDirectObject, &items);
810 if (err != noErr)
811 AEDisposeDesc (result);
812 }
813
814 AEDisposeDesc (&items);
815
816 return err;
817}
818#endif /* TARGET_API_MAC_CARBON */
737 819
738/*********************************************************************** 820/***********************************************************************
739 Conversion between Lisp and Core Foundation objects 821 Conversion between Lisp and Core Foundation objects
@@ -4686,16 +4768,6 @@ On successful conversion, return the result string, else return nil. */)
4686#endif /* TARGET_API_MAC_CARBON */ 4768#endif /* TARGET_API_MAC_CARBON */
4687 4769
4688 4770
4689DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, Smac_clear_font_name_table, 0, 0, 0,
4690 doc: /* Clear the font name table. */)
4691 ()
4692{
4693 check_mac ();
4694 mac_clear_font_name_table ();
4695 return Qnil;
4696}
4697
4698
4699static Lisp_Object 4771static Lisp_Object
4700mac_get_system_locale () 4772mac_get_system_locale ()
4701{ 4773{
@@ -5167,7 +5239,6 @@ syms_of_mac ()
5167 defsubr (&Smac_get_preference); 5239 defsubr (&Smac_get_preference);
5168 defsubr (&Smac_code_convert_string); 5240 defsubr (&Smac_code_convert_string);
5169#endif 5241#endif
5170 defsubr (&Smac_clear_font_name_table);
5171 5242
5172 defsubr (&Smac_set_file_creator); 5243 defsubr (&Smac_set_file_creator);
5173 defsubr (&Smac_set_file_type); 5244 defsubr (&Smac_set_file_type);
diff --git a/src/macfns.c b/src/macfns.c
index 2a83fef0870..bb2b8b540ff 100644
--- a/src/macfns.c
+++ b/src/macfns.c
@@ -2013,6 +2013,22 @@ mac_update_title_bar (f, save_match_data)
2013#endif 2013#endif
2014} 2014}
2015 2015
2016static void
2017mac_set_font (f, arg, oldval)
2018 struct frame *f;
2019 Lisp_Object arg, oldval;
2020{
2021 x_set_font (f, arg, oldval);
2022#if USE_MAC_FONT_PANEL
2023 if (FRAME_MAC_DISPLAY_INFO (f)->x_focus_frame == f)
2024 {
2025 BLOCK_INPUT;
2026 mac_set_font_info_for_selection (f);
2027 UNBLOCK_INPUT;
2028 }
2029#endif
2030}
2031
2016 2032
2017/* Subroutines of creating a frame. */ 2033/* Subroutines of creating a frame. */
2018 2034
@@ -2213,8 +2229,10 @@ mac_window (f)
2213#if TARGET_API_MAC_CARBON 2229#if TARGET_API_MAC_CARBON
2214 CreateNewWindow (kDocumentWindowClass, 2230 CreateNewWindow (kDocumentWindowClass,
2215 kWindowStandardDocumentAttributes 2231 kWindowStandardDocumentAttributes
2216 /* | kWindowToolbarButtonAttribute */, 2232#ifdef MAC_OSX
2217 &r, &FRAME_MAC_WINDOW (f)); 2233 | kWindowToolbarButtonAttribute
2234#endif
2235 , &r, &FRAME_MAC_WINDOW (f));
2218 if (FRAME_MAC_WINDOW (f)) 2236 if (FRAME_MAC_WINDOW (f))
2219 { 2237 {
2220 SetWRefCon (FRAME_MAC_WINDOW (f), (long) f->output_data.mac); 2238 SetWRefCon (FRAME_MAC_WINDOW (f), (long) f->output_data.mac);
@@ -4469,6 +4487,43 @@ mac_nav_event_callback (selector, parms, data)
4469#endif 4487#endif
4470 4488
4471/*********************************************************************** 4489/***********************************************************************
4490 Fonts
4491 ***********************************************************************/
4492
4493DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table,
4494 Smac_clear_font_name_table, 0, 0, 0,
4495 doc: /* Clear the font name table. */)
4496 ()
4497{
4498 check_mac ();
4499 mac_clear_font_name_table ();
4500 return Qnil;
4501}
4502
4503#if USE_MAC_FONT_PANEL
4504DEFUN ("mac-set-font-panel-visibility", Fmac_set_font_panel_visibility,
4505 Smac_set_font_panel_visibility, 1, 1, 0,
4506 doc: /* Set the font panel visibile if and only if VISIBLE is non-nil.
4507This is for internal use only. Use `mac-font-panel-mode' instead. */)
4508 (visible)
4509 Lisp_Object visible;
4510{
4511 OSStatus err = noErr;
4512
4513 check_mac ();
4514
4515 BLOCK_INPUT;
4516 if (NILP (visible) == (FPIsFontPanelVisible () == true))
4517 err = FPShowHideFontPanel ();
4518 UNBLOCK_INPUT;
4519
4520 if (err != noErr)
4521 error ("Cannot change visibility of the font panel");
4522 return Qnil;
4523}
4524#endif
4525
4526/***********************************************************************
4472 Initialization 4527 Initialization
4473 ***********************************************************************/ 4528 ***********************************************************************/
4474 4529
@@ -4484,7 +4539,7 @@ frame_parm_handler mac_frame_parm_handlers[] =
4484 x_set_border_width, 4539 x_set_border_width,
4485 x_set_cursor_color, 4540 x_set_cursor_color,
4486 x_set_cursor_type, 4541 x_set_cursor_type,
4487 x_set_font, 4542 mac_set_font,
4488 x_set_foreground_color, 4543 x_set_foreground_color,
4489 x_set_icon_name, 4544 x_set_icon_name,
4490 0, /* MAC_TODO: x_set_icon_type, */ 4545 0, /* MAC_TODO: x_set_icon_type, */
@@ -4660,7 +4715,7 @@ Chinese, Japanese, and Korean. */);
4660 load_font_func = x_load_font; 4715 load_font_func = x_load_font;
4661 find_ccl_program_func = x_find_ccl_program; 4716 find_ccl_program_func = x_find_ccl_program;
4662 query_font_func = x_query_font; 4717 query_font_func = x_query_font;
4663 set_frame_fontset_func = x_set_font; 4718 set_frame_fontset_func = mac_set_font;
4664 check_window_system_func = check_mac; 4719 check_window_system_func = check_mac;
4665 4720
4666 hourglass_atimer = NULL; 4721 hourglass_atimer = NULL;
@@ -4679,6 +4734,10 @@ Chinese, Japanese, and Korean. */);
4679#if TARGET_API_MAC_CARBON 4734#if TARGET_API_MAC_CARBON
4680 defsubr (&Sx_file_dialog); 4735 defsubr (&Sx_file_dialog);
4681#endif 4736#endif
4737 defsubr (&Smac_clear_font_name_table);
4738#if USE_MAC_FONT_PANEL
4739 defsubr (&Smac_set_font_panel_visibility);
4740#endif
4682} 4741}
4683 4742
4684/* arch-tag: d7591289-f374-4377-b245-12f5dbbb8edc 4743/* arch-tag: d7591289-f374-4377-b245-12f5dbbb8edc
diff --git a/src/macgui.h b/src/macgui.h
index 579ae2b7663..f7005600d43 100644
--- a/src/macgui.h
+++ b/src/macgui.h
@@ -103,6 +103,13 @@ typedef unsigned long Time;
103#endif 103#endif
104#endif 104#endif
105 105
106/* Whether to use the standard Font Panel floating dialog. */
107#ifndef USE_MAC_FONT_PANEL
108#if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
109#define USE_MAC_FONT_PANEL 1
110#endif
111#endif
112
106typedef WindowPtr Window; 113typedef WindowPtr Window;
107typedef GWorldPtr Pixmap; 114typedef GWorldPtr Pixmap;
108 115
diff --git a/src/macmenu.c b/src/macmenu.c
index be565f89259..e7d69d5657c 100644
--- a/src/macmenu.c
+++ b/src/macmenu.c
@@ -318,6 +318,7 @@ restore_menu_items (saved)
318 menu_items_n_panes = XINT (XCAR (saved)); 318 menu_items_n_panes = XINT (XCAR (saved));
319 saved = XCDR (saved); 319 saved = XCDR (saved);
320 menu_items_submenu_depth = XINT (XCAR (saved)); 320 menu_items_submenu_depth = XINT (XCAR (saved));
321 return Qnil;
321} 322}
322 323
323/* Push the whole state of menu_items processing onto the specpdl. 324/* Push the whole state of menu_items processing onto the specpdl.
@@ -634,6 +635,7 @@ cleanup_popup_menu (arg)
634 Lisp_Object arg; 635 Lisp_Object arg;
635{ 636{
636 discard_menu_items (); 637 discard_menu_items ();
638 return Qnil;
637} 639}
638 640
639DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, 641DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0,
diff --git a/src/macselect.c b/src/macselect.c
index fe4a7c8eccc..dd96102e19b 100644
--- a/src/macselect.c
+++ b/src/macselect.c
@@ -1,5 +1,5 @@
1/* Selection processing for Emacs on Mac OS. 1/* Selection processing for Emacs on Mac OS.
2 Copyright (C) 2005 Free Software Foundation, Inc. 2 Copyright (C) 2005, 2006 Free Software Foundation, Inc.
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -918,8 +918,8 @@ static struct
918 int size, count; 918 int size, count;
919} deferred_apple_events; 919} deferred_apple_events;
920extern Lisp_Object Qundefined; 920extern Lisp_Object Qundefined;
921extern OSErr mac_store_apple_event P_ ((Lisp_Object, Lisp_Object, 921extern void mac_store_apple_event P_ ((Lisp_Object, Lisp_Object,
922 const AEDesc *)); 922 const AEDesc *));
923 923
924struct apple_event_binding 924struct apple_event_binding
925{ 925{
@@ -1079,9 +1079,8 @@ mac_handle_apple_event (apple_event, reply, refcon)
1079 { 1079 {
1080 if (INTEGERP (binding)) 1080 if (INTEGERP (binding))
1081 return XINT (binding); 1081 return XINT (binding);
1082 err = mac_store_apple_event (class_key, id_key, apple_event); 1082 mac_store_apple_event (class_key, id_key, apple_event);
1083 if (err == noErr) 1083 return noErr;
1084 return noErr;
1085 } 1084 }
1086 } 1085 }
1087 return errAEEventNotHandled; 1086 return errAEEventNotHandled;
@@ -1146,6 +1145,198 @@ DEFUN ("mac-process-deferred-apple-events", Fmac_process_deferred_apple_events,
1146} 1145}
1147 1146
1148 1147
1148#if TARGET_API_MAC_CARBON
1149static Lisp_Object Vmac_dnd_known_types;
1150static pascal OSErr mac_do_track_drag P_ ((DragTrackingMessage, WindowRef,
1151 void *, DragRef));
1152static pascal OSErr mac_do_receive_drag P_ ((WindowRef, void *, DragRef));
1153static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL;
1154static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL;
1155
1156extern void mac_store_drag_event P_ ((WindowRef, Point, SInt16,
1157 const AEDesc *));
1158
1159static pascal OSErr
1160mac_do_track_drag (message, window, refcon, drag)
1161 DragTrackingMessage message;
1162 WindowRef window;
1163 void *refcon;
1164 DragRef drag;
1165{
1166 OSErr err = noErr;
1167 static int can_accept;
1168 UInt16 num_items, index;
1169
1170 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
1171 return dragNotAcceptedErr;
1172
1173 switch (message)
1174 {
1175 case kDragTrackingEnterHandler:
1176 err = CountDragItems (drag, &num_items);
1177 if (err != noErr)
1178 break;
1179 can_accept = 0;
1180 for (index = 1; index <= num_items; index++)
1181 {
1182 ItemReference item;
1183 FlavorFlags flags;
1184 Lisp_Object rest;
1185
1186 err = GetDragItemReferenceNumber (drag, index, &item);
1187 if (err != noErr)
1188 continue;
1189 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
1190 {
1191 Lisp_Object str;
1192 FlavorType type;
1193
1194 str = XCAR (rest);
1195 if (!(STRINGP (str) && SBYTES (str) == 4))
1196 continue;
1197 type = EndianU32_BtoN (*((UInt32 *) SDATA (str)));
1198
1199 err = GetFlavorFlags (drag, item, type, &flags);
1200 if (err == noErr)
1201 {
1202 can_accept = 1;
1203 break;
1204 }
1205 }
1206 }
1207 break;
1208
1209 case kDragTrackingEnterWindow:
1210 if (can_accept)
1211 {
1212 RgnHandle hilite_rgn = NewRgn ();
1213
1214 if (hilite_rgn)
1215 {
1216 Rect r;
1217
1218 GetWindowPortBounds (window, &r);
1219 OffsetRect (&r, -r.left, -r.top);
1220 RectRgn (hilite_rgn, &r);
1221 ShowDragHilite (drag, hilite_rgn, true);
1222 DisposeRgn (hilite_rgn);
1223 }
1224 SetThemeCursor (kThemeCopyArrowCursor);
1225 }
1226 break;
1227
1228 case kDragTrackingInWindow:
1229 break;
1230
1231 case kDragTrackingLeaveWindow:
1232 if (can_accept)
1233 {
1234 HideDragHilite (drag);
1235 SetThemeCursor (kThemeArrowCursor);
1236 }
1237 break;
1238
1239 case kDragTrackingLeaveHandler:
1240 break;
1241 }
1242
1243 if (err != noErr)
1244 return dragNotAcceptedErr;
1245 return noErr;
1246}
1247
1248static pascal OSErr
1249mac_do_receive_drag (window, refcon, drag)
1250 WindowRef window;
1251 void *refcon;
1252 DragRef drag;
1253{
1254 OSErr err;
1255 int num_types, i;
1256 Lisp_Object rest, str;
1257 FlavorType *types;
1258 AppleEvent apple_event;
1259 Point mouse_pos;
1260 SInt16 modifiers;
1261
1262 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
1263 return dragNotAcceptedErr;
1264
1265 num_types = 0;
1266 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
1267 {
1268 str = XCAR (rest);
1269 if (STRINGP (str) && SBYTES (str) == 4)
1270 num_types++;
1271 }
1272
1273 types = xmalloc (sizeof (FlavorType) * num_types);
1274 i = 0;
1275 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
1276 {
1277 str = XCAR (rest);
1278 if (STRINGP (str) && SBYTES (str) == 4)
1279 types[i++] = EndianU32_BtoN (*((UInt32 *) SDATA (str)));
1280 }
1281
1282 err = create_apple_event_from_drag_ref (drag, num_types, types,
1283 &apple_event);
1284 xfree (types);
1285
1286 if (err == noErr)
1287 err = GetDragMouse (drag, &mouse_pos, NULL);
1288 if (err == noErr)
1289 {
1290 GlobalToLocal (&mouse_pos);
1291 err = GetDragModifiers (drag, NULL, NULL, &modifiers);
1292 }
1293
1294 if (err == noErr)
1295 {
1296 mac_store_drag_event (window, mouse_pos, modifiers, &apple_event);
1297 AEDisposeDesc (&apple_event);
1298 /* Post a harmless event so as to wake up from ReceiveNextEvent. */
1299 mac_post_mouse_moved_event ();
1300 return noErr;
1301 }
1302 else
1303 return dragNotAcceptedErr;
1304}
1305#endif /* TARGET_API_MAC_CARBON */
1306
1307OSErr
1308install_drag_handler (window)
1309 WindowRef window;
1310{
1311 OSErr err = noErr;
1312
1313#if TARGET_API_MAC_CARBON
1314 if (mac_do_track_dragUPP == NULL)
1315 mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag);
1316 if (mac_do_receive_dragUPP == NULL)
1317 mac_do_receive_dragUPP = NewDragReceiveHandlerUPP (mac_do_receive_drag);
1318
1319 err = InstallTrackingHandler (mac_do_track_dragUPP, window, NULL);
1320 if (err == noErr)
1321 err = InstallReceiveHandler (mac_do_receive_dragUPP, window, NULL);
1322#endif
1323
1324 return err;
1325}
1326
1327void
1328remove_drag_handler (window)
1329 WindowRef window;
1330{
1331#if TARGET_API_MAC_CARBON
1332 if (mac_do_track_dragUPP)
1333 RemoveTrackingHandler (mac_do_track_dragUPP, window);
1334 if (mac_do_receive_dragUPP)
1335 RemoveReceiveHandler (mac_do_receive_dragUPP, window);
1336#endif
1337}
1338
1339
1149#ifdef MAC_OSX 1340#ifdef MAC_OSX
1150void 1341void
1151init_service_handler () 1342init_service_handler ()
@@ -1158,7 +1349,7 @@ init_service_handler ()
1158 GetEventTypeCount (specs), specs, NULL, NULL); 1349 GetEventTypeCount (specs), specs, NULL, NULL);
1159} 1350}
1160 1351
1161extern OSErr mac_store_services_event P_ ((EventRef)); 1352extern OSStatus mac_store_services_event P_ ((EventRef));
1162 1353
1163static OSStatus 1354static OSStatus
1164copy_scrap_flavor_data (from_scrap, to_scrap, flavor_type) 1355copy_scrap_flavor_data (from_scrap, to_scrap, flavor_type)
@@ -1408,6 +1599,17 @@ set to nil. */);
1408 doc: /* Keymap for Apple events handled by Emacs. */); 1599 doc: /* Keymap for Apple events handled by Emacs. */);
1409 Vmac_apple_event_map = Qnil; 1600 Vmac_apple_event_map = Qnil;
1410 1601
1602#if TARGET_API_MAC_CARBON
1603 DEFVAR_LISP ("mac-dnd-known-types", &Vmac_dnd_known_types,
1604 doc: /* The types accepted by default for dropped data.
1605The types are chosen in the order they appear in the list. */);
1606 Vmac_dnd_known_types = list4 (build_string ("hfs "), build_string ("utxt"),
1607 build_string ("TEXT"), build_string ("TIFF"));
1608#ifdef MAC_OSX
1609 Vmac_dnd_known_types = Fcons (build_string ("furl"), Vmac_dnd_known_types);
1610#endif
1611#endif
1612
1411#ifdef MAC_OSX 1613#ifdef MAC_OSX
1412 DEFVAR_LISP ("mac-services-selection", &Vmac_services_selection, 1614 DEFVAR_LISP ("mac-services-selection", &Vmac_services_selection,
1413 doc: /* Selection name for communication via Services menu. */); 1615 doc: /* Selection name for communication via Services menu. */);
diff --git a/src/macterm.c b/src/macterm.c
index 45bc533893c..8af067e086b 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -4097,6 +4097,11 @@ x_new_focus_frame (dpyinfo, frame)
4097 pending_autoraise_frame = dpyinfo->x_focus_frame; 4097 pending_autoraise_frame = dpyinfo->x_focus_frame;
4098 else 4098 else
4099 pending_autoraise_frame = 0; 4099 pending_autoraise_frame = 0;
4100
4101#if USE_MAC_FONT_PANEL
4102 if (frame)
4103 mac_set_font_info_for_selection (frame);
4104#endif
4100 } 4105 }
4101 4106
4102 x_frame_rehighlight (dpyinfo); 4107 x_frame_rehighlight (dpyinfo);
@@ -4454,35 +4459,11 @@ scroll_bar_timer_callback (timer, data)
4454 EventLoopTimerRef timer; 4459 EventLoopTimerRef timer;
4455 void *data; 4460 void *data;
4456{ 4461{
4457 EventRef event = NULL; 4462 OSStatus err;
4458 OSErr err;
4459
4460 err = CreateEvent (NULL, kEventClassMouse, kEventMouseMoved, 0,
4461 kEventAttributeNone, &event);
4462 if (err == noErr)
4463 {
4464 Point mouse_pos;
4465
4466 GetMouse (&mouse_pos);
4467 LocalToGlobal (&mouse_pos);
4468 err = SetEventParameter (event, kEventParamMouseLocation, typeQDPoint,
4469 sizeof (Point), &mouse_pos);
4470 }
4471 if (err == noErr)
4472 {
4473 UInt32 modifiers = GetCurrentKeyModifiers ();
4474 4463
4475 err = SetEventParameter (event, kEventParamKeyModifiers, typeUInt32, 4464 err = mac_post_mouse_moved_event ();
4476 sizeof (UInt32), &modifiers);
4477 }
4478 if (err == noErr)
4479 err = PostEventToQueue (GetCurrentEventQueue (), event,
4480 kEventPriorityStandard);
4481 if (err == noErr) 4465 if (err == noErr)
4482 scroll_bar_timer_event_posted_p = 1; 4466 scroll_bar_timer_event_posted_p = 1;
4483
4484 if (event)
4485 ReleaseEvent (event);
4486} 4467}
4487 4468
4488static OSStatus 4469static OSStatus
@@ -6723,10 +6704,6 @@ xlfdpat_create (pattern)
6723 } 6704 }
6724 6705
6725 return pat; 6706 return pat;
6726
6727 error:
6728 xlfdpat_destroy (pat);
6729 return NULL;
6730} 6707}
6731 6708
6732static INLINE int 6709static INLINE int
@@ -6895,6 +6872,8 @@ static Lisp_Object fm_font_family_alist;
6895#if USE_ATSUI 6872#if USE_ATSUI
6896/* Hash table linking font family names to ATSU font IDs. */ 6873/* Hash table linking font family names to ATSU font IDs. */
6897static Lisp_Object atsu_font_id_hash; 6874static Lisp_Object atsu_font_id_hash;
6875static Lisp_Object Vmac_atsu_font_table;
6876extern Lisp_Object QCfamily, QCweight, QCslant, Qnormal, Qbold, Qitalic;
6898#endif 6877#endif
6899 6878
6900/* Alist linking character set strings to Mac text encoding and Emacs 6879/* Alist linking character set strings to Mac text encoding and Emacs
@@ -7190,8 +7169,21 @@ init_font_name_table ()
7190 NULL, NULL); 7169 NULL, NULL);
7191 if (err == noErr) 7170 if (err == noErr)
7192 { 7171 {
7172 FMFontFamily ff;
7173 FMFontStyle style = normal;
7174
7193 decode_mac_font_name (name, name_len + 1, Qnil); 7175 decode_mac_font_name (name, name_len + 1, Qnil);
7194 family = make_unibyte_string (name, name_len); 7176 family = make_unibyte_string (name, name_len);
7177 FMGetFontFamilyInstanceFromFont (font_ids[i], &ff, &style);
7178 Fputhash (make_unibyte_string ((char *)(font_ids + i),
7179 sizeof (ATSUFontID)),
7180 Fcons (QCfamily,
7181 list5 (family,
7182 QCweight,
7183 style & bold ? Qbold : Qnormal,
7184 QCslant,
7185 style & italic ? Qitalic : Qnormal)),
7186 Vmac_atsu_font_table);
7195 if (*name != '.' 7187 if (*name != '.'
7196 && hash_lookup (h, family, &hash_code) < 0) 7188 && hash_lookup (h, family, &hash_code) < 0)
7197 { 7189 {
@@ -7737,6 +7729,7 @@ XLoadQueryFont (Display *dpy, char *fontname)
7737 ATSUFontFeatureSelector selectors[] = {kAllTypeFeaturesOffSelector, 7729 ATSUFontFeatureSelector selectors[] = {kAllTypeFeaturesOffSelector,
7738 kDecomposeDiacriticsSelector}; 7730 kDecomposeDiacriticsSelector};
7739 Lisp_Object font_id_cons; 7731 Lisp_Object font_id_cons;
7732 FMFontStyle style;
7740 7733
7741 font_id_cons = Fgethash (make_unibyte_string (family, strlen (family)), 7734 font_id_cons = Fgethash (make_unibyte_string (family, strlen (family)),
7742 atsu_font_id_hash, Qnil); 7735 atsu_font_id_hash, Qnil);
@@ -7755,7 +7748,11 @@ XLoadQueryFont (Display *dpy, char *fontname)
7755 return NULL; 7748 return NULL;
7756 err = ATSUSetAttributes (mac_style, sizeof (tags) / sizeof (tags[0]), 7749 err = ATSUSetAttributes (mac_style, sizeof (tags) / sizeof (tags[0]),
7757 tags, sizes, values); 7750 tags, sizes, values);
7758 fontnum = -1; 7751 if (err != noErr)
7752 return NULL;
7753 err = FMGetFontFamilyInstanceFromFont (font_id, &fontnum, &style);
7754 if (err != noErr)
7755 fontnum = -1;
7759 scriptcode = kTextEncodingMacUnicode; 7756 scriptcode = kTextEncodingMacUnicode;
7760 } 7757 }
7761 else 7758 else
@@ -7815,22 +7812,20 @@ XLoadQueryFont (Display *dpy, char *fontname)
7815 pcm_init (font->bounds.rows[0], 0x100); 7812 pcm_init (font->bounds.rows[0], 0x100);
7816 7813
7817#if USE_CG_TEXT_DRAWING 7814#if USE_CG_TEXT_DRAWING
7818 { 7815 if (fontnum != -1)
7819 FMFontFamily font_family; 7816 {
7820 FMFontStyle style; 7817 FMFontStyle style;
7821 ATSFontRef ats_font; 7818 ATSFontRef ats_font;
7822 7819
7823 err = FMGetFontFamilyInstanceFromFont (font_id, &font_family, &style); 7820 err = FMGetFontFromFontFamilyInstance (fontnum, fontface,
7824 if (err == noErr)
7825 err = FMGetFontFromFontFamilyInstance (font_family, fontface,
7826 &font_id, &style); 7821 &font_id, &style);
7827 /* Use CG text drawing if italic/bold is not synthesized. */ 7822 /* Use CG text drawing if italic/bold is not synthesized. */
7828 if (err == noErr && style == fontface) 7823 if (err == noErr && style == fontface)
7829 { 7824 {
7830 ats_font = FMGetATSFontRefFromFont (font_id); 7825 ats_font = FMGetATSFontRefFromFont (font_id);
7831 font->cg_font = CGFontCreateWithPlatformFont (&ats_font); 7826 font->cg_font = CGFontCreateWithPlatformFont (&ats_font);
7832 } 7827 }
7833 } 7828 }
7834 7829
7835 if (font->cg_font) 7830 if (font->cg_font)
7836 { 7831 {
@@ -8319,6 +8314,42 @@ x_find_ccl_program (fontp)
8319 } 8314 }
8320} 8315}
8321 8316
8317#if USE_MAC_FONT_PANEL
8318OSStatus
8319mac_set_font_info_for_selection (f)
8320 struct frame *f;
8321{
8322 OSStatus err;
8323
8324 if (f == NULL)
8325 err = SetFontInfoForSelection (kFontSelectionATSUIType, 0, NULL, NULL);
8326 else
8327 {
8328 struct face *default_face = FACE_FROM_ID (f, DEFAULT_FACE_ID);
8329 XFontStruct *ascii_font = default_face->ascii_face->font;
8330 EventTargetRef target = GetWindowEventTarget (FRAME_MAC_WINDOW (f));
8331
8332 if (ascii_font->mac_fontnum != -1)
8333 {
8334 FontSelectionQDStyle qd_style;
8335
8336 qd_style.version = kFontSelectionQDStyleVersionZero;
8337 qd_style.instance.fontFamily = ascii_font->mac_fontnum;
8338 qd_style.instance.fontStyle = ascii_font->mac_fontface;
8339 qd_style.size = ascii_font->mac_fontsize;
8340 qd_style.hasColor = false;
8341
8342 err = SetFontInfoForSelection (kFontSelectionQDType,
8343 1, &qd_style, target);
8344 }
8345 else
8346 err = SetFontInfoForSelection (kFontSelectionATSUIType,
8347 1, &ascii_font->mac_style, target);
8348 }
8349
8350 return err;
8351}
8352#endif
8322 8353
8323 8354
8324/* The Mac Event loop code */ 8355/* The Mac Event loop code */
@@ -8406,6 +8437,14 @@ Point saved_menu_event_location;
8406/* Apple Events */ 8437/* Apple Events */
8407#if USE_CARBON_EVENTS 8438#if USE_CARBON_EVENTS
8408static Lisp_Object Qhicommand; 8439static Lisp_Object Qhicommand;
8440#ifdef MAC_OSX
8441extern Lisp_Object Qwindow;
8442static Lisp_Object Qtoolbar_switch_mode;
8443#endif
8444#if USE_MAC_FONT_PANEL
8445extern Lisp_Object Qfont;
8446static Lisp_Object Qpanel_closed, Qselection;
8447#endif
8409#endif 8448#endif
8410extern int mac_ready_for_apple_events; 8449extern int mac_ready_for_apple_events;
8411extern Lisp_Object Qundefined; 8450extern Lisp_Object Qundefined;
@@ -8415,13 +8454,9 @@ extern void mac_find_apple_event_spec P_ ((AEEventClass, AEEventID,
8415 Lisp_Object *)); 8454 Lisp_Object *));
8416extern OSErr init_coercion_handler P_ ((void)); 8455extern OSErr init_coercion_handler P_ ((void));
8417 8456
8418#if TARGET_API_MAC_CARBON
8419/* Drag and Drop */ 8457/* Drag and Drop */
8420static pascal OSErr mac_do_track_drag (DragTrackingMessage, WindowPtr, void*, DragReference); 8458OSErr install_drag_handler P_ ((WindowRef));
8421static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference); 8459void remove_drag_handler P_ ((WindowRef));
8422static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL;
8423static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL;
8424#endif
8425 8460
8426#if USE_CARBON_EVENTS 8461#if USE_CARBON_EVENTS
8427#ifdef MAC_OSX 8462#ifdef MAC_OSX
@@ -8977,47 +9012,84 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out)
8977 x_real_positions (f, &f->left_pos, &f->top_pos); 9012 x_real_positions (f, &f->left_pos, &f->top_pos);
8978} 9013}
8979 9014
8980OSErr 9015void
8981mac_store_apple_event (class, id, desc) 9016mac_store_apple_event (class, id, desc)
8982 Lisp_Object class, id; 9017 Lisp_Object class, id;
8983 const AEDesc *desc; 9018 const AEDesc *desc;
8984{ 9019{
8985 OSErr err;
8986 struct input_event buf; 9020 struct input_event buf;
8987 AEDesc *desc_copy;
8988 9021
8989 desc_copy = xmalloc (sizeof (AEDesc)); 9022 EVENT_INIT (buf);
8990 err = AEDuplicateDesc (desc, desc_copy); 9023
8991 if (err == noErr) 9024 buf.kind = MAC_APPLE_EVENT;
8992 { 9025 buf.x = class;
8993 EVENT_INIT (buf); 9026 buf.y = id;
9027 XSETFRAME (buf.frame_or_window,
9028 mac_focus_frame (&one_mac_display_info));
9029 /* Now that Lisp object allocations are protected by BLOCK_INPUT, it
9030 is safe to use them during read_socket_hook. */
9031 buf.arg = mac_aedesc_to_lisp (desc);
9032 kbd_buffer_store_event (&buf);
9033}
9034
9035#if TARGET_API_MAC_CARBON
9036static OSStatus
9037mac_store_event_ref_as_apple_event (class, id, class_key, id_key,
9038 event, num_params, names, types)
9039 AEEventClass class;
9040 AEEventID id;
9041 Lisp_Object class_key, id_key;
9042 EventRef event;
9043 UInt32 num_params;
9044 EventParamName *names;
9045 EventParamType *types;
9046{
9047 OSStatus err = eventNotHandledErr;
9048 Lisp_Object binding;
8994 9049
8995 buf.kind = MAC_APPLE_EVENT; 9050 mac_find_apple_event_spec (class, id, &class_key, &id_key, &binding);
8996 buf.x = class; 9051 if (!NILP (binding) && !EQ (binding, Qundefined))
8997 buf.y = id; 9052 {
8998 buf.code = (int)desc_copy; 9053 if (INTEGERP (binding))
8999 XSETFRAME (buf.frame_or_window, 9054 err = XINT (binding);
9000 mac_focus_frame (&one_mac_display_info)); 9055 else
9001 buf.arg = Qnil; 9056 {
9002 kbd_buffer_store_event (&buf); 9057 AppleEvent apple_event;
9058 err = create_apple_event_from_event_ref (event, num_params,
9059 names, types,
9060 &apple_event);
9061 if (err == noErr)
9062 {
9063 mac_store_apple_event (class_key, id_key, &apple_event);
9064 AEDisposeDesc (&apple_event);
9065 }
9066 }
9003 } 9067 }
9004 9068
9005 return err; 9069 return err;
9006} 9070}
9007 9071
9008Lisp_Object 9072void
9009mac_make_lispy_event_code (code) 9073mac_store_drag_event (window, mouse_pos, modifiers, desc)
9010 int code; 9074 WindowRef window;
9075 Point mouse_pos;
9076 SInt16 modifiers;
9077 const AEDesc *desc;
9011{ 9078{
9012 AEDesc *desc = (AEDesc *)code; 9079 struct input_event buf;
9013 Lisp_Object obj;
9014 9080
9015 obj = mac_aedesc_to_lisp (desc); 9081 EVENT_INIT (buf);
9016 AEDisposeDesc (desc);
9017 xfree (desc);
9018 9082
9019 return obj; 9083 buf.kind = DRAG_N_DROP_EVENT;
9084 buf.modifiers = mac_to_emacs_modifiers (modifiers);
9085 buf.timestamp = TickCount () * (1000 / 60);
9086 XSETINT (buf.x, mouse_pos.h);
9087 XSETINT (buf.y, mouse_pos.v);
9088 XSETFRAME (buf.frame_or_window, mac_window_to_frame (window));
9089 buf.arg = mac_aedesc_to_lisp (desc);
9090 kbd_buffer_store_event (&buf);
9020} 9091}
9092#endif
9021 9093
9022#if USE_CARBON_EVENTS 9094#if USE_CARBON_EVENTS
9023static pascal OSStatus 9095static pascal OSStatus
@@ -9028,7 +9100,11 @@ mac_handle_command_event (next_handler, event, data)
9028{ 9100{
9029 OSStatus result, err; 9101 OSStatus result, err;
9030 HICommand command; 9102 HICommand command;
9031 Lisp_Object class_key, id_key, binding; 9103 static EventParamName names[] = {kEventParamDirectObject,
9104 kEventParamKeyModifiers};
9105 static EventParamType types[] = {typeHICommand,
9106 typeUInt32};
9107 int num_params = sizeof (names) / sizeof (names[0]);
9032 9108
9033 result = CallNextEventHandler (next_handler, event); 9109 result = CallNextEventHandler (next_handler, event);
9034 if (result != eventNotHandledErr) 9110 if (result != eventNotHandledErr)
@@ -9042,33 +9118,10 @@ mac_handle_command_event (next_handler, event, data)
9042 9118
9043 /* A HICommand event is mapped to an Apple event whose event class 9119 /* A HICommand event is mapped to an Apple event whose event class
9044 symbol is `hicommand' and event ID is its command ID. */ 9120 symbol is `hicommand' and event ID is its command ID. */
9045 class_key = Qhicommand; 9121 err = mac_store_event_ref_as_apple_event (0, command.commandID,
9046 mac_find_apple_event_spec (0, command.commandID, 9122 Qhicommand, Qnil,
9047 &class_key, &id_key, &binding); 9123 event, num_params, names, types);
9048 if (!NILP (binding) && !EQ (binding, Qundefined)) 9124 return err == noErr ? noErr : eventNotHandledErr;
9049 {
9050 if (INTEGERP (binding))
9051 return XINT (binding);
9052 else
9053 {
9054 AppleEvent apple_event;
9055 static EventParamName names[] = {kEventParamDirectObject,
9056 kEventParamKeyModifiers};
9057 static EventParamType types[] = {typeHICommand,
9058 typeUInt32};
9059 err = create_apple_event_from_event_ref (event, 2, names, types,
9060 &apple_event);
9061 if (err == noErr)
9062 {
9063 err = mac_store_apple_event (class_key, id_key, &apple_event);
9064 AEDisposeDesc (&apple_event);
9065 }
9066 if (err == noErr)
9067 return noErr;
9068 }
9069 }
9070
9071 return eventNotHandledErr;
9072} 9125}
9073 9126
9074static OSErr 9127static OSErr
@@ -9171,6 +9224,33 @@ mac_handle_window_event (next_handler, event, data)
9171 return noErr; 9224 return noErr;
9172 9225
9173 break; 9226 break;
9227
9228#ifdef MAC_OSX
9229 case kEventWindowToolbarSwitchMode:
9230 result = CallNextEventHandler (next_handler, event);
9231 {
9232 static EventParamName names[] = {kEventParamDirectObject,
9233 kEventParamWindowMouseLocation,
9234 kEventParamKeyModifiers,
9235 kEventParamMouseButton,
9236 kEventParamClickCount,
9237 kEventParamMouseChord};
9238 static EventParamType types[] = {typeWindowRef,
9239 typeQDPoint,
9240 typeUInt32,
9241 typeMouseButton,
9242 typeUInt32,
9243 typeUInt32};
9244 int num_params = sizeof (names) / sizeof (names[0]);
9245
9246 err = mac_store_event_ref_as_apple_event (0, 0,
9247 Qwindow,
9248 Qtoolbar_switch_mode,
9249 event, num_params,
9250 names, types);
9251 }
9252 return err == noErr ? noErr : result;
9253#endif
9174 } 9254 }
9175 9255
9176 return eventNotHandledErr; 9256 return eventNotHandledErr;
@@ -9245,45 +9325,96 @@ mac_handle_mouse_event (next_handler, event, data)
9245 return eventNotHandledErr; 9325 return eventNotHandledErr;
9246} 9326}
9247 9327
9328#if USE_MAC_FONT_PANEL
9329static pascal OSStatus
9330mac_handle_font_event (next_handler, event, data)
9331 EventHandlerCallRef next_handler;
9332 EventRef event;
9333 void *data;
9334{
9335 OSStatus result, err;
9336 Lisp_Object id_key;
9337 int num_params;
9338 EventParamName *names;
9339 EventParamType *types;
9340 static EventParamName names_sel[] = {kEventParamATSUFontID,
9341 kEventParamATSUFontSize,
9342 kEventParamFMFontFamily,
9343 kEventParamFMFontSize,
9344 kEventParamFontColor};
9345 static EventParamType types_sel[] = {typeATSUFontID,
9346 typeATSUSize,
9347 typeFMFontFamily,
9348 typeFMFontSize,
9349 typeFontColor};
9350
9351 result = CallNextEventHandler (next_handler, event);
9352 if (result != eventNotHandledErr)
9353 return result;
9354
9355 switch (GetEventKind (event))
9356 {
9357 case kEventFontPanelClosed:
9358 id_key = Qpanel_closed;
9359 num_params = 0;
9360 names = NULL;
9361 types = NULL;
9362 break;
9363
9364 case kEventFontSelection:
9365 id_key = Qselection;
9366 num_params = sizeof (names_sel) / sizeof (names_sel[0]);
9367 names = names_sel;
9368 types = types_sel;
9369 break;
9370 }
9371
9372 err = mac_store_event_ref_as_apple_event (0, 0, Qfont, id_key,
9373 event, num_params,
9374 names, types);
9375
9376 return err == noErr ? noErr : eventNotHandledErr;
9377}
9378#endif
9379
9248#ifdef MAC_OSX 9380#ifdef MAC_OSX
9249OSErr 9381OSStatus
9250mac_store_services_event (event) 9382mac_store_services_event (event)
9251 EventRef event; 9383 EventRef event;
9252{ 9384{
9253 OSErr err; 9385 OSStatus err;
9254 AppleEvent apple_event;
9255 Lisp_Object id_key; 9386 Lisp_Object id_key;
9387 int num_params;
9388 EventParamName *names;
9389 EventParamType *types;
9390 static EventParamName names_pfm[] = {kEventParamServiceMessageName,
9391 kEventParamServiceUserData};
9392 static EventParamType types_pfm[] = {typeCFStringRef,
9393 typeCFStringRef};
9256 9394
9257 switch (GetEventKind (event)) 9395 switch (GetEventKind (event))
9258 { 9396 {
9259 case kEventServicePaste: 9397 case kEventServicePaste:
9260 id_key = Qpaste; 9398 id_key = Qpaste;
9261 err = create_apple_event_from_event_ref (event, 0, NULL, NULL, 9399 num_params = 0;
9262 &apple_event); 9400 names = NULL;
9401 types = NULL;
9263 break; 9402 break;
9264 9403
9265 case kEventServicePerform: 9404 case kEventServicePerform:
9266 { 9405 id_key = Qperform;
9267 static EventParamName names[] = {kEventParamServiceMessageName, 9406 num_params = sizeof (names_pfm) / sizeof (names_pfm[0]);
9268 kEventParamServiceUserData}; 9407 names = names_pfm;
9269 static EventParamType types[] = {typeCFStringRef, 9408 types = types_pfm;
9270 typeCFStringRef};
9271
9272 id_key = Qperform;
9273 err = create_apple_event_from_event_ref (event, 2, names, types,
9274 &apple_event);
9275 }
9276 break; 9409 break;
9277 9410
9278 default: 9411 default:
9279 abort (); 9412 abort ();
9280 } 9413 }
9281 9414
9282 if (err == noErr) 9415 err = mac_store_event_ref_as_apple_event (0, 0, Qservices, id_key,
9283 { 9416 event, num_params,
9284 err = mac_store_apple_event (Qservices, id_key, &apple_event); 9417 names, types);
9285 AEDisposeDesc (&apple_event);
9286 }
9287 9418
9288 return err; 9419 return err;
9289} 9420}
@@ -9303,15 +9434,28 @@ install_window_handler (window)
9303 {kEventClassWindow, kEventWindowShown}, 9434 {kEventClassWindow, kEventWindowShown},
9304 {kEventClassWindow, kEventWindowHidden}, 9435 {kEventClassWindow, kEventWindowHidden},
9305 {kEventClassWindow, kEventWindowExpanded}, 9436 {kEventClassWindow, kEventWindowExpanded},
9306 {kEventClassWindow, kEventWindowCollapsed}}; 9437 {kEventClassWindow, kEventWindowCollapsed},
9438#ifdef MAC_OSX
9439 {kEventClassWindow, kEventWindowToolbarSwitchMode},
9440#endif
9441 };
9307 EventTypeSpec specs_mouse[] = {{kEventClassMouse, kEventMouseWheelMoved}}; 9442 EventTypeSpec specs_mouse[] = {{kEventClassMouse, kEventMouseWheelMoved}};
9308 static EventHandlerUPP handle_window_eventUPP = NULL; 9443 static EventHandlerUPP handle_window_eventUPP = NULL;
9309 static EventHandlerUPP handle_mouse_eventUPP = NULL; 9444 static EventHandlerUPP handle_mouse_eventUPP = NULL;
9445#if USE_MAC_FONT_PANEL
9446 EventTypeSpec specs_font[] = {{kEventClassFont, kEventFontPanelClosed},
9447 {kEventClassFont, kEventFontSelection}};
9448 static EventHandlerUPP handle_font_eventUPP = NULL;
9449#endif
9310 9450
9311 if (handle_window_eventUPP == NULL) 9451 if (handle_window_eventUPP == NULL)
9312 handle_window_eventUPP = NewEventHandlerUPP (mac_handle_window_event); 9452 handle_window_eventUPP = NewEventHandlerUPP (mac_handle_window_event);
9313 if (handle_mouse_eventUPP == NULL) 9453 if (handle_mouse_eventUPP == NULL)
9314 handle_mouse_eventUPP = NewEventHandlerUPP (mac_handle_mouse_event); 9454 handle_mouse_eventUPP = NewEventHandlerUPP (mac_handle_mouse_event);
9455#if USE_MAC_FONT_PANEL
9456 if (handle_font_eventUPP == NULL)
9457 handle_font_eventUPP = NewEventHandlerUPP (mac_handle_font_event);
9458#endif
9315 err = InstallWindowEventHandler (window, handle_window_eventUPP, 9459 err = InstallWindowEventHandler (window, handle_window_eventUPP,
9316 GetEventTypeCount (specs_window), 9460 GetEventTypeCount (specs_window),
9317 specs_window, NULL, NULL); 9461 specs_window, NULL, NULL);
@@ -9319,18 +9463,16 @@ install_window_handler (window)
9319 err = InstallWindowEventHandler (window, handle_mouse_eventUPP, 9463 err = InstallWindowEventHandler (window, handle_mouse_eventUPP,
9320 GetEventTypeCount (specs_mouse), 9464 GetEventTypeCount (specs_mouse),
9321 specs_mouse, NULL, NULL); 9465 specs_mouse, NULL, NULL);
9322#endif 9466#if USE_MAC_FONT_PANEL
9323#if TARGET_API_MAC_CARBON
9324 if (mac_do_track_dragUPP == NULL)
9325 mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag);
9326 if (mac_do_receive_dragUPP == NULL)
9327 mac_do_receive_dragUPP = NewDragReceiveHandlerUPP (mac_do_receive_drag);
9328
9329 if (err == noErr)
9330 err = InstallTrackingHandler (mac_do_track_dragUPP, window, NULL);
9331 if (err == noErr) 9467 if (err == noErr)
9332 err = InstallReceiveHandler (mac_do_receive_dragUPP, window, NULL); 9468 err = InstallWindowEventHandler (window, handle_font_eventUPP,
9469 GetEventTypeCount (specs_font),
9470 specs_font, NULL, NULL);
9333#endif 9471#endif
9472#endif
9473 if (err == noErr)
9474 err = install_drag_handler (window);
9475
9334 return err; 9476 return err;
9335} 9477}
9336 9478
@@ -9338,167 +9480,9 @@ void
9338remove_window_handler (window) 9480remove_window_handler (window)
9339 WindowPtr window; 9481 WindowPtr window;
9340{ 9482{
9341#if TARGET_API_MAC_CARBON 9483 remove_drag_handler (window);
9342 if (mac_do_track_dragUPP)
9343 RemoveTrackingHandler (mac_do_track_dragUPP, window);
9344 if (mac_do_receive_dragUPP)
9345 RemoveReceiveHandler (mac_do_receive_dragUPP, window);
9346#endif
9347}
9348
9349#if TARGET_API_MAC_CARBON
9350static pascal OSErr
9351mac_do_track_drag (DragTrackingMessage message, WindowPtr window,
9352 void *handlerRefCon, DragReference theDrag)
9353{
9354 static int can_accept;
9355 short items;
9356 short index;
9357 ItemReference theItem;
9358 FlavorFlags theFlags;
9359 OSErr result;
9360
9361 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
9362 return dragNotAcceptedErr;
9363
9364 switch (message)
9365 {
9366 case kDragTrackingEnterHandler:
9367 CountDragItems (theDrag, &items);
9368 can_accept = 0;
9369 for (index = 1; index <= items; index++)
9370 {
9371 GetDragItemReferenceNumber (theDrag, index, &theItem);
9372 result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags);
9373 if (result == noErr)
9374 {
9375 can_accept = 1;
9376 break;
9377 }
9378 }
9379 break;
9380
9381 case kDragTrackingEnterWindow:
9382 if (can_accept)
9383 {
9384 RgnHandle hilite_rgn = NewRgn ();
9385 Rect r;
9386 struct frame *f = mac_window_to_frame (window);
9387
9388 GetWindowPortBounds (window, &r);
9389 OffsetRect (&r, -r.left, -r.top);
9390 RectRgn (hilite_rgn, &r);
9391 ShowDragHilite (theDrag, hilite_rgn, true);
9392 DisposeRgn (hilite_rgn);
9393 SetThemeCursor (kThemeCopyArrowCursor);
9394 }
9395 break;
9396
9397 case kDragTrackingInWindow:
9398 break;
9399
9400 case kDragTrackingLeaveWindow:
9401 if (can_accept)
9402 {
9403 struct frame *f = mac_window_to_frame (window);
9404
9405 HideDragHilite (theDrag);
9406 SetThemeCursor (kThemeArrowCursor);
9407 }
9408 break;
9409
9410 case kDragTrackingLeaveHandler:
9411 break;
9412 }
9413
9414 return noErr;
9415} 9484}
9416 9485
9417static pascal OSErr
9418mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
9419 DragReference theDrag)
9420{
9421 short items;
9422 short index;
9423 FlavorFlags theFlags;
9424 Point mouse;
9425 OSErr result;
9426 ItemReference theItem;
9427 HFSFlavor data;
9428 Size size = sizeof (HFSFlavor);
9429 Lisp_Object file_list;
9430
9431 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
9432 return dragNotAcceptedErr;
9433
9434 file_list = Qnil;
9435 GetDragMouse (theDrag, &mouse, 0L);
9436 CountDragItems (theDrag, &items);
9437 for (index = 1; index <= items; index++)
9438 {
9439 /* Only handle file references. */
9440 GetDragItemReferenceNumber (theDrag, index, &theItem);
9441 result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags);
9442 if (result == noErr)
9443 {
9444 OSErr err;
9445 AEDesc desc;
9446
9447 err = GetFlavorData (theDrag, theItem, flavorTypeHFS,
9448 &data, &size, 0L);
9449 if (err == noErr)
9450 err = AECoercePtr (typeFSS, &data.fileSpec, sizeof (FSSpec),
9451 TYPE_FILE_NAME, &desc);
9452 if (err == noErr)
9453 {
9454 Lisp_Object file;
9455
9456 /* x-dnd functions expect undecoded filenames. */
9457 file = make_uninit_string (AEGetDescDataSize (&desc));
9458 err = AEGetDescData (&desc, SDATA (file), SBYTES (file));
9459 if (err == noErr)
9460 file_list = Fcons (file, file_list);
9461 AEDisposeDesc (&desc);
9462 }
9463 }
9464 }
9465 /* If there are items in the list, construct an event and post it to
9466 the queue like an interrupt using kbd_buffer_store_event. */
9467 if (!NILP (file_list))
9468 {
9469 struct input_event event;
9470 Lisp_Object frame;
9471 struct frame *f = mac_window_to_frame (window);
9472 SInt16 modifiers;
9473
9474 GlobalToLocal (&mouse);
9475 GetDragModifiers (theDrag, NULL, NULL, &modifiers);
9476
9477 event.kind = DRAG_N_DROP_EVENT;
9478 event.code = 0;
9479 event.modifiers = mac_to_emacs_modifiers (modifiers);
9480 event.timestamp = TickCount () * (1000 / 60);
9481 XSETINT (event.x, mouse.h);
9482 XSETINT (event.y, mouse.v);
9483 XSETFRAME (frame, f);
9484 event.frame_or_window = frame;
9485 event.arg = file_list;
9486 /* Post to the interrupt queue */
9487 kbd_buffer_store_event (&event);
9488 /* MAC_TODO: Mimic behavior of windows by switching contexts to Emacs */
9489 {
9490 ProcessSerialNumber psn;
9491 GetCurrentProcess (&psn);
9492 SetFrontProcess (&psn);
9493 }
9494
9495 return noErr;
9496 }
9497 else
9498 return dragNotAcceptedErr;
9499}
9500#endif
9501
9502 9486
9503#if __profile__ 9487#if __profile__
9504void 9488void
@@ -9784,6 +9768,41 @@ mac_wait_next_event (er, sleep_time, dequeue)
9784} 9768}
9785#endif /* not USE_CARBON_EVENTS */ 9769#endif /* not USE_CARBON_EVENTS */
9786 9770
9771#if TARGET_API_MAC_CARBON
9772OSStatus
9773mac_post_mouse_moved_event ()
9774{
9775 EventRef event = NULL;
9776 OSStatus err;
9777
9778 err = CreateEvent (NULL, kEventClassMouse, kEventMouseMoved, 0,
9779 kEventAttributeNone, &event);
9780 if (err == noErr)
9781 {
9782 Point mouse_pos;
9783
9784 GetMouse (&mouse_pos);
9785 LocalToGlobal (&mouse_pos);
9786 err = SetEventParameter (event, kEventParamMouseLocation, typeQDPoint,
9787 sizeof (Point), &mouse_pos);
9788 }
9789 if (err == noErr)
9790 {
9791 UInt32 modifiers = GetCurrentKeyModifiers ();
9792
9793 err = SetEventParameter (event, kEventParamKeyModifiers, typeUInt32,
9794 sizeof (UInt32), &modifiers);
9795 }
9796 if (err == noErr)
9797 err = PostEventToQueue (GetCurrentEventQueue (), event,
9798 kEventPriorityStandard);
9799 if (event)
9800 ReleaseEvent (event);
9801
9802 return err;
9803}
9804#endif
9805
9787/* Emacs calls this whenever it wants to read an input event from the 9806/* Emacs calls this whenever it wants to read an input event from the
9788 user. */ 9807 user. */
9789int 9808int
@@ -9911,7 +9930,8 @@ XTread_socket (sd, expected, hold_quit)
9911 break; 9930 break;
9912 9931
9913 case inContent: 9932 case inContent:
9914 if (window_ptr != FRAME_MAC_WINDOW (mac_focus_frame (dpyinfo))) 9933 if (dpyinfo->x_focus_frame == NULL
9934 || window_ptr != FRAME_MAC_WINDOW (dpyinfo->x_focus_frame))
9915 SelectWindow (window_ptr); 9935 SelectWindow (window_ptr);
9916 else 9936 else
9917 { 9937 {
@@ -10058,20 +10078,18 @@ XTread_socket (sd, expected, hold_quit)
10058 } 10078 }
10059 break; 10079 break;
10060 10080
10061#if TARGET_API_MAC_CARBON
10062 case inProxyIcon:
10063 if (TrackWindowProxyDrag (window_ptr, er.where)
10064 != errUserWantsToDragWindow)
10065 break;
10066 /* fall through */
10067#endif
10068 case inDrag: 10081 case inDrag:
10069#if TARGET_API_MAC_CARBON 10082#if TARGET_API_MAC_CARBON
10083 case inProxyIcon:
10070 if (IsWindowPathSelectClick (window_ptr, &er)) 10084 if (IsWindowPathSelectClick (window_ptr, &er))
10071 { 10085 {
10072 WindowPathSelect (window_ptr, NULL, NULL); 10086 WindowPathSelect (window_ptr, NULL, NULL);
10073 break; 10087 break;
10074 } 10088 }
10089 if (part_code == inProxyIcon
10090 && (TrackWindowProxyDrag (window_ptr, er.where)
10091 != errUserWantsToDragWindow))
10092 break;
10075 DragWindow (window_ptr, er.where, NULL); 10093 DragWindow (window_ptr, er.where, NULL);
10076#else /* not TARGET_API_MAC_CARBON */ 10094#else /* not TARGET_API_MAC_CARBON */
10077 DragWindow (window_ptr, er.where, &qd.screenBits.bounds); 10095 DragWindow (window_ptr, er.where, &qd.screenBits.bounds);
@@ -11010,6 +11028,13 @@ syms_of_macterm ()
11010#if USE_CARBON_EVENTS 11028#if USE_CARBON_EVENTS
11011 Qhicommand = intern ("hicommand"); staticpro (&Qhicommand); 11029 Qhicommand = intern ("hicommand"); staticpro (&Qhicommand);
11012#ifdef MAC_OSX 11030#ifdef MAC_OSX
11031 Qtoolbar_switch_mode = intern ("toolbar-switch-mode");
11032 staticpro (&Qtoolbar_switch_mode);
11033#if USE_MAC_FONT_PANEL
11034 Qpanel_closed = intern ("panel-closed"); staticpro (&Qpanel_closed);
11035 Qselection = intern ("selection"); staticpro (&Qselection);
11036#endif
11037
11013 Qservices = intern ("services"); staticpro (&Qservices); 11038 Qservices = intern ("services"); staticpro (&Qservices);
11014 Qpaste = intern ("paste"); staticpro (&Qpaste); 11039 Qpaste = intern ("paste"); staticpro (&Qpaste);
11015 Qperform = intern ("perform"); staticpro (&Qperform); 11040 Qperform = intern ("perform"); staticpro (&Qperform);
@@ -11050,7 +11075,7 @@ NOTE: Not supported on Mac yet. */);
11050 x_use_underline_position_properties = 0; 11075 x_use_underline_position_properties = 0;
11051 11076
11052 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, 11077 DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
11053 doc: /* If not nil, Emacs uses toolkit scroll bars. */); 11078 doc: /* If not nil, Emacs uses toolkit scroll bars. */);
11054#ifdef USE_TOOLKIT_SCROLL_BARS 11079#ifdef USE_TOOLKIT_SCROLL_BARS
11055 Vx_toolkit_scroll_bars = Qt; 11080 Vx_toolkit_scroll_bars = Qt;
11056#else 11081#else
@@ -11104,23 +11129,23 @@ mouse-3 and the command-key will register for mouse-2. */);
11104 11129
11105#if USE_CARBON_EVENTS 11130#if USE_CARBON_EVENTS
11106 DEFVAR_BOOL ("mac-wheel-button-is-mouse-2", &mac_wheel_button_is_mouse_2, 11131 DEFVAR_BOOL ("mac-wheel-button-is-mouse-2", &mac_wheel_button_is_mouse_2,
11107 doc: /* *Non-nil if the wheel button is mouse-2 and the right click mouse-3. 11132 doc: /* *Non-nil if the wheel button is mouse-2 and the right click mouse-3.
11108Otherwise, the right click will be treated as mouse-2 and the wheel 11133Otherwise, the right click will be treated as mouse-2 and the wheel
11109button will be mouse-3. */); 11134button will be mouse-3. */);
11110 mac_wheel_button_is_mouse_2 = 1; 11135 mac_wheel_button_is_mouse_2 = 1;
11111 11136
11112 DEFVAR_BOOL ("mac-pass-command-to-system", &mac_pass_command_to_system, 11137 DEFVAR_BOOL ("mac-pass-command-to-system", &mac_pass_command_to_system,
11113 doc: /* *Non-nil if command key presses are passed on to the Mac Toolbox. */); 11138 doc: /* *Non-nil if command key presses are passed on to the Mac Toolbox. */);
11114 mac_pass_command_to_system = 1; 11139 mac_pass_command_to_system = 1;
11115 11140
11116 DEFVAR_BOOL ("mac-pass-control-to-system", &mac_pass_control_to_system, 11141 DEFVAR_BOOL ("mac-pass-control-to-system", &mac_pass_control_to_system,
11117 doc: /* *Non-nil if control key presses are passed on to the Mac Toolbox. */); 11142 doc: /* *Non-nil if control key presses are passed on to the Mac Toolbox. */);
11118 mac_pass_control_to_system = 1; 11143 mac_pass_control_to_system = 1;
11119 11144
11120#endif 11145#endif
11121 11146
11122 DEFVAR_BOOL ("mac-allow-anti-aliasing", &mac_use_core_graphics, 11147 DEFVAR_BOOL ("mac-allow-anti-aliasing", &mac_use_core_graphics,
11123 doc: /* *If non-nil, allow anti-aliasing. 11148 doc: /* *If non-nil, allow anti-aliasing.
11124The text will be rendered using Core Graphics text rendering which 11149The text will be rendered using Core Graphics text rendering which
11125may anti-alias the text. */); 11150may anti-alias the text. */);
11126#if USE_CG_DRAWING 11151#if USE_CG_DRAWING
@@ -11133,7 +11158,7 @@ may anti-alias the text. */);
11133 creating the terminal frame on Mac OS 9 before loading 11158 creating the terminal frame on Mac OS 9 before loading
11134 term/mac-win.elc. */ 11159 term/mac-win.elc. */
11135 DEFVAR_LISP ("mac-charset-info-alist", &Vmac_charset_info_alist, 11160 DEFVAR_LISP ("mac-charset-info-alist", &Vmac_charset_info_alist,
11136 doc: /* Alist of Emacs character sets vs text encodings and coding systems. 11161 doc: /* Alist of Emacs character sets vs text encodings and coding systems.
11137Each entry should be of the form: 11162Each entry should be of the form:
11138 11163
11139 (CHARSET-NAME TEXT-ENCODING CODING-SYSTEM) 11164 (CHARSET-NAME TEXT-ENCODING CODING-SYSTEM)
@@ -11144,6 +11169,18 @@ CODING_SYSTEM is a coding system corresponding to TEXT-ENCODING. */);
11144 Vmac_charset_info_alist = 11169 Vmac_charset_info_alist =
11145 Fcons (list3 (build_string ("mac-roman"), 11170 Fcons (list3 (build_string ("mac-roman"),
11146 make_number (smRoman), Qnil), Qnil); 11171 make_number (smRoman), Qnil), Qnil);
11172
11173#if USE_ATSUI
11174 DEFVAR_LISP ("mac-atsu-font-table", &Vmac_atsu_font_table,
11175 doc: /* Hash table of ATSU font IDs vs plist of attributes and values.
11176Each font ID is represented as a four-byte string in native byte
11177order. */);
11178 Vmac_atsu_font_table =
11179 make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE),
11180 make_float (DEFAULT_REHASH_SIZE),
11181 make_float (DEFAULT_REHASH_THRESHOLD),
11182 Qnil, Qnil, Qnil);
11183#endif
11147} 11184}
11148 11185
11149/* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b 11186/* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b
diff --git a/src/macterm.h b/src/macterm.h
index 80276b45102..7406fb2fda6 100644
--- a/src/macterm.h
+++ b/src/macterm.h
@@ -581,10 +581,11 @@ extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int,
581extern void mac_clear_area P_ ((struct frame *, int, int, 581extern void mac_clear_area P_ ((struct frame *, int, int,
582 unsigned int, unsigned int)); 582 unsigned int, unsigned int));
583extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *)); 583extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *));
584extern OSStatus mac_set_font_info_for_selection P_ ((struct frame *));
584extern OSErr install_window_handler P_ ((WindowPtr)); 585extern OSErr install_window_handler P_ ((WindowPtr));
585extern void remove_window_handler P_ ((WindowPtr)); 586extern void remove_window_handler P_ ((WindowPtr));
586extern Lisp_Object mac_make_lispy_event_code P_ ((int));
587extern void do_menu_choice P_ ((SInt32)); 587extern void do_menu_choice P_ ((SInt32));
588extern OSStatus mac_post_mouse_moved_event P_ ((void));
588#if USE_CG_DRAWING 589#if USE_CG_DRAWING
589extern void mac_prepare_for_quickdraw P_ ((struct frame *)); 590extern void mac_prepare_for_quickdraw P_ ((struct frame *));
590#endif 591#endif
@@ -620,12 +621,15 @@ extern void free_frame_menubar P_ ((struct frame *));
620/* Defined in mac.c. */ 621/* Defined in mac.c. */
621 622
622extern void mac_clear_font_name_table P_ ((void)); 623extern void mac_clear_font_name_table P_ ((void));
623extern Lisp_Object mac_aedesc_to_lisp P_ ((AEDesc *)); 624extern Lisp_Object mac_aedesc_to_lisp P_ ((const AEDesc *));
624#if TARGET_API_MAC_CARBON 625#if TARGET_API_MAC_CARBON
625extern OSErr create_apple_event_from_event_ref P_ ((EventRef, UInt32, 626extern OSErr create_apple_event_from_event_ref P_ ((EventRef, UInt32,
626 EventParamName *, 627 EventParamName *,
627 EventParamType *, 628 EventParamType *,
628 AppleEvent *)); 629 AppleEvent *));
630extern OSErr create_apple_event_from_drag_ref P_ ((DragRef, UInt32,
631 FlavorType *,
632 AppleEvent *));
629extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *)); 633extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *));
630extern CFStringRef cfstring_create_with_string P_ ((Lisp_Object)); 634extern CFStringRef cfstring_create_with_string P_ ((Lisp_Object));
631extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef)); 635extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef));
diff --git a/src/minibuf.c b/src/minibuf.c
index 5f3f7454a0c..dc920287304 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -2805,7 +2805,7 @@ syms_of_minibuf ()
2805 DEFVAR_LISP ("history-length", &Vhistory_length, 2805 DEFVAR_LISP ("history-length", &Vhistory_length,
2806 doc: /* *Maximum length for history lists before truncation takes place. 2806 doc: /* *Maximum length for history lists before truncation takes place.
2807A number means that length; t means infinite. Truncation takes place 2807A number means that length; t means infinite. Truncation takes place
2808just after a new element is inserted. Setting the history-length 2808just after a new element is inserted. Setting the `history-length'
2809property of a history variable overrides this default. */); 2809property of a history variable overrides this default. */);
2810 XSETFASTINT (Vhistory_length, 30); 2810 XSETFASTINT (Vhistory_length, 30);
2811 2811
diff --git a/src/process.c b/src/process.c
index 6e633a5825c..de4dbd4a3ff 100644
--- a/src/process.c
+++ b/src/process.c
@@ -695,6 +695,8 @@ setup_process_coding_systems (process)
695 = (struct coding_system *) xmalloc (sizeof (struct coding_system)); 695 = (struct coding_system *) xmalloc (sizeof (struct coding_system));
696 setup_coding_system (p->encode_coding_system, 696 setup_coding_system (p->encode_coding_system,
697 proc_encode_coding_system[outch]); 697 proc_encode_coding_system[outch]);
698 if (proc_encode_coding_system[outch]->eol_type == CODING_EOL_UNDECIDED)
699 proc_encode_coding_system[outch]->eol_type = system_eol_type;
698} 700}
699 701
700DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0, 702DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0,
@@ -5071,6 +5073,10 @@ read_process_output (proc, channel)
5071 p->encode_coding_system = coding->symbol; 5073 p->encode_coding_system = coding->symbol;
5072 setup_coding_system (coding->symbol, 5074 setup_coding_system (coding->symbol,
5073 proc_encode_coding_system[XINT (p->outfd)]); 5075 proc_encode_coding_system[XINT (p->outfd)]);
5076 if (proc_encode_coding_system[XINT (p->outfd)]->eol_type
5077 == CODING_EOL_UNDECIDED)
5078 proc_encode_coding_system[XINT (p->outfd)]->eol_type
5079 = system_eol_type;
5074 } 5080 }
5075 } 5081 }
5076 5082
@@ -5178,6 +5184,10 @@ read_process_output (proc, channel)
5178 p->encode_coding_system = coding->symbol; 5184 p->encode_coding_system = coding->symbol;
5179 setup_coding_system (coding->symbol, 5185 setup_coding_system (coding->symbol,
5180 proc_encode_coding_system[XINT (p->outfd)]); 5186 proc_encode_coding_system[XINT (p->outfd)]);
5187 if (proc_encode_coding_system[XINT (p->outfd)]->eol_type
5188 == CODING_EOL_UNDECIDED)
5189 proc_encode_coding_system[XINT (p->outfd)]->eol_type
5190 = system_eol_type;
5181 } 5191 }
5182 } 5192 }
5183 carryover = nbytes - coding->consumed; 5193 carryover = nbytes - coding->consumed;
@@ -5320,6 +5330,8 @@ send_process (proc, buf, len, object)
5320 sending a multibyte text, thus we must encode it by the 5330 sending a multibyte text, thus we must encode it by the
5321 original coding system specified for the current process. */ 5331 original coding system specified for the current process. */
5322 setup_coding_system (p->encode_coding_system, coding); 5332 setup_coding_system (p->encode_coding_system, coding);
5333 if (coding->eol_type == CODING_EOL_UNDECIDED)
5334 coding->eol_type = system_eol_type;
5323 /* src_multibyte should be set to 1 _after_ a call to 5335 /* src_multibyte should be set to 1 _after_ a call to
5324 setup_coding_system, since it resets src_multibyte to 5336 setup_coding_system, since it resets src_multibyte to
5325 zero. */ 5337 zero. */
diff --git a/src/termhooks.h b/src/termhooks.h
index 13b41f95f70..8937a709f85 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -183,9 +183,9 @@ enum event_kind
183 /* Generated when an Apple event, a HICommand event, or a Services 183 /* Generated when an Apple event, a HICommand event, or a Services
184 menu event is received and the corresponding handler is 184 menu event is received and the corresponding handler is
185 registered. Members `x' and `y' are for the event class and ID 185 registered. Members `x' and `y' are for the event class and ID
186 symbols, respectively. Member `code' points to the Apple event 186 symbols, respectively. Member `arg' is a Lisp object converted
187 descriptor. Parameters for Non-Apple events are converted to 187 from the received Apple event. Parameters for non-Apple events
188 those in Apple events. */ 188 are converted to those in Apple events. */
189 MAC_APPLE_EVENT 189 MAC_APPLE_EVENT
190#endif 190#endif
191}; 191};
diff --git a/src/xdisp.c b/src/xdisp.c
index d05b1c5293d..4ad511c18b0 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -4433,6 +4433,24 @@ handle_composition_prop (it)
4433 4433
4434 if (id >= 0) 4434 if (id >= 0)
4435 { 4435 {
4436 struct composition *cmp = composition_table[id];
4437
4438 if (cmp->glyph_len == 0)
4439 {
4440 /* No glyph. */
4441 if (STRINGP (it->string))
4442 {
4443 IT_STRING_CHARPOS (*it) = end;
4444 IT_STRING_BYTEPOS (*it) = string_char_to_byte (it->string,
4445 end);
4446 }
4447 else
4448 {
4449 IT_CHARPOS (*it) = end;
4450 IT_BYTEPOS (*it) = CHAR_TO_BYTE (end);
4451 }
4452 return HANDLED_RECOMPUTE_PROPS;
4453 }
4436 it->method = GET_FROM_COMPOSITION; 4454 it->method = GET_FROM_COMPOSITION;
4437 it->cmp_id = id; 4455 it->cmp_id = id;
4438 it->cmp_len = COMPOSITION_LENGTH (prop); 4456 it->cmp_len = COMPOSITION_LENGTH (prop);