/* Graphical user interface functions for Mac OS.
Copyright (C) 2000, 2001, 2002, 2003, 2004,
- 2005, 2006 Free Software Foundation, Inc.
+ 2005, 2006, 2007 Free Software Foundation, Inc.
This file is part of GNU Emacs.
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 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Emacs is distributed in the hope that it will be useful,
extern void free_frame_menubar ();
+#if TARGET_API_MAC_CARBON
+
+/* Carbon version info */
+
+static Lisp_Object Vmac_carbon_version_string;
+
+#endif /* TARGET_API_MAC_CARBON */
+
/* Non-zero means we're allowed to display an hourglass cursor. */
int display_hourglass_p;
int image_cache_refcount, dpyinfo_refcount;
#endif
-
#if 0 /* Use xstricmp instead. */
/* compare two strings ignoring case */
void x_set_menu_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
void x_set_title P_ ((struct frame *, Lisp_Object, Lisp_Object));
void x_set_tool_bar_lines P_ ((struct frame *, Lisp_Object, Lisp_Object));
-
-extern void mac_get_window_bounds P_ ((struct frame *, Rect *, Rect *));
-
\f
/* Store the screen positions of frame F into XPTR and YPTR.
char *name;
} colormap_t;
-colormap_t mac_color_map[] =
+static const colormap_t mac_color_map[] =
{
{ RGB_TO_ULONG(255, 250, 250), "snow" },
{ RGB_TO_ULONG(248, 248, 255), "ghost white" },
Lisp_Object
mac_color_map_lookup (colorname)
- char *colorname;
+ const char *colorname;
{
Lisp_Object ret = Qnil;
int i;
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;
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;
if (STRINGP (oldval) && EQ (Fstring_equal (oldval, arg), Qt))
return;
}
- else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil))
+ else if (!NILP (arg) || NILP (oldval))
return;
f->icon_name = arg;
/* Make sure we redisplay all windows in this frame. */
++windows_or_buffers_changed;
+#if USE_MAC_TOOLBAR
+ FRAME_TOOL_BAR_LINES (f) = 0;
+ if (nlines)
+ {
+ FRAME_EXTERNAL_TOOL_BAR (f) = 1;
+ if (FRAME_MAC_P (f) && !IsWindowToolbarVisible (FRAME_MAC_WINDOW (f)))
+ /* Make sure next redisplay shows the tool bar. */
+ XWINDOW (FRAME_SELECTED_WINDOW (f))->update_mode_line = Qt;
+ }
+ else
+ {
+ if (FRAME_EXTERNAL_TOOL_BAR (f))
+ free_frame_tool_bar (f);
+ FRAME_EXTERNAL_TOOL_BAR (f) = 0;
+ }
+
+ return;
+#endif
+
delta = nlines - FRAME_TOOL_BAR_LINES (f);
/* Don't resize the tool-bar to more than we have room for. */
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
#endif /* not MAC_OSX */
}
-void
-mac_set_scroll_bar_width (f, arg, oldval)
- struct frame *f;
- Lisp_Object arg, oldval;
-{
-#ifdef MAC_OSX
- if (INTEGERP (arg) && XINT (arg) > 0)
- {
- if (XINT (arg) < (MAC_AQUA_SMALL_VERTICAL_SCROLL_BAR_WIDTH
- + MAC_AQUA_VERTICAL_SCROLL_BAR_WIDTH) / 2)
- XSETINT (arg, MAC_AQUA_SMALL_VERTICAL_SCROLL_BAR_WIDTH);
- else
- XSETINT (arg, MAC_AQUA_VERTICAL_SCROLL_BAR_WIDTH);
- }
-#endif
- x_set_scroll_bar_width (f, arg, oldval);
-}
-
static void
mac_set_font (f, arg, oldval)
struct frame *f;
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);
-
- if (FRAME_FILE_NAME (f) == NULL && !STRINGP (file_name))
- return;
- if (FRAME_FILE_NAME (f) && STRINGP (file_name)
- && strcmp (FRAME_FILE_NAME (f), SDATA (file_name)) == 0)
- return;
-
- if (FRAME_FILE_NAME (f))
- {
- xfree (FRAME_FILE_NAME (f));
- FRAME_FILE_NAME (f) = NULL;
- }
+ AliasHandle alias = NULL;
BLOCK_INPUT;
+ err = GetWindowProxyAlias (w, &alias);
+ if (err == errWindowDoesNotHaveProxy && !STRINGP (file_name))
+ goto out;
+
if (STRINGP (file_name))
{
- OSStatus err;
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_OS8
+#ifdef MAC_OSX
+ err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name),
+ SBYTES (encoded_file_name), typeFSRef, &desc);
+#else
SetPortWindowPort (w);
-#endif
err = AECoercePtr (TYPE_FILE_NAME, SDATA (encoded_file_name),
- SBYTES (encoded_file_name), typeAlias, &desc);
+ SBYTES (encoded_file_name), typeFSS, &desc);
+#endif
if (err == noErr)
{
- Size size = AEGetDescDataSize (&desc);
- AliasHandle alias = (AliasHandle) NewHandle (size);
-
- if (alias == NULL)
- err = memFullErr;
- else
- {
- HLock ((Handle) alias);
- err = AEGetDescData (&desc, *alias, size);
- HUnlock ((Handle) alias);
- if (err == noErr)
- err = SetWindowProxyAlias (w, alias);
- DisposeHandle ((Handle) alias);
- }
+#ifdef MAC_OSX
+ err = AEGetDescData (&desc, &fref, sizeof (FSRef));
+#else
+ err = AEGetDescData (&desc, &fss, sizeof (FSSpec));
+#endif
AEDisposeDesc (&desc);
}
if (err == noErr)
{
- FRAME_FILE_NAME (f) = xmalloc (SBYTES (file_name) + 1);
- strcpy (FRAME_FILE_NAME (f), SDATA (file_name));
+ 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 (FRAME_FILE_NAME (f) == NULL)
+ if (alias)
+ DisposeHandle ((Handle) alias);
+
+ if (err != noErr || !STRINGP (file_name))
RemoveWindowProxy (w);
+ out:
UNBLOCK_INPUT;
}
#endif
confusing. */
|| (!MINI_WINDOW_P (w)
&& (modified_p != !NILP (w->last_had_star))))
- SetWindowModified (FRAME_MAC_WINDOW (f),
- !MINI_WINDOW_P (w) && modified_p);
-
- if (windows_or_buffers_changed)
- mac_update_proxy_icon (f);
+ {
+ SetWindowModified (FRAME_MAC_WINDOW (f),
+ !MINI_WINDOW_P (w) && modified_p);
+ mac_update_proxy_icon (f);
+ }
#endif
}
/* Create and set up the Mac window for frame F. */
static void
-mac_window (f)
+mac_window (f, window_prompting, minibuffer_only)
struct frame *f;
+ long window_prompting;
+ int minibuffer_only;
{
Rect r;
FRAME_MAC_WINDOW (f) = NULL;
}
}
-#else
+#else /* !TARGET_API_MAC_CARBON */
FRAME_MAC_WINDOW (f)
= NewCWindow (NULL, &r, "\p", false, zoomDocProc,
- (WindowPtr) -1, 1, (long) f->output_data.mac);
-#endif
+ (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 */
XSetWindowBackground (FRAME_MAC_DISPLAY(f), FRAME_MAC_WINDOW (f),
FRAME_BACKGROUND_PIXEL (f));
+#if USE_MAC_TOOLBAR
+ /* At the moment, the size of the tool bar is not yet known. We
+ record the gravity value of the newly created window and use it
+ to adjust the position of the window (especially for a negative
+ specification of its vertical position) when the tool bar is
+ first redisplayed. */
+ if (FRAME_EXTERNAL_TOOL_BAR (f))
+ f->output_data.mac->toolbar_win_gravity = f->win_gravity;
+#endif
+
validate_x_resource_name ();
/* x_set_name normally ignores requests to set the name if the
= (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
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.
+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;
check_mac ();
- parms = Fcopy_alist (parms);
-
/* Use this general default value to start with
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;
+ kb = dpyinfo->terminal->kboard;
#else
kb = &the_only_kboard;
#endif
- 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))
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))
/* 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);
/* 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));
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. */
#if GLYPH_DEBUG
image_cache_refcount = FRAME_X_IMAGE_CACHE (f)->refcount;
dpyinfo_refcount = dpyinfo->reference_count;
{
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. */
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))
error ("Cannot find any usable font");
UNBLOCK_INPUT;
- x_default_parameter (f, parms, Qfont, font,
+ 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);
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);
+ mac_window (f, window_prompting, minibuffer_only);
+ x_icon (f, parameters);
- x_icon (f, parms);
x_make_gc (f);
/* Now consider the frame official. */
/* 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
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
{
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;
/* 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; !NILP (tem); tem = XCDR (tem))
if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
f->param_alist = Fcons (XCAR (tem), f->param_alist);
+ store_frame_param (f, Qwindow_system, Qmac);
+
UNGCPRO;
/* Make sure windows on this frame appear in calls to next-window
(frame)
Lisp_Object frame;
{
+ OSErr err;
+ ProcessSerialNumber front_psn;
+ static const ProcessSerialNumber current_psn = {0, kCurrentProcess};
+ Boolean front_p;
struct frame *f = check_x_frame (frame);
BLOCK_INPUT;
+ /* Move the current process to the foreground if it is not. Don't
+ call SetFrontProcess if the current process is already running in
+ the foreground so as not to change the z-order of windows. */
+ err = GetFrontProcess (&front_psn);
+ if (err == noErr)
+ err = SameProcess (&front_psn, ¤t_psn, &front_p);
+ if (err == noErr)
+ if (!front_p)
+ {
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1020
+ if (FrontNonFloatingWindow () == FRAME_MAC_WINDOW (f))
+ SetFrontProcessWithOptions (¤t_psn,
+ kSetFrontProcessFrontWindowOnly);
+ else
+#endif
+ SetFrontProcess (¤t_psn);
+ }
+
#ifdef MAC_OSX
ActivateWindow (ActiveNonFloatingWindow (), false);
ActivateWindow (FRAME_MAC_WINDOW (f), true);
CHECK_STRING (color);
if (mac_defined_color (f, SDATA (color), &foo, 0))
- {
- Lisp_Object rgb[3];
-
- rgb[0] = make_number (foo.red);
- rgb[1] = make_number (foo.green);
- rgb[2] = make_number (foo.blue);
- return Flist (3, rgb);
- }
+ return list3 (make_number (foo.red),
+ make_number (foo.green),
+ make_number (foo.blue));
else
return Qnil;
}
(display)
Lisp_Object display;
{
- return build_string ("Apple Computers");
+ return build_string ("Apple Inc.");
}
DEFUN ("x-server-version", Fx_server_version, Sx_server_version, 0, 1, 0,
(display)
Lisp_Object display;
{
- /* MAC_TODO: this is an approximation, and only of the main display */
-
struct mac_display_info *dpyinfo = check_x_display_info (display);
+ float mm_per_pixel;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+ if (CGDisplayScreenSize != NULL)
+#endif
+ {
+ CGSize size;
+
+ BLOCK_INPUT;
+ size = CGDisplayScreenSize (kCGDirectMainDisplay);
+ mm_per_pixel = size.height / CGDisplayPixelsHigh (kCGDirectMainDisplay);
+ UNBLOCK_INPUT;
+ }
+#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+ else /* CGDisplayScreenSize == NULL */
+#endif
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 || MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+ {
+ /* This is an approximation. */
+ mm_per_pixel = 25.4f / dpyinfo->resy;
+ }
+#endif
- return make_number ((int) (dpyinfo->height * 25.4 / dpyinfo->resy));
+ return make_number ((int) (dpyinfo->height * mm_per_pixel + 0.5f));
}
DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
(display)
Lisp_Object display;
{
- /* MAC_TODO: this is an approximation, and only of the main display */
-
struct mac_display_info *dpyinfo = check_x_display_info (display);
+ float mm_per_pixel;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1030
+#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+ if (CGDisplayScreenSize != NULL)
+#endif
+ {
+ CGSize size;
- return make_number ((int) (dpyinfo->width * 25.4 / dpyinfo->resx));
+ BLOCK_INPUT;
+ size = CGDisplayScreenSize (kCGDirectMainDisplay);
+ mm_per_pixel = size.width / CGDisplayPixelsWide (kCGDirectMainDisplay);
+ UNBLOCK_INPUT;
+ }
+#if MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+ else /* CGDisplayScreenSize == NULL */
+#endif
+#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1030 */
+#if MAC_OS_X_VERSION_MAX_ALLOWED < 1030 || MAC_OS_X_VERSION_MIN_REQUIRED == 1020
+ {
+ /* This is an approximation. */
+ mm_per_pixel = 25.4f / dpyinfo->resx;
+ }
+#endif
+
+ return make_number ((int) (dpyinfo->width * mm_per_pixel + 0.5f));
}
DEFUN ("x-display-backing-store", Fx_display_backing_store,
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))
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
EMACS_TIME delay;
int secs, usecs = 0;
- /* Don't bother for ttys. */
- if (NILP (Vwindow_system))
- return;
-
cancel_hourglass ();
if (INTEGERP (Vhourglass_delay)
parms = Fcopy_alist (parms);
#ifdef MULTI_KBOARD
- kb = dpyinfo->kboard;
+ kb = dpyinfo->terminal->kboard;
#else
kb = &the_only_kboard;
#endif
Point mouse_pos;
BLOCK_INPUT;
+#if TARGET_API_MAC_CARBON
+ GetGlobalMouse (&mouse_pos);
+#else
GetMouse (&mouse_pos);
LocalToGlobal (&mouse_pos);
+#endif
*root_x = mouse_pos.h;
*root_y = mouse_pos.v;
UNBLOCK_INPUT;
doc: /* Show STRING in a "tooltip" window on frame FRAME.
A tooltip window is a small window displaying a string.
+This is an internal function; Lisp code should call `tooltip-show'.
+
FRAME nil or omitted means use the selected frame.
PARMS is an optional list of frame parameters which can be used to
(prompt, dir, default_filename, mustmatch, only_dir_p)
Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
{
- struct frame *f = SELECTED_FRAME ();
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);
filename[len++] = '/';
CFStringGetCString(reply.saveFileName, filename+len,
sizeof (filename) - len,
-#if MAC_OSX
+#ifdef MAC_OSX
kCFStringEncodingUTF8
#else
CFStringGetSystemEncoding ()
}
#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.
+DEFUN ("mac-set-font-panel-visible-p", Fmac_set_font_panel_visible_p,
+ Smac_set_font_panel_visible_p, 1, 1, 0,
+ doc: /* Make the font panel visible if and only if FLAG is non-nil.
This is for internal use only. Use `mac-font-panel-mode' instead. */)
- (visible)
- Lisp_Object visible;
+ (flag)
+ Lisp_Object flag;
{
OSStatus err = noErr;
check_mac ();
BLOCK_INPUT;
- if (NILP (visible) == (FPIsFontPanelVisible () == true))
- err = FPShowHideFontPanel ();
+ if (NILP (flag) != !mac_font_panel_visible_p ())
+ {
+ err = mac_show_hide_font_panel ();
+ if (err == noErr && !NILP (flag))
+ {
+ Lisp_Object focus_frame = x_get_focus_frame (SELECTED_FRAME ());
+ struct frame *f = (NILP (focus_frame) ? SELECTED_FRAME ()
+ : XFRAME (focus_frame));
+
+ mac_set_font_info_for_selection (f, DEFAULT_FACE_ID, 0);
+ }
+ }
UNBLOCK_INPUT;
if (err != noErr)
return Qnil;
}
#endif
+
+#if USE_ATSUI
+extern Lisp_Object mac_atsu_font_face_attributes P_ ((ATSUFontID));
+
+DEFUN ("mac-atsu-font-face-attributes", Fmac_atsu_font_face_attributes,
+ Smac_atsu_font_face_attributes, 1, 1, 0,
+ doc: /* Return plist of face attributes and values for ATSU font ID.
+ID is specified by either an integer or a float. */)
+ (id)
+ Lisp_Object id;
+{
+ ATSUFontID font_id;
+ Lisp_Object result;
+
+ check_mac ();
+ CHECK_NUMBER_OR_FLOAT(id);
+ font_id = NUMBERP (id) ? XINT (id) : (ATSUFontID) XFLOAT (id);
+ BLOCK_INPUT;
+ result = mac_atsu_font_face_attributes (font_id);
+ UNBLOCK_INPUT;
+ return result;
+}
+#endif
+
\f
/***********************************************************************
Initialization
x_set_menu_bar_lines,
x_set_mouse_color,
x_explicitly_set_name,
- mac_set_scroll_bar_width,
+ x_set_scroll_bar_width,
x_set_title,
x_set_unsplittable,
x_set_vertical_scroll_bars,
Chinese, Japanese, and Korean. */);
Vx_pixel_size_width_font_regexp = Qnil;
+#if TARGET_API_MAC_CARBON
+ DEFVAR_LISP ("mac-carbon-version-string", &Vmac_carbon_version_string,
+ doc: /* Version info for Carbon API. */);
+ {
+ OSErr err;
+ UInt32 response;
+ char carbon_version[16] = "Unknown";
+
+ err = Gestalt (gestaltCarbonVersion, &response);
+ if (err == noErr)
+ sprintf (carbon_version, "%u.%u.%u",
+ (response >> 8) & 0xf, (response >> 4) & 0xf, response & 0xf);
+ Vmac_carbon_version_string = build_string (carbon_version);
+ }
+#endif /* TARGET_API_MAC_CARBON */
+
/* X window properties. */
defsubr (&Sx_change_window_property);
defsubr (&Sx_delete_window_property);
#endif
defsubr (&Smac_clear_font_name_table);
#if USE_MAC_FONT_PANEL
- defsubr (&Smac_set_font_panel_visibility);
+ defsubr (&Smac_set_font_panel_visible_p);
+#endif
+#if USE_ATSUI
+ defsubr (&Smac_atsu_font_face_attributes);
#endif
}