/* Functions for the NeXT/Open/GNUstep and MacOSX window system.
-Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2011
- Free Software Foundation, Inc.
+Copyright (C) 1989, 1992-1994, 2005-2006, 2008-2013 Free Software
+Foundation, Inc.
This file is part of GNU Emacs.
interpretation of even the system includes. */
#include <config.h>
-#include <signal.h>
#include <math.h>
-#include <setjmp.h>
+#include <c-strcase.h>
#include "lisp.h"
#include "blockinput.h"
#include "nsterm.h"
#include "window.h"
+#include "character.h"
#include "buffer.h"
#include "keyboard.h"
#include "termhooks.h"
#include "fontset.h"
-#include "character.h"
#include "font.h"
#if 0
extern Lisp_Object Qunderline, Qundefined;
extern Lisp_Object Qheight, Qminibuffer, Qname, Qonly, Qwidth;
extern Lisp_Object Qunsplittable, Qmenu_bar_lines, Qbuffer_predicate, Qtitle;
-extern Lisp_Object Qnone;
Lisp_Object Qbuffered;
/* Need forward declaration here to preserve organizational integrity of file */
Lisp_Object Fx_open_connection (Lisp_Object, Lisp_Object, Lisp_Object);
-extern BOOL ns_in_resize;
-
/* Static variables to handle applescript execution. */
static Lisp_Object as_script, *as_result;
static int as_status;
+#ifdef GLYPH_DEBUG
+static ptrdiff_t image_cache_refcount;
+#endif
+
/* ==========================================================================
Internal utility functions
if (face)
{
col = ns_lookup_indexed_color (NS_FACE_BACKGROUND (face), f);
- face->background
- = (EMACS_UINT) [[col colorWithAlphaComponent: alpha] retain];
- [col release];
+ face->background = ns_index_color
+ ([col colorWithAlphaComponent: alpha], f);
update_face_from_frame_parameter (f, Qbackground_color, arg);
}
NSView *view = FRAME_NS_VIEW (f);
NSTRACE (x_set_icon_name);
- if (ns_in_resize)
- return;
-
/* see if it's changed */
if (STRINGP (arg))
{
else if (!STRINGP (oldval) && EQ (oldval, Qnil) == EQ (arg, Qnil))
return;
- f->icon_name = arg;
+ fset_icon_name (f, arg);
if (NILP (arg))
{
if ([[view window] miniwindowTitle] &&
([[[view window] miniwindowTitle]
isEqualToString: [NSString stringWithUTF8String:
- SDATA (arg)]]))
+ SSDATA (arg)]]))
return;
[[view window] setMiniwindowTitle:
- [NSString stringWithUTF8String: SDATA (arg)]];
+ [NSString stringWithUTF8String: SSDATA (arg)]];
}
static void
encoded_name = ENCODE_UTF_8 (name);
UNGCPRO;
- str = [NSString stringWithUTF8String: SDATA (encoded_name)];
+ str = [NSString stringWithUTF8String: SSDATA (encoded_name)];
/* Don't change the name if it's already NAME. */
if (! [[[view window] title] isEqualToString: str])
else
encoded_icon_name = ENCODE_UTF_8 (f->icon_name);
- str = [NSString stringWithUTF8String: SDATA (encoded_icon_name)];
+ str = [NSString stringWithUTF8String: SSDATA (encoded_icon_name)];
if ([[view window] miniwindowTitle] &&
! [[[view window] miniwindowTitle] isEqualToString: str])
static void
ns_set_name (struct frame *f, Lisp_Object name, int explicit)
{
- NSView *view;
NSTRACE (ns_set_name);
- if (ns_in_resize)
- return;
-
/* Make sure that requests from lisp code override requests from
Emacs redisplay code. */
if (explicit)
if (! NILP (Fstring_equal (name, f->name)))
return;
- f->name = name;
+ fset_name (f, name);
/* title overrides explicit name */
if (! NILP (f->title))
update_mode_lines = 1;
- f->title = name;
+ fset_title (f, name);
if (NILP (name))
name = f->name;
NSString *str;
NSTRACE (ns_set_name_as_filename);
- if (f->explicit_name || ! NILP (f->title) || ns_in_resize)
+ if (f->explicit_name || ! NILP (f->title))
return;
- BLOCK_INPUT;
+ block_input ();
pool = [[NSAutoreleasePool alloc] init];
filename = BVAR (XBUFFER (buf), filename);
name = BVAR (XBUFFER (buf), name);
title = FRAME_ICONIFIED_P (f) ? [[[view window] miniwindowTitle] UTF8String]
: [[[view window] title] UTF8String];
- if (title && (! strcmp (title, SDATA (encoded_name))))
+ if (title && (! strcmp (title, SSDATA (encoded_name))))
{
[pool release];
- UNBLOCK_INPUT;
+ unblock_input ();
return;
}
- str = [NSString stringWithUTF8String: SDATA (encoded_name)];
+ str = [NSString stringWithUTF8String: SSDATA (encoded_name)];
if (str == nil) str = @"Bad coding";
if (FRAME_ICONIFIED_P (f))
encoded_filename = ENCODE_UTF_8 (filename);
UNGCPRO;
- fstr = [NSString stringWithUTF8String: SDATA (encoded_filename)];
+ fstr = [NSString stringWithUTF8String: SSDATA (encoded_filename)];
if (fstr == nil) fstr = @"";
#ifdef NS_IMPL_COCOA
/* work around a bug observed on 10.3 and later where
[[view window] setRepresentedFilename: fstr];
[[view window] setTitle: str];
- f->name = name;
+ fset_name (f, name);
}
[pool release];
- UNBLOCK_INPUT;
+ unblock_input ();
}
NSAutoreleasePool *pool;
if (!MINI_WINDOW_P (XWINDOW (f->selected_window)))
{
- BLOCK_INPUT;
+ block_input ();
pool = [[NSAutoreleasePool alloc] init];
[[view window] setDocumentEdited: !NILP (arg)];
[pool release];
- UNBLOCK_INPUT;
+ unblock_input ();
}
}
x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
int nlines;
- int olines = FRAME_MENU_BAR_LINES (f);
if (FRAME_MINIBUF_ONLY_P (f))
return;
x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
{
int nlines;
- Lisp_Object root_window;
if (FRAME_MINIBUF_ONLY_P (f))
return;
{
Lisp_Object tem;
EmacsView *view = FRAME_NS_VIEW (f);
- id image =nil;
+ id image = nil;
Lisp_Object chain, elt;
NSAutoreleasePool *pool;
BOOL setMini = YES;
NSTRACE (ns_implicitly_set_icon_type);
- BLOCK_INPUT;
+ block_input ();
pool = [[NSAutoreleasePool alloc] init];
if (f->output_data.ns->miniimage
- && [[NSString stringWithUTF8String: SDATA (f->name)]
+ && [[NSString stringWithUTF8String: SSDATA (f->name)]
isEqualToString: [(NSImage *)f->output_data.ns->miniimage name]])
{
[pool release];
- UNBLOCK_INPUT;
+ unblock_input ();
return;
}
if (CONSP (tem) && ! NILP (XCDR (tem)))
{
[pool release];
- UNBLOCK_INPUT;
+ unblock_input ();
return;
}
for (chain = Vns_icon_type_alist;
- (image = nil) && CONSP (chain);
+ image == nil && CONSP (chain);
chain = XCDR (chain))
{
elt = XCAR (chain);
/* special case: 't' means go by file type */
- if (SYMBOLP (elt) && EQ (elt, Qt) && SDATA (f->name)[0] == '/')
+ if (SYMBOLP (elt) && EQ (elt, Qt) && SSDATA (f->name)[0] == '/')
{
NSString *str
- = [NSString stringWithUTF8String: SDATA (f->name)];
+ = [NSString stringWithUTF8String: SSDATA (f->name)];
if ([[NSFileManager defaultManager] fileExistsAtPath: str])
image = [[[NSWorkspace sharedWorkspace] iconForFile: str] retain];
}
if (image == nil)
image = [[NSImage imageNamed:
[NSString stringWithUTF8String:
- SDATA (XCDR (elt))]] retain];
+ SSDATA (XCDR (elt))]] retain];
}
}
f->output_data.ns->miniimage = image;
[view setMiniwindowImage: setMini];
[pool release];
- UNBLOCK_INPUT;
+ unblock_input ();
}
if (!NILP (arg) && SYMBOLP (arg))
{
- arg =build_string (SDATA (SYMBOL_NAME (arg)));
+ arg =build_string (SSDATA (SYMBOL_NAME (arg)));
store_frame_param (f, Qicon_type, arg);
}
image = [EmacsImage allocInitFromFile: arg];
if (image == nil)
image =[NSImage imageNamed: [NSString stringWithUTF8String:
- SDATA (arg)]];
+ SSDATA (arg)]];
if (image == nil)
{
}
-/* Xism; we stub out (we do implement this in ns-win.el) */
-int
-XParseGeometry (char *string, int *x, int *y,
- unsigned int *width, unsigned int *height)
-{
- message1 ("Warning: XParseGeometry not supported under NS.\n");
- return 0;
-}
-
-
/* TODO: move to nsterm? */
int
ns_lisp_to_cursor_type (Lisp_Object arg)
{
char *str;
if (XTYPE (arg) == Lisp_String)
- str = SDATA (arg);
+ str = SSDATA (arg);
else if (XTYPE (arg) == Lisp_Symbol)
- str = SDATA (SYMBOL_NAME (arg));
+ str = SSDATA (SYMBOL_NAME (arg));
else return -1;
if (!strcmp (str, "box")) return FILLED_BOX_CURSOR;
if (!strcmp (str, "hollow")) return HOLLOW_BOX_CURSOR;
x_set_fringe_width, /* generic OK */
x_set_fringe_width, /* generic OK */
0, /* x_set_wait_for_wm, will ignore */
- 0, /* x_set_fullscreen will ignore */
+ x_set_fullscreen, /* generic OK */
x_set_font_backend, /* generic OK */
x_set_alpha,
0, /* x_set_sticky */
};
+/* Handler for signals raised during x_create_frame.
+ FRAME is the frame which is partially constructed. */
+
+static Lisp_Object
+unwind_create_frame (Lisp_Object frame)
+{
+ struct frame *f = XFRAME (frame);
+
+ /* If frame is already dead, nothing to do. This can happen if the
+ display is disconnected after the frame has become official, but
+ before x_create_frame removes the unwind protect. */
+ if (!FRAME_LIVE_P (f))
+ return Qnil;
+
+ /* If frame is ``official'', nothing to do. */
+ if (NILP (Fmemq (frame, Vframe_list)))
+ {
+#if defined GLYPH_DEBUG && defined ENABLE_CHECKING
+ struct ns_display_info *dpyinfo = FRAME_X_DISPLAY_INFO (f);
+#endif
+
+ x_free_frame_resources (f);
+ free_glyphs (f);
+
+#ifdef GLYPH_DEBUG
+ /* Check that reference counts are indeed correct. */
+ eassert (dpyinfo->terminal->image_cache->refcount == image_cache_refcount);
+#endif
+ return Qt;
+ }
+
+ return Qnil;
+}
+
+/*
+ * Read geometry related parameters from preferences if not in PARMS.
+ * Returns the union of parms and any preferences read.
+ */
+
+static Lisp_Object
+get_geometry_from_preferences (struct ns_display_info *dpyinfo,
+ Lisp_Object parms)
+{
+ struct {
+ const char *val;
+ const char *cls;
+ Lisp_Object tem;
+ } r[] = {
+ { "width", "Width", Qwidth },
+ { "height", "Height", Qheight },
+ { "left", "Left", Qleft },
+ { "top", "Top", Qtop },
+ };
+
+ int i;
+ for (i = 0; i < sizeof (r)/sizeof (r[0]); ++i)
+ {
+ if (NILP (Fassq (r[i].tem, parms)))
+ {
+ Lisp_Object value
+ = x_get_arg (dpyinfo, parms, r[i].tem, r[i].val, r[i].cls,
+ RES_TYPE_NUMBER);
+ if (! EQ (value, Qunbound))
+ parms = Fcons (Fcons (r[i].tem, value), parms);
+ }
+ }
+
+ return parms;
+}
/* ==========================================================================
DEFUN ("x-create-frame", Fx_create_frame, Sx_create_frame,
1, 1, 0,
- doc: /* Make a new Nextstep window, called a \"frame\" in Emacs terms.
+ doc: /* Make a new Nextstep window, called a "frame" in Emacs terms.
Return an Emacs frame object.
PARMS 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. */)
+be shared by the new frame.
+
+This function is an internal primitive--use `make-frame' instead. */)
(Lisp_Object parms)
{
- static int desc_ctr = 1;
struct frame *f;
- struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
Lisp_Object frame, tem;
Lisp_Object name;
int minibuffer_only = 0;
+ int window_prompting = 0;
+ int width, height;
ptrdiff_t count = specpdl_ptr - specpdl;
+ struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
Lisp_Object display;
struct ns_display_info *dpyinfo = NULL;
Lisp_Object parent;
struct kboard *kb;
Lisp_Object tfont, tfontsize;
- int window_prompting = 0;
- int width, height;
+ static int desc_ctr = 1;
check_ns ();
- /* Seems a little strange, but other terms do it. Perhaps the code below
- is modifying something? */
+ /* x_get_arg modifies parms. */
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 = x_get_arg (dpyinfo, parms, Qterminal, 0, 0, RES_TYPE_STRING);
if (EQ (display, Qunbound))
display = Qnil;
dpyinfo = check_ns_display_info (display);
+ kb = dpyinfo->terminal->kboard;
if (!dpyinfo->terminal->name)
error ("Terminal is not live, can't create new frames on it");
- kb = dpyinfo->terminal->kboard;
-
name = x_get_arg (dpyinfo, parms, Qname, 0, 0, RES_TYPE_STRING);
if (!STRINGP (name)
&& ! EQ (name, Qunbound)
if (STRINGP (name))
Vx_resource_name = name;
- else
- Vx_resource_name = Vinvocation_name;
parent = x_get_arg (dpyinfo, parms, Qparent_id, 0, 0, RES_TYPE_NUMBER);
if (EQ (parent, Qunbound))
if (! NILP (parent))
CHECK_NUMBER (parent);
+ /* make_frame_without_minibuffer can run Lisp code and garbage collect. */
+ /* 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 = x_get_arg (dpyinfo, parms, Qminibuffer, "minibuffer", "Minibuffer",
RES_TYPE_SYMBOL);
if (EQ (tem, Qnone) || NILP (tem))
- {
f = make_frame_without_minibuffer (Qnil, kb, display);
- }
else if (EQ (tem, Qonly))
{
f = make_minibuffer_frame ();
minibuffer_only = 1;
}
else if (WINDOWP (tem))
- {
f = make_frame_without_minibuffer (tem, kb, display);
- }
else
- {
f = make_frame (1);
- }
-
- /* Set the name; the functions to which we pass f expect the name to
- be set. */
- if (EQ (name, Qunbound) || NILP (name) || (XTYPE (name) != Lisp_String))
- {
- f->name = build_string ([ns_app_name UTF8String]);
- f->explicit_name =0;
- }
- else
- {
- f->name = name;
- f->explicit_name = 1;
- specbind (Qx_resource_name, name);
- }
XSETFRAME (frame, f);
FRAME_CAN_HAVE_SCROLL_BARS (f) = 1;
f->terminal = dpyinfo->terminal;
- f->terminal->reference_count++;
f->output_method = output_ns;
- f->output_data.ns = (struct ns_output *)xmalloc (sizeof *(f->output_data.ns));
- memset (f->output_data.ns, 0, sizeof (*(f->output_data.ns)));
+ f->output_data.ns = xzalloc (sizeof *f->output_data.ns);
FRAME_FONTSET (f) = -1;
- /* record_unwind_protect (unwind_create_frame, frame); safety; maybe later? */
-
- f->icon_name = x_get_arg (dpyinfo, parms, Qicon_name, "iconName", "Title",
- RES_TYPE_STRING);
+ fset_icon_name (f, x_get_arg (dpyinfo, parms, Qicon_name,
+ "iconName", "Title",
+ RES_TYPE_STRING));
if (! STRINGP (f->icon_name))
- f->icon_name = Qnil;
+ fset_icon_name (f, Qnil);
FRAME_NS_DISPLAY_INFO (f) = dpyinfo;
+ /* With FRAME_NS_DISPLAY_INFO set up, this unwind-protect is safe. */
+ record_unwind_protect (unwind_create_frame, frame);
+
f->output_data.ns->window_desc = desc_ctr++;
if (TYPE_RANGED_INTEGERP (Window, parent))
{
f->output_data.ns->explicit_parent = 0;
}
+ /* Set the name; the functions to which we pass f expect the name to
+ be set. */
+ if (EQ (name, Qunbound) || NILP (name) || ! STRINGP (name))
+ {
+ fset_name (f, build_string ([ns_app_name UTF8String]));
+ f->explicit_name = 0;
+ }
+ else
+ {
+ fset_name (f, name);
+ f->explicit_name = 1;
+ specbind (Qx_resource_name, name);
+ }
+
f->resx = dpyinfo->resx;
f->resy = dpyinfo->resy;
- BLOCK_INPUT;
+ block_input ();
register_font_driver (&nsfont_driver, f);
x_default_parameter (f, parms, Qfont_backend, Qnil,
"fontBackend", "FontBackend", RES_TYPE_STRING);
build_string ([[font fontName] UTF8String]),
"font", "Font", RES_TYPE_STRING);
}
- UNBLOCK_INPUT;
+ unblock_input ();
x_default_parameter (f, parms, Qborder_width, make_number (0),
"borderwidth", "BorderWidth", RES_TYPE_NUMBER);
"foreground", "Foreground", RES_TYPE_STRING);
x_default_parameter (f, parms, Qbackground_color, build_string ("White"),
"background", "Background", RES_TYPE_STRING);
- /* FIXME: not suppported yet in Nextstep */
+ /* FIXME: not supported yet in Nextstep */
x_default_parameter (f, parms, Qline_spacing, Qnil,
"lineSpacing", "LineSpacing", RES_TYPE_NUMBER);
x_default_parameter (f, parms, Qleft_fringe, Qnil,
"leftFringe", "LeftFringe", RES_TYPE_NUMBER);
x_default_parameter (f, parms, Qright_fringe, Qnil,
"rightFringe", "RightFringe", RES_TYPE_NUMBER);
- /* end PENDING */
+
+#ifdef GLYPH_DEBUG
+ image_cache_refcount =
+ FRAME_IMAGE_CACHE (f) ? FRAME_IMAGE_CACHE (f)->refcount : 0;
+#endif
init_frame_faces (f);
- /* The X resources controlling the menu-bar and tool-bar are
+ /* The resources controlling the menu-bar and tool-bar are
processed specially at startup, and reflected in the mode
variables; ignore them here. */
x_default_parameter (f, parms, Qmenu_bar_lines,
x_default_parameter (f, parms, Qtitle, Qnil, "title", "Title",
RES_TYPE_STRING);
-/* TODO: other terms seem to get away w/o this complexity.. */
- if (NILP (Fassq (Qwidth, parms)))
- {
- Lisp_Object value
- = x_get_arg (dpyinfo, parms, Qwidth, "width", "Width",
- RES_TYPE_NUMBER);
- if (! EQ (value, Qunbound))
- parms = Fcons (Fcons (Qwidth, value), parms);
- }
- if (NILP (Fassq (Qheight, parms)))
- {
- Lisp_Object value
- = x_get_arg (dpyinfo, parms, Qheight, "height", "Height",
- RES_TYPE_NUMBER);
- if (! EQ (value, Qunbound))
- parms = Fcons (Fcons (Qheight, value), parms);
- }
- if (NILP (Fassq (Qleft, parms)))
- {
- Lisp_Object value
- = x_get_arg (dpyinfo, parms, Qleft, "left", "Left", RES_TYPE_NUMBER);
- if (! EQ (value, Qunbound))
- parms = Fcons (Fcons (Qleft, value), parms);
- }
- if (NILP (Fassq (Qtop, parms)))
- {
- Lisp_Object value
- = x_get_arg (dpyinfo, parms, Qtop, "top", "Top", RES_TYPE_NUMBER);
- if (! EQ (value, Qunbound))
- parms = Fcons (Fcons (Qtop, value), parms);
- }
-
+ parms = get_geometry_from_preferences (dpyinfo, parms);
window_prompting = x_figure_window_size (f, parms, 1);
tem = x_get_arg (dpyinfo, parms, Qunsplittable, 0, 0, RES_TYPE_BOOLEAN);
x_icon (f, parms);
+ /* ns_display_info does not have a reference_count. */
+ f->terminal->reference_count++;
+
/* It is now ok to make the frame official even if we get an error below.
The frame needs to be on Vframe_list or making it visible won't work. */
Vframe_list = Fcons (frame, Vframe_list);
- /*FRAME_NS_DISPLAY_INFO (f)->reference_count++; */
-
- x_default_parameter (f, parms, Qicon_type, Qnil, "bitmapIcon", "BitmapIcon",
- RES_TYPE_SYMBOL);
- x_default_parameter (f, parms, Qauto_raise, Qnil, "autoRaise", "AutoRaiseLower",
- RES_TYPE_BOOLEAN);
- x_default_parameter (f, parms, Qauto_lower, Qnil, "autoLower", "AutoLower",
- RES_TYPE_BOOLEAN);
- x_default_parameter (f, parms, 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, parms, Qalpha, Qnil, "alpha", "Alpha",
- RES_TYPE_NUMBER);
+
+ x_default_parameter (f, parms, Qicon_type, Qnil,
+ "bitmapIcon", "BitmapIcon", RES_TYPE_SYMBOL);
+
+ x_default_parameter (f, parms, Qauto_raise, Qnil,
+ "autoRaise", "AutoRaiseLower", RES_TYPE_BOOLEAN);
+ x_default_parameter (f, parms, Qauto_lower, Qnil,
+ "autoLower", "AutoLower", RES_TYPE_BOOLEAN);
+ x_default_parameter (f, parms, 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, parms, Qalpha, Qnil,
+ "alpha", "Alpha", RES_TYPE_NUMBER);
+ x_default_parameter (f, parms, Qfullscreen, Qnil,
+ "fullscreen", "Fullscreen", RES_TYPE_SYMBOL);
width = FRAME_COLS (f);
height = FRAME_LINES (f);
if (! f->output_data.ns->explicit_parent)
{
- tem = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0, RES_TYPE_SYMBOL);
- if (EQ (tem, Qunbound))
- tem = Qt;
- x_set_visibility (f, tem, Qnil);
- if (EQ (tem, Qicon))
+ Lisp_Object visibility;
+
+ visibility = x_get_arg (dpyinfo, parms, Qvisibility, 0, 0,
+ RES_TYPE_SYMBOL);
+ if (EQ (visibility, Qunbound))
+ visibility = Qt;
+
+ if (EQ (visibility, Qicon))
x_iconify_frame (f);
- else if (! NILP (tem))
+ else if (! NILP (visibility))
{
x_make_frame_visible (f);
- f->async_visible = 1;
[[FRAME_NS_VIEW (f) window] makeKeyWindow];
}
else
- f->async_visible = 0;
+ {
+ /* Must have been Qnil. */
+ }
}
if (FRAME_HAS_MINIBUF_P (f)
&& (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame))
|| !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))))
- KVAR (kb, Vdefault_minibuffer_frame) = frame;
+ kset_default_minibuffer_frame (kb, frame);
/* 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; CONSP (tem); tem = XCDR (tem))
if (CONSP (XCAR (tem)) && !NILP (XCAR (XCAR (tem))))
- f->param_alist = Fcons (XCAR (tem), f->param_alist);
+ fset_param_alist (f, Fcons (XCAR (tem), f->param_alist));
UNGCPRO;
+
+ if (window_prompting & USPosition)
+ x_set_offset (f, f->left_pos, f->top_pos, 1);
+
+ /* Make sure windows on this frame appear in calls to next-window
+ and similar functions. */
Vwindow_list = Qnil;
return unbind_to (count, frame);
if (dpyinfo->x_focus_frame != f)
{
EmacsView *view = FRAME_NS_VIEW (f);
- BLOCK_INPUT;
+ block_input ();
[NSApp activateIgnoringOtherApps: YES];
[[view window] makeKeyAndOrderFront: view];
- UNBLOCK_INPUT;
+ unblock_input ();
}
return Qnil;
}
-DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 4, 0,
+DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 5, 0,
doc: /* Use a graphical panel to read a file name, using prompt PROMPT.
Optional arg DIR, if non-nil, supplies a default directory.
Optional arg MUSTMATCH, if non-nil, means the returned file or
directory must exist.
-Optional arg INIT, if non-nil, provides a default file name to use. */)
- (Lisp_Object prompt, Lisp_Object dir, Lisp_Object mustmatch, Lisp_Object init)
+Optional arg INIT, if non-nil, provides a default file name to use.
+Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
+ (Lisp_Object prompt, Lisp_Object dir, Lisp_Object mustmatch,
+ Lisp_Object init, Lisp_Object dir_only_p)
{
static id fileDelegate = nil;
int ret;
Lisp_Object fname;
NSString *promptS = NILP (prompt) || !STRINGP (prompt) ? nil :
- [NSString stringWithUTF8String: SDATA (prompt)];
+ [NSString stringWithUTF8String: SSDATA (prompt)];
NSString *dirS = NILP (dir) || !STRINGP (dir) ?
- [NSString stringWithUTF8String: SDATA (BVAR (current_buffer, directory))] :
- [NSString stringWithUTF8String: SDATA (dir)];
+ [NSString stringWithUTF8String: SSDATA (BVAR (current_buffer, directory))] :
+ [NSString stringWithUTF8String: SSDATA (dir)];
NSString *initS = NILP (init) || !STRINGP (init) ? nil :
- [NSString stringWithUTF8String: SDATA (init)];
+ [NSString stringWithUTF8String: SSDATA (init)];
check_ns ();
if ([dirS characterAtIndex: 0] == '~')
dirS = [dirS stringByExpandingTildeInPath];
- panel = NILP (mustmatch) ?
+ panel = NILP (mustmatch) && NILP (dir_only_p) ?
(id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
[panel setTitle: promptS];
- /* Puma (10.1) does not have */
- if ([panel respondsToSelector: @selector (setAllowsOtherFileTypes:)])
- [panel setAllowsOtherFileTypes: YES];
-
+ [panel setAllowsOtherFileTypes: YES];
[panel setTreatsFilePackagesAsDirectories: YES];
[panel setDelegate: fileDelegate];
panelOK = 0;
- BLOCK_INPUT;
- if (NILP (mustmatch))
+ if (! NILP (dir_only_p))
+ {
+ [panel setCanChooseDirectories: YES];
+ [panel setCanChooseFiles: NO];
+ }
+
+ block_input ();
+#if defined (NS_IMPL_COCOA) && \
+ MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ if (! NILP (mustmatch) || ! NILP (dir_only_p))
+ [panel setAllowedFileTypes: nil];
+ if (dirS) [panel setDirectoryURL: [NSURL fileURLWithPath: dirS]];
+ if (initS && NILP (Ffile_directory_p (init)))
+ [panel setNameFieldStringValue: [initS lastPathComponent]];
+ else
+ [panel setNameFieldStringValue: @""];
+
+ ret = [panel runModal];
+#else
+ if (NILP (mustmatch) && NILP (dir_only_p))
{
ret = [panel runModalForDirectory: dirS file: initS];
}
[panel setCanChooseDirectories: YES];
ret = [panel runModalForDirectory: dirS file: initS types: nil];
}
+#endif
ret = (ret == NSOKButton) || panelOK;
fname = build_string ([[panel filename] UTF8String]);
[[FRAME_NS_VIEW (SELECTED_FRAME ()) window] makeKeyWindow];
- UNBLOCK_INPUT;
+ unblock_input ();
return ret ? fname : Qnil;
}
+const char *
+ns_get_defaults_value (const char *key)
+{
+ NSObject *obj = [[NSUserDefaults standardUserDefaults]
+ objectForKey: [NSString stringWithUTF8String: key]];
+
+ if (!obj) return NULL;
+
+ return [[NSString stringWithFormat: @"%@", obj] UTF8String];
+}
+
DEFUN ("ns-get-resource", Fns_get_resource, Sns_get_resource, 2, 2, 0,
doc: /* Return the value of the property NAME of OWNER from the defaults database.
if (NILP (owner))
owner = build_string([ns_app_name UTF8String]);
CHECK_STRING (name);
-/*fprintf (stderr, "ns-get-resource checking resource '%s'\n", SDATA (name)); */
+/*fprintf (stderr, "ns-get-resource checking resource '%s'\n", SSDATA (name)); */
- value =[[[NSUserDefaults standardUserDefaults]
- objectForKey: [NSString stringWithUTF8String: SDATA (name)]]
- UTF8String];
+ value = ns_get_defaults_value (SSDATA (name));
if (value)
return build_string (value);
if (NILP (value))
{
[[NSUserDefaults standardUserDefaults] removeObjectForKey:
- [NSString stringWithUTF8String: SDATA (name)]];
+ [NSString stringWithUTF8String: SSDATA (name)]];
}
else
{
CHECK_STRING (value);
[[NSUserDefaults standardUserDefaults] setObject:
- [NSString stringWithUTF8String: SDATA (value)]
+ [NSString stringWithUTF8String: SSDATA (value)]
forKey: [NSString stringWithUTF8String:
- SDATA (name)]];
+ SSDATA (name)]];
}
return Qnil;
DEFUN ("x-display-backing-store", Fx_display_backing_store,
Sx_display_backing_store, 0, 1, 0,
- doc: /* Return whether the Nexstep display DISPLAY supports backing store.
+ doc: /* Return whether the Nextstep display DISPLAY supports backing store.
The value may be `buffered', `retained', or `non-retained'.
DISPLAY should be a frame, the display name as a string, or a terminal ID.
If omitted or nil, the selected frame's display is used. */)
{
if (!NILP (must_succeed))
fatal ("OpenStep on %s not responding.\n",
- SDATA (display));
+ SSDATA (display));
else
error ("OpenStep on %s not responding.\n",
- SDATA (display));
+ SSDATA (display));
}
- /* Register our external input/output types, used for determining
- applicable services and also drag/drop eligibility. */
- ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain];
- ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil]
- retain];
- ns_drag_types = [[NSArray arrayWithObjects:
- NSStringPboardType,
- NSTabularTextPboardType,
- NSFilenamesPboardType,
- NSURLPboardType,
- NSColorPboardType,
- NSFontPboardType, nil] retain];
-
return Qnil;
}
DEFUN ("ns-font-name", Fns_font_name, Sns_font_name, 1, 1, 0,
- doc: /* Determine font postscript or family name for font NAME.
+ doc: /* Determine font PostScript or family name for font NAME.
NAME should be a string containing either the font name or an XLFD
font descriptor. If string contains `fontset' and not
`fontset-startup', it is left alone. */)
{
char *nm;
CHECK_STRING (name);
- nm = SDATA (name);
+ nm = SSDATA (name);
if (nm[0] != '-')
return name;
if (strstr (nm, "fontset") && !strstr (nm, "fontset-startup"))
return name;
- return build_string (ns_xlfd_to_fontname (SDATA (name)));
+ return build_string (ns_xlfd_to_fontname (SSDATA (name)));
}
error ("non-Nextstep frame used in `ns-list-colors'");
}
- BLOCK_INPUT;
+ block_input ();
colorlists = [[NSColorList availableColorLists] objectEnumerator];
- while (clist = [colorlists nextObject])
+ while ((clist = [colorlists nextObject]))
{
if ([[clist name] length] < 7 ||
[[clist name] rangeOfString: @"PANTONE"].location == 0)
{
NSEnumerator *cnames = [[clist allKeys] reverseObjectEnumerator];
NSString *cname;
- while (cname = [cnames nextObject])
+ while ((cname = [cnames nextObject]))
list = Fcons (build_string ([cname UTF8String]), list);
/* for (i = [[clist allKeys] count] - 1; i >= 0; i--)
list = Fcons (build_string ([[[clist allKeys] objectAtIndex: i]
}
}
- UNBLOCK_INPUT;
+ unblock_input ();
return list;
}
check_ns ();
svcs = [[NSMenu alloc] initWithTitle: @"Services"];
- [NSApp setServicesMenu: svcs]; /* this and next rebuild on <10.4 */
+ [NSApp setServicesMenu: svcs];
[NSApp registerServicesMenuSendTypes: ns_send_types
returnTypes: ns_return_types];
/* On Tiger, services menu updating was made lazier (waits for user to
actually click on the menu), so we have to force things along: */
#ifdef NS_IMPL_COCOA
- if (NSAppKitVersionNumber >= 744.0)
+ delegate = [svcs delegate];
+ if (delegate != nil)
{
- delegate = [svcs delegate];
- if (delegate != nil)
+ if ([delegate respondsToSelector: @selector (menuNeedsUpdate:)])
+ [delegate menuNeedsUpdate: svcs];
+ if ([delegate respondsToSelector:
+ @selector (menu:updateItem:atIndex:shouldCancel:)])
{
- if ([delegate respondsToSelector: @selector (menuNeedsUpdate:)])
- [delegate menuNeedsUpdate: svcs];
- if ([delegate respondsToSelector:
- @selector (menu:updateItem:atIndex:shouldCancel:)])
- {
- int i, len = [delegate numberOfItemsInMenu: svcs];
- for (i =0; i<len; i++)
- [svcs addItemWithTitle: @"" action: NULL keyEquivalent: @""];
- for (i =0; i<len; i++)
- if (![delegate menu: svcs
- updateItem: (NSMenuItem *)[svcs itemAtIndex: i]
- atIndex: i shouldCancel: NO])
- break;
- }
+ int i, len = [delegate numberOfItemsInMenu: svcs];
+ for (i =0; i<len; i++)
+ [svcs addItemWithTitle: @"" action: NULL keyEquivalent: @""];
+ for (i =0; i<len; i++)
+ if (![delegate menu: svcs
+ updateItem: (NSMenuItem *)[svcs itemAtIndex: i]
+ atIndex: i shouldCancel: NO])
+ break;
}
}
#endif
id pb;
NSString *svcName;
char *utfStr;
- int len;
CHECK_STRING (service);
check_ns ();
- utfStr = SDATA (service);
+ utfStr = SSDATA (service);
svcName = [NSString stringWithUTF8String: utfStr];
pb =[NSPasteboard pasteboardWithUniqueName];
NSString *utfStr;
CHECK_STRING (str);
- utfStr = [NSString stringWithUTF8String: SDATA (str)];
+ utfStr = [NSString stringWithUTF8String: SSDATA (str)];
if (![utfStr respondsToSelector:
@selector (precomposedStringWithCanonicalMapping)])
{
NSAppleScript* scriptObject =
[[NSAppleScript alloc] initWithSource:
- [NSString stringWithUTF8String: SDATA (script)]];
+ [NSString stringWithUTF8String: SSDATA (script)]];
returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
[scriptObject release];
*result = Qt;
// script returned an AppleScript result
if ((typeUnicodeText == [returnDescriptor descriptorType]) ||
-#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4
+#if defined (NS_IMPL_COCOA)
(typeUTF16ExternalRepresentation
== [returnDescriptor descriptorType]) ||
#endif
CHECK_STRING (script);
check_ns ();
- BLOCK_INPUT;
+ block_input ();
as_script = script;
as_result = &result;
as_status = 0;
as_script = Qnil;
as_result = 0;
- UNBLOCK_INPUT;
+ unblock_input ();
if (status == 0)
return result;
else if (!STRINGP (result))
error ("AppleScript error %d", status);
else
- error ("%s", SDATA (result));
+ error ("%s", SSDATA (result));
}
#endif
/* --quick was passed, so this is a no-op. */
return NULL;
- res = [[[NSUserDefaults standardUserDefaults] objectForKey:
- [NSString stringWithUTF8String: toCheck]] UTF8String];
+ res = ns_get_defaults_value (toCheck);
return !res ? NULL :
- (!strncasecmp (res, "YES", 3) ? "true" :
- (!strncasecmp (res, "NO", 2) ? "false" : res));
+ (!c_strncasecmp (res, "YES", 3) ? "true" :
+ (!c_strncasecmp (res, "NO", 2) ? "false" : res));
}
that stands for the selected frame's display. */)
(Lisp_Object display)
{
- int top;
NSScreen *screen;
NSRect vScreen;
GCPRO4 (string, parms, frame, timeout);
CHECK_STRING (string);
- str = SDATA (string);
+ str = SSDATA (string);
f = check_x_frame (frame);
if (NILP (timeout))
timeout = make_number (5);
else
CHECK_NUMBER (dy);
- BLOCK_INPUT;
+ block_input ();
if (ns_tooltip == nil)
ns_tooltip = [[EmacsTooltip alloc] init];
else
&root_x, &root_y);
[ns_tooltip showAtX: root_x Y: root_y for: XINT (timeout)];
- UNBLOCK_INPUT;
+ unblock_input ();
UNGCPRO;
return unbind_to (count, Qnil);
void
syms_of_nsfns (void)
{
- int i;
-
Qfontsize = intern_c_string ("fontsize");
staticpro (&Qfontsize);