X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/1bb9a689acfe821e0aa777ddf4e074556c7817a1..45cebfd9b4a33d69c2bd7108059c728ef6507c75:/src/macfns.c diff --git a/src/macfns.c b/src/macfns.c index 2cfdc9f17c..82153da884 100644 --- a/src/macfns.c +++ b/src/macfns.c @@ -1,13 +1,13 @@ /* Graphical user interface functions for Mac OS. - Copyright (C) 2000, 2001, 2002, 2003, 2004, - 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008 Free Software Foundation, Inc. This file is part of GNU Emacs. -GNU Emacs is free software; you can redistribute it and/or modify +GNU Emacs is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3, or (at your option) -any later version. +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -15,9 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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., 51 Franklin Street, Fifth Floor, -Boston, MA 02110-1301, USA. */ +along with GNU Emacs. If not, see . */ /* Contributed by Andrew Choi (akochoi@mac.com). */ @@ -107,8 +105,7 @@ extern Lisp_Object Vwindow_system_version; int image_cache_refcount, dpyinfo_refcount; #endif - -#if 0 /* Use xstricmp instead. */ +#if 0 /* Use xstrcasecmp instead. */ /* compare two strings ignoring case */ static int @@ -1014,7 +1011,7 @@ mac_color_map_lookup (colorname) BLOCK_INPUT; for (i = 0; i < sizeof (mac_color_map) / sizeof (mac_color_map[0]); i++) - if (xstricmp (colorname, mac_color_map[i].name) == 0) + if (xstrcasecmp (colorname, mac_color_map[i].name) == 0) { ret = make_number (mac_color_map[i].color); break; @@ -1347,7 +1344,7 @@ x_set_background_color (f, arg, oldval) BLOCK_INPUT; XSetBackground (dpy, mac->normal_gc, bg); XSetForeground (dpy, mac->reverse_gc, bg); - XSetWindowBackground (dpy, FRAME_MAC_WINDOW (f), bg); + mac_set_frame_window_background (f, bg); XSetForeground (dpy, mac->cursor_gc, bg); UNBLOCK_INPUT; @@ -1367,11 +1364,11 @@ x_set_mouse_color (f, arg, oldval) Cursor cursor, nontext_cursor, mode_cursor, hand_cursor; 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; + unsigned long mask_color = FRAME_BACKGROUND_PIXEL (f); /* Don't let pointers be invisible. */ if (mask_color == pixel) - pixel = x->foreground_pixel; + pixel = FRAME_FOREGROUND_PIXEL (f); f->output_data.mac->mouse_pixel = pixel; @@ -1444,7 +1441,7 @@ x_set_mouse_color (f, arg, oldval) BLOCK_INPUT; if (FRAME_MAC_WINDOW (f) != 0) - rif->define_frame_cursor (f, cursor); + FRAME_TERMINAL (f)->rif->define_frame_cursor (f, cursor); f->output_data.mac->text_cursor = cursor; f->output_data.mac->nontext_cursor = nontext_cursor; @@ -1687,7 +1684,8 @@ x_set_tool_bar_lines (f, value, oldval) if (nlines) { FRAME_EXTERNAL_TOOL_BAR (f) = 1; - if (FRAME_MAC_P (f) && !IsWindowToolbarVisible (FRAME_MAC_WINDOW (f))) + if (FRAME_MAC_P (f) + && !mac_is_window_toolbar_visible (FRAME_MAC_WINDOW (f))) /* Make sure next redisplay shows the tool bar. */ XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt; } @@ -1724,10 +1722,8 @@ x_set_tool_bar_lines (f, value, oldval) below the menu bar. */ if (FRAME_MAC_WINDOW (f) && FRAME_TOOL_BAR_LINES (f) == 0) { - updating_frame = f; - clear_frame (); + clear_frame (f); clear_current_matrices (f); - updating_frame = NULL; } /* If the tool bar gets smaller, the internal border below it @@ -1773,7 +1769,7 @@ x_set_name_internal (f, name) CFStringRef windowTitle = cfstring_create_with_utf8_cstring (SDATA (name)); - SetWindowTitleWithCFString (FRAME_MAC_WINDOW (f), windowTitle); + mac_set_window_title (FRAME_MAC_WINDOW (f), windowTitle); CFRelease (windowTitle); #else Str255 windowTitle; @@ -1871,15 +1867,7 @@ x_implicitly_set_name (f, arg, oldval) } /* Change the title of frame F to NAME. - If NAME is nil, use the frame name as the title. - - 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 - F->explicit_name; if NAME is Qnil, then clear F->explicit_name. - - If EXPLICIT is zero, that indicates that Emacs redisplay code is - suggesting a new name, which lisp code should override; if - F->explicit_name is set, ignore the new name; otherwise, set it. */ + If NAME is nil, use the frame name as the title. */ void x_set_title (f, name, old_name) @@ -1946,98 +1934,6 @@ mac_set_font (f, arg, oldval) #endif } -#if TARGET_API_MAC_CARBON -static void -mac_update_proxy_icon (f) - struct frame *f; -{ - OSStatus err; - Lisp_Object file_name = - XBUFFER (XWINDOW (FRAME_SELECTED_WINDOW (f))->buffer)->filename; - Window w = FRAME_MAC_WINDOW (f); - AliasHandle alias = NULL; - - BLOCK_INPUT; - - err = GetWindowProxyAlias (w, &alias); - if (err == errWindowDoesNotHaveProxy && !STRINGP (file_name)) - goto out; - - if (STRINGP (file_name)) - { - AEDesc desc; -#ifdef MAC_OSX - FSRef fref, fref_proxy; -#else - FSSpec fss, fss_proxy; -#endif - Boolean changed; - Lisp_Object encoded_file_name = ENCODE_FILE (file_name); - -#ifdef MAC_OSX - err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name), - SBYTES (encoded_file_name), typeFSRef, &desc); -#else - SetPortWindowPort (w); - err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name), - SBYTES (encoded_file_name), typeFSS, &desc); -#endif - if (err == noErr) - { -#ifdef MAC_OSX - err = AEGetDescData (&desc, &fref, sizeof (FSRef)); -#else - err = AEGetDescData (&desc, &fss, sizeof (FSSpec)); -#endif - AEDisposeDesc (&desc); - } - if (err == noErr) - { - if (alias) - { - /* (FS)ResolveAlias never sets `changed' to true if - `alias' is minimal. */ -#ifdef MAC_OSX - err = FSResolveAlias (NULL, alias, &fref_proxy, &changed); - if (err == noErr) - err = FSCompareFSRefs (&fref, &fref_proxy); -#else - err = ResolveAlias (NULL, alias, &fss_proxy, &changed); - if (err == noErr) - err = !(fss.vRefNum == fss_proxy.vRefNum - && fss.parID == fss_proxy.parID - && EqualString (fss.name, fss_proxy.name, - false, true)); -#endif - } - if (err != noErr || alias == NULL) - { - if (alias) - DisposeHandle ((Handle) alias); -#ifdef MAC_OSX - err = FSNewAliasMinimal (&fref, &alias); -#else - err = NewAliasMinimal (&fss, &alias); -#endif - changed = true; - } - } - if (err == noErr) - if (changed) - err = SetWindowProxyAlias (w, alias); - } - - if (alias) - DisposeHandle ((Handle) alias); - - if (err != noErr || !STRINGP (file_name)) - RemoveWindowProxy (w); - - out: - UNBLOCK_INPUT; -} -#endif - void mac_update_title_bar (f, save_match_data) struct frame *f; @@ -2059,9 +1955,11 @@ mac_update_title_bar (f, save_match_data) || (!MINI_WINDOW_P (w) && (modified_p != !NILP (w->last_had_star)))) { - SetWindowModified (FRAME_MAC_WINDOW (f), - !MINI_WINDOW_P (w) && modified_p); + BLOCK_INPUT; + mac_set_window_modified (FRAME_MAC_WINDOW (f), + !MINI_WINDOW_P (w) && modified_p); mac_update_proxy_icon (f); + UNBLOCK_INPUT; } #endif } @@ -2256,52 +2154,12 @@ static void mac_window (f) struct frame *f; { - Rect r; - BLOCK_INPUT; - SetRect (&r, f->left_pos, f->top_pos, - f->left_pos + FRAME_PIXEL_WIDTH (f), - f->top_pos + FRAME_PIXEL_HEIGHT (f)); -#if TARGET_API_MAC_CARBON - CreateNewWindow (kDocumentWindowClass, - kWindowStandardDocumentAttributes -#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); - if (install_window_handler (FRAME_MAC_WINDOW (f)) != noErr) - { - DisposeWindow (FRAME_MAC_WINDOW (f)); - FRAME_MAC_WINDOW (f) = NULL; - } - } -#else /* !TARGET_API_MAC_CARBON */ - FRAME_MAC_WINDOW (f) - = NewCWindow (NULL, &r, "\p", false, zoomDocProc, - (WindowRef) -1, 1, (long) f->output_data.mac); -#endif /* !TARGET_API_MAC_CARBON */ - /* 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; + mac_create_frame_window (f, 0); - 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)); + mac_set_frame_window_background (f, FRAME_BACKGROUND_PIXEL (f)); #if USE_MAC_TOOLBAR /* At the moment, the size of the tool bar is not yet known. We @@ -2427,8 +2285,8 @@ x_make_gc (f) = (XCreatePixmapFromBitmapData (FRAME_X_DISPLAY (f), FRAME_X_DISPLAY_INFO (f)->root_window, gray_bits, gray_width, gray_height, - f->output_data.x->foreground_pixel, - f->output_data.x->background_pixel, + FRAME_FOREGROUND_PIXEL (f), + FRAME_BACKGROUND_PIXEL (f), DefaultDepth (FRAME_X_DISPLAY (f), FRAME_X_SCREEN_NUMBER (f)))); #endif @@ -2522,16 +2380,16 @@ 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. -Returns an Emacs frame object. -ALIST is an alist of frame parameters. +Return an Emacs frame object. +PARAMETERS is an alist of frame parameters. If the parameters specify that the frame should not have a minibuffer, and do not specify a specific minibuffer window to use, 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) - Lisp_Object parms; + (parameters) + Lisp_Object parameters; { struct frame *f; Lisp_Object frame, tem; @@ -2554,17 +2412,13 @@ This function is an internal primitive--use `make-frame' instead. */) until we know if this frame has a specified name. */ Vx_resource_name = Vinvocation_name; - display = mac_get_arg (parms, Qdisplay, 0, 0, RES_TYPE_STRING); + display = mac_get_arg (parameters, Qdisplay, 0, 0, RES_TYPE_STRING); if (EQ (display, Qunbound)) display = Qnil; dpyinfo = check_x_display_info (display); -#ifdef MULTI_KBOARD - kb = dpyinfo->kboard; -#else - kb = &the_only_kboard; -#endif + kb = dpyinfo->terminal->kboard; - name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING); + name = mac_get_arg (parameters, Qname, "name", "Name", RES_TYPE_STRING); if (!STRINGP (name) && ! EQ (name, Qunbound) && ! NILP (name)) @@ -2574,7 +2428,7 @@ This function is an internal primitive--use `make-frame' instead. */) Vx_resource_name = name; /* See if parent window is specified. */ - parent = mac_get_arg (parms, Qparent_id, NULL, NULL, RES_TYPE_NUMBER); + parent = mac_get_arg (parameters, Qparent_id, NULL, NULL, RES_TYPE_NUMBER); if (EQ (parent, Qunbound)) parent = Qnil; if (! NILP (parent)) @@ -2584,8 +2438,8 @@ This function is an internal primitive--use `make-frame' instead. */) /* No need to protect DISPLAY because that's not used after passing it to make_frame_without_minibuffer. */ frame = Qnil; - GCPRO4 (parms, parent, name, frame); - tem = mac_get_arg (parms, Qminibuffer, "minibuffer", "Minibuffer", + GCPRO4 (parameters, parent, name, frame); + tem = mac_get_arg (parameters, Qminibuffer, "minibuffer", "Minibuffer", RES_TYPE_SYMBOL); if (EQ (tem, Qnone) || NILP (tem)) f = make_frame_without_minibuffer (Qnil, kb, display); @@ -2604,27 +2458,29 @@ This function is an internal primitive--use `make-frame' instead. */) /* Note that X Windows does support scroll bars. */ FRAME_CAN_HAVE_SCROLL_BARS (f) = 1; + f->terminal = dpyinfo->terminal; + f->terminal->reference_count++; + f->output_method = output_mac; f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output)); bzero (f->output_data.mac, sizeof (struct mac_output)); FRAME_FONTSET (f) = -1; + record_unwind_protect (unwind_create_frame, frame); f->icon_name - = mac_get_arg (parms, Qicon_name, "iconName", "Title", RES_TYPE_STRING); + = mac_get_arg (parameters, Qicon_name, "iconName", "Title", RES_TYPE_STRING); if (! STRINGP (f->icon_name)) f->icon_name = Qnil; -/* FRAME_MAC_DISPLAY_INFO (f) = dpyinfo; */ + /* XXX Is this needed? */ + /*FRAME_MAC_DISPLAY_INFO (f) = dpyinfo;*/ /* With FRAME_MAC_DISPLAY_INFO set up, this unwind-protect is safe. */ - record_unwind_protect (unwind_create_frame, frame); #if GLYPH_DEBUG - image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; + image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; dpyinfo_refcount = dpyinfo->reference_count; #endif /* GLYPH_DEBUG */ -#ifdef MULTI_KBOARD FRAME_KBOARD (f) = kb; -#endif /* Specify the parent under which to make this window. */ @@ -2659,7 +2515,7 @@ This function is an internal primitive--use `make-frame' instead. */) { Lisp_Object font; - font = mac_get_arg (parms, Qfont, "font", "Font", RES_TYPE_STRING); + font = mac_get_arg (parameters, Qfont, "font", "Font", RES_TYPE_STRING); BLOCK_INPUT; /* First, try whatever font the caller has specified. */ @@ -2671,7 +2527,6 @@ This function is an internal primitive--use `make-frame' instead. */) else font = x_new_font (f, SDATA (font)); } - /* Try out a font which we hope has bold and italic variations. */ #if USE_ATSUI if (! STRINGP (font)) @@ -2690,48 +2545,50 @@ This function is an internal primitive--use `make-frame' instead. */) error ("Cannot find any usable font"); UNBLOCK_INPUT; - x_set_frame_parameters (f, Fcons (Fcons (Qfont, font), Qnil)); + x_default_parameter (f, parameters, Qfont, font, + "font", "Font", RES_TYPE_STRING); } - x_default_parameter (f, parms, Qborder_width, make_number (0), + /* XXX Shouldn't this be borderWidth, not borderwidth ?*/ + x_default_parameter (f, parameters, Qborder_width, make_number (0), "borderwidth", "BorderWidth", RES_TYPE_NUMBER); /* This defaults to 2 in order to match xterm. We recognize either internalBorderWidth or internalBorder (which is what xterm calls it). */ - if (NILP (Fassq (Qinternal_border_width, parms))) + if (NILP (Fassq (Qinternal_border_width, parameters))) { Lisp_Object value; - value = mac_get_arg (parms, Qinternal_border_width, + value = mac_get_arg (parameters, Qinternal_border_width, "internalBorder", "InternalBorder", RES_TYPE_NUMBER); if (! EQ (value, Qunbound)) - parms = Fcons (Fcons (Qinternal_border_width, value), - parms); + parameters = Fcons (Fcons (Qinternal_border_width, value), + parameters); } /* Default internalBorderWidth to 0 on Windows to match other programs. */ - x_default_parameter (f, parms, Qinternal_border_width, make_number (0), + x_default_parameter (f, parameters, Qinternal_border_width, make_number (0), "internalBorderWidth", "InternalBorder", RES_TYPE_NUMBER); - x_default_parameter (f, parms, Qvertical_scroll_bars, Qright, + x_default_parameter (f, parameters, Qvertical_scroll_bars, Qright, "verticalScrollBars", "ScrollBars", RES_TYPE_SYMBOL); /* Also do the stuff which must be set before the window exists. */ - x_default_parameter (f, parms, Qforeground_color, build_string ("black"), + x_default_parameter (f, parameters, Qforeground_color, build_string ("black"), "foreground", "Foreground", RES_TYPE_STRING); - x_default_parameter (f, parms, Qbackground_color, build_string ("white"), + x_default_parameter (f, parameters, Qbackground_color, build_string ("white"), "background", "Background", RES_TYPE_STRING); - x_default_parameter (f, parms, Qmouse_color, build_string ("black"), + x_default_parameter (f, parameters, Qmouse_color, build_string ("black"), "pointerColor", "Foreground", RES_TYPE_STRING); - x_default_parameter (f, parms, Qcursor_color, build_string ("black"), + x_default_parameter (f, parameters, Qcursor_color, build_string ("black"), "cursorColor", "Foreground", RES_TYPE_STRING); - x_default_parameter (f, parms, Qborder_color, build_string ("black"), + x_default_parameter (f, parameters, Qborder_color, build_string ("black"), "borderColor", "BorderColor", RES_TYPE_STRING); - x_default_parameter (f, parms, Qscreen_gamma, Qnil, + x_default_parameter (f, parameters, Qscreen_gamma, Qnil, "screenGamma", "ScreenGamma", RES_TYPE_FLOAT); - x_default_parameter (f, parms, Qline_spacing, Qnil, + x_default_parameter (f, parameters, Qline_spacing, Qnil, "lineSpacing", "LineSpacing", RES_TYPE_NUMBER); - x_default_parameter (f, parms, Qleft_fringe, Qnil, + x_default_parameter (f, parameters, Qleft_fringe, Qnil, "leftFringe", "LeftFringe", RES_TYPE_NUMBER); - x_default_parameter (f, parms, Qright_fringe, Qnil, + x_default_parameter (f, parameters, Qright_fringe, Qnil, "rightFringe", "RightFringe", RES_TYPE_NUMBER); @@ -2743,29 +2600,29 @@ This function is an internal primitive--use `make-frame' instead. */) happen. */ init_frame_faces (f); - x_default_parameter (f, parms, Qmenu_bar_lines, make_number (1), + x_default_parameter (f, parameters, Qmenu_bar_lines, make_number (1), "menuBar", "MenuBar", RES_TYPE_NUMBER); - x_default_parameter (f, parms, Qtool_bar_lines, make_number (1), - "toolBar", "ToolBar", RES_TYPE_NUMBER); - x_default_parameter (f, parms, Qbuffer_predicate, Qnil, - "bufferPredicate", "BufferPredicate", - RES_TYPE_SYMBOL); - x_default_parameter (f, parms, Qtitle, Qnil, + x_default_parameter (f, parameters, Qtool_bar_lines, make_number (1), + "toolBar", "ToolBar", RES_TYPE_NUMBER); + + x_default_parameter (f, parameters, Qbuffer_predicate, Qnil, + "bufferPredicate", "BufferPredicate", RES_TYPE_SYMBOL); + x_default_parameter (f, parameters, Qtitle, Qnil, "title", "Title", RES_TYPE_STRING); - x_default_parameter (f, parms, Qfullscreen, Qnil, + x_default_parameter (f, parameters, Qfullscreen, Qnil, "fullscreen", "Fullscreen", RES_TYPE_SYMBOL); f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; /* Compute the size of the window. */ - window_prompting = x_figure_window_size (f, parms, 1); + window_prompting = x_figure_window_size (f, parameters, 1); - tem = mac_get_arg (parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); + tem = mac_get_arg (parameters, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN); f->no_split = minibuffer_only || EQ (tem, Qt); mac_window (f); + x_icon (f, parameters); - x_icon (f, parms); x_make_gc (f); /* Now consider the frame official. */ @@ -2774,18 +2631,17 @@ This function is an internal primitive--use `make-frame' instead. */) /* We need to do this after creating the window, so that the icon-creation functions can say whose icon they're describing. */ - x_default_parameter (f, parms, Qicon_type, Qnil, + x_default_parameter (f, parameters, Qicon_type, Qnil, "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL); - x_default_parameter (f, parms, Qauto_raise, Qnil, + x_default_parameter (f, parameters, Qauto_raise, Qnil, "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN); - x_default_parameter (f, parms, Qauto_lower, Qnil, + x_default_parameter (f, parameters, Qauto_lower, Qnil, "autoLower", "AutoRaiseLower", RES_TYPE_BOOLEAN); - x_default_parameter (f, parms, Qcursor_type, Qbox, + x_default_parameter (f, parameters, Qcursor_type, Qbox, "cursorType", "CursorType", RES_TYPE_SYMBOL); - x_default_parameter (f, parms, Qscroll_bar_width, Qnil, - "scrollBarWidth", "ScrollBarWidth", - RES_TYPE_NUMBER); + x_default_parameter (f, parameters, Qscroll_bar_width, Qnil, + "scrollBarWidth", "ScrollBarWidth", RES_TYPE_NUMBER); /* Dimensions, especially FRAME_LINES (f), must be done via change_frame_size. Change will not be effected unless different from the current @@ -2793,8 +2649,8 @@ This function is an internal primitive--use `make-frame' instead. */) width = FRAME_COLS (f); height = FRAME_LINES (f); - SET_FRAME_COLS (f, 0); FRAME_LINES (f) = 0; + SET_FRAME_COLS (f, 0); change_frame_size (f, height, width, 1, 0, 0); /* Tell the server what size and position, etc, we want, and how @@ -2811,7 +2667,7 @@ This function is an internal primitive--use `make-frame' instead. */) { Lisp_Object visibility; - visibility = mac_get_arg (parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL); + visibility = mac_get_arg (parameters, Qvisibility, 0, 0, RES_TYPE_SYMBOL); if (EQ (visibility, Qunbound)) visibility = Qt; @@ -2833,7 +2689,7 @@ This function is an internal primitive--use `make-frame' instead. */) /* All remaining specified parameters, which have not been "used" by x_get_arg and friends, now go in the misc. alist of the frame. */ - for (tem = parms; !NILP (tem); tem = XCDR (tem)) + for (tem = parameters; CONSP (tem); tem = XCDR (tem)) if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem)))) f->param_alist = Fcons (XCAR (tem), f->param_alist); @@ -2888,7 +2744,7 @@ FRAME nil means use the selected frame. */) if (!front_p) { #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 - if (FrontNonFloatingWindow () == FRAME_MAC_WINDOW (f)) + if (mac_front_non_floating_window () == FRAME_MAC_WINDOW (f)) SetFrontProcessWithOptions (¤t_psn, kSetFrontProcessFrontWindowOnly); else @@ -2897,8 +2753,8 @@ FRAME nil means use the selected frame. */) } #ifdef MAC_OSX - ActivateWindow (ActiveNonFloatingWindow (), false); - ActivateWindow (FRAME_MAC_WINDOW (f), true); + mac_activate_window (mac_active_non_floating_window (), false); + mac_activate_window (FRAME_MAC_WINDOW (f), true); #else #if !TARGET_API_MAC_CARBON /* SelectWindow (Non-Carbon) does not issue deactivate events if the @@ -2982,7 +2838,7 @@ 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 DISPLAY. + doc: /* Return 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. */) @@ -2996,7 +2852,7 @@ 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 DISPLAY. + doc: /* Return 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. */) @@ -3010,7 +2866,7 @@ 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 DISPLAY. + doc: /* Return 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. */) @@ -3024,7 +2880,7 @@ 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 DISPLAY. + doc: /* Return 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. */) @@ -3040,7 +2896,7 @@ 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. + doc: /* Return 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. */) @@ -3053,7 +2909,7 @@ 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: /* Return 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. */) @@ -3064,7 +2920,7 @@ If omitted or nil, that stands for the selected frame's display. */) } DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0, - doc: /* Returns the version numbers of the Mac OS system. + doc: /* Return 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'. @@ -3198,7 +3054,7 @@ 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 does backing store. + doc: /* Return 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). @@ -3211,7 +3067,7 @@ 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 DISPLAY. + doc: /* Return 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'. @@ -3242,7 +3098,7 @@ 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 DISPLAY supports the save-under feature. + doc: /* Return 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. */) @@ -3299,9 +3155,6 @@ x_display_info_for_name (name) CHECK_STRING (name); - if (! EQ (Vwindow_system, intern ("mac"))) - error ("Not using Mac native windows"); - for (dpyinfo = &one_mac_display_info, names = x_display_name_list; dpyinfo; dpyinfo = dpyinfo->next, names = XCDR (names)) @@ -3346,9 +3199,6 @@ terminate Emacs if we can't open the connection. */) if (! NILP (xrm_string)) CHECK_STRING (xrm_string); - if (! EQ (Vwindow_system, intern ("mac"))) - error ("Not using Mac native windows"); - if (! NILP (xrm_string)) xrm_option = (unsigned char *) SDATA (xrm_string); else @@ -3413,7 +3263,7 @@ DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0, Lisp_Object tail, result; result = Qnil; - for (tail = x_display_name_list; ! NILP (tail); tail = XCDR (tail)) + for (tail = x_display_name_list; CONSP (tail); tail = XCDR (tail)) result = Fcons (XCAR (XCAR (tail)), result); return result; @@ -3611,10 +3461,6 @@ start_hourglass () EMACS_TIME delay; int secs, usecs = 0; - /* Don't bother for ttys. */ - if (NILP (Vwindow_system)) - return; - cancel_hourglass (); if (INTEGERP (Vhourglass_delay) @@ -3686,26 +3532,7 @@ show_hourglass (timer) if (FRAME_LIVE_P (f) && FRAME_MAC_P (f) && FRAME_MAC_WINDOW (f) != tip_window) - { -#if USE_CG_DRAWING - mac_prepare_for_quickdraw (f); -#endif - 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; - } - - if (f->output_data.mac->hourglass_control) - ShowControl (f->output_data.mac->hourglass_control); - } + mac_show_hourglass (f); } hourglass_shown_p = 1; @@ -3731,15 +3558,8 @@ hide_hourglass () { struct frame *f = XFRAME (frame); - if (FRAME_MAC_P (f) - /* Watch out for newly created frames. */ - && f->output_data.mac->hourglass_control) - { -#if USE_CG_DRAWING - mac_prepare_for_quickdraw (f); -#endif - HideControl (f->output_data.mac->hourglass_control); - } + if (FRAME_MAC_P (f)) + mac_hide_hourglass (f); } hourglass_shown_p = 0; @@ -3826,11 +3646,7 @@ x_create_tip_frame (dpyinfo, parms, text) parms = Fcopy_alist (parms); -#ifdef MULTI_KBOARD - kb = dpyinfo->kboard; -#else - kb = &the_only_kboard; -#endif + kb = dpyinfo->terminal->kboard; /* Get the name of the frame to use for resource lookup. */ name = mac_get_arg (parms, Qname, "name", "Name", RES_TYPE_STRING); @@ -3862,6 +3678,8 @@ x_create_tip_frame (dpyinfo, parms, text) the frame is live, as per FRAME_LIVE_P. If we get a signal from this point on, x_destroy_window might screw up reference counts etc. */ + f->terminal = dpyinfo->terminal; + f->terminal->reference_count++; f->output_method = output_mac; f->output_data.mac = (struct mac_output *) xmalloc (sizeof (struct mac_output)); @@ -3871,12 +3689,10 @@ x_create_tip_frame (dpyinfo, parms, text) f->icon_name = Qnil; /* FRAME_X_DISPLAY_INFO (f) = dpyinfo; */ #if GLYPH_DEBUG - image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount; + image_cache_refcount = FRAME_IMAGE_CACHE (f)->refcount; dpyinfo_refcount = dpyinfo->reference_count; #endif /* GLYPH_DEBUG */ -#ifdef MULTI_KBOARD FRAME_KBOARD (f) = kb; -#endif f->output_data.mac->parent_desc = FRAME_MAC_DISPLAY_INFO (f)->root_window; f->output_data.mac->explicit_parent = 0; @@ -3980,33 +3796,17 @@ x_create_tip_frame (dpyinfo, parms, text) window_prompting = x_figure_window_size (f, parms, 0); - { - Rect r; + BLOCK_INPUT; - BLOCK_INPUT; - SetRect (&r, 0, 0, 1, 1); -#if TARGET_API_MAC_CARBON - if (CreateNewWindow (kHelpWindowClass, -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020 - kWindowIgnoreClicksAttribute | -#endif - kWindowNoUpdatesAttribute | - kWindowNoActivatesAttribute, - &r, &tip_window) == noErr) -#else - if (tip_window = NewCWindow (NULL, &r, "\p", false, plainDBox, - NULL, false, 0L)) -#endif - { - FRAME_MAC_WINDOW (f) = tip_window; - XSetWindowBackground (FRAME_MAC_DISPLAY(f), tip_window, - FRAME_BACKGROUND_PIXEL (f)); - SetWRefCon (tip_window, (long) f->output_data.mac); - /* so that update events can find this mac_output struct */ - f->output_data.mac->mFP = f; - } - UNBLOCK_INPUT; - } + mac_create_frame_window (f, 1); + + if (FRAME_MAC_WINDOW (f)) + { + mac_set_frame_window_background (f, FRAME_BACKGROUND_PIXEL (f)); + tip_window = FRAME_MAC_WINDOW (f); + } + + UNBLOCK_INPUT; x_make_gc (f); @@ -4044,7 +3844,7 @@ x_create_tip_frame (dpyinfo, parms, text) /* Set tip_frame here, so that */ tip_frame = frame; - call1 (Qface_set_after_frame_default, frame); + call2 (Qface_set_after_frame_default, frame, Qnil); if (!EQ (bg, Fframe_parameter (frame, Qbackground_color))) Fmodify_frame_parameters (frame, Fcons (Fcons (Qbackground_color, bg), @@ -4103,7 +3903,7 @@ compute_tip_xy (f, parms, dx, dy, width, height, root_x, root_y) BLOCK_INPUT; #if TARGET_API_MAC_CARBON - GetGlobalMouse (&mouse_pos); + mac_get_global_mouse (&mouse_pos); #else GetMouse (&mouse_pos); LocalToGlobal (&mouse_pos); @@ -4227,7 +4027,7 @@ Text larger than the specified size is clipped. */) BLOCK_INPUT; compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f), FRAME_PIXEL_HEIGHT (f), &root_x, &root_y); - MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false); + mac_move_window (FRAME_MAC_WINDOW (f), root_x, root_y, false); UNBLOCK_INPUT; goto start_timer; } @@ -4329,10 +4129,10 @@ Text larger than the specified size is clipped. */) compute_tip_xy (f, parms, dx, dy, width, height, &root_x, &root_y); BLOCK_INPUT; - MoveWindow (FRAME_MAC_WINDOW (f), root_x, root_y, false); - SizeWindow (FRAME_MAC_WINDOW (f), width, height, true); - ShowWindow (FRAME_MAC_WINDOW (f)); - BringToFront (FRAME_MAC_WINDOW (f)); + mac_move_window (FRAME_MAC_WINDOW (f), root_x, root_y, false); + mac_size_window (FRAME_MAC_WINDOW (f), width, height, true); + mac_show_window (FRAME_MAC_WINDOW (f)); + mac_bring_window_to_front (FRAME_MAC_WINDOW (f)); UNBLOCK_INPUT; FRAME_PIXEL_WIDTH (f) = width; @@ -4393,25 +4193,11 @@ Value is t if tooltip was open, nil otherwise. */) -#if TARGET_API_MAC_CARBON /*********************************************************************** File selection dialog ***********************************************************************/ -static pascal void mac_nav_event_callback P_ ((NavEventCallbackMessage, - NavCBRecPtr, void *)); - -/** - There is a relatively standard way to do this using applescript to run - a (choose file) method. However, this doesn't do "the right thing" - by working only if the find-file occurred during a menu or toolbar - click. So we must do the file dialog by hand, using the navigation - manager. This also has more flexibility in determining the default - directory and whether or not we are going to choose a file. - **/ - -extern Lisp_Object Qfile_name_history; - +#if TARGET_API_MAC_CARBON DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, doc: /* Read file name, prompting with PROMPT in directory DIR. Use a file selection dialog. @@ -4421,182 +4207,10 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) (prompt, dir, default_filename, mustmatch, only_dir_p) Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p; { - Lisp_Object file = Qnil; - int count = SPECPDL_INDEX (); - struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6; - char filename[MAXPATHLEN]; - static NavEventUPP mac_nav_event_callbackUPP = NULL; - - check_mac (); - - GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p); - CHECK_STRING (prompt); - CHECK_STRING (dir); - - /* Create the dialog with PROMPT as title, using DIR as initial - directory and using "*" as pattern. */ - dir = Fexpand_file_name (dir, Qnil); - - { - OSStatus status; - NavDialogCreationOptions options; - NavDialogRef dialogRef; - NavTypeListHandle fileTypes = NULL; - NavUserAction userAction; - CFStringRef message=NULL, saveName = NULL; - - BLOCK_INPUT; - /* No need for a callback function because we are modal */ - NavGetDefaultDialogCreationOptions(&options); - options.modality = kWindowModalityAppModal; - options.location.h = options.location.v = -1; - options.optionFlags = kNavDefaultNavDlogOptions; - options.optionFlags |= kNavAllFilesInPopup; /* All files allowed */ - options.optionFlags |= kNavSelectAllReadableItem; - options.optionFlags &= ~kNavAllowMultipleFiles; - if (!NILP(prompt)) - { - message = cfstring_create_with_string (prompt); - options.message = message; - } - /* Don't set the application, let it use default. - options.clientName = CFSTR ("Emacs"); - */ - - if (mac_nav_event_callbackUPP == NULL) - mac_nav_event_callbackUPP = NewNavEventUPP (mac_nav_event_callback); - - if (!NILP (only_dir_p)) - status = NavCreateChooseFolderDialog(&options, mac_nav_event_callbackUPP, - NULL, NULL, &dialogRef); - else if (NILP (mustmatch)) - { - /* This is a save dialog */ - options.optionFlags |= kNavDontConfirmReplacement; - options.actionButtonLabel = CFSTR ("Ok"); - options.windowTitle = CFSTR ("Enter name"); - - if (STRINGP (default_filename)) - { - Lisp_Object utf8 = ENCODE_UTF_8 (default_filename); - char *begPtr = SDATA(utf8); - char *filePtr = begPtr + SBYTES(utf8); - while (filePtr != begPtr && !IS_DIRECTORY_SEP(filePtr[-1])) - filePtr--; - saveName = cfstring_create_with_utf8_cstring (filePtr); - options.saveFileName = saveName; - options.optionFlags |= kNavSelectDefaultLocation; - } - status = NavCreatePutFileDialog(&options, - 'TEXT', kNavGenericSignature, - mac_nav_event_callbackUPP, NULL, - &dialogRef); - } - else - { - /* This is an open dialog*/ - status = NavCreateChooseFileDialog(&options, fileTypes, - mac_nav_event_callbackUPP, NULL, - NULL, NULL, &dialogRef); - } - - /* Set the default location and continue*/ - if (status == noErr) - { - Lisp_Object encoded_dir = ENCODE_FILE (dir); - AEDesc defLocAed; - - status = AECreateDesc (TYPE_FILE_NAME, SDATA (encoded_dir), - SBYTES (encoded_dir), &defLocAed); - if (status == noErr) - { - NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed); - AEDisposeDesc(&defLocAed); - } - status = NavDialogRun(dialogRef); - } - - if (saveName) CFRelease(saveName); - if (message) CFRelease(message); - - if (status == noErr) { - userAction = NavDialogGetUserAction(dialogRef); - switch (userAction) - { - case kNavUserActionNone: - case kNavUserActionCancel: - break; /* Treat cancel like C-g */ - case kNavUserActionOpen: - case kNavUserActionChoose: - case kNavUserActionSaveAs: - { - NavReplyRecord reply; - Size len; - - status = NavDialogGetReply(dialogRef, &reply); - if (status != noErr) - break; - status = AEGetNthPtr (&reply.selection, 1, TYPE_FILE_NAME, - NULL, NULL, filename, - sizeof (filename) - 1, &len); - if (status == noErr) - { - len = min (len, sizeof (filename) - 1); - filename[len] = '\0'; - if (reply.saveFileName) - { - /* If it was a saved file, we need to add the file name */ - if (len && len < sizeof (filename) - 1 - && filename[len-1] != '/') - filename[len++] = '/'; - CFStringGetCString(reply.saveFileName, filename+len, - sizeof (filename) - len, -#ifdef MAC_OSX - kCFStringEncodingUTF8 -#else - CFStringGetSystemEncoding () -#endif - ); - } - file = DECODE_FILE (make_unibyte_string (filename, - strlen (filename))); - } - NavDisposeReply(&reply); - } - 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); - } - } - - UNGCPRO; - - /* Make "Cancel" equivalent to C-g. */ - if (NILP (file)) - Fsignal (Qquit, Qnil); - - return unbind_to (count, file); -} - - -/* Need to register some event callback function for enabling drag and - drop in Navigation Service dialogs. */ -static pascal void -mac_nav_event_callback (selector, parms, data) - NavEventCallbackMessage selector; - NavCBRecPtr parms; - void *data ; -{ + return mac_file_dialog (prompt, dir, default_filename, mustmatch, only_dir_p); } #endif + /*********************************************************************** Fonts @@ -4659,8 +4273,8 @@ ID is specified by either an integer or a float. */) Lisp_Object result; check_mac (); - CHECK_NUMBER_OR_FLOAT(id); - font_id = NUMBERP (id) ? XINT (id) : (ATSUFontID) XFLOAT (id); + CHECK_NUMBER_OR_FLOAT (id); + font_id = INTEGERP (id) ? XINT (id) : XFLOAT_DATA (id); BLOCK_INPUT; result = mac_atsu_font_face_attributes (font_id); UNBLOCK_INPUT; @@ -4707,6 +4321,8 @@ frame_parm_handler mac_frame_parm_handlers[] = x_set_fringe_width, 0, /* x_set_wait_for_wm, */ x_set_fullscreen, + 0, /* x_set_font_backend, */ + 0 /* x_set_alpha, */ }; void