Lisp_Object Qbuffered;
Lisp_Object Qfontsize;
-/* hack for OS X file panels */
-char panelOK = 0;
-
EmacsTooltip *ns_tooltip = nil;
/* Need forward declaration here to preserve organizational integrity of file */
struct frame *sf = XFRAME (selected_frame);
if (FRAME_NS_P (sf) && FRAME_LIVE_P (sf))
- dpyinfo = FRAME_NS_DISPLAY_INFO (sf);
+ dpyinfo = FRAME_DISPLAY_INFO (sf);
else if (x_display_list != 0)
dpyinfo = x_display_list;
else
dpyinfo = ns_display_info_for_name (object);
else
{
- FRAME_PTR f = decode_window_system_frame (object);
- dpyinfo = FRAME_NS_DISPLAY_INFO (f);
+ struct frame *f = decode_window_system_frame (object);
+ dpyinfo = FRAME_DISPLAY_INFO (f);
}
return dpyinfo;
x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
NSColor *col;
- CGFloat r, g, b, alpha;
+ EmacsCGFloat r, g, b, alpha;
if (ns_lisp_to_color (arg, &col))
{
struct face *face;
NSColor *col;
NSView *view = FRAME_NS_VIEW (f);
- CGFloat r, g, b, alpha;
+ EmacsCGFloat r, g, b, alpha;
if (ns_lisp_to_color (arg, &col))
{
{
[[view window] setBackgroundColor: col];
- if (alpha != 1.0)
+ if (alpha != (EmacsCGFloat) 1.0)
[[view window] setOpaque: NO];
else
[[view window] setOpaque: YES];
}
static void
-ns_set_name_internal (FRAME_PTR f, Lisp_Object name)
+ns_set_name_internal (struct frame *f, Lisp_Object name)
{
struct gcpro gcpro1;
Lisp_Object encoded_name, encoded_icon_name;
specified a name for the frame; the name will override any set by the
redisplay code. */
static void
-x_explicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
+x_explicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
NSTRACE (x_explicitly_set_name);
ns_set_name (f, arg, 1);
name; names set this way will never override names set by the user's
lisp code. */
void
-x_implicitly_set_name (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
+x_implicitly_set_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
NSTRACE (x_implicitly_set_name);
}
-void
+static void
ns_implicitly_set_icon_type (struct frame *f)
{
Lisp_Object tem;
}
/* This is the same as the xfns.c definition. */
-void
-x_set_cursor_type (FRAME_PTR f, Lisp_Object arg, Lisp_Object oldval)
+static void
+x_set_cursor_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
{
set_frame_cursor_types (f, arg);
-
- /* Make sure the cursor gets redrawn. */
- cursor_type_changed = 1;
}
-\f
/* called to set mouse pointer color, but all other terms use it to
initialize pointer types (and don't set the color ;) */
#ifdef NS_IMPL_GNUSTEP
sprintf(tmp, "gnustep-gui-%s", Xstr(GNUSTEP_GUI_VERSION));
-#elif defined(NS_IMPL_COCOA)
+#elif defined (NS_IMPL_COCOA)
sprintf(tmp, "apple-appkit-%.2f", NSAppKitVersionNumber);
#else
tmp = "ns-unknown";
{
#ifdef NS_IMPL_GNUSTEP
return GNUSTEP_GUI_MAJOR_VERSION * 100 + GNUSTEP_GUI_MINOR_VERSION;
-#elif defined(NS_IMPL_COCOA)
+#elif defined (NS_IMPL_COCOA)
return (int)NSAppKitVersionNumber;
#endif
return 0;
/* Handler for signals raised during x_create_frame.
FRAME is the frame which is partially constructed. */
-static Lisp_Object
+static void
unwind_create_frame (Lisp_Object frame)
{
struct frame *f = XFRAME (frame);
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;
+ return;
/* 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);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
#endif
x_free_frame_resources (f);
/* Check that reference counts are indeed correct. */
eassert (dpyinfo->terminal->image_cache->refcount == image_cache_refcount);
#endif
- return Qt;
}
-
- return Qnil;
}
/*
Lisp_Object frame, tem;
Lisp_Object name;
int minibuffer_only = 0;
- int window_prompting = 0;
+ long window_prompting = 0;
int width, height;
ptrdiff_t count = specpdl_ptr - specpdl;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
struct ns_display_info *dpyinfo = NULL;
Lisp_Object parent;
struct kboard *kb;
- Lisp_Object tfont, tfontsize;
static int desc_ctr = 1;
/* x_get_arg modifies parms. */
if (! STRINGP (f->icon_name))
fset_icon_name (f, Qnil);
- FRAME_NS_DISPLAY_INFO (f) = dpyinfo;
+ FRAME_DISPLAY_INFO (f) = dpyinfo;
- /* With FRAME_NS_DISPLAY_INFO set up, this unwind-protect is safe. */
+ /* With FRAME_DISPLAY_INFO set up, this unwind-protect is safe. */
record_unwind_protect (unwind_create_frame, frame);
f->output_data.ns->window_desc = desc_ctr++;
}
else
{
- f->output_data.ns->parent_desc = FRAME_NS_DISPLAY_INFO (f)->root_window;
+ f->output_data.ns->parent_desc = FRAME_DISPLAY_INFO (f)->root_window;
f->output_data.ns->explicit_parent = 0;
}
{
/* use for default font name */
id font = [NSFont userFixedPitchFontOfSize: -1.0]; /* default */
- tfontsize = x_default_parameter (f, parms, Qfontsize,
+ x_default_parameter (f, parms, Qfontsize,
make_number (0 /*(int)[font pointSize]*/),
"fontSize", "FontSize", RES_TYPE_NUMBER);
- tfont = x_default_parameter (f, parms, Qfont,
+ x_default_parameter (f, parms, Qfont,
build_string ([[font fontName] UTF8String]),
"font", "Font", RES_TYPE_STRING);
}
f->output_data.ns->hand_cursor = [NSCursor pointingHandCursor];
f->output_data.ns->hourglass_cursor = [NSCursor disappearingItemCursor];
f->output_data.ns->horizontal_drag_cursor = [NSCursor resizeLeftRightCursor];
- FRAME_NS_DISPLAY_INFO (f)->vertical_scroll_bar_cursor
+ FRAME_DISPLAY_INFO (f)->vertical_scroll_bar_cursor
= [NSCursor arrowCursor];
f->output_data.ns->current_pointer = f->output_data.ns->text_cursor;
(Lisp_Object frame)
{
struct frame *f = decode_window_system_frame (frame);
- struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
if (dpyinfo->x_focus_frame != f)
{
return Qnil;
}
+static struct
+{
+ id panel;
+ BOOL ret;
+#if ! defined (NS_IMPL_COCOA) || \
+ MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
+ NSString *dirS, *initS;
+ BOOL no_types;
+#endif
+} ns_fd_data;
+
+void
+ns_run_file_dialog (void)
+{
+ if (ns_fd_data.panel == nil) return;
+#if defined (NS_IMPL_COCOA) && \
+ MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ ns_fd_data.ret = [ns_fd_data.panel runModal];
+#else
+ if (ns_fd_data.no_types)
+ {
+ ns_fd_data.ret = [ns_fd_data.panel
+ runModalForDirectory: ns_fd_data.dirS
+ file: ns_fd_data.initS];
+ }
+ else
+ {
+ ns_fd_data.ret = [ns_fd_data.panel
+ runModalForDirectory: ns_fd_data.dirS
+ file: ns_fd_data.initS
+ types: nil];
+ }
+#endif
+ ns_fd_data.panel = nil;
+}
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.
{
static id fileDelegate = nil;
BOOL ret;
+ BOOL isSave = NILP (mustmatch) && NILP (dir_only_p);
id panel;
Lisp_Object fname;
[NSString stringWithUTF8String: SSDATA (dir)];
NSString *initS = NILP (init) || !STRINGP (init) ? nil :
[NSString stringWithUTF8String: SSDATA (init)];
+ NSEvent *nxev;
check_window_system (NULL);
if ([dirS characterAtIndex: 0] == '~')
dirS = [dirS stringByExpandingTildeInPath];
- panel = NILP (mustmatch) && NILP (dir_only_p) ?
+ panel = isSave ?
(id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
[panel setTitle: promptS];
[panel setTreatsFilePackagesAsDirectories: YES];
[panel setDelegate: fileDelegate];
- panelOK = 0;
if (! NILP (dir_only_p))
{
[panel setCanChooseDirectories: YES];
[panel setCanChooseFiles: NO];
}
- else
+ else if (! isSave)
{
/* This is not quite what the documentation says, but it is compatible
with the Gtk+ code. Also, the menu entry says "Open File...". */
[panel setCanChooseFiles: YES];
}
- block_input ();
+ block_input ();
+ ns_fd_data.panel = panel;
+ ns_fd_data.ret = NO;
#if defined (NS_IMPL_COCOA) && \
MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
if (! NILP (mustmatch) || ! NILP (dir_only_p))
else
[panel setNameFieldStringValue: @""];
- ret = [panel runModal];
#else
- if (NILP (mustmatch) && NILP (dir_only_p))
- {
- ret = [panel runModalForDirectory: dirS file: initS];
- }
- else
- {
- ret = [panel runModalForDirectory: dirS file: initS types: nil];
- }
+ ns_fd_data.no_types = NILP (mustmatch) && NILP (dir_only_p);
+ ns_fd_data.dirS = dirS;
+ ns_fd_data.initS = initS;
#endif
- ret = (ret == NSOKButton) || panelOK;
+ /* runModalForDirectory/runModal restarts the main event loop when done,
+ so we must start an event loop and then pop up the file dialog.
+ The file dialog may pop up a confirm dialog after Ok has been pressed,
+ so we can not simply pop down on the Ok/Cancel press.
+ */
+ nxev = [NSEvent otherEventWithType: NSApplicationDefined
+ location: NSMakePoint (0, 0)
+ modifierFlags: 0
+ timestamp: 0
+ windowNumber: [[NSApp mainWindow] windowNumber]
+ context: [NSApp context]
+ subtype: 0
+ data1: 0
+ data2: NSAPP_DATA2_RUNFILEDIALOG];
+
+ [NSApp postEvent: nxev atStart: NO];
+ while (ns_fd_data.panel != nil)
+ [NSApp run];
+
+ ret = (ns_fd_data.ret == NSOKButton);
if (ret)
{
- NSString *str = [panel getFilename];
- if (! str) str = [panel getDirectory];
+ NSString *str = ns_filename_from_panel (panel);
+ if (! str) str = ns_directory_from_panel (panel);
if (! str) ret = NO;
else fname = build_string ([str UTF8String]);
}
#else
Lisp_Object ret = Qnil;
NSMenu *svcs;
+#ifdef NS_IMPL_COCOA
id delegate;
+#endif
check_window_system (NULL);
svcs = [[NSMenu alloc] initWithTitle: @"Services"];
ns_string_to_pasteboard (pb, send);
if (NSPerformService (svcName, pb) == NO)
- Fsignal (Qquit, Fcons (build_string ("service not available"), Qnil));
+ Fsignal (Qquit, list1 (build_string ("service not available")));
if ([[pb types] count] == 0)
return build_string ("");
/* TODO: If GNUstep ever implements precomposedStringWithCanonicalMapping,
remove this. */
NSString *utfStr;
+ Lisp_Object ret;
CHECK_STRING (str);
- utfStr = [NSString stringWithUTF8String: SSDATA (str)];
- if (![utfStr respondsToSelector:
- @selector (precomposedStringWithCanonicalMapping)])
- {
- message1
- ("Warning: ns-convert-utf8-nfd-to-nfc unsupported under GNUstep.\n");
- return Qnil;
- }
- else
- utfStr = [utfStr precomposedStringWithCanonicalMapping];
- return build_string ([utfStr UTF8String]);
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ utfStr = [NSString stringWithUTF8String: SSDATA (str)];
+#ifdef NS_IMPL_COCOA
+ utfStr = [utfStr precomposedStringWithCanonicalMapping];
+#endif
+ ret = build_string ([utfStr UTF8String]);
+ [pool release];
+ return ret;
}
}
+extern const char *x_get_string_resource (XrmDatabase, char *, char *);
+
+
/* terms impl this instead of x-get-resource directly */
const char *
x_get_string_resource (XrmDatabase rdb, char *name, char *class)
Lisp_Object
x_get_focus_frame (struct frame *frame)
{
- struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (frame);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
Lisp_Object nsfocus;
if (!dpyinfo->x_focus_frame)
return nsfocus;
}
-
-int
-x_pixel_width (struct frame *f)
-{
- return FRAME_PIXEL_WIDTH (f);
-}
-
-
-int
-x_pixel_height (struct frame *f)
-{
- return FRAME_PIXEL_HEIGHT (f);
-}
-
-
-int
-x_screen_planes (struct frame *f)
-{
- return FRAME_NS_DISPLAY_INFO (f)->n_planes;
-}
-
-
-void
-x_sync (struct frame *f)
-{
- /* XXX Not implemented XXX */
- return;
-}
-
-
-
/* ==========================================================================
Lisp definitions that, for whatever reason, we can't alias as 'ns-XXX'.
(Lisp_Object color, Lisp_Object frame)
{
NSColor * col;
- CGFloat red, green, blue, alpha;
+ EmacsCGFloat red, green, blue, alpha;
check_window_system (NULL);
CHECK_STRING (color);
if (n_monitors == 0)
return Qnil;
- monitors = (struct MonitorInfo *) xzalloc (n_monitors * sizeof (*monitors));
+ monitors = xzalloc (n_monitors * sizeof *monitors);
for (i = 0; i < [screens count]; ++i)
{
struct MonitorInfo *m = &monitors[i];
NSRect fr = [s frame];
NSRect vfr = [s visibleFrame];
- NSDictionary *dict = [s deviceDescription];
- NSValue *resval = [dict valueForKey:NSDeviceResolution];
short y, vy;
#ifdef NS_IMPL_COCOA
+ NSDictionary *dict = [s deviceDescription];
NSNumber *nid = [dict objectForKey:@"NSScreenNumber"];
CGDirectDisplayID did = [nid unsignedIntValue];
#endif
vy = (short) (primary_display_height -
vfr.size.height - vfr.origin.y);
}
-
+
m->geom.x = (short) fr.origin.x;
m->geom.y = y;
m->geom.width = (unsigned short) fr.size.width;
{
/* Absolute coordinates. */
pt.x = XINT (left);
- pt.y = x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)) - XINT (top)
+ pt.y = x_display_pixel_height (FRAME_DISPLAY_INFO (f)) - XINT (top)
- height;
}
else if (pt.x + XINT (dx) <= 0)
*root_x = 0; /* Can happen for negative dx */
else if (pt.x + XINT (dx) + width
- <= x_display_pixel_width (FRAME_NS_DISPLAY_INFO (f)))
+ <= x_display_pixel_width (FRAME_DISPLAY_INFO (f)))
/* It fits to the right of the pointer. */
*root_x = pt.x + XINT (dx);
else if (width + XINT (dx) <= pt.x)
/* It fits below the pointer. */
*root_y = pt.y - height - XINT (dy);
else if (pt.y + XINT (dy) + height
- <= x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)))
+ <= x_display_pixel_height (FRAME_DISPLAY_INFO (f)))
/* It fits above the pointer */
*root_y = pt.y + XINT (dy);
else
/* Put it on the top. */
- *root_y = x_display_pixel_height (FRAME_NS_DISPLAY_INFO (f)) - height;
+ *root_y = x_display_pixel_height (FRAME_DISPLAY_INFO (f)) - height;
}
case NSPageUpFunctionKey:
case NSPageDownFunctionKey:
case NSEndFunctionKey:
- [panel sendEvent: theEvent];
- ret = YES;
+ /* Don't send command modified keys, as those are handled in the
+ performKeyEquivalent method of the super class.
+ */
+ if (! ([theEvent modifierFlags] & NSCommandKeyMask))
+ {
+ [panel sendEvent: theEvent];
+ ret = YES;
+ }
break;
/* As we don't have the standard key commands for
copy/paste/cut/select-all in our edit menu, we must handle
}
@implementation EmacsSavePanel
-#ifdef NS_IMPL_COCOA
-/* --------------------------------------------------------------------------
- These are overridden to intercept on OS X: ending panel restarts NSApp
- event loop if it is stopped. Not sure if this is correct behavior,
- perhaps should check if running and if so send an appdefined.
- -------------------------------------------------------------------------- */
-- (void) ok: (id)sender
-{
- [super ok: sender];
- panelOK = 1;
- [NSApp stop: self];
-}
-- (void) cancel: (id)sender
-{
- [super cancel: sender];
- [NSApp stop: self];
-}
-#endif
-- (NSString *) getFilename
-{
- return ns_filename_from_panel (self);
-}
-- (NSString *) getDirectory
-{
- return ns_directory_from_panel (self);
-}
-
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
{
BOOL ret = handlePanelKeys (self, theEvent);
@implementation EmacsOpenPanel
-#ifdef NS_IMPL_COCOA
-/* --------------------------------------------------------------------------
- These are overridden to intercept on OS X: ending panel restarts NSApp
- event loop if it is stopped. Not sure if this is correct behavior,
- perhaps should check if running and if so send an appdefined.
- -------------------------------------------------------------------------- */
-- (void) ok: (id)sender
-{
- [super ok: sender];
-
- // If not choosing directories, and Open is pressed on a directory, return.
- if (! [self canChooseDirectories] && [self getDirectory] &&
- ! [self getFilename])
- return;
-
- panelOK = 1;
- [NSApp stop: self];
-}
-- (void) cancel: (id)sender
-{
- [super cancel: sender];
- [NSApp stop: self];
-}
-
-#endif
-- (NSString *) getFilename
-{
- return ns_filename_from_panel (self);
-}
-- (NSString *) getDirectory
-{
- return ns_directory_from_panel (self);
-}
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
{
// NSOpenPanel inherits NSSavePanel, so passing self is OK.
When you miniaturize a Group, Summary or Article frame, Gnus.tiff will
be used as the image of the icon representing the frame. */);
- Vns_icon_type_alist = Fcons (Qt, Qnil);
+ Vns_icon_type_alist = list1 (Qt);
DEFVAR_LISP ("ns-version-string", Vns_version_string,
doc: /* Toolkit version for NS Windowing. */);