diff options
author | Miles Bader <miles@gnu.org> | 2006-05-10 20:42:41 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 2006-05-10 20:42:41 +0000 |
commit | 3bcf2b084a0dd1ff0399480d57b87e01cfe061dc (patch) | |
tree | 355c68cda5a5c9c73824840df3cdae6320017283 /src | |
parent | 0ea38cf9dca8f2b148d78f638eed17e8896984af (diff) | |
parent | d105bfecce2288cd99f591382586a22a4ce1b6f2 (diff) | |
download | emacs-3bcf2b084a0dd1ff0399480d57b87e01cfe061dc.tar.gz emacs-3bcf2b084a0dd1ff0399480d57b87e01cfe061dc.tar.bz2 emacs-3bcf2b084a0dd1ff0399480d57b87e01cfe061dc.zip |
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-60
Merge from emacs--devo--0
Patches applied:
* emacs--devo--0 (patch 259-273)
- Update from CVS
- lisp/replace.el (occur-engine): Bind `inhibit-field-text-motion' to t
- Merge from gnus--rel--5.10
- Rename "field-at-point" to "field-at-pos"
- (comint-insert-input): Remove redundant calls to setq and goto-char
* gnus--rel--5.10 (patch 99-100)
- Merge from emacs--devo--0
- Update from CVS
Diffstat (limited to 'src')
-rw-r--r-- | src/.gdbinit | 155 | ||||
-rw-r--r-- | src/ChangeLog | 200 | ||||
-rw-r--r-- | src/callproc.c | 2 | ||||
-rw-r--r-- | src/coding.h | 3 | ||||
-rw-r--r-- | src/image.c | 26 | ||||
-rw-r--r-- | src/keyboard.c | 3 | ||||
-rw-r--r-- | src/keymap.c | 13 | ||||
-rw-r--r-- | src/mac.c | 125 | ||||
-rw-r--r-- | src/macfns.c | 80 | ||||
-rw-r--r-- | src/macgui.h | 7 | ||||
-rw-r--r-- | src/macmenu.c | 2 | ||||
-rw-r--r-- | src/macselect.c | 234 | ||||
-rw-r--r-- | src/macterm.c | 684 | ||||
-rw-r--r-- | src/macterm.h | 8 | ||||
-rw-r--r-- | src/minibuf.c | 4 | ||||
-rw-r--r-- | src/process.c | 10 | ||||
-rw-r--r-- | src/sound.c | 71 | ||||
-rw-r--r-- | src/termhooks.h | 6 | ||||
-rw-r--r-- | src/xdisp.c | 18 | ||||
-rw-r--r-- | src/xfaces.c | 10 |
20 files changed, 1242 insertions, 419 deletions
diff --git a/src/.gdbinit b/src/.gdbinit index 881a11dc8c0..7de361fddfb 100644 --- a/src/.gdbinit +++ b/src/.gdbinit @@ -211,6 +211,7 @@ define pitx printf "vpos=%d hpos=%d", $it->vpos, $it->hpos, printf " y=%d lvy=%d", $it->current_y, $it->last_visible_y printf " x=%d vx=%d-%d", $it->current_x, $it->first_visible_x, $it->last_visible_x + printf " w=%d", $it->pixel_width printf " a+d=%d+%d=%d", $it->ascent, $it->descent, $it->ascent+$it->descent printf " max=%d+%d=%d", $it->max_ascent, $it->max_descent, $it->max_ascent+$it->max_descent printf "\n" @@ -544,6 +545,10 @@ end define xframe xgetptr $ print (struct frame *) $ptr + xgetptr $->name + set $ptr = (struct Lisp_String *) $ptr + xprintstr $ptr + echo \n end document xframe Print $ as a frame pointer, assuming it is an Emacs Lisp frame value. @@ -676,6 +681,31 @@ document xcdr Print the cdr of $, assuming it is an Emacs Lisp pair. end +define xlist + xgetptr $ + set $cons = (struct Lisp_Cons *) $ptr + xgetptr Qnil + set $nil = $ptr + set $i = 0 + while $cons != $nil && $i < 10 + p/x $cons->car + xpr + xgetptr $cons->u.cdr + set $cons = (struct Lisp_Cons *) $ptr + set $i = $i + 1 + printf "---\n" + end + if $cons == $nil + printf "nil\n" + else + printf "...\n" + p $ptr + end +end +document xlist +Print $ assuming it is a list. +end + define xfloat xgetptr $ print ((struct Lisp_Float *) $ptr)->u.data @@ -694,6 +724,108 @@ document xscrollbar Print $ as a scrollbar pointer. end +define xpr + xtype + if $type == Lisp_Int + xint + end + if $type == Lisp_Symbol + xsymbol + end + if $type == Lisp_String + xstring + end + if $type == Lisp_Cons + xcons + end + if $type == Lisp_Float + xfloat + end + if $type == Lisp_Misc + set $misc = (enum Lisp_Misc_Type) (((struct Lisp_Free *) $ptr)->type) + if $misc == Lisp_Misc_Free + xmiscfree + end + if $misc == Lisp_Misc_Boolfwd + xboolfwd + end + if $misc == Lisp_Misc_Marker + xmarker + end + if $misc == Lisp_Misc_Intfwd + xintfwd + end + if $misc == Lisp_Misc_Boolfwd + xboolfwd + end + if $misc == Lisp_Misc_Objfwd + xobjfwd + end + if $misc == Lisp_Misc_Buffer_Objfwd + xbufobjfwd + end + if $misc == Lisp_Misc_Buffer_Local_Value + xbuflocal + end +# if $misc == Lisp_Misc_Some_Buffer_Local_Value +# xvalue +# end + if $misc == Lisp_Misc_Overlay + xoverlay + end + if $misc == Lisp_Misc_Kboard_Objfwd + xkbobjfwd + end +# if $misc == Lisp_Misc_Save_Value +# xsavevalue +# end + end + if $type == Lisp_Vectorlike + set $size = ((struct Lisp_Vector *) $ptr)->size + if ($size & PVEC_FLAG) + set $vec = (enum pvec_type) ($size & PVEC_TYPE_MASK) + if $vec == PVEC_NORMAL_VECTOR + xvector + end + if $vec == PVEC_PROCESS + xprocess + end + if $vec == PVEC_FRAME + xframe + end + if $vec == PVEC_COMPILED + xcompiled + end + if $vec == PVEC_WINDOW + xwindow + end + if $vec == PVEC_WINDOW_CONFIGURATION + xwinconfig + end + if $vec == PVEC_SUBR + xsubr + end + if $vec == PVEC_CHAR_TABLE + xchartable + end + if $vec == PVEC_BOOL_VECTOR + xboolvector + end + if $vec == PVEC_BUFFER + xbuffer + end + if $vec == PVEC_HASH_TABLE + xhashtable + end + else + xvector + end + end +end +document xpr +Print $ as a lisp object of any type. +end + define xprintstr set $data = $arg0->data output ($arg0->size > 1000) ? 0 : ($data[0])@($arg0->size_byte < 0 ? $arg0->size & ~gdb_array_mark_flag : $arg0->size_byte) @@ -739,7 +871,7 @@ define xbacktrace xgettype (*$bt->function) if $type == Lisp_Symbol xprintsym (*$bt->function) - echo \n + printf " (0x%x)\n", *$bt->args else printf "0x%x ", *$bt->function if $type == Lisp_Vectorlike @@ -760,6 +892,27 @@ document xbacktrace an error was signaled. end +define which + set debug_print (which_symbols ($arg0)) +end +document which + Print symbols which references a given lisp object, + either as its symbol value or symbol function. +end + +define xbytecode + set $bt = byte_stack_list + while $bt + xgettype ($bt->byte_string) + printf "0x%x => ", $bt->byte_string + which $bt->byte_string + set $bt = $bt->next + end +end +document xbytecode + Print a backtrace of the byte code stack. +end + # Show Lisp backtrace after normal backtrace. define hookpost-backtrace set $bt = backtrace_list diff --git a/src/ChangeLog b/src/ChangeLog index f68510f2fb4..d7e8293ad27 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,203 @@ +2006-05-10 Kenichi Handa <handa@m17n.org> + + * xfaces.c (realize_default_face) [HAVE_X_WINDOWS]: If the font + chosen for the default face was different from the frame font, + adjust the frame font. + +2006-05-10 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * image.c (Qduration) [MAC_OS]: Undo previous change. + (syms_of_image) [MAC_OS]: Likewise. + [MAC_OS] (gif_load): Emulate Graphic Control Extension block. + + * macfns.c (x_to_mac_color): Fix shift amount change. + [USE_MAC_FONT_PANEL] (mac_set_font): Use x_get_focus_frame. + [USE_MAC_FONT_PANEL] (Fmac_set_font_panel_visibility): Doc fix. + + * macselect.c (Vmac_service_selection) [MAC_OSX]: Rename from + Vmac_services_selection. All uses changed. + (mac_store_service_event): Rename from mac_store_services_event in + extern and calls. + + * macterm.c (Qservice) [MAC_OSX]: Rename from Qservices. All uses + changed. + [MAC_OSX] (mac_store_service_event): Rename from + mac_store_services_event. All callers changed. + [USE_MAC_FONT_PANEL] (mac_set_font_info_for_selection): Add args + FACE_ID and C. All callers changed. + (x_free_frame_resources) [USE_MAC_FONT_PANEL]: Call + mac_set_font_info_for_selection when focus frame is destroyed. + (XTread_socket): Revert to FrontNonFloatingWindow/FrontWindow. + + * macterm.h (mac_set_font_info_for_selection): Add 2nd and 3rd + args in extern. + +2006-05-09 Chong Yidong <cyd@stupidchicken.com> + + * keymap.c (describe_map): Avoid generating duplicate entries if + the shadowed binding has the same definition. + +2006-05-09 Kenichi Handa <handa@m17n.org> + + * keymap.c (push_key_description): Handle invalid character key. + +2006-05-08 Kenichi Handa <handa@m17n.org> + + * callproc.c (Fcall_process): Use system_eol_type for encoding + arguments if eol_type is not yet decided. + + * coding.h (system_eol_type): Extern it. + + * coding.c (setup_coding_system): For invalid coding-system, set + coding->eol_type to CODING_EOL_UNDECIDED. + (encode_coding): Cancel previous change. + (shrink_encoding_region): Likewise. + (code_convert_region1): Likewise. + (code_convert_string1): Likewise. + (code_convert_string_norecord): Likewise. + + * fileio.c (choose_write_coding_system): Use system_eol_type for + encoding if eol_type is not yet decided. + + * process.c (setup_process_coding_systems): Use system_eol_type + for encoding if eol_type is not yet decided. + (read_process_output): Likewise. + (send_process): Likewise. + +2006-05-07 Juanma Barranquero <lekktu@gmail.com> + + * minibuf.c (syms_of_minibuf) <history-length>: Fix typo in doc. + +2006-05-07 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * mac.c (Fmac_clear_font_name_table): Move defun to macfns.c. + (syms_of_mac): Likewise for defsubr. + + * macfns.c (mac_set_font): New function. + (mac_frame_parm_handlers, syms_of_macfns): Replace x_set_font with it. + (mac_window) [TARGET_API_MAC_CARBON && MAC_OSX]: Specify + kWindowToolbarButtonAttribute when creating window. + (Fmac_clear_font_name_table): Move from macfns.c. + (syms_of_macfns): Likewise for defsubr. + [USE_MAC_FONT_PANEL] (Fmac_set_font_panel_visibility): New defun. + (syms_of_macfns) [USE_MAC_FONT_PANEL]: Defsubr it. + + * macgui.h (USE_MAC_FONT_PANEL): Define to 1 if USE_ATSUI is set + and build is done on Mac OS X 10.2 and later. + + * macselect.c (mac_do_receive_drag): Remove unused variable `index'. + (mac_store_services_event): Change return type in extern. + + * macterm.c (XLoadQueryFont) [USE_ATSUI]: Set font->mac_fontnum to + FMFontFamily value. + [USE_MAC_FONT_PANEL] (mac_set_font_info_for_selection): New function. + (x_new_focus_frame) [USE_MAC_FONT_PANEL]: Use it. + (QCfamily, QCweight, QCslant, Qnormal, Qbold, Qitalic): Add extern. + (QWindow) [MAC_OSX]: Likewise. + (Qfont) [USE_MAC_FONT_PANEL]: Likewise. + (Vmac_atsu_font_table) [USE_ATSUI]: New variable. + (syms_of_macterm) [USE_ATSUI]: Defvar it. + (Qtoolbar_switch_mode) [MAC_OSX]: New variable. + (Qpanel_closed, Qselection) [USE_MAC_FONT_PANEL]: Likewise. + (syms_of_macterm): Intern and staticpro them. + (init_font_name_table) [USE_ATSUI]: Add data to Vmac_atsu_font_table. + [TARGET_API_MAC_CARBON] (mac_store_event_ref_as_apple_event): New + function. + [USE_CARBON_EVENTS] (mac_handle_command_event): Use it. + [MAC_OSX] (mac_store_services_event): Likewise. + [USE_CARBON_EVENTS] (mac_handle_window_event) [MAC_OSX]: Handle + kEventWindowToolbarSwitchMode event. + (install_window_handler) [USE_CARBON_EVENTS && MAC_OSX]: Register it. + [MAC_OSX] (mac_store_services_event): Change return type to OSStatus. + [USE_MAC_FONT_PANEL] (mac_handle_font_event): New function. + (install_window_handler) [USE_MAC_FONT_PANEL]: Install it. + (XTread_socket): Select window on mouse click if x_focus_frame is NULL. + + * macterm.h (mac_set_font_info_for_selection): Add extern. + +2006-05-06 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * image.c (Qduration) [MAC_OS]: New variable. + (syms_of_image) [MAC_OS]: Intern and staticpro it. + [MAC_OS] (gif_load): Save image extension data in img->data.lisp_val. + [MAC_OSX] (image_load_quartz2d): Use cfstring_create_with_utf8_cstring + instead of cfstring_create_with_string. + +2006-05-06 Kim F. Storm <storm@cua.dk> + + * .gdbinit (xframe): Print frame name. + (xlist): New command to print a list (max 10 elements). + (xpr): Print lisp object of any type. + (pitx): Print it->pixel_width. + +2006-05-05 Kenichi Handa <handa@m17n.org> + + * xdisp.c (handle_composition_prop): Fix for the case of empty + composition component. + +2006-05-05 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> + + * keyboard.c (make_lispy_event) [MAC_OS]: Get Apple event info + from event->arg. + + * termhooks.h (enum event_kind) [MAC_OS]: Update comment for + MAC_APPLE_EVENT. + + * macterm.h (mac_make_lispy_event_code): Remove extern. + (mac_post_mouse_moved_event): Add extern. + (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to + `const AEDesc *' in externs. + (create_apple_event_from_drag_ref) [TARGET_API_MAC_CARBON]: New extern. + + * mac.c (mac_aelist_to_lisp, mac_aedesc_to_lisp): Change arg 1 to + `const AEDesc *'. + [TARGET_API_MAC_CARBON] (create_apple_event): New function. + [TARGET_API_MAC_CARBON] (create_apple_event_from_event_ref): Use it. + Use xrealloc instead of repeated xmalloc/xfree. + [TARGET_API_MAC_CARBON] (create_apple_event_from_drag_ref): New + function. + + * macmenu.c (restore_menu_items, cleanup_popup_menu): Return a value. + + * macselect.c: Update copyright year. + (mac_store_apple_event): Change return type to void in extern. + (mac_handle_apple_event): Don't get return value from + mac_store_apple_event. + [TARGET_API_MAC_CARBON] (Vmac_dnd_known_types): New variable. + (syms_of_macselect) [TARGET_API_MAC_CARBON]: Defvar it. + [TARGET_API_MAC_CARBON] (mac_do_track_drag): Move function from + macterm.c. Use Vmac_dnd_known_types as acceptable flavors. + [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Likewise. New + implementation using create_apple_event_from_drag_ref. + [TARGET_API_MAC_CARBON] (mac_do_track_dragUPP) + (mac_do_receive_dragUPP): Move variables from macterm.c. + (install_drag_handler, remove_drag_handler): New functions. + + * macterm.c (XTread_socket) [TARGET_API_MAC_CARBON]: Try window + path select also for proxy icon click. + [TARGET_API_MAC_CARBON] (mac_post_mouse_moved_event): New function. + [USE_TOOLKIT_SCROLL_BARS] (scroll_bar_timer_callback): Use it. + (xlfdpat_create): Remove unused label `error' and trailing sentences. + (mac_do_track_drag, mac_do_receive_drag): Move functions to macselect.c. + (mac_do_track_dragUPP, mac_do_receive_dragUPP): Move variables to + macselect.c. + (install_drag_handler, remove_drag_handler): Add extern. + (mac_store_apple_event): Change return type to void. All uses changed. + Create Lisp object from Apple event and store it into input event. + (mac_make_lispy_event_code): Remove function. + [TARGET_API_MAC_CARBON] (mac_store_drag_event): New function. + (install_window_handler): Call install_drag_handler. + (remove_window_handler): Call remove_drag_handler. + +2006-05-03 Richard Stallman <rms@gnu.org> + + * sound.c (Fplay_sound_internal): Dynamically allocate + current_sound_device and current_sound. + (sound_cleanup): Free them. + + * minibuf.c (read_minibuf): Don't use read_minibuf_noninteractive + when inside a keyboard macro. + 2006-05-02 Andreas Schwab <schwab@suse.de> * xmenu.c (restore_menu_items): Return a value. diff --git a/src/callproc.c b/src/callproc.c index 54ebf53979e..5f314f4de2a 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -295,6 +295,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */) val = Qnil; } setup_coding_system (Fcheck_coding_system (val), &argument_coding); + if (argument_coding.eol_type == CODING_EOL_UNDECIDED) + argument_coding.eol_type = system_eol_type; } } diff --git a/src/coding.h b/src/coding.h index 41f4aab509c..aa5c8f05015 100644 --- a/src/coding.h +++ b/src/coding.h @@ -717,6 +717,9 @@ extern Lisp_Object eol_mnemonic_unix, eol_mnemonic_dos, eol_mnemonic_mac; /* Mnemonic string to indicate type of end-of-line is not yet decided. */ extern Lisp_Object eol_mnemonic_undecided; +/* Format of end-of-line decided by system. */ +extern int system_eol_type; + #ifdef emacs extern Lisp_Object Qfile_coding_system; extern Lisp_Object Qcall_process, Qcall_process_region; diff --git a/src/image.c b/src/image.c index 688ff200055..f309a401139 100644 --- a/src/image.c +++ b/src/image.c @@ -2628,7 +2628,7 @@ image_load_quartz2d (f, img, png_p) UNGCPRO; return 0; } - path = cfstring_create_with_string (file); + path = cfstring_create_with_utf8_cstring (SDATA (file)); url = CFURLCreateWithFileSystemPath (NULL, path, kCFURLPOSIXPathStyle, 0); CFRelease (path); @@ -7920,7 +7920,8 @@ gif_load (f, img) RGBColor bg_color; int width, height; XImagePtr ximg; - TimeValue time; + TimeScale time_scale; + TimeValue time, duration; int ino; CGrafPtr old_port; GDHandle old_gdh; @@ -8028,6 +8029,7 @@ gif_load (f, img) image, img->spec); goto error; } + time_scale = GetMediaTimeScale (media); specified_bg = image_spec_value (img->spec, QCbackground, NULL); if (!STRINGP (specified_bg) || @@ -8053,7 +8055,7 @@ gif_load (f, img) SetGWorld (old_port, old_gdh); SetMovieActive (movie, 1); SetMovieGWorld (movie, ximg, NULL); - SampleNumToMediaTime (media, ino + 1, &time, NULL); + SampleNumToMediaTime (media, ino + 1, &time, &duration); SetMovieTimeValue (movie, time); MoviesTask (movie, 0L); DisposeTrackMedia (media); @@ -8061,6 +8063,24 @@ gif_load (f, img) DisposeMovie (movie); if (dh) DisposeHandle (dh); + + /* Save GIF image extension data for `image-extension-data'. + Format is (count IMAGES 0xf9 GRAPHIC_CONTROL_EXTENSION_BLOCK). */ + { + unsigned char gce[4]; + int centisec = ((float)duration / time_scale) * 100.0f + 0.5f; + + /* Fill the delay time field. */ + gce[1] = centisec & 0xff; + gce[2] = (centisec >> 8) & 0xff; + /* We don't know about other fields. */ + gce[0] = gce[3] = 0; + + img->data.lisp_val = list4 (Qcount, make_number (nsamples), + make_number (0xf9), + make_unibyte_string (gce, 4)); + } + /* Maybe fill in the background field while we have ximg handy. */ if (NILP (image_spec_value (img->spec, QCbackground, NULL))) IMAGE_BACKGROUND (img, f, ximg); diff --git a/src/keyboard.c b/src/keyboard.c index e3a77653ed6..b47df2bec7a 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -5881,8 +5881,7 @@ make_lispy_event (event) spec[1] = event->y; return Fcons (Qmac_apple_event, Fcons (Fvector (2, spec), - Fcons (mac_make_lispy_event_code (event->code), - Qnil))); + Fcons (event->arg, Qnil))); } #endif diff --git a/src/keymap.c b/src/keymap.c index f5aea3b3902..fb506200a1c 100644 --- a/src/keymap.c +++ b/src/keymap.c @@ -2120,12 +2120,21 @@ push_key_description (c, p, force_multibyte) int force_multibyte; { unsigned c2; + int valid_p; /* Clear all the meaningless bits above the meta bit. */ c &= meta_modifier | ~ - meta_modifier; c2 = c & ~(alt_modifier | ctrl_modifier | hyper_modifier | meta_modifier | shift_modifier | super_modifier); + valid_p = SINGLE_BYTE_CHAR_P (c2) || char_valid_p (c2, 0); + if (! valid_p) + { + /* KEY_DESCRIPTION_SIZE is large enough for this. */ + p += sprintf (p, "[%d]", c); + return p; + } + if (c & alt_modifier) { *p++ = 'A'; @@ -3310,7 +3319,9 @@ describe_map (map, prefix, elt_describer, partial, shadow, tem = shadow_lookup (shadow, kludge, Qt); if (!NILP (tem)) { - if (mention_shadow) + /* Avoid generating duplicate entries if the + shadowed binding has the same definition. */ + if (mention_shadow && !EQ (tem, definition)) this_shadowed = 1; else continue; 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; static Lisp_Object mac_aelist_to_lisp (desc_list) - AEDescList *desc_list; + const AEDescList *desc_list; { OSErr err; long count; @@ -337,7 +337,7 @@ mac_aelist_to_lisp (desc_list) Lisp_Object mac_aedesc_to_lisp (desc) - AEDesc *desc; + const AEDesc *desc; { OSErr err = noErr; DescType desc_type = desc->descriptorType; @@ -665,33 +665,46 @@ init_coercion_handler () } #if TARGET_API_MAC_CARBON -OSErr -create_apple_event_from_event_ref (event, num_params, names, types, result) - EventRef event; - UInt32 num_params; - EventParamName *names; - EventParamType *types; +static OSErr +create_apple_event (class, id, result) + AEEventClass class; + AEEventID id; AppleEvent *result; { OSErr err; static const ProcessSerialNumber psn = {0, kCurrentProcess}; AEAddressDesc address_desc; - UInt32 i, size; - CFStringRef string; - CFDataRef data; - char *buf; err = AECreateDesc (typeProcessSerialNumber, &psn, sizeof (ProcessSerialNumber), &address_desc); if (err == noErr) { - err = AECreateAppleEvent (0, 0, /* Dummy class and ID. */ + err = AECreateAppleEvent (class, id, &address_desc, /* NULL is not allowed on Mac OS Classic. */ kAutoGenerateReturnID, kAnyTransactionID, result); AEDisposeDesc (&address_desc); } + + return err; +} + +OSErr +create_apple_event_from_event_ref (event, num_params, names, types, result) + EventRef event; + UInt32 num_params; + EventParamName *names; + EventParamType *types; + AppleEvent *result; +{ + OSErr err; + UInt32 i, size; + CFStringRef string; + CFDataRef data; + char *buf = NULL; + + err = create_apple_event (0, 0, result); /* Dummy class and ID. */ if (err != noErr) return err; @@ -721,19 +734,88 @@ create_apple_event_from_event_ref (event, num_params, names, types, result) 0, &size, NULL); if (err != noErr) break; - buf = xmalloc (size); + buf = xrealloc (buf, size); err = GetEventParameter (event, names[i], types[i], NULL, size, NULL, buf); if (err == noErr) AEPutParamPtr (result, names[i], types[i], buf, size); - xfree (buf); break; } + if (buf) + xfree (buf); return noErr; } -#endif +OSErr +create_apple_event_from_drag_ref (drag, num_types, types, result) + DragRef drag; + UInt32 num_types; + FlavorType *types; + AppleEvent *result; +{ + OSErr err; + UInt16 num_items; + AppleEvent items; + long index; + char *buf = NULL; + + err = CountDragItems (drag, &num_items); + if (err != noErr) + return err; + err = AECreateList (NULL, 0, false, &items); + if (err != noErr) + return err; + + for (index = 1; index <= num_items; index++) + { + ItemReference item; + DescType desc_type = typeNull; + Size size; + + err = GetDragItemReferenceNumber (drag, index, &item); + if (err == noErr) + { + int i; + + for (i = 0; i < num_types; i++) + { + err = GetFlavorDataSize (drag, item, types[i], &size); + if (err == noErr) + { + buf = xrealloc (buf, size); + err = GetFlavorData (drag, item, types[i], buf, &size, 0); + } + if (err == noErr) + { + desc_type = types[i]; + break; + } + } + } + err = AEPutPtr (&items, index, desc_type, + desc_type != typeNull ? buf : NULL, + desc_type != typeNull ? size : 0); + if (err != noErr) + break; + } + if (buf) + xfree (buf); + + if (err == noErr) + { + err = create_apple_event (0, 0, result); /* Dummy class and ID. */ + if (err == noErr) + err = AEPutParamDesc (result, keyDirectObject, &items); + if (err != noErr) + AEDisposeDesc (result); + } + + AEDisposeDesc (&items); + + return err; +} +#endif /* TARGET_API_MAC_CARBON */ /*********************************************************************** Conversion between Lisp and Core Foundation objects @@ -4686,16 +4768,6 @@ On successful conversion, return the result string, else return nil. */) #endif /* TARGET_API_MAC_CARBON */ -DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, Smac_clear_font_name_table, 0, 0, 0, - doc: /* Clear the font name table. */) - () -{ - check_mac (); - mac_clear_font_name_table (); - return Qnil; -} - - static Lisp_Object mac_get_system_locale () { @@ -5167,7 +5239,6 @@ syms_of_mac () defsubr (&Smac_get_preference); defsubr (&Smac_code_convert_string); #endif - defsubr (&Smac_clear_font_name_table); defsubr (&Smac_set_file_creator); defsubr (&Smac_set_file_type); diff --git a/src/macfns.c b/src/macfns.c index 74b5288e781..8e0d5153034 100644 --- a/src/macfns.c +++ b/src/macfns.c @@ -1091,7 +1091,7 @@ x_to_mac_color (colorname) char *color; unsigned long colorval; int i, pos; - pos = 0; + pos = 16; colorval = 0; color = colorname + 4; @@ -1127,7 +1127,7 @@ x_to_mac_color (colorname) if (value == ULONG_MAX) break; colorval |= (value << pos); - pos += 0x8; + pos -= 0x8; if (i == 2) { if (*end != '\0') @@ -1146,7 +1146,7 @@ x_to_mac_color (colorname) char *color; unsigned long colorval; int i, pos; - pos = 0; + pos = 16; colorval = 0; color = colorname + 5; @@ -1168,7 +1168,7 @@ x_to_mac_color (colorname) if (val == 0x100) val = 0xFF; colorval |= (val << pos); - pos += 0x8; + pos -= 0x8; if (i == 2) { if (*end != '\0') @@ -1919,6 +1919,27 @@ mac_set_scroll_bar_width (f, arg, oldval) x_set_scroll_bar_width (f, arg, oldval); } +static void +mac_set_font (f, arg, oldval) + struct frame *f; + Lisp_Object arg, oldval; +{ + x_set_font (f, arg, oldval); +#if USE_MAC_FONT_PANEL + { + Lisp_Object focus_frame = x_get_focus_frame (f); + + if ((NILP (focus_frame) && f == SELECTED_FRAME ()) + || XFRAME (focus_frame) == f) + { + BLOCK_INPUT; + mac_set_font_info_for_selection (f, DEFAULT_FACE_ID, 0); + UNBLOCK_INPUT; + } + } +#endif +} + #if TARGET_API_MAC_CARBON static void mac_update_proxy_icon (f) @@ -2213,8 +2234,10 @@ mac_window (f) #if TARGET_API_MAC_CARBON CreateNewWindow (kDocumentWindowClass, kWindowStandardDocumentAttributes - /* | kWindowToolbarButtonAttribute */, - &r, &FRAME_MAC_WINDOW (f)); +#ifdef MAC_OSX + | kWindowToolbarButtonAttribute +#endif + , &r, &FRAME_MAC_WINDOW (f)); if (FRAME_MAC_WINDOW (f)) { SetWRefCon (FRAME_MAC_WINDOW (f), (long) f->output_data.mac); @@ -4469,6 +4492,43 @@ mac_nav_event_callback (selector, parms, data) #endif /*********************************************************************** + Fonts + ***********************************************************************/ + +DEFUN ("mac-clear-font-name-table", Fmac_clear_font_name_table, + Smac_clear_font_name_table, 0, 0, 0, + doc: /* Clear the font name table. */) + () +{ + check_mac (); + mac_clear_font_name_table (); + return Qnil; +} + +#if USE_MAC_FONT_PANEL +DEFUN ("mac-set-font-panel-visibility", Fmac_set_font_panel_visibility, + Smac_set_font_panel_visibility, 1, 1, 0, + doc: /* Make the font panel visible if and only if VISIBLE is non-nil. +This is for internal use only. Use `mac-font-panel-mode' instead. */) + (visible) + Lisp_Object visible; +{ + OSStatus err = noErr; + + check_mac (); + + BLOCK_INPUT; + if (NILP (visible) == (FPIsFontPanelVisible () == true)) + err = FPShowHideFontPanel (); + UNBLOCK_INPUT; + + if (err != noErr) + error ("Cannot change visibility of the font panel"); + return Qnil; +} +#endif + +/*********************************************************************** Initialization ***********************************************************************/ @@ -4484,7 +4544,7 @@ frame_parm_handler mac_frame_parm_handlers[] = x_set_border_width, x_set_cursor_color, x_set_cursor_type, - x_set_font, + mac_set_font, x_set_foreground_color, x_set_icon_name, 0, /* MAC_TODO: x_set_icon_type, */ @@ -4660,7 +4720,7 @@ Chinese, Japanese, and Korean. */); load_font_func = x_load_font; find_ccl_program_func = x_find_ccl_program; query_font_func = x_query_font; - set_frame_fontset_func = x_set_font; + set_frame_fontset_func = mac_set_font; check_window_system_func = check_mac; hourglass_atimer = NULL; @@ -4679,6 +4739,10 @@ Chinese, Japanese, and Korean. */); #if TARGET_API_MAC_CARBON defsubr (&Sx_file_dialog); #endif + defsubr (&Smac_clear_font_name_table); +#if USE_MAC_FONT_PANEL + defsubr (&Smac_set_font_panel_visibility); +#endif } /* arch-tag: d7591289-f374-4377-b245-12f5dbbb8edc diff --git a/src/macgui.h b/src/macgui.h index c09f1a8d173..690840c6c33 100644 --- a/src/macgui.h +++ b/src/macgui.h @@ -105,6 +105,13 @@ typedef unsigned long Time; #endif #endif +/* Whether to use the standard Font Panel floating dialog. */ +#ifndef USE_MAC_FONT_PANEL +#if USE_ATSUI && MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 +#define USE_MAC_FONT_PANEL 1 +#endif +#endif + typedef WindowPtr Window; typedef GWorldPtr Pixmap; 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) menu_items_n_panes = XINT (XCAR (saved)); saved = XCDR (saved); menu_items_submenu_depth = XINT (XCAR (saved)); + return Qnil; } /* Push the whole state of menu_items processing onto the specpdl. @@ -634,6 +635,7 @@ cleanup_popup_menu (arg) Lisp_Object arg; { discard_menu_items (); + return Qnil; } DEFUN ("x-popup-menu", Fx_popup_menu, Sx_popup_menu, 2, 2, 0, diff --git a/src/macselect.c b/src/macselect.c index fe4a7c8eccc..1b6a1a46cc3 100644 --- a/src/macselect.c +++ b/src/macselect.c @@ -1,5 +1,5 @@ /* Selection processing for Emacs on Mac OS. - Copyright (C) 2005 Free Software Foundation, Inc. + Copyright (C) 2005, 2006 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -101,7 +101,7 @@ static Lisp_Object Qmac_scrap_name, Qmac_ostype; #ifdef MAC_OSX /* Selection name for communication via Services menu. */ -static Lisp_Object Vmac_services_selection; +static Lisp_Object Vmac_service_selection; #endif /* Get a reference to the scrap corresponding to the symbol SYM. The @@ -918,8 +918,8 @@ static struct int size, count; } deferred_apple_events; extern Lisp_Object Qundefined; -extern OSErr mac_store_apple_event P_ ((Lisp_Object, Lisp_Object, - const AEDesc *)); +extern void mac_store_apple_event P_ ((Lisp_Object, Lisp_Object, + const AEDesc *)); struct apple_event_binding { @@ -1079,9 +1079,8 @@ mac_handle_apple_event (apple_event, reply, refcon) { if (INTEGERP (binding)) return XINT (binding); - err = mac_store_apple_event (class_key, id_key, apple_event); - if (err == noErr) - return noErr; + mac_store_apple_event (class_key, id_key, apple_event); + return noErr; } } return errAEEventNotHandled; @@ -1146,6 +1145,198 @@ DEFUN ("mac-process-deferred-apple-events", Fmac_process_deferred_apple_events, } +#if TARGET_API_MAC_CARBON +static Lisp_Object Vmac_dnd_known_types; +static pascal OSErr mac_do_track_drag P_ ((DragTrackingMessage, WindowRef, + void *, DragRef)); +static pascal OSErr mac_do_receive_drag P_ ((WindowRef, void *, DragRef)); +static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL; +static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL; + +extern void mac_store_drag_event P_ ((WindowRef, Point, SInt16, + const AEDesc *)); + +static pascal OSErr +mac_do_track_drag (message, window, refcon, drag) + DragTrackingMessage message; + WindowRef window; + void *refcon; + DragRef drag; +{ + OSErr err = noErr; + static int can_accept; + UInt16 num_items, index; + + if (GetFrontWindowOfClass (kMovableModalWindowClass, false)) + return dragNotAcceptedErr; + + switch (message) + { + case kDragTrackingEnterHandler: + err = CountDragItems (drag, &num_items); + if (err != noErr) + break; + can_accept = 0; + for (index = 1; index <= num_items; index++) + { + ItemReference item; + FlavorFlags flags; + Lisp_Object rest; + + err = GetDragItemReferenceNumber (drag, index, &item); + if (err != noErr) + continue; + for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest)) + { + Lisp_Object str; + FlavorType type; + + str = XCAR (rest); + if (!(STRINGP (str) && SBYTES (str) == 4)) + continue; + type = EndianU32_BtoN (*((UInt32 *) SDATA (str))); + + err = GetFlavorFlags (drag, item, type, &flags); + if (err == noErr) + { + can_accept = 1; + break; + } + } + } + break; + + case kDragTrackingEnterWindow: + if (can_accept) + { + RgnHandle hilite_rgn = NewRgn (); + + if (hilite_rgn) + { + Rect r; + + GetWindowPortBounds (window, &r); + OffsetRect (&r, -r.left, -r.top); + RectRgn (hilite_rgn, &r); + ShowDragHilite (drag, hilite_rgn, true); + DisposeRgn (hilite_rgn); + } + SetThemeCursor (kThemeCopyArrowCursor); + } + break; + + case kDragTrackingInWindow: + break; + + case kDragTrackingLeaveWindow: + if (can_accept) + { + HideDragHilite (drag); + SetThemeCursor (kThemeArrowCursor); + } + break; + + case kDragTrackingLeaveHandler: + break; + } + + if (err != noErr) + return dragNotAcceptedErr; + return noErr; +} + +static pascal OSErr +mac_do_receive_drag (window, refcon, drag) + WindowRef window; + void *refcon; + DragRef drag; +{ + OSErr err; + int num_types, i; + Lisp_Object rest, str; + FlavorType *types; + AppleEvent apple_event; + Point mouse_pos; + SInt16 modifiers; + + if (GetFrontWindowOfClass (kMovableModalWindowClass, false)) + return dragNotAcceptedErr; + + num_types = 0; + for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest)) + { + str = XCAR (rest); + if (STRINGP (str) && SBYTES (str) == 4) + num_types++; + } + + types = xmalloc (sizeof (FlavorType) * num_types); + i = 0; + for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest)) + { + str = XCAR (rest); + if (STRINGP (str) && SBYTES (str) == 4) + types[i++] = EndianU32_BtoN (*((UInt32 *) SDATA (str))); + } + + err = create_apple_event_from_drag_ref (drag, num_types, types, + &apple_event); + xfree (types); + + if (err == noErr) + err = GetDragMouse (drag, &mouse_pos, NULL); + if (err == noErr) + { + GlobalToLocal (&mouse_pos); + err = GetDragModifiers (drag, NULL, NULL, &modifiers); + } + + if (err == noErr) + { + mac_store_drag_event (window, mouse_pos, modifiers, &apple_event); + AEDisposeDesc (&apple_event); + /* Post a harmless event so as to wake up from ReceiveNextEvent. */ + mac_post_mouse_moved_event (); + return noErr; + } + else + return dragNotAcceptedErr; +} +#endif /* TARGET_API_MAC_CARBON */ + +OSErr +install_drag_handler (window) + WindowRef window; +{ + OSErr err = noErr; + +#if TARGET_API_MAC_CARBON + if (mac_do_track_dragUPP == NULL) + mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag); + if (mac_do_receive_dragUPP == NULL) + mac_do_receive_dragUPP = NewDragReceiveHandlerUPP (mac_do_receive_drag); + + err = InstallTrackingHandler (mac_do_track_dragUPP, window, NULL); + if (err == noErr) + err = InstallReceiveHandler (mac_do_receive_dragUPP, window, NULL); +#endif + + return err; +} + +void +remove_drag_handler (window) + WindowRef window; +{ +#if TARGET_API_MAC_CARBON + if (mac_do_track_dragUPP) + RemoveTrackingHandler (mac_do_track_dragUPP, window); + if (mac_do_receive_dragUPP) + RemoveReceiveHandler (mac_do_receive_dragUPP, window); +#endif +} + + #ifdef MAC_OSX void init_service_handler () @@ -1158,7 +1349,7 @@ init_service_handler () GetEventTypeCount (specs), specs, NULL, NULL); } -extern OSErr mac_store_services_event P_ ((EventRef)); +extern OSStatus mac_store_service_event P_ ((EventRef)); static OSStatus copy_scrap_flavor_data (from_scrap, to_scrap, flavor_type) @@ -1215,12 +1406,12 @@ mac_handle_service_event (call_ref, event, data) Lisp_Object rest; ScrapFlavorType flavor_type; - /* Check if Vmac_services_selection is a valid selection that has a + /* Check if Vmac_service_selection is a valid selection that has a corresponding scrap. */ - if (!SYMBOLP (Vmac_services_selection)) + if (!SYMBOLP (Vmac_service_selection)) err = eventNotHandledErr; else - err = get_scrap_from_symbol (Vmac_services_selection, 0, &cur_scrap); + err = get_scrap_from_symbol (Vmac_service_selection, 0, &cur_scrap); if (!(err == noErr && cur_scrap)) return eventNotHandledErr; @@ -1257,7 +1448,7 @@ mac_handle_service_event (call_ref, event, data) if (err != noErr) break; - if (NILP (Fx_selection_owner_p (Vmac_services_selection))) + if (NILP (Fx_selection_owner_p (Vmac_service_selection))) break; else goto copy_all_flavors; @@ -1267,7 +1458,7 @@ mac_handle_service_event (call_ref, event, data) typeScrapRef, NULL, sizeof (ScrapRef), NULL, &specific_scrap); if (err != noErr - || NILP (Fx_selection_owner_p (Vmac_services_selection))) + || NILP (Fx_selection_owner_p (Vmac_service_selection))) { err = eventNotHandledErr; break; @@ -1342,7 +1533,7 @@ mac_handle_service_event (call_ref, event, data) if (!data_exists_p) err = eventNotHandledErr; else - err = mac_store_services_event (event); + err = mac_store_service_event (event); } break; } @@ -1408,10 +1599,21 @@ set to nil. */); doc: /* Keymap for Apple events handled by Emacs. */); Vmac_apple_event_map = Qnil; +#if TARGET_API_MAC_CARBON + DEFVAR_LISP ("mac-dnd-known-types", &Vmac_dnd_known_types, + doc: /* The types accepted by default for dropped data. +The types are chosen in the order they appear in the list. */); + Vmac_dnd_known_types = list4 (build_string ("hfs "), build_string ("utxt"), + build_string ("TEXT"), build_string ("TIFF")); +#ifdef MAC_OSX + Vmac_dnd_known_types = Fcons (build_string ("furl"), Vmac_dnd_known_types); +#endif +#endif + #ifdef MAC_OSX - DEFVAR_LISP ("mac-services-selection", &Vmac_services_selection, + DEFVAR_LISP ("mac-service-selection", &Vmac_service_selection, doc: /* Selection name for communication via Services menu. */); - Vmac_services_selection = intern ("PRIMARY"); + Vmac_service_selection = intern ("PRIMARY"); #endif QPRIMARY = intern ("PRIMARY"); staticpro (&QPRIMARY); diff --git a/src/macterm.c b/src/macterm.c index 8ddd8febd69..e3b8b3b5881 100644 --- a/src/macterm.c +++ b/src/macterm.c @@ -4099,6 +4099,11 @@ x_new_focus_frame (dpyinfo, frame) pending_autoraise_frame = dpyinfo->x_focus_frame; else pending_autoraise_frame = 0; + +#if USE_MAC_FONT_PANEL + if (frame) + mac_set_font_info_for_selection (frame, DEFAULT_FACE_ID, 0); +#endif } x_frame_rehighlight (dpyinfo); @@ -4456,35 +4461,11 @@ scroll_bar_timer_callback (timer, data) EventLoopTimerRef timer; void *data; { - EventRef event = NULL; - OSErr err; - - err = CreateEvent (NULL, kEventClassMouse, kEventMouseMoved, 0, - kEventAttributeNone, &event); - if (err == noErr) - { - Point mouse_pos; - - GetMouse (&mouse_pos); - LocalToGlobal (&mouse_pos); - err = SetEventParameter (event, kEventParamMouseLocation, typeQDPoint, - sizeof (Point), &mouse_pos); - } - if (err == noErr) - { - UInt32 modifiers = GetCurrentKeyModifiers (); + OSStatus err; - err = SetEventParameter (event, kEventParamKeyModifiers, typeUInt32, - sizeof (UInt32), &modifiers); - } - if (err == noErr) - err = PostEventToQueue (GetCurrentEventQueue (), event, - kEventPriorityStandard); + err = mac_post_mouse_moved_event (); if (err == noErr) scroll_bar_timer_event_posted_p = 1; - - if (event) - ReleaseEvent (event); } static OSStatus @@ -6386,7 +6367,12 @@ x_free_frame_resources (f) f->output_data.mac = NULL; if (f == dpyinfo->x_focus_frame) - dpyinfo->x_focus_frame = 0; + { + dpyinfo->x_focus_frame = 0; +#if USE_MAC_FONT_PANEL + mac_set_font_info_for_selection (NULL, DEFAULT_FACE_ID, 0); +#endif + } if (f == dpyinfo->x_focus_event_frame) dpyinfo->x_focus_event_frame = 0; if (f == dpyinfo->x_highlight_frame) @@ -6742,10 +6728,6 @@ xlfdpat_create (pattern) } return pat; - - error: - xlfdpat_destroy (pat); - return NULL; } static INLINE int @@ -6914,6 +6896,8 @@ static Lisp_Object fm_font_family_alist; #if USE_ATSUI /* Hash table linking font family names to ATSU font IDs. */ static Lisp_Object atsu_font_id_hash; +static Lisp_Object Vmac_atsu_font_table; +extern Lisp_Object QCfamily, QCweight, QCslant, Qnormal, Qbold, Qitalic; #endif /* Alist linking character set strings to Mac text encoding and Emacs @@ -7209,8 +7193,21 @@ init_font_name_table () NULL, NULL); if (err == noErr) { + FMFontFamily ff; + FMFontStyle style = normal; + decode_mac_font_name (name, name_len + 1, Qnil); family = make_unibyte_string (name, name_len); + FMGetFontFamilyInstanceFromFont (font_ids[i], &ff, &style); + Fputhash (make_unibyte_string ((char *)(font_ids + i), + sizeof (ATSUFontID)), + Fcons (QCfamily, + list5 (family, + QCweight, + style & bold ? Qbold : Qnormal, + QCslant, + style & italic ? Qitalic : Qnormal)), + Vmac_atsu_font_table); if (*name != '.' && hash_lookup (h, family, &hash_code) < 0) { @@ -7756,6 +7753,7 @@ XLoadQueryFont (Display *dpy, char *fontname) ATSUFontFeatureSelector selectors[] = {kAllTypeFeaturesOffSelector, kDecomposeDiacriticsSelector}; Lisp_Object font_id_cons; + FMFontStyle style; font_id_cons = Fgethash (make_unibyte_string (family, strlen (family)), atsu_font_id_hash, Qnil); @@ -7774,7 +7772,11 @@ XLoadQueryFont (Display *dpy, char *fontname) return NULL; err = ATSUSetAttributes (mac_style, sizeof (tags) / sizeof (tags[0]), tags, sizes, values); - fontnum = -1; + if (err != noErr) + return NULL; + err = FMGetFontFamilyInstanceFromFont (font_id, &fontnum, &style); + if (err != noErr) + fontnum = -1; scriptcode = kTextEncodingMacUnicode; } else @@ -7834,22 +7836,20 @@ XLoadQueryFont (Display *dpy, char *fontname) pcm_init (font->bounds.rows[0], 0x100); #if USE_CG_TEXT_DRAWING - { - FMFontFamily font_family; - FMFontStyle style; - ATSFontRef ats_font; + if (fontnum != -1) + { + FMFontStyle style; + ATSFontRef ats_font; - err = FMGetFontFamilyInstanceFromFont (font_id, &font_family, &style); - if (err == noErr) - err = FMGetFontFromFontFamilyInstance (font_family, fontface, + err = FMGetFontFromFontFamilyInstance (fontnum, fontface, &font_id, &style); - /* Use CG text drawing if italic/bold is not synthesized. */ - if (err == noErr && style == fontface) - { - ats_font = FMGetATSFontRefFromFont (font_id); - font->cg_font = CGFontCreateWithPlatformFont (&ats_font); - } - } + /* Use CG text drawing if italic/bold is not synthesized. */ + if (err == noErr && style == fontface) + { + ats_font = FMGetATSFontRefFromFont (font_id); + font->cg_font = CGFontCreateWithPlatformFont (&ats_font); + } + } if (font->cg_font) { @@ -8340,6 +8340,55 @@ x_find_ccl_program (fontp) } } +#if USE_MAC_FONT_PANEL +OSStatus +mac_set_font_info_for_selection (f, face_id, c) + struct frame *f; + int face_id, c; +{ + OSStatus err; + EventTargetRef target = NULL; + XFontStruct *font = NULL; + + if (f) + { + target = GetWindowEventTarget (FRAME_MAC_WINDOW (f)); + + if (FRAME_FACE_CACHE (f) && CHAR_VALID_P (c, 0)) + { + struct face *face; + + face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c); + face = FACE_FROM_ID (f, face_id); + font = face->font; + } + } + + if (font == NULL) + err = SetFontInfoForSelection (kFontSelectionATSUIType, 0, NULL, target); + else + { + if (font->mac_fontnum != -1) + { + FontSelectionQDStyle qd_style; + + qd_style.version = kFontSelectionQDStyleVersionZero; + qd_style.instance.fontFamily = font->mac_fontnum; + qd_style.instance.fontStyle = font->mac_fontface; + qd_style.size = font->mac_fontsize; + qd_style.hasColor = false; + + err = SetFontInfoForSelection (kFontSelectionQDType, + 1, &qd_style, target); + } + else + err = SetFontInfoForSelection (kFontSelectionATSUIType, + 1, &font->mac_style, target); + } + + return err; +} +#endif /* The Mac Event loop code */ @@ -8427,6 +8476,14 @@ Point saved_menu_event_location; /* Apple Events */ #if USE_CARBON_EVENTS static Lisp_Object Qhicommand; +#ifdef MAC_OSX +extern Lisp_Object Qwindow; +static Lisp_Object Qtoolbar_switch_mode; +#endif +#if USE_MAC_FONT_PANEL +extern Lisp_Object Qfont; +static Lisp_Object Qpanel_closed, Qselection; +#endif #endif extern int mac_ready_for_apple_events; extern Lisp_Object Qundefined; @@ -8436,18 +8493,14 @@ extern void mac_find_apple_event_spec P_ ((AEEventClass, AEEventID, Lisp_Object *)); extern OSErr init_coercion_handler P_ ((void)); -#if TARGET_API_MAC_CARBON /* Drag and Drop */ -static pascal OSErr mac_do_track_drag (DragTrackingMessage, WindowPtr, void*, DragReference); -static pascal OSErr mac_do_receive_drag (WindowPtr, void*, DragReference); -static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL; -static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL; -#endif +OSErr install_drag_handler P_ ((WindowRef)); +void remove_drag_handler P_ ((WindowRef)); #if USE_CARBON_EVENTS #ifdef MAC_OSX extern void init_service_handler (); -static Lisp_Object Qservices, Qpaste, Qperform; +static Lisp_Object Qservice, Qpaste, Qperform; #endif /* Window Event Handler */ static pascal OSStatus mac_handle_window_event (EventHandlerCallRef, @@ -8998,47 +9051,84 @@ do_zoom_window (WindowPtr w, int zoom_in_or_out) x_real_positions (f, &f->left_pos, &f->top_pos); } -OSErr +void mac_store_apple_event (class, id, desc) Lisp_Object class, id; const AEDesc *desc; { - OSErr err; struct input_event buf; - AEDesc *desc_copy; - desc_copy = xmalloc (sizeof (AEDesc)); - err = AEDuplicateDesc (desc, desc_copy); - if (err == noErr) - { - EVENT_INIT (buf); + EVENT_INIT (buf); + + buf.kind = MAC_APPLE_EVENT; + buf.x = class; + buf.y = id; + XSETFRAME (buf.frame_or_window, + mac_focus_frame (&one_mac_display_info)); + /* Now that Lisp object allocations are protected by BLOCK_INPUT, it + is safe to use them during read_socket_hook. */ + buf.arg = mac_aedesc_to_lisp (desc); + kbd_buffer_store_event (&buf); +} - buf.kind = MAC_APPLE_EVENT; - buf.x = class; - buf.y = id; - buf.code = (int)desc_copy; - XSETFRAME (buf.frame_or_window, - mac_focus_frame (&one_mac_display_info)); - buf.arg = Qnil; - kbd_buffer_store_event (&buf); +#if TARGET_API_MAC_CARBON +static OSStatus +mac_store_event_ref_as_apple_event (class, id, class_key, id_key, + event, num_params, names, types) + AEEventClass class; + AEEventID id; + Lisp_Object class_key, id_key; + EventRef event; + UInt32 num_params; + EventParamName *names; + EventParamType *types; +{ + OSStatus err = eventNotHandledErr; + Lisp_Object binding; + + mac_find_apple_event_spec (class, id, &class_key, &id_key, &binding); + if (!NILP (binding) && !EQ (binding, Qundefined)) + { + if (INTEGERP (binding)) + err = XINT (binding); + else + { + AppleEvent apple_event; + err = create_apple_event_from_event_ref (event, num_params, + names, types, + &apple_event); + if (err == noErr) + { + mac_store_apple_event (class_key, id_key, &apple_event); + AEDisposeDesc (&apple_event); + } + } } return err; } -Lisp_Object -mac_make_lispy_event_code (code) - int code; +void +mac_store_drag_event (window, mouse_pos, modifiers, desc) + WindowRef window; + Point mouse_pos; + SInt16 modifiers; + const AEDesc *desc; { - AEDesc *desc = (AEDesc *)code; - Lisp_Object obj; + struct input_event buf; - obj = mac_aedesc_to_lisp (desc); - AEDisposeDesc (desc); - xfree (desc); + EVENT_INIT (buf); - return obj; + buf.kind = DRAG_N_DROP_EVENT; + buf.modifiers = mac_to_emacs_modifiers (modifiers); + buf.timestamp = TickCount () * (1000 / 60); + XSETINT (buf.x, mouse_pos.h); + XSETINT (buf.y, mouse_pos.v); + XSETFRAME (buf.frame_or_window, mac_window_to_frame (window)); + buf.arg = mac_aedesc_to_lisp (desc); + kbd_buffer_store_event (&buf); } +#endif #if USE_CARBON_EVENTS static pascal OSStatus @@ -9049,7 +9139,11 @@ mac_handle_command_event (next_handler, event, data) { OSStatus result, err; HICommand command; - Lisp_Object class_key, id_key, binding; + static EventParamName names[] = {kEventParamDirectObject, + kEventParamKeyModifiers}; + static EventParamType types[] = {typeHICommand, + typeUInt32}; + int num_params = sizeof (names) / sizeof (names[0]); result = CallNextEventHandler (next_handler, event); if (result != eventNotHandledErr) @@ -9063,33 +9157,10 @@ mac_handle_command_event (next_handler, event, data) /* A HICommand event is mapped to an Apple event whose event class symbol is `hicommand' and event ID is its command ID. */ - class_key = Qhicommand; - mac_find_apple_event_spec (0, command.commandID, - &class_key, &id_key, &binding); - if (!NILP (binding) && !EQ (binding, Qundefined)) - { - if (INTEGERP (binding)) - return XINT (binding); - else - { - AppleEvent apple_event; - static EventParamName names[] = {kEventParamDirectObject, - kEventParamKeyModifiers}; - static EventParamType types[] = {typeHICommand, - typeUInt32}; - err = create_apple_event_from_event_ref (event, 2, names, types, - &apple_event); - if (err == noErr) - { - err = mac_store_apple_event (class_key, id_key, &apple_event); - AEDisposeDesc (&apple_event); - } - if (err == noErr) - return noErr; - } - } - - return eventNotHandledErr; + err = mac_store_event_ref_as_apple_event (0, command.commandID, + Qhicommand, Qnil, + event, num_params, names, types); + return err == noErr ? noErr : eventNotHandledErr; } static OSErr @@ -9192,6 +9263,33 @@ mac_handle_window_event (next_handler, event, data) return noErr; break; + +#ifdef MAC_OSX + case kEventWindowToolbarSwitchMode: + result = CallNextEventHandler (next_handler, event); + { + static EventParamName names[] = {kEventParamDirectObject, + kEventParamWindowMouseLocation, + kEventParamKeyModifiers, + kEventParamMouseButton, + kEventParamClickCount, + kEventParamMouseChord}; + static EventParamType types[] = {typeWindowRef, + typeQDPoint, + typeUInt32, + typeMouseButton, + typeUInt32, + typeUInt32}; + int num_params = sizeof (names) / sizeof (names[0]); + + err = mac_store_event_ref_as_apple_event (0, 0, + Qwindow, + Qtoolbar_switch_mode, + event, num_params, + names, types); + } + return err == noErr ? noErr : result; +#endif } return eventNotHandledErr; @@ -9266,45 +9364,96 @@ mac_handle_mouse_event (next_handler, event, data) return eventNotHandledErr; } +#if USE_MAC_FONT_PANEL +static pascal OSStatus +mac_handle_font_event (next_handler, event, data) + EventHandlerCallRef next_handler; + EventRef event; + void *data; +{ + OSStatus result, err; + Lisp_Object id_key; + int num_params; + EventParamName *names; + EventParamType *types; + static EventParamName names_sel[] = {kEventParamATSUFontID, + kEventParamATSUFontSize, + kEventParamFMFontFamily, + kEventParamFMFontSize, + kEventParamFontColor}; + static EventParamType types_sel[] = {typeATSUFontID, + typeATSUSize, + typeFMFontFamily, + typeFMFontSize, + typeFontColor}; + + result = CallNextEventHandler (next_handler, event); + if (result != eventNotHandledErr) + return result; + + switch (GetEventKind (event)) + { + case kEventFontPanelClosed: + id_key = Qpanel_closed; + num_params = 0; + names = NULL; + types = NULL; + break; + + case kEventFontSelection: + id_key = Qselection; + num_params = sizeof (names_sel) / sizeof (names_sel[0]); + names = names_sel; + types = types_sel; + break; + } + + err = mac_store_event_ref_as_apple_event (0, 0, Qfont, id_key, + event, num_params, + names, types); + + return err == noErr ? noErr : eventNotHandledErr; +} +#endif + #ifdef MAC_OSX -OSErr -mac_store_services_event (event) +OSStatus +mac_store_service_event (event) EventRef event; { - OSErr err; - AppleEvent apple_event; + OSStatus err; Lisp_Object id_key; + int num_params; + EventParamName *names; + EventParamType *types; + static EventParamName names_pfm[] = {kEventParamServiceMessageName, + kEventParamServiceUserData}; + static EventParamType types_pfm[] = {typeCFStringRef, + typeCFStringRef}; switch (GetEventKind (event)) { case kEventServicePaste: id_key = Qpaste; - err = create_apple_event_from_event_ref (event, 0, NULL, NULL, - &apple_event); + num_params = 0; + names = NULL; + types = NULL; break; case kEventServicePerform: - { - static EventParamName names[] = {kEventParamServiceMessageName, - kEventParamServiceUserData}; - static EventParamType types[] = {typeCFStringRef, - typeCFStringRef}; - - id_key = Qperform; - err = create_apple_event_from_event_ref (event, 2, names, types, - &apple_event); - } + id_key = Qperform; + num_params = sizeof (names_pfm) / sizeof (names_pfm[0]); + names = names_pfm; + types = types_pfm; break; default: abort (); } - if (err == noErr) - { - err = mac_store_apple_event (Qservices, id_key, &apple_event); - AEDisposeDesc (&apple_event); - } + err = mac_store_event_ref_as_apple_event (0, 0, Qservice, id_key, + event, num_params, + names, types); return err; } @@ -9324,15 +9473,28 @@ install_window_handler (window) {kEventClassWindow, kEventWindowShown}, {kEventClassWindow, kEventWindowHidden}, {kEventClassWindow, kEventWindowExpanded}, - {kEventClassWindow, kEventWindowCollapsed}}; + {kEventClassWindow, kEventWindowCollapsed}, +#ifdef MAC_OSX + {kEventClassWindow, kEventWindowToolbarSwitchMode}, +#endif + }; EventTypeSpec specs_mouse[] = {{kEventClassMouse, kEventMouseWheelMoved}}; static EventHandlerUPP handle_window_eventUPP = NULL; static EventHandlerUPP handle_mouse_eventUPP = NULL; +#if USE_MAC_FONT_PANEL + EventTypeSpec specs_font[] = {{kEventClassFont, kEventFontPanelClosed}, + {kEventClassFont, kEventFontSelection}}; + static EventHandlerUPP handle_font_eventUPP = NULL; +#endif if (handle_window_eventUPP == NULL) handle_window_eventUPP = NewEventHandlerUPP (mac_handle_window_event); if (handle_mouse_eventUPP == NULL) handle_mouse_eventUPP = NewEventHandlerUPP (mac_handle_mouse_event); +#if USE_MAC_FONT_PANEL + if (handle_font_eventUPP == NULL) + handle_font_eventUPP = NewEventHandlerUPP (mac_handle_font_event); +#endif err = InstallWindowEventHandler (window, handle_window_eventUPP, GetEventTypeCount (specs_window), specs_window, NULL, NULL); @@ -9340,18 +9502,16 @@ install_window_handler (window) err = InstallWindowEventHandler (window, handle_mouse_eventUPP, GetEventTypeCount (specs_mouse), specs_mouse, NULL, NULL); -#endif -#if TARGET_API_MAC_CARBON - if (mac_do_track_dragUPP == NULL) - mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag); - if (mac_do_receive_dragUPP == NULL) - mac_do_receive_dragUPP = NewDragReceiveHandlerUPP (mac_do_receive_drag); - +#if USE_MAC_FONT_PANEL if (err == noErr) - err = InstallTrackingHandler (mac_do_track_dragUPP, window, NULL); - if (err == noErr) - err = InstallReceiveHandler (mac_do_receive_dragUPP, window, NULL); + err = InstallWindowEventHandler (window, handle_font_eventUPP, + GetEventTypeCount (specs_font), + specs_font, NULL, NULL); +#endif #endif + if (err == noErr) + err = install_drag_handler (window); + return err; } @@ -9359,167 +9519,9 @@ void remove_window_handler (window) WindowPtr window; { -#if TARGET_API_MAC_CARBON - if (mac_do_track_dragUPP) - RemoveTrackingHandler (mac_do_track_dragUPP, window); - if (mac_do_receive_dragUPP) - RemoveReceiveHandler (mac_do_receive_dragUPP, window); -#endif + remove_drag_handler (window); } -#if TARGET_API_MAC_CARBON -static pascal OSErr -mac_do_track_drag (DragTrackingMessage message, WindowPtr window, - void *handlerRefCon, DragReference theDrag) -{ - static int can_accept; - short items; - short index; - ItemReference theItem; - FlavorFlags theFlags; - OSErr result; - - if (GetFrontWindowOfClass (kMovableModalWindowClass, false)) - return dragNotAcceptedErr; - - switch (message) - { - case kDragTrackingEnterHandler: - CountDragItems (theDrag, &items); - can_accept = 0; - for (index = 1; index <= items; index++) - { - GetDragItemReferenceNumber (theDrag, index, &theItem); - result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags); - if (result == noErr) - { - can_accept = 1; - break; - } - } - break; - - case kDragTrackingEnterWindow: - if (can_accept) - { - RgnHandle hilite_rgn = NewRgn (); - Rect r; - struct frame *f = mac_window_to_frame (window); - - GetWindowPortBounds (window, &r); - OffsetRect (&r, -r.left, -r.top); - RectRgn (hilite_rgn, &r); - ShowDragHilite (theDrag, hilite_rgn, true); - DisposeRgn (hilite_rgn); - SetThemeCursor (kThemeCopyArrowCursor); - } - break; - - case kDragTrackingInWindow: - break; - - case kDragTrackingLeaveWindow: - if (can_accept) - { - struct frame *f = mac_window_to_frame (window); - - HideDragHilite (theDrag); - SetThemeCursor (kThemeArrowCursor); - } - break; - - case kDragTrackingLeaveHandler: - break; - } - - return noErr; -} - -static pascal OSErr -mac_do_receive_drag (WindowPtr window, void *handlerRefCon, - DragReference theDrag) -{ - short items; - short index; - FlavorFlags theFlags; - Point mouse; - OSErr result; - ItemReference theItem; - HFSFlavor data; - Size size = sizeof (HFSFlavor); - Lisp_Object file_list; - - if (GetFrontWindowOfClass (kMovableModalWindowClass, false)) - return dragNotAcceptedErr; - - file_list = Qnil; - GetDragMouse (theDrag, &mouse, 0L); - CountDragItems (theDrag, &items); - for (index = 1; index <= items; index++) - { - /* Only handle file references. */ - GetDragItemReferenceNumber (theDrag, index, &theItem); - result = GetFlavorFlags (theDrag, theItem, flavorTypeHFS, &theFlags); - if (result == noErr) - { - OSErr err; - AEDesc desc; - - err = GetFlavorData (theDrag, theItem, flavorTypeHFS, - &data, &size, 0L); - if (err == noErr) - err = AECoercePtr (typeFSS, &data.fileSpec, sizeof (FSSpec), - TYPE_FILE_NAME, &desc); - if (err == noErr) - { - Lisp_Object file; - - /* x-dnd functions expect undecoded filenames. */ - file = make_uninit_string (AEGetDescDataSize (&desc)); - err = AEGetDescData (&desc, SDATA (file), SBYTES (file)); - if (err == noErr) - file_list = Fcons (file, file_list); - AEDisposeDesc (&desc); - } - } - } - /* If there are items in the list, construct an event and post it to - the queue like an interrupt using kbd_buffer_store_event. */ - if (!NILP (file_list)) - { - struct input_event event; - Lisp_Object frame; - struct frame *f = mac_window_to_frame (window); - SInt16 modifiers; - - GlobalToLocal (&mouse); - GetDragModifiers (theDrag, NULL, NULL, &modifiers); - - event.kind = DRAG_N_DROP_EVENT; - event.code = 0; - event.modifiers = mac_to_emacs_modifiers (modifiers); - event.timestamp = TickCount () * (1000 / 60); - XSETINT (event.x, mouse.h); - XSETINT (event.y, mouse.v); - XSETFRAME (frame, f); - event.frame_or_window = frame; - event.arg = file_list; - /* Post to the interrupt queue */ - kbd_buffer_store_event (&event); - /* MAC_TODO: Mimic behavior of windows by switching contexts to Emacs */ - { - ProcessSerialNumber psn; - GetCurrentProcess (&psn); - SetFrontProcess (&psn); - } - - return noErr; - } - else - return dragNotAcceptedErr; -} -#endif - #if __profile__ void @@ -9805,6 +9807,41 @@ mac_wait_next_event (er, sleep_time, dequeue) } #endif /* not USE_CARBON_EVENTS */ +#if TARGET_API_MAC_CARBON +OSStatus +mac_post_mouse_moved_event () +{ + EventRef event = NULL; + OSStatus err; + + err = CreateEvent (NULL, kEventClassMouse, kEventMouseMoved, 0, + kEventAttributeNone, &event); + if (err == noErr) + { + Point mouse_pos; + + GetMouse (&mouse_pos); + LocalToGlobal (&mouse_pos); + err = SetEventParameter (event, kEventParamMouseLocation, typeQDPoint, + sizeof (Point), &mouse_pos); + } + if (err == noErr) + { + UInt32 modifiers = GetCurrentKeyModifiers (); + + err = SetEventParameter (event, kEventParamKeyModifiers, typeUInt32, + sizeof (UInt32), &modifiers); + } + if (err == noErr) + err = PostEventToQueue (GetCurrentEventQueue (), event, + kEventPriorityStandard); + if (event) + ReleaseEvent (event); + + return err; +} +#endif + /* Emacs calls this whenever it wants to read an input event from the user. */ int @@ -9932,7 +9969,13 @@ XTread_socket (sd, expected, hold_quit) break; case inContent: - if (window_ptr != FRAME_MAC_WINDOW (mac_focus_frame (dpyinfo))) + if ( +#if TARGET_API_MAC_CARBON + FrontNonFloatingWindow () +#else + FrontWindow () +#endif + != window_ptr) SelectWindow (window_ptr); else { @@ -10079,20 +10122,18 @@ XTread_socket (sd, expected, hold_quit) } break; -#if TARGET_API_MAC_CARBON - case inProxyIcon: - if (TrackWindowProxyDrag (window_ptr, er.where) - != errUserWantsToDragWindow) - break; - /* fall through */ -#endif case inDrag: #if TARGET_API_MAC_CARBON + case inProxyIcon: if (IsWindowPathSelectClick (window_ptr, &er)) { WindowPathSelect (window_ptr, NULL, NULL); break; } + if (part_code == inProxyIcon + && (TrackWindowProxyDrag (window_ptr, er.where) + != errUserWantsToDragWindow)) + break; DragWindow (window_ptr, er.where, NULL); #else /* not TARGET_API_MAC_CARBON */ DragWindow (window_ptr, er.where, &qd.screenBits.bounds); @@ -11030,7 +11071,14 @@ syms_of_macterm () #if USE_CARBON_EVENTS Qhicommand = intern ("hicommand"); staticpro (&Qhicommand); #ifdef MAC_OSX - Qservices = intern ("services"); staticpro (&Qservices); + Qtoolbar_switch_mode = intern ("toolbar-switch-mode"); + staticpro (&Qtoolbar_switch_mode); +#if USE_MAC_FONT_PANEL + Qpanel_closed = intern ("panel-closed"); staticpro (&Qpanel_closed); + Qselection = intern ("selection"); staticpro (&Qselection); +#endif + + Qservice = intern ("service"); staticpro (&Qservice); Qpaste = intern ("paste"); staticpro (&Qpaste); Qperform = intern ("perform"); staticpro (&Qperform); #endif @@ -11070,7 +11118,7 @@ NOTE: Not supported on Mac yet. */); x_use_underline_position_properties = 0; DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars, - doc: /* If not nil, Emacs uses toolkit scroll bars. */); + doc: /* If not nil, Emacs uses toolkit scroll bars. */); #ifdef USE_TOOLKIT_SCROLL_BARS Vx_toolkit_scroll_bars = Qt; #else @@ -11124,23 +11172,23 @@ mouse-3 and the command-key will register for mouse-2. */); #if USE_CARBON_EVENTS DEFVAR_BOOL ("mac-wheel-button-is-mouse-2", &mac_wheel_button_is_mouse_2, - doc: /* *Non-nil if the wheel button is mouse-2 and the right click mouse-3. + doc: /* *Non-nil if the wheel button is mouse-2 and the right click mouse-3. Otherwise, the right click will be treated as mouse-2 and the wheel button will be mouse-3. */); mac_wheel_button_is_mouse_2 = 1; DEFVAR_BOOL ("mac-pass-command-to-system", &mac_pass_command_to_system, - doc: /* *Non-nil if command key presses are passed on to the Mac Toolbox. */); + doc: /* *Non-nil if command key presses are passed on to the Mac Toolbox. */); mac_pass_command_to_system = 1; DEFVAR_BOOL ("mac-pass-control-to-system", &mac_pass_control_to_system, - doc: /* *Non-nil if control key presses are passed on to the Mac Toolbox. */); + doc: /* *Non-nil if control key presses are passed on to the Mac Toolbox. */); mac_pass_control_to_system = 1; #endif DEFVAR_BOOL ("mac-allow-anti-aliasing", &mac_use_core_graphics, - doc: /* *If non-nil, allow anti-aliasing. + doc: /* *If non-nil, allow anti-aliasing. The text will be rendered using Core Graphics text rendering which may anti-alias the text. */); #if USE_CG_DRAWING @@ -11153,7 +11201,7 @@ may anti-alias the text. */); creating the terminal frame on Mac OS 9 before loading term/mac-win.elc. */ DEFVAR_LISP ("mac-charset-info-alist", &Vmac_charset_info_alist, - doc: /* Alist of Emacs character sets vs text encodings and coding systems. + doc: /* Alist of Emacs character sets vs text encodings and coding systems. Each entry should be of the form: (CHARSET-NAME TEXT-ENCODING CODING-SYSTEM) @@ -11164,6 +11212,18 @@ CODING_SYSTEM is a coding system corresponding to TEXT-ENCODING. */); Vmac_charset_info_alist = Fcons (list3 (build_string ("mac-roman"), make_number (smRoman), Qnil), Qnil); + +#if USE_ATSUI + DEFVAR_LISP ("mac-atsu-font-table", &Vmac_atsu_font_table, + doc: /* Hash table of ATSU font IDs vs plist of attributes and values. +Each font ID is represented as a four-byte string in native byte +order. */); + Vmac_atsu_font_table = + make_hash_table (Qequal, make_number (DEFAULT_HASH_SIZE), + make_float (DEFAULT_REHASH_SIZE), + make_float (DEFAULT_REHASH_THRESHOLD), + Qnil, Qnil, Qnil); +#endif } /* arch-tag: f2259165-4454-4c04-a029-a133c8af7b5b diff --git a/src/macterm.h b/src/macterm.h index f23554f01c6..8b45777e546 100644 --- a/src/macterm.h +++ b/src/macterm.h @@ -584,10 +584,11 @@ extern void mac_draw_line_to_pixmap P_ ((Display *, Pixmap, GC, int, int, extern void mac_clear_area P_ ((struct frame *, int, int, unsigned int, unsigned int)); extern void mac_unload_font P_ ((struct mac_display_info *, XFontStruct *)); +extern OSStatus mac_set_font_info_for_selection P_ ((struct frame *, int, int)); extern OSErr install_window_handler P_ ((WindowPtr)); extern void remove_window_handler P_ ((WindowPtr)); -extern Lisp_Object mac_make_lispy_event_code P_ ((int)); extern void do_menu_choice P_ ((SInt32)); +extern OSStatus mac_post_mouse_moved_event P_ ((void)); #if USE_CG_DRAWING extern void mac_prepare_for_quickdraw P_ ((struct frame *)); #endif @@ -623,12 +624,15 @@ extern void free_frame_menubar P_ ((struct frame *)); /* Defined in mac.c. */ extern void mac_clear_font_name_table P_ ((void)); -extern Lisp_Object mac_aedesc_to_lisp P_ ((AEDesc *)); +extern Lisp_Object mac_aedesc_to_lisp P_ ((const AEDesc *)); #if TARGET_API_MAC_CARBON extern OSErr create_apple_event_from_event_ref P_ ((EventRef, UInt32, EventParamName *, EventParamType *, AppleEvent *)); +extern OSErr create_apple_event_from_drag_ref P_ ((DragRef, UInt32, + FlavorType *, + AppleEvent *)); extern CFStringRef cfstring_create_with_utf8_cstring P_ ((const char *)); extern CFStringRef cfstring_create_with_string P_ ((Lisp_Object)); extern Lisp_Object cfdata_to_lisp P_ ((CFDataRef)); diff --git a/src/minibuf.c b/src/minibuf.c index 2894eb19324..d37f82c9dcd 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -523,7 +523,7 @@ read_minibuf (map, initial, prompt, backup_n, expflag, build_string ("Command attempted to use minibuffer while in minibuffer")); } - if (noninteractive) + if (noninteractive && NILP (Vexecuting_kbd_macro)) { val = read_minibuf_noninteractive (map, initial, prompt, make_number (pos), @@ -2790,7 +2790,7 @@ syms_of_minibuf () DEFVAR_LISP ("history-length", &Vhistory_length, doc: /* *Maximum length for history lists before truncation takes place. A number means that length; t means infinite. Truncation takes place -just after a new element is inserted. Setting the history-length +just after a new element is inserted. Setting the `history-length' property of a history variable overrides this default. */); XSETFASTINT (Vhistory_length, 30); diff --git a/src/process.c b/src/process.c index 8e4a0d22160..4e2717577cd 100644 --- a/src/process.c +++ b/src/process.c @@ -696,6 +696,8 @@ setup_process_coding_systems (process) = (struct coding_system *) xmalloc (sizeof (struct coding_system)); setup_coding_system (p->encode_coding_system, proc_encode_coding_system[outch]); + if (proc_encode_coding_system[outch]->eol_type == CODING_EOL_UNDECIDED) + proc_encode_coding_system[outch]->eol_type = system_eol_type; } DEFUN ("processp", Fprocessp, Sprocessp, 1, 1, 0, @@ -5067,6 +5069,10 @@ read_process_output (proc, channel) p->encode_coding_system = Vlast_coding_system_used; setup_coding_system (p->encode_coding_system, proc_encode_coding_system[XINT (p->outfd)]); + if (proc_encode_coding_system[XINT (p->outfd)]->eol_type + == CODING_EOL_UNDECIDED) + proc_encode_coding_system[XINT (p->outfd)]->eol_type + = system_eol_type; } } @@ -5176,6 +5182,10 @@ read_process_output (proc, channel) p->encode_coding_system = Vlast_coding_system_used; setup_coding_system (p->encode_coding_system, proc_encode_coding_system[XINT (p->outfd)]); + if (proc_encode_coding_system[XINT (p->outfd)]->eol_type + == CODING_EOL_UNDECIDED) + proc_encode_coding_system[XINT (p->outfd)]->eol_type + = system_eol_type; } } if (coding->carryover_bytes > 0) diff --git a/src/sound.c b/src/sound.c index c1d5c40e9bb..0fbeceb4b9e 100644 --- a/src/sound.c +++ b/src/sound.c @@ -452,13 +452,12 @@ static Lisp_Object sound_cleanup (arg) Lisp_Object arg; { - if (current_sound_device) - { - if (current_sound_device->close) - current_sound_device->close (current_sound_device); - if (current_sound->fd > 0) - emacs_close (current_sound->fd); - } + if (current_sound_device->close) + current_sound_device->close (current_sound_device); + if (current_sound->fd > 0) + emacs_close (current_sound->fd); + free (current_sound_device); + free (current_sound); return Qnil; } @@ -991,8 +990,6 @@ Internal use only, use `play-sound' instead.\n */) #ifndef WINDOWSNT Lisp_Object file; struct gcpro gcpro1, gcpro2; - struct sound_device sd; - struct sound s; Lisp_Object args[2]; #else /* WINDOWSNT */ int len = 0; @@ -1010,48 +1007,50 @@ Internal use only, use `play-sound' instead.\n */) #ifndef WINDOWSNT file = Qnil; GCPRO2 (sound, file); - bzero (&sd, sizeof sd); - bzero (&s, sizeof s); - current_sound_device = &sd; - current_sound = &s; + current_sound_device = (struct sound_device *) xmalloc (sizeof (struct sound_device)); + bzero (current_sound_device, sizeof (struct sound_device)); + current_sound = (struct sound *) xmalloc (sizeof (struct sound)); + bzero (current_sound, sizeof (struct sound)); record_unwind_protect (sound_cleanup, Qnil); - s.header = (char *) alloca (MAX_SOUND_HEADER_BYTES); + current_sound->header = (char *) alloca (MAX_SOUND_HEADER_BYTES); if (STRINGP (attrs[SOUND_FILE])) { /* Open the sound file. */ - s.fd = openp (Fcons (Vdata_directory, Qnil), - attrs[SOUND_FILE], Qnil, &file, Qnil); - if (s.fd < 0) + current_sound->fd = openp (Fcons (Vdata_directory, Qnil), + attrs[SOUND_FILE], Qnil, &file, Qnil); + if (current_sound->fd < 0) sound_perror ("Could not open sound file"); /* Read the first bytes from the file. */ - s.header_size = emacs_read (s.fd, s.header, MAX_SOUND_HEADER_BYTES); - if (s.header_size < 0) + current_sound->header_size + = emacs_read (current_sound->fd, current_sound->header, + MAX_SOUND_HEADER_BYTES); + if (current_sound->header_size < 0) sound_perror ("Invalid sound file header"); } else { - s.data = attrs[SOUND_DATA]; - s.header_size = min (MAX_SOUND_HEADER_BYTES, SBYTES (s.data)); - bcopy (SDATA (s.data), s.header, s.header_size); + current_sound->data = attrs[SOUND_DATA]; + current_sound->header_size = min (MAX_SOUND_HEADER_BYTES, SBYTES (current_sound->data)); + bcopy (SDATA (current_sound->data), current_sound->header, current_sound->header_size); } /* Find out the type of sound. Give up if we can't tell. */ - find_sound_type (&s); + find_sound_type (current_sound); /* Set up a device. */ if (STRINGP (attrs[SOUND_DEVICE])) { int len = SCHARS (attrs[SOUND_DEVICE]); - sd.file = (char *) alloca (len + 1); - strcpy (sd.file, SDATA (attrs[SOUND_DEVICE])); + current_sound_device->file = (char *) alloca (len + 1); + strcpy (current_sound_device->file, SDATA (attrs[SOUND_DEVICE])); } if (INTEGERP (attrs[SOUND_VOLUME])) - sd.volume = XFASTINT (attrs[SOUND_VOLUME]); + current_sound_device->volume = XFASTINT (attrs[SOUND_VOLUME]); else if (FLOATP (attrs[SOUND_VOLUME])) - sd.volume = XFLOAT_DATA (attrs[SOUND_VOLUME]) * 100; + current_sound_device->volume = XFLOAT_DATA (attrs[SOUND_VOLUME]) * 100; args[0] = Qplay_sound_functions; args[1] = sound; @@ -1060,27 +1059,15 @@ Internal use only, use `play-sound' instead.\n */) /* There is only one type of device we currently support, the VOX sound driver. Set up the device interface functions for that device. */ - vox_init (&sd); + vox_init (current_sound_device); /* Open the device. */ - sd.open (&sd); + current_sound_device->open (current_sound_device); /* Play the sound. */ - s.play (&s, &sd); - - /* Close the input file, if any. */ - if (!STRINGP (s.data)) - { - emacs_close (s.fd); - s.fd = -1; - } - - /* Close the device. */ - sd.close (&sd); + current_sound->play (current_sound, current_sound_device); /* Clean up. */ - current_sound_device = NULL; - current_sound = NULL; UNGCPRO; #else /* WINDOWSNT */ diff --git a/src/termhooks.h b/src/termhooks.h index 8405cac3b88..de43d580c9b 100644 --- a/src/termhooks.h +++ b/src/termhooks.h @@ -332,9 +332,9 @@ enum event_kind /* Generated when an Apple event, a HICommand event, or a Services menu event is received and the corresponding handler is registered. Members `x' and `y' are for the event class and ID - symbols, respectively. Member `code' points to the Apple event - descriptor. Parameters for Non-Apple events are converted to - those in Apple events. */ + symbols, respectively. Member `arg' is a Lisp object converted + from the received Apple event. Parameters for non-Apple events + are converted to those in Apple events. */ MAC_APPLE_EVENT #endif }; diff --git a/src/xdisp.c b/src/xdisp.c index 63a1338b2cb..b1404d9c593 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -4543,6 +4543,24 @@ handle_composition_prop (it) if (id >= 0) { + struct composition *cmp = composition_table[id]; + + if (cmp->glyph_len == 0) + { + /* No glyph. */ + if (STRINGP (it->string)) + { + IT_STRING_CHARPOS (*it) = end; + IT_STRING_BYTEPOS (*it) = string_char_to_byte (it->string, + end); + } + else + { + IT_CHARPOS (*it) = end; + IT_BYTEPOS (*it) = CHAR_TO_BYTE (end); + } + return HANDLED_RECOMPUTE_PROPS; + } it->method = GET_FROM_COMPOSITION; it->cmp_id = id; it->cmp_len = COMPOSITION_LENGTH (prop); diff --git a/src/xfaces.c b/src/xfaces.c index 3a066ee12c3..5596d5dc613 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -7255,6 +7255,16 @@ realize_default_face (f) check_lface (lface); bcopy (XVECTOR (lface)->contents, attrs, sizeof attrs); face = realize_face (c, attrs, DEFAULT_FACE_ID); + +#ifdef HAVE_WINDOW_SYSTEM +#ifdef HAVE_X_WINDOWS + if (face->font != FRAME_FONT (f)) + /* As the font specified for the frame was not acceptable as a + font for the default face (perhaps because auto-scaled fonts + are rejected), we must adjust the frame font. */ + x_set_font (f, build_string (face->font_name), Qnil); +#endif /* HAVE_X_WINDOWS */ +#endif /* HAVE_WINDOW_SYSTEM */ return 1; } |