X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/f6c62d96905001cee7e45e1e4e621fdcda9dabbf..974aae61bbb8c05e0d0fc1a95b419fe596423fd8:/src/macfns.c diff --git a/src/macfns.c b/src/macfns.c index 416522b49b..daa1767fd5 100644 --- a/src/macfns.c +++ b/src/macfns.c @@ -15,65 +15,40 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ /* Contributed by Andrew Choi (akochoi@mac.com). */ #include - -#include #include #include -#include -#include #include "lisp.h" -#include "charset.h" #include "macterm.h" #include "frame.h" #include "window.h" #include "buffer.h" -#include "dispextern.h" -#include "fontset.h" #include "intervals.h" +#include "dispextern.h" #include "keyboard.h" #include "blockinput.h" -#include "epaths.h" -#include "termhooks.h" +#include +#include "charset.h" #include "coding.h" +#include "fontset.h" #include "systime.h" +#include "termhooks.h" +#include "atimer.h" -/* #include "bitmaps/gray.xbm" */ -#define gray_width 2 -#define gray_height 2 -static unsigned char gray_bits[] = { - 0x01, 0x02}; - -/*#include -#include */ #include #include #include +#include +#include #include -#include -#include - -/*extern void free_frame_menubar (); -extern double atof (); -extern int w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state); -extern int quit_char;*/ - -extern char *lispy_function_keys[]; - -/* The gray bitmap `bitmaps/gray'. This is done because macterm.c uses - it, and including `bitmaps/gray' more than once is a problem when - config.h defines `static' as an empty replacement string. */ - -int gray_bitmap_width = gray_width; -int gray_bitmap_height = gray_height; -unsigned char *gray_bitmap_bits = gray_bits; +extern void free_frame_menubar (); /* Non-zero means we're allowed to display an hourglass cursor. */ @@ -110,52 +85,12 @@ Lisp_Object Vx_no_window_manager; Lisp_Object Vx_pixel_size_width_font_regexp; -/* Evaluate this expression to rebuild the section of syms_of_macfns - that initializes and staticpros the symbols declared below. Note - that Emacs 18 has a bug that keeps C-x C-e from being able to - evaluate this expression. - -(progn - ;; Accumulate a list of the symbols we want to initialize from the - ;; declarations at the top of the file. - (goto-char (point-min)) - (search-forward "/\*&&& symbols declared here &&&*\/\n") - (let (symbol-list) - (while (looking-at "Lisp_Object \\(Q[a-z_]+\\)") - (setq symbol-list - (cons (buffer-substring (match-beginning 1) (match-end 1)) - symbol-list)) - (forward-line 1)) - (setq symbol-list (nreverse symbol-list)) - ;; Delete the section of syms_of_... where we initialize the symbols. - (search-forward "\n /\*&&& init symbols here &&&*\/\n") - (let ((start (point))) - (while (looking-at "^ Q") - (forward-line 2)) - (kill-region start (point))) - ;; Write a new symbol initialization section. - (while symbol-list - (insert (format " %s = intern (\"" (car symbol-list))) - (let ((start (point))) - (insert (substring (car symbol-list) 1)) - (subst-char-in-region start (point) ?_ ?-)) - (insert (format "\");\n staticpro (&%s);\n" (car symbol-list))) - (setq symbol-list (cdr symbol-list))))) - - */ - -/*&&& symbols declared here &&&*/ Lisp_Object Qnone; Lisp_Object Qsuppress_icon; Lisp_Object Qundefined_color; Lisp_Object Qcancel_timer; -Lisp_Object Qhyper; -Lisp_Object Qsuper; -Lisp_Object Qmeta; -Lisp_Object Qalt; -Lisp_Object Qctrl; -Lisp_Object Qcontrol; -Lisp_Object Qshift; + +/* In dispnew.c */ extern Lisp_Object Vwindow_system_version; @@ -216,7 +151,7 @@ check_x_frame (frame) CHECK_LIVE_FRAME (frame); f = XFRAME (frame); if (! FRAME_MAC_P (f)) - error ("non-mac frame used"); + error ("Non-Mac frame used"); return f; } @@ -251,40 +186,11 @@ check_x_display_info (frame) return dpyinfo; } - -/* Return the Emacs frame-object corresponding to a mac window. - It could be the frame's main window or an icon window. */ - -/* This function can be called during GC, so use GC_xxx type test macros. */ - -struct frame * -x_window_to_frame (dpyinfo, wdesc) - struct mac_display_info *dpyinfo; - WindowPtr wdesc; -{ - Lisp_Object tail, frame; - struct frame *f; - - for (tail = Vframe_list; GC_CONSP (tail); tail = XCDR (tail)) - { - frame = XCAR (tail); - if (!GC_FRAMEP (frame)) - continue; - f = XFRAME (frame); - if (!FRAME_W32_P (f) || FRAME_MAC_DISPLAY_INFO (f) != dpyinfo) - continue; - /*if (f->output_data.w32->hourglass_window == wdesc) - return f;*/ - - /* MAC_TODO: Check tooltips when supported. */ - if (FRAME_MAC_WINDOW (f) == wdesc) - return f; - } - return 0; -} + static Lisp_Object unwind_create_frame P_ ((Lisp_Object)); +static Lisp_Object unwind_create_tip_frame P_ ((Lisp_Object)); void x_set_foreground_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); void x_set_background_color P_ ((struct frame *, Lisp_Object, Lisp_Object)); @@ -310,6 +216,8 @@ static Lisp_Object x_default_scroll_bar_color_parameter P_ ((struct frame *, extern void mac_get_window_bounds P_ ((struct frame *, Rect *, Rect *)); + + /* Store the screen positions of frame F into XPTR and YPTR. These are the positions of the containing window manager window, not Emacs's own window. */ @@ -1453,148 +1361,99 @@ x_set_mouse_color (f, arg, oldval) struct frame *f; Lisp_Object arg, oldval; { + struct x_output *x = f->output_data.x; + Display *dpy = FRAME_MAC_DISPLAY (f); Cursor cursor, nontext_cursor, mode_cursor, hand_cursor; - int count; - int mask_color; - - if (!EQ (Qnil, arg)) - f->output_data.mac->mouse_pixel - = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); - mask_color = FRAME_BACKGROUND_PIXEL (f); + Cursor hourglass_cursor, horizontal_drag_cursor; + unsigned long pixel = x_decode_color (f, arg, BLACK_PIX_DEFAULT (f)); + unsigned long mask_color = x->background_pixel; /* Don't let pointers be invisible. */ - if (mask_color == f->output_data.mac->mouse_pixel - && mask_color == FRAME_BACKGROUND_PIXEL (f)) - f->output_data.mac->mouse_pixel = FRAME_FOREGROUND_PIXEL (f); - -#if 0 /* MAC_TODO : cursor changes */ - BLOCK_INPUT; + if (mask_color == pixel) + pixel = x->foreground_pixel; - /* It's not okay to crash if the user selects a screwy cursor. */ - count = x_catch_errors (FRAME_W32_DISPLAY (f)); + f->output_data.mac->mouse_pixel = pixel; - if (!EQ (Qnil, Vx_pointer_shape)) + if (!NILP (Vx_pointer_shape)) { CHECK_NUMBER (Vx_pointer_shape); - cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XINT (Vx_pointer_shape)); + cursor = XINT (Vx_pointer_shape); } else - cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_xterm); - x_check_errors (FRAME_W32_DISPLAY (f), "bad text pointer cursor: %s"); + cursor = kThemeIBeamCursor; - if (!EQ (Qnil, Vx_nontext_pointer_shape)) + if (!NILP (Vx_nontext_pointer_shape)) { CHECK_NUMBER (Vx_nontext_pointer_shape); - nontext_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), - XINT (Vx_nontext_pointer_shape)); + nontext_cursor = XINT (Vx_nontext_pointer_shape); } else - nontext_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_left_ptr); - x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s"); + nontext_cursor = kThemeArrowCursor; - if (!EQ (Qnil, Vx_hourglass_pointer_shape)) + if (!NILP (Vx_hourglass_pointer_shape)) { CHECK_NUMBER (Vx_hourglass_pointer_shape); - hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), - XINT (Vx_hourglass_pointer_shape)); + hourglass_cursor = XINT (Vx_hourglass_pointer_shape); } else - hourglass_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_watch); - x_check_errors (FRAME_W32_DISPLAY (f), "bad busy pointer cursor: %s"); + hourglass_cursor = kThemeWatchCursor; - x_check_errors (FRAME_W32_DISPLAY (f), "bad nontext pointer cursor: %s"); - if (!EQ (Qnil, Vx_mode_pointer_shape)) + if (!NILP (Vx_mode_pointer_shape)) { CHECK_NUMBER (Vx_mode_pointer_shape); - mode_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), - XINT (Vx_mode_pointer_shape)); + mode_cursor = XINT (Vx_mode_pointer_shape); } else - mode_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_xterm); - x_check_errors (FRAME_W32_DISPLAY (f), "bad modeline pointer cursor: %s"); + mode_cursor = kThemeArrowCursor; - if (!EQ (Qnil, Vx_sensitive_text_pointer_shape)) + if (!NILP (Vx_sensitive_text_pointer_shape)) { CHECK_NUMBER (Vx_sensitive_text_pointer_shape); - hand_cursor - = XCreateFontCursor (FRAME_W32_DISPLAY (f), - XINT (Vx_sensitive_text_pointer_shape)); + hand_cursor = XINT (Vx_sensitive_text_pointer_shape); } else - hand_cursor = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_crosshair); + hand_cursor = kThemePointingHandCursor; if (!NILP (Vx_window_horizontal_drag_shape)) { CHECK_NUMBER (Vx_window_horizontal_drag_shape); - horizontal_drag_cursor - = XCreateFontCursor (FRAME_W32_DISPLAY (f), - XINT (Vx_window_horizontal_drag_shape)); + horizontal_drag_cursor = XINT (Vx_window_horizontal_drag_shape); } else - horizontal_drag_cursor - = XCreateFontCursor (FRAME_W32_DISPLAY (f), XC_sb_h_double_arrow); - - /* Check and report errors with the above calls. */ - x_check_errors (FRAME_W32_DISPLAY (f), "can't set cursor shape: %s"); - x_uncatch_errors (FRAME_W32_DISPLAY (f), count); + horizontal_drag_cursor = kThemeResizeLeftRightCursor; +#if 0 /* MAC_TODO: cursor color changes */ { XColor fore_color, back_color; - fore_color.pixel = f->output_data.w32->mouse_pixel; + fore_color.pixel = f->output_data.mac->mouse_pixel; + x_query_color (f, &fore_color); back_color.pixel = mask_color; - XQueryColor (FRAME_W32_DISPLAY (f), - DefaultColormap (FRAME_W32_DISPLAY (f), - DefaultScreen (FRAME_W32_DISPLAY (f))), - &fore_color); - XQueryColor (FRAME_W32_DISPLAY (f), - DefaultColormap (FRAME_W32_DISPLAY (f), - DefaultScreen (FRAME_W32_DISPLAY (f))), - &back_color); - XRecolorCursor (FRAME_W32_DISPLAY (f), cursor, - &fore_color, &back_color); - XRecolorCursor (FRAME_W32_DISPLAY (f), nontext_cursor, - &fore_color, &back_color); - XRecolorCursor (FRAME_W32_DISPLAY (f), mode_cursor, - &fore_color, &back_color); - XRecolorCursor (FRAME_W32_DISPLAY (f), hand_cursor, - &fore_color, &back_color); - XRecolorCursor (FRAME_W32_DISPLAY (f), hourglass_cursor, - &fore_color, &back_color); + x_query_color (f, &back_color); + + XRecolorCursor (dpy, cursor, &fore_color, &back_color); + XRecolorCursor (dpy, nontext_cursor, &fore_color, &back_color); + XRecolorCursor (dpy, mode_cursor, &fore_color, &back_color); + XRecolorCursor (dpy, hand_cursor, &fore_color, &back_color); + XRecolorCursor (dpy, hourglass_cursor, &fore_color, &back_color); + XRecolorCursor (dpy, horizontal_drag_cursor, &fore_color, &back_color); } +#endif - if (FRAME_W32_WINDOW (f) != 0) - XDefineCursor (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), cursor); - - if (cursor != f->output_data.w32->text_cursor && f->output_data.w32->text_cursor != 0) - XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->text_cursor); - f->output_data.w32->text_cursor = cursor; - - if (nontext_cursor != f->output_data.w32->nontext_cursor - && f->output_data.w32->nontext_cursor != 0) - XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->nontext_cursor); - f->output_data.w32->nontext_cursor = nontext_cursor; - - if (hourglass_cursor != f->output_data.w32->hourglass_cursor - && f->output_data.w32->hourglass_cursor != 0) - XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->hourglass_cursor); - f->output_data.w32->hourglass_cursor = hourglass_cursor; + BLOCK_INPUT; - if (mode_cursor != f->output_data.w32->modeline_cursor - && f->output_data.w32->modeline_cursor != 0) - XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->modeline_cursor); - f->output_data.w32->modeline_cursor = mode_cursor; + rif->define_frame_cursor (f, cursor); - if (hand_cursor != f->output_data.w32->hand_cursor - && f->output_data.w32->hand_cursor != 0) - XFreeCursor (FRAME_W32_DISPLAY (f), f->output_data.w32->hand_cursor); - f->output_data.w32->hand_cursor = hand_cursor; + f->output_data.mac->text_cursor = cursor; + f->output_data.mac->nontext_cursor = nontext_cursor; + f->output_data.mac->hourglass_cursor = hourglass_cursor; + f->output_data.mac->modeline_cursor = mode_cursor; + f->output_data.mac->hand_cursor = hand_cursor; + f->output_data.mac->horizontal_drag_cursor = horizontal_drag_cursor; - XFlush (FRAME_W32_DISPLAY (f)); UNBLOCK_INPUT; update_face_from_frame_parameter (f, Qmouse_color, arg); -#endif /* MAC_TODO */ } void @@ -1627,9 +1486,10 @@ x_set_cursor_color (f, arg, oldval) { BLOCK_INPUT; /* Update frame's cursor_gc. */ - f->output_data.mac->cursor_gc->foreground = fore_pixel; - f->output_data.mac->cursor_gc->background = pixel; - + XSetBackground (FRAME_MAC_DISPLAY (f), + f->output_data.mac->cursor_gc, pixel); + XSetForeground (FRAME_MAC_DISPLAY (f), + f->output_data.mac->cursor_gc, fore_pixel); UNBLOCK_INPUT; if (FRAME_VISIBLE_P (f)) @@ -1890,8 +1750,49 @@ x_set_tool_bar_lines (f, value, oldval) } + +/* Set the Mac window title to NAME for frame F. */ + +static void +x_set_name_internal (f, name) + FRAME_PTR f; + Lisp_Object name; +{ + if (FRAME_MAC_WINDOW (f)) + { + if (STRING_MULTIBYTE (name)) +#if TARGET_API_MAC_CARBON + name = ENCODE_UTF_8 (name); +#else + name = ENCODE_SYSTEM (name); +#endif + + BLOCK_INPUT; + + { +#if TARGET_API_MAC_CARBON + CFStringRef windowTitle = + cfstring_create_with_utf8_cstring (SDATA (name)); + + SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle); + CFRelease (windowTitle); +#else + Str255 windowTitle; + if (strlen (SDATA (name)) < 255) + { + strcpy (windowTitle, SDATA (name)); + c2pstr (windowTitle); + SetWTitle (FRAME_MAC_WINDOW (f), windowTitle); + } +#endif + } + + UNBLOCK_INPUT; + } +} + /* Change the name of frame F to NAME. If NAME is nil, set F's name to - w32_id_name. + mac_id_name. If EXPLICIT is non-zero, that indicates that lisp code is setting the name; if NAME is a string, set F's name to NAME and set @@ -1921,7 +1822,7 @@ x_set_name (f, name, explicit) else if (f->explicit_name) return; - /* If NAME is nil, set the name to the w32_id_name. */ + /* If NAME is nil, set the name to the mac_id_name. */ if (NILP (name)) { /* Check for no change needed in this very common case @@ -1945,37 +1846,7 @@ x_set_name (f, name, explicit) if (! NILP (f->title)) name = f->title; - if (FRAME_MAC_WINDOW (f)) - { - if (STRING_MULTIBYTE (name)) -#if TARGET_API_MAC_CARBON - name = ENCODE_UTF_8 (name); -#else - return; -#endif - - BLOCK_INPUT; - - { -#if TARGET_API_MAC_CARBON - CFStringRef windowTitle = - cfstring_create_with_utf8_cstring (SDATA (name)); - - SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle); - CFRelease (windowTitle); -#else - Str255 windowTitle; - if (strlen (SDATA (name)) < 255) - { - strcpy (windowTitle, SDATA (name)); - c2pstr (windowTitle); - SetWTitle (FRAME_MAC_WINDOW (f), windowTitle); - } -#endif - } - - UNBLOCK_INPUT; - } + x_set_name_internal (f, name); } /* This function should be called when the user's lisp code has @@ -2026,38 +1897,10 @@ x_set_title (f, name, old_name) if (NILP (name)) name = f->name; + else + CHECK_STRING (name); - if (FRAME_MAC_WINDOW (f)) - { - if (STRING_MULTIBYTE (name)) -#if TARGET_API_MAC_CARBON - name = ENCODE_UTF_8 (name); -#else - return; -#endif - - BLOCK_INPUT; - - { -#if TARGET_API_MAC_CARBON - CFStringRef windowTitle = - cfstring_create_with_utf8_cstring (SDATA (name)); - - SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle); - CFRelease (windowTitle); -#else - Str255 windowTitle; - if (strlen (SDATA (name)) < 255) - { - strcpy (windowTitle, SDATA (name)); - c2pstr (windowTitle); - SetWTitle (FRAME_MAC_WINDOW (f), windowTitle); - } -#endif - } - - UNBLOCK_INPUT; - } + x_set_name_internal (f, name); } void @@ -2086,49 +1929,24 @@ x_set_scroll_bar_default_width (f) /* Subroutines of creating a frame. */ -static char * -mac_get_rdb_resource (rdb, resource) - char *rdb; - char *resource; -{ - char *value = rdb; - int len = strlen (resource); - - while (*value) - { - if ((strncmp (value, resource, len) == 0) && (value[len] == ':')) - return xstrdup (&value[len + 1]); - - value = strchr (value, '\0') + 1; - } - - return NULL; -} - /* Retrieve the string resource specified by NAME with CLASS from - database RDB. */ + database RDB. + + The return value points to the contents of a Lisp string. So it + will not be valid after the next GC where string compaction will + occur. */ char * x_get_string_resource (rdb, name, class) XrmDatabase rdb; char *name, *class; { - if (rdb) - { - char *resource; + Lisp_Object value = xrm_get_resource (rdb, name, class); - if (resource = mac_get_rdb_resource (rdb, name)) - return resource; - if (resource = mac_get_rdb_resource (rdb, class)) - return resource; - } - - /* MAC_TODO: implement resource strings. (Maybe Property Lists?) */ -#if 0 - return mac_get_string_resource (name, class); -#else - return (char *)0; -#endif + if (STRINGP (value)) + return SDATA (value); + else + return NULL; } /* Return the value of parameter PARAM. @@ -2294,8 +2112,6 @@ XParseGeometry (string, x, y, width, height) /* Create and set up the Mac window for frame F. */ -extern OSErr install_window_handler (WindowPtr); - static void mac_window (f) struct frame *f; @@ -2329,6 +2145,18 @@ mac_window (f) /* so that update events can find this mac_output struct */ f->output_data.mac->mFP = f; /* point back to emacs frame */ +#ifndef MAC_OSX + if (FRAME_MAC_WINDOW (f)) + { + ControlRef root_control; + + if (CreateRootControl (FRAME_MAC_WINDOW (f), &root_control) != noErr) + { + DisposeWindow (FRAME_MAC_WINDOW (f)); + FRAME_MAC_WINDOW (f) = NULL; + } + } +#endif if (FRAME_MAC_WINDOW (f)) XSetWindowBackground (FRAME_MAC_DISPLAY(f), FRAME_MAC_WINDOW (f), FRAME_BACKGROUND_PIXEL (f)); @@ -2541,7 +2369,7 @@ unwind_create_frame (frame) DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame, 1, 1, 0, - doc: /* Make a new window, which is called a \"frame\" in Emacs terms. + doc: /* Make a new window, which is called a "frame" in Emacs terms. Returns an Emacs frame object. ALIST is an alist of frame parameters. If the parameters specify that the frame should not have a minibuffer, @@ -2550,7 +2378,7 @@ then `default-minibuffer-frame' must be a frame whose minibuffer can be shared by the new frame. This function is an internal primitive--use `make-frame' instead. */) - (parms) + (parms) Lisp_Object parms; { struct frame *f; @@ -2702,6 +2530,8 @@ This function is an internal primitive--use `make-frame' instead. */) if (! STRINGP (font)) font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1"); /* If those didn't work, look for something which will at least work. */ + if (! STRINGP (font)) + font = x_new_fontset (f, "fontset-mac"); if (! STRINGP (font)) font = x_new_font (f, "-*-monaco-*-12-*-mac-roman"); if (! STRINGP (font)) @@ -2777,22 +2607,6 @@ This function is an internal primitive--use `make-frame' instead. */) f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; -#if TARGET_API_MAC_CARBON - f->output_data.mac->text_cursor = kThemeIBeamCursor; - f->output_data.mac->nontext_cursor = kThemeArrowCursor; - f->output_data.mac->modeline_cursor = kThemeArrowCursor; - f->output_data.mac->hand_cursor = kThemePointingHandCursor; - f->output_data.mac->hourglass_cursor = kThemeWatchCursor; - f->output_data.mac->horizontal_drag_cursor = kThemeResizeLeftRightCursor; -#else - f->output_data.mac->text_cursor = GetCursor (iBeamCursor); - f->output_data.mac->nontext_cursor = &arrow_cursor; - f->output_data.mac->modeline_cursor = &arrow_cursor; - f->output_data.mac->hand_cursor = &arrow_cursor; - f->output_data.mac->hourglass_cursor = GetCursor (watchCursor); - f->output_data.mac->horizontal_drag_cursor = &arrow_cursor; -#endif - /* Compute the size of the window. */ window_prompting = x_figure_window_size (f, parms, 1); @@ -2889,7 +2703,7 @@ x_get_focus_frame (frame) DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, doc: /* Internal function called by `color-defined-p', which see. */) - (color, frame) + (color, frame) Lisp_Object color, frame; { XColor foo; @@ -2905,7 +2719,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0, DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, doc: /* Internal function called by `color-values', which see. */) - (color, frame) + (color, frame) Lisp_Object color, frame; { XColor foo; @@ -2928,7 +2742,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0, DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0, doc: /* Internal function called by `display-color-p', which see. */) - (display) + (display) Lisp_Object display; { struct mac_display_info *dpyinfo = check_x_display_info (display); @@ -2941,12 +2755,12 @@ DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0, DEFUN ("x-display-grayscale-p", Fx_display_grayscale_p, Sx_display_grayscale_p, 0, 1, 0, - doc: /* Return t if the X display supports shades of gray. + doc: /* Return t if DISPLAY supports shades of gray. Note that color displays do support shades of gray. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { struct mac_display_info *dpyinfo = check_x_display_info (display); @@ -2959,11 +2773,11 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-pixel-width", Fx_display_pixel_width, Sx_display_pixel_width, 0, 1, 0, - doc: /* Returns the width in pixels of the X display DISPLAY. + doc: /* Returns the width in pixels of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { struct mac_display_info *dpyinfo = check_x_display_info (display); @@ -2973,11 +2787,11 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-pixel-height", Fx_display_pixel_height, Sx_display_pixel_height, 0, 1, 0, - doc: /* Returns the height in pixels of the X display DISPLAY. + doc: /* Returns the height in pixels of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { struct mac_display_info *dpyinfo = check_x_display_info (display); @@ -2987,11 +2801,11 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes, 0, 1, 0, - doc: /* Returns the number of bitplanes of the display DISPLAY. + doc: /* Returns the number of bitplanes of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { struct mac_display_info *dpyinfo = check_x_display_info (display); @@ -3001,11 +2815,11 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells, 0, 1, 0, - doc: /* Returns the number of color cells of the display DISPLAY. + doc: /* Returns the number of color cells of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { struct mac_display_info *dpyinfo = check_x_display_info (display); @@ -3017,11 +2831,11 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-server-max-request-size", Fx_server_max_request_size, Sx_server_max_request_size, 0, 1, 0, - doc: /* Returns the maximum request size of the server of display DISPLAY. + doc: /* Returns the maximum request size of the server of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { struct mac_display_info *dpyinfo = check_x_display_info (display); @@ -3030,18 +2844,18 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0, - doc: /* Returns the vendor ID string of the Mac OS system (Apple). + doc: /* Returns the "vendor ID" string of the Mac OS system (Apple). The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { return build_string ("Apple Computers"); } DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, - doc: /* Returns the version numbers of the server of display DISPLAY. + doc: /* Returns the version numbers of the Mac OS system. The value is a list of three integers: the major and minor version numbers, and the vendor-specific release number. See also the function `x-server-vendor'. @@ -3049,13 +2863,18 @@ number. See also the function `x-server-vendor'. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { int mac_major_version; SInt32 response; + OSErr err; + + BLOCK_INPUT; + err = Gestalt (gestaltSystemVersion, &response); + UNBLOCK_INPUT; - if (Gestalt (gestaltSystemVersion, &response) != noErr) + if (err != noErr) error ("Cannot get Mac OS version"); mac_major_version = (response >> 8) & 0xff; @@ -3069,22 +2888,22 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0, - doc: /* Return the number of screens on the server of display DISPLAY. + doc: /* Return the number of screens on the server of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { return make_number (1); } DEFUN ("x-display-mm-height", Fx_display_mm_height, Sx_display_mm_height, 0, 1, 0, - doc: /* Return the height in millimeters of the X display DISPLAY. + doc: /* Return the height in millimeters of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { /* MAC_TODO: this is an approximation, and only of the main display */ @@ -3095,11 +2914,11 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0, - doc: /* Return the width in millimeters of the X display DISPLAY. + doc: /* Return the width in millimeters of DISPLAY. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { /* MAC_TODO: this is an approximation, and only of the main display */ @@ -3111,12 +2930,12 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-backing-store", Fx_display_backing_store, Sx_display_backing_store, 0, 1, 0, - doc: /* Returns an indication of whether display DISPLAY does backing store. + doc: /* Returns an indication of whether DISPLAY does backing store. The value may be `always', `when-mapped', or `not-useful'. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { return intern ("not-useful"); @@ -3124,14 +2943,14 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-visual-class", Fx_display_visual_class, Sx_display_visual_class, 0, 1, 0, - doc: /* Returns the visual class of the display DISPLAY. + doc: /* Returns the visual class of DISPLAY. The value is one of the symbols `static-gray', `gray-scale', `static-color', `pseudo-color', `true-color', or `direct-color'. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { struct mac_display_info *dpyinfo = check_x_display_info (display); @@ -3155,11 +2974,11 @@ If omitted or nil, that stands for the selected frame's display. */) DEFUN ("x-display-save-under", Fx_display_save_under, Sx_display_save_under, 0, 1, 0, - doc: /* Returns t if the display DISPLAY supports the save-under feature. + doc: /* Returns t if DISPLAY supports the save-under feature. The optional argument DISPLAY specifies which display to ask about. DISPLAY should be either a frame or a display name (a string). If omitted or nil, that stands for the selected frame's display. */) - (display) + (display) Lisp_Object display; { return Qnil; @@ -3249,7 +3068,7 @@ DISPLAY is the name of the display to connect to. Optional second arg XRM-STRING is a string of resources in xrdb format. If the optional third arg MUST-SUCCEED is non-nil, terminate Emacs if we can't open the connection. */) - (display, xrm_string, must_succeed) + (display, xrm_string, must_succeed) Lisp_Object display, xrm_string, must_succeed; { unsigned char *xrm_option; @@ -3294,8 +3113,8 @@ DEFUN ("x-close-connection", Fx_close_connection, doc: /* Close the connection to DISPLAY's server. For DISPLAY, specify either a frame or a display name (a string). If DISPLAY is nil, that stands for the selected frame's display. */) - (display) - Lisp_Object display; + (display) + Lisp_Object display; { struct mac_display_info *dpyinfo = check_x_display_info (display); int i; @@ -3321,7 +3140,7 @@ If DISPLAY is nil, that stands for the selected frame's display. */) DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, doc: /* Return the list of display names that Emacs has connections to. */) - () + () { Lisp_Object tail, result; @@ -3333,13 +3152,8 @@ DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, } DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0, - doc: /* If ON is non-nil, report errors as soon as the erring request is made. -If ON is nil, allow buffering of requests. -This is a noop on Mac OS systems. -The optional second argument DISPLAY specifies which display to act on. -DISPLAY should be either a frame or a display name (a string). -If DISPLAY is omitted or nil, that stands for the selected frame's display. */) - (on, display) + doc: /* This is a noop on Mac OS systems. */) + (on, display) Lisp_Object display, on; { return Qnil; @@ -3398,7 +3212,7 @@ DEFUN ("x-delete-window-property", Fx_delete_window_property, Sx_delete_window_property, 1, 2, 0, doc: /* Remove window property PROP from X window of FRAME. FRAME nil or omitted means use the selected frame. Value is PROP. */) - (prop, frame) + (prop, frame) Lisp_Object prop, frame; { #if 0 /* MAC_TODO : port window properties to Mac */ @@ -3426,7 +3240,7 @@ DEFUN ("x-window-property", Fx_window_property, Sx_window_property, If FRAME is nil or omitted, use the selected frame. Value is nil if FRAME hasn't a property with name PROP or if PROP has no string value. */) - (prop, frame) + (prop, frame) Lisp_Object prop, frame; { #if 0 /* MAC_TODO : port window properties to Mac */ @@ -3477,7 +3291,7 @@ value. */) /*********************************************************************** - Hourglass cursor + Busy cursor ***********************************************************************/ /* If non-null, an asynchronous timer that, when it expires, displays @@ -3503,13 +3317,21 @@ static Lisp_Object Vhourglass_delay; static void show_hourglass P_ ((struct atimer *)); static void hide_hourglass P_ ((void)); +/* Return non-zero if houglass timer has been started or hourglass is shown. */ + +int +hourglass_started () +{ + return hourglass_shown_p || hourglass_atimer != NULL; +} + /* Cancel a currently active hourglass timer, and start a new one. */ void start_hourglass () { -#if 0 /* MAC_TODO: cursor shape changes. */ +#ifdef MAC_OSX EMACS_TIME delay; int secs, usecs = 0; @@ -3532,16 +3354,17 @@ start_hourglass () EMACS_SET_SECS_USECS (delay, secs, usecs); hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay, show_hourglass, NULL); -#endif /* MAC_TODO */ +#endif /* MAC_OSX */ } -/* Cancel the hourglass cursor timer if active, hide an hourglass - cursor if shown. */ +/* Cancel the hourglass cursor timer if active, hide a busy cursor if + shown. */ void cancel_hourglass () { +#ifdef MAC_OSX if (hourglass_atimer) { cancel_atimer (hourglass_atimer); @@ -3550,22 +3373,22 @@ cancel_hourglass () if (hourglass_shown_p) hide_hourglass (); +#endif /* MAC_OSX */ } /* Timer function of hourglass_atimer. TIMER is equal to hourglass_atimer. - Display an hourglass cursor on all frames by mapping the frames' - hourglass_window. Set the hourglass_p flag in the frames' - output_data.x structure to indicate that an hourglass cursor is - shown on the frames. */ + On Mac, busy status is shown by the progress indicator (chasing + arrows) at the upper-right corner of each frame instead of the + hourglass pointer. */ static void show_hourglass (timer) struct atimer *timer; { -#if 0 /* MAC_TODO: cursor shape changes. */ +#if TARGET_API_MAC_CARBON /* The timer implementation will cancel this timer automatically after this function has run. Set hourglass_atimer to null so that we know the timer doesn't have to be canceled. */ @@ -3578,46 +3401,44 @@ show_hourglass (timer) BLOCK_INPUT; FOR_EACH_FRAME (rest, frame) - if (FRAME_W32_P (XFRAME (frame))) - { - struct frame *f = XFRAME (frame); - - f->output_data.w32->hourglass_p = 1; + { + struct frame *f = XFRAME (frame); - if (!f->output_data.w32->hourglass_window) - { - unsigned long mask = CWCursor; - XSetWindowAttributes attrs; - - attrs.cursor = f->output_data.w32->hourglass_cursor; - - f->output_data.w32->hourglass_window - = XCreateWindow (FRAME_X_DISPLAY (f), - FRAME_OUTER_WINDOW (f), - 0, 0, 32000, 32000, 0, 0, - InputOnly, - CopyFromParent, - mask, &attrs); - } + if (FRAME_LIVE_P (f) && FRAME_MAC_P (f) + && FRAME_MAC_WINDOW (f) != tip_window) + { + if (!f->output_data.mac->hourglass_control) + { + Window w = FRAME_MAC_WINDOW (f); + Rect r; + ControlRef c; + + GetWindowPortBounds (w, &r); + r.left = r.right - HOURGLASS_WIDTH; + r.bottom = r.top + HOURGLASS_HEIGHT; + if (CreateChasingArrowsControl (w, &r, &c) == noErr) + f->output_data.mac->hourglass_control = c; + } - XMapRaised (FRAME_X_DISPLAY (f), - f->output_data.w32->hourglass_window); - XFlush (FRAME_X_DISPLAY (f)); - } + if (f->output_data.mac->hourglass_control) + ShowControl (f->output_data.mac->hourglass_control); + } + } hourglass_shown_p = 1; UNBLOCK_INPUT; } -#endif /* MAC_TODO */ +#endif /* TARGET_API_MAC_CARBON */ } -/* Hide the hourglass cursor on all frames, if it is currently shown. */ +/* Hide the progress indicators on all frames, if it is currently + shown. */ static void hide_hourglass () { -#if 0 /* MAC_TODO: cursor shape changes. */ +#if TARGET_API_MAC_CARBON if (hourglass_shown_p) { Lisp_Object rest, frame; @@ -3627,23 +3448,16 @@ hide_hourglass () { struct frame *f = XFRAME (frame); - if (FRAME_W32_P (f) + if (FRAME_MAC_P (f) /* Watch out for newly created frames. */ - && f->output_data.x->hourglass_window) - { - XUnmapWindow (FRAME_X_DISPLAY (f), - f->output_data.x->hourglass_window); - /* Sync here because XTread_socket looks at the - hourglass_p flag that is reset to zero below. */ - XSync (FRAME_X_DISPLAY (f), False); - f->output_data.x->hourglass_p = 0; - } + && f->output_data.mac->hourglass_control) + HideControl (f->output_data.mac->hourglass_control); } hourglass_shown_p = 0; UNBLOCK_INPUT; } -#endif /* MAC_TODO */ +#endif /* TARGET_API_MAC_CARBON */ } @@ -3722,9 +3536,6 @@ x_create_tip_frame (dpyinfo, parms, text) check_mac (); - /* Use this general default value to start with until we know if - this frame has a specified name. */ - Vx_resource_name = Vinvocation_name; #ifdef MULTI_KBOARD kb = dpyinfo->kboard; @@ -3738,7 +3549,6 @@ x_create_tip_frame (dpyinfo, parms, text) && !EQ (name, Qunbound) && !NILP (name)) error ("Invalid frame name--not a string or nil"); - Vx_resource_name = name; frame = Qnil; GCPRO3 (parms, name, frame); @@ -3818,6 +3628,8 @@ x_create_tip_frame (dpyinfo, parms, text) if (! STRINGP (font)) font = x_new_font (f, "-ETL-fixed-medium-r-*--*-160-*-*-*-*-iso8859-1"); /* If those didn't work, look for something which will at least work. */ + if (! STRINGP (font)) + font = x_new_fontset (f, "fontset-mac"); if (! STRINGP (font)) font = x_new_font (f, "-*-monaco-*-12-*-mac-roman"); if (! STRINGP (font)) @@ -3882,7 +3694,7 @@ x_create_tip_frame (dpyinfo, parms, text) SetRect (&r, 0, 0, 1, 1); #if TARGET_API_MAC_CARBON if (CreateNewWindow (kHelpWindowClass, -#ifdef MAC_OS_X_VERSION_10_2 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 kWindowIgnoreClicksAttribute | #endif kWindowNoUpdatesAttribute | @@ -4030,7 +3842,7 @@ compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) DEFUN ("x-show-tip", Fx_show_tip, Sx_show_tip, 1, 6, 0, doc: /* Show STRING in a "tooltip" window on frame FRAME. -A tooltip window is a small X window displaying a string. +A tooltip window is a small window displaying a string. FRAME nil or omitted means use the selected frame. @@ -4040,7 +3852,7 @@ change the tooltip's appearance. Automatically hide the tooltip after TIMEOUT seconds. TIMEOUT nil means use the default timeout of 5 seconds. -If the list of frame parameters PARAMS contains a `left' parameters, +If the list of frame parameters PARMS contains a `left' parameter, the tooltip is displayed at that x-position. Otherwise it is displayed at the mouse position, with offset DX added (default is 5 if DX isn't specified). Likewise for the y-position; if a `top' frame @@ -4171,7 +3983,7 @@ Text larger than the specified size is clipped. */) clear_glyph_matrix (w->desired_matrix); clear_glyph_matrix (w->current_matrix); SET_TEXT_POS (pos, BEGV, BEGV_BYTE); - try_window (FRAME_ROOT_WINDOW (f), pos); + try_window (FRAME_ROOT_WINDOW (f), pos, 0); /* Compute width and height of the tooltip. */ width = height = 0; @@ -4298,7 +4110,7 @@ Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file selection box, if specified. Ensure that file exists if MUSTMATCH is non-nil. If ONLY-DIR-P is non-nil, the user can only select directories. */) - (prompt, dir, default_filename, mustmatch, only_dir_p) + (prompt, dir, default_filename, mustmatch, only_dir_p) Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p; { struct frame *f = SELECTED_FRAME (); @@ -4324,7 +4136,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) NavTypeListHandle fileTypes = NULL; NavUserAction userAction; CFStringRef message=NULL, saveName = NULL; - + BLOCK_INPUT; /* No need for a callback function because we are modal */ NavGetDefaultDialogCreationOptions(&options); @@ -4335,8 +4147,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) options.optionFlags |= kNavSelectAllReadableItem; if (!NILP(prompt)) { - message = - cfstring_create_with_utf8_cstring (SDATA (ENCODE_UTF_8 (prompt))); + message = cfstring_create_with_string (prompt); options.message = message; } /* Don't set the application, let it use default. @@ -4349,14 +4160,14 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) if (!NILP (only_dir_p)) status = NavCreateChooseFolderDialog(&options, mac_nav_event_callbackUPP, NULL, NULL, &dialogRef); - else if (NILP (mustmatch)) - { + else if (NILP (mustmatch)) + { /* This is a save dialog */ options.optionFlags |= kNavDontConfirmReplacement; options.actionButtonLabel = CFSTR ("Ok"); options.windowTitle = CFSTR ("Enter name"); - if (!NILP(default_filename)) + if (STRINGP (default_filename)) { Lisp_Object utf8 = ENCODE_UTF_8 (default_filename); char *begPtr = SDATA(utf8); @@ -4367,7 +4178,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) options.saveFileName = saveName; options.optionFlags |= kNavSelectDefaultLocation; } - status = NavCreatePutFileDialog(&options, + status = NavCreatePutFileDialog(&options, 'TEXT', kNavGenericSignature, mac_nav_event_callbackUPP, NULL, &dialogRef); @@ -4379,24 +4190,31 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) mac_nav_event_callbackUPP, NULL, NULL, NULL, &dialogRef); } - + /* Set the default location and continue*/ - if (status == noErr) { - if (!NILP(dir)) { - FSRef defLoc; + if (status == noErr) + { AEDesc defLocAed; +#ifdef MAC_OSX + FSRef defLoc; status = FSPathMakeRef(SDATA(ENCODE_FILE(dir)), &defLoc, NULL); - if (status == noErr) +#else + FSSpec defLoc; + status = posix_pathname_to_fsspec (SDATA (ENCODE_FILE (dir)), &defLoc); +#endif + if (status == noErr) { +#ifdef MAC_OSX AECreateDesc(typeFSRef, &defLoc, sizeof(FSRef), &defLocAed); +#else + AECreateDesc(typeFSS, &defLoc, sizeof(FSSpec), &defLocAed); +#endif NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed); AEDisposeDesc(&defLocAed); } + status = NavDialogRun(dialogRef); } - status = NavDialogRun(dialogRef); - } - if (saveName) CFRelease(saveName); if (message) CFRelease(message); @@ -4413,11 +4231,22 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) { NavReplyRecord reply; AEDesc aed; +#ifdef MAC_OSX FSRef fsRef; +#else + FSSpec fs; +#endif status = NavDialogGetReply(dialogRef, &reply); + +#ifdef MAC_OSX AECoerceDesc(&reply.selection, typeFSRef, &aed); AEGetDescData(&aed, (void *) &fsRef, sizeof (FSRef)); FSRefMakePath(&fsRef, (UInt8 *) filename, sizeof (filename)); +#else + AECoerceDesc (&reply.selection, typeFSS, &aed); + AEGetDescData (&aed, (void *) &fs, sizeof (FSSpec)); + fsspec_to_posix_pathname (&fs, filename, sizeof (filename) - 1); +#endif AEDisposeDesc(&aed); if (reply.saveFileName) { @@ -4425,9 +4254,14 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) int len = strlen(filename); if (len && filename[len-1] != '/') filename[len++] = '/'; - CFStringGetCString(reply.saveFileName, filename+len, + CFStringGetCString(reply.saveFileName, filename+len, sizeof (filename) - len, - kCFStringEncodingUTF8); +#if MAC_OSX + kCFStringEncodingUTF8 +#else + CFStringGetSystemEncoding () +#endif + ); } file = DECODE_FILE (make_unibyte_string (filename, strlen (filename))); @@ -4436,22 +4270,23 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) break; } NavDialogDispose(dialogRef); + UNBLOCK_INPUT; } else { + UNBLOCK_INPUT; /* Fall back on minibuffer if there was a problem */ file = Fcompleting_read (prompt, intern ("read-file-name-internal"), dir, mustmatch, dir, Qfile_name_history, default_filename, Qnil); } - UNBLOCK_INPUT; } UNGCPRO; - + /* Make "Cancel" equivalent to C-g. */ if (NILP (file)) Fsignal (Qquit, Qnil); - + return unbind_to (count, file); } @@ -4471,7 +4306,7 @@ mac_nav_event_callback (selector, parms, data) Initialization ***********************************************************************/ -/* Keep this list in the same order as frame_parms in frame.c. +/* Keep this list in the same order as frame_parms in frame.c. Use 0 for unsupported frame parameters. */ frame_parm_handler mac_frame_parm_handlers[] = @@ -4529,29 +4364,12 @@ syms_of_macfns () staticpro (&Qundefined_color); Qcancel_timer = intern ("cancel-timer"); staticpro (&Qcancel_timer); - - Qhyper = intern ("hyper"); - staticpro (&Qhyper); - Qsuper = intern ("super"); - staticpro (&Qsuper); - Qmeta = intern ("meta"); - staticpro (&Qmeta); - Qalt = intern ("alt"); - staticpro (&Qalt); - Qctrl = intern ("ctrl"); - staticpro (&Qctrl); - Qcontrol = intern ("control"); - staticpro (&Qcontrol); - Qshift = intern ("shift"); - staticpro (&Qshift); /* This is the end of symbol initialization. */ /* Text property `display' should be nonsticky by default. */ Vtext_property_default_nonsticky = Fcons (Fcons (Qdisplay, Qt), Vtext_property_default_nonsticky); - Qface_set_after_frame_default = intern ("face-set-after-frame-default"); - staticpro (&Qface_set_after_frame_default); Fput (Qundefined_color, Qerror_conditions, Fcons (Qundefined_color, Fcons (Qerror, Qnil))); @@ -4559,39 +4377,58 @@ syms_of_macfns () build_string ("Undefined color")); DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape, - doc: /* The shape of the pointer when over text. + doc: /* The shape of the pointer when over text. Changing the value does not affect existing frames unless you set the mouse color. */); Vx_pointer_shape = Qnil; +#if 0 /* This doesn't really do anything. */ + DEFVAR_LISP ("x-nontext-pointer-shape", &Vx_nontext_pointer_shape, + doc: /* The shape of the pointer when not over text. +This variable takes effect when you create a new frame +or when you set the mouse color. */); +#endif Vx_nontext_pointer_shape = Qnil; - Vx_mode_pointer_shape = Qnil; - DEFVAR_LISP ("x-hourglass-pointer-shape", &Vx_hourglass_pointer_shape, - doc: /* The shape of the pointer when Emacs is hourglass. + doc: /* The shape of the pointer when Emacs is busy. This variable takes effect when you create a new frame or when you set the mouse color. */); Vx_hourglass_pointer_shape = Qnil; DEFVAR_BOOL ("display-hourglass", &display_hourglass_p, - doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */); + doc: /* Non-zero means Emacs displays an hourglass pointer on window systems. */); display_hourglass_p = 1; DEFVAR_LISP ("hourglass-delay", &Vhourglass_delay, - doc: /* *Seconds to wait before displaying an hourglass pointer. + doc: /* *Seconds to wait before displaying an hourglass pointer. Value must be an integer or float. */); Vhourglass_delay = make_number (DEFAULT_HOURGLASS_DELAY); +#if 0 /* This doesn't really do anything. */ + DEFVAR_LISP ("x-mode-pointer-shape", &Vx_mode_pointer_shape, + doc: /* The shape of the pointer when over the mode line. +This variable takes effect when you create a new frame +or when you set the mouse color. */); +#endif + Vx_mode_pointer_shape = Qnil; + DEFVAR_LISP ("x-sensitive-text-pointer-shape", - &Vx_sensitive_text_pointer_shape, + &Vx_sensitive_text_pointer_shape, doc: /* The shape of the pointer when over mouse-sensitive text. This variable takes effect when you create a new frame or when you set the mouse color. */); Vx_sensitive_text_pointer_shape = Qnil; + DEFVAR_LISP ("x-window-horizontal-drag-cursor", + &Vx_window_horizontal_drag_shape, + doc: /* Pointer shape to use for indicating a window can be dragged horizontally. +This variable takes effect when you create a new frame +or when you set the mouse color. */); + Vx_window_horizontal_drag_shape = Qnil; + DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel, - doc: /* A string indicating the foreground color of the cursor box. */); + doc: /* A string indicating the foreground color of the cursor box. */); Vx_cursor_fore_pixel = Qnil; DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size, @@ -4600,7 +4437,7 @@ Text larger than this is clipped. */); Vx_max_tooltip_size = Fcons (make_number (80), make_number (40)); DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager, - doc: /* Non-nil if no window manager is in use. + doc: /* Non-nil if no window manager is in use. Emacs doesn't try to figure this out; this is always nil unless you set it to something else. */); /* We don't have any way to find this out, so set it to nil @@ -4609,7 +4446,7 @@ unless you set it to something else. */); DEFVAR_LISP ("x-pixel-size-width-font-regexp", &Vx_pixel_size_width_font_regexp, - doc: /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. + doc: /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'. Since Emacs gets width of a font matching with this regexp from PIXEL_SIZE field of the name, font finding mechanism gets faster for