extern Lisp_Object Qcursor_color, Qcursor_type, Qns, Qleft;
static Lisp_Object QUTF8_STRING;
+static Lisp_Object Qcocoa, Qgnustep;
/* On OS X picks up the default NSGlobalDomain AppleAntiAliasingThreshold,
the maximum font size to NOT antialias. On GNUstep there is currently
no way to control this behavior. */
float ns_antialias_threshold;
-/* Used to pick up AppleHighlightColor on OS X */
-NSString *ns_selection_color;
-
NSArray *ns_send_types =0, *ns_return_types =0, *ns_drag_types =0;
NSString *ns_app_name = @"Emacs"; /* default changed later */
/* Display variables */
struct ns_display_info *x_display_list; /* Chain of existing displays */
-Lisp_Object ns_display_name_list;
long context_menu_value = 0;
/* display update */
NSTRACE (ns_update_auto_hide_menu_bar);
- if (NSApp != nil
- && [NSApp isActive]
- && [NSApp respondsToSelector:@selector(setPresentationOptions:)])
+ if (NSApp != nil && [NSApp isActive])
{
// Note, "setPresentationOptions" triggers an error unless the
// application is active.
if (menu_bar_should_be_hidden != ns_menu_bar_is_hidden)
{
NSApplicationPresentationOptions options
- = NSApplicationPresentationAutoHideDock;
+ = NSApplicationPresentationDefault;
if (menu_bar_should_be_hidden)
- options |= NSApplicationPresentationAutoHideMenuBar;
+ options |= NSApplicationPresentationAutoHideMenuBar
+ | NSApplicationPresentationAutoHideDock;
[NSApp setPresentationOptions: options];
external (RIF) call; whole frame, called before update_window_begin
-------------------------------------------------------------------------- */
{
- NSView *view = FRAME_NS_VIEW (f);
+ EmacsView *view = FRAME_NS_VIEW (f);
NSTRACE (ns_update_begin);
ns_update_auto_hide_menu_bar ();
+#ifdef NS_IMPL_COCOA
+ if ([view isFullscreen] && [view fsIsNative])
+ {
+ // Fix reappearing tool bar in fullscreen for OSX 10.7
+ BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (f) ? YES : NO;
+ NSToolbar *toolbar = [FRAME_NS_VIEW (f) toolbar];
+ if (! tbar_visible != ! [toolbar isVisible])
+ [toolbar setVisible: tbar_visible];
+ }
+#endif
+
ns_updating_frame = f;
[view lockFocus];
/*fprintf (stderr, "ns_get_color: '%s'\n", name); */
block_input ();
- if ([nsname isEqualToString: @"ns_selection_color"])
+ if ([nsname isEqualToString: @"ns_selection_bg_color"])
+ {
+#ifdef NS_IMPL_COCOA
+ NSString *defname = [[NSUserDefaults standardUserDefaults]
+ stringForKey: @"AppleHighlightColor"];
+ if (defname != nil)
+ nsname = defname;
+ else
+#endif
+ if ((new = [NSColor selectedTextBackgroundColor]) != nil)
+ {
+ *col = [new colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
+ unblock_input ();
+ return 0;
+ }
+ else
+ nsname = NS_SELECTION_BG_COLOR_DEFAULT;
+
+ name = [nsname UTF8String];
+ }
+ else if ([nsname isEqualToString: @"ns_selection_fg_color"])
{
- nsname = ns_selection_color;
- name = [ns_selection_color UTF8String];
+ /* NOTE: OSX applications normally don't set foreground selection, but
+ text may be unreadable if we don't.
+ */
+ if ((new = [NSColor selectedTextColor]) != nil)
+ {
+ *col = [new colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
+ unblock_input ();
+ return 0;
+ }
+
+ nsname = NS_SELECTION_FG_COLOR_DEFAULT;
+ name = [nsname UTF8String];
}
/* First, check for some sort of numeric specification. */
ns_last_use_native_fullscreen = ns_use_native_fullscreen;
- /* Clear the mouse-moved flag for every frame on this display. */
FOR_EACH_FRAME (tail, frame)
{
struct frame *f = XFRAME (frame);
&& ![NSCalibratedWhiteColorSpace isEqualToString:
NSColorSpaceFromDepth (depth)];
dpyinfo->n_planes = NSBitsPerPixelFromDepth (depth);
- dpyinfo->image_cache = make_image_cache ();
dpyinfo->color_table = xmalloc (sizeof *dpyinfo->color_table);
dpyinfo->color_table->colors = NULL;
dpyinfo->root_window = 42; /* a placeholder.. */
terminal->delete_frame_hook = x_destroy_window;
terminal->delete_terminal_hook = ns_delete_terminal;
- terminal->scroll_region_ok = 1;
- terminal->char_ins_del_ok = 1;
- terminal->line_ins_del_ok = 1;
- terminal->fast_clear_end_of_line = 1;
- terminal->memory_below_frame = 0;
-
return terminal;
}
ns_initialize_display_info (dpyinfo);
terminal = ns_create_terminal (dpyinfo);
- terminal->kboard = xmalloc (sizeof *terminal->kboard);
- init_kboard (terminal->kboard);
- kset_window_system (terminal->kboard, Qns);
- terminal->kboard->next_kboard = all_kboards;
- all_kboards = terminal->kboard;
+ terminal->kboard = allocate_kboard (Qns);
/* Don't let the initial kboard remain current longer than necessary.
That would cause problems if a file loaded on startup tries to
prompt in the mini-buffer. */
dpyinfo->next = x_display_list;
x_display_list = dpyinfo;
- /* Put it on ns_display_name_list */
- ns_display_name_list = Fcons (Fcons (display_name, Qnil),
- ns_display_name_list);
- dpyinfo->name_list_element = XCAR (ns_display_name_list);
+ dpyinfo->name_list_element = Fcons (display_name, Qnil);
terminal->name = xstrdup (SSDATA (display_name));
ns_antialias_threshold = NILP (tmp) ? 10.0 : XFLOATINT (tmp);
}
- ns_selection_color = [[NSUserDefaults standardUserDefaults]
- stringForKey: @"AppleHighlightColor"];
- if (ns_selection_color == nil)
- ns_selection_color = NS_SELECTION_COLOR_DEFAULT;
-
{
NSColorList *cl = [NSColorList colorListNamed: @"Emacs"];
@implementation EmacsApp
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9
+- (id)init
+{
+ if (self = [super init])
+ self->isFirst = YES;
+
+ return self;
+}
+
+- (void)run
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ if (isFirst) [self finishLaunching];
+ isFirst = NO;
+
+ shouldKeepRunning = YES;
+ do
+ {
+ [pool release];
+ pool = [[NSAutoreleasePool alloc] init];
+
+ NSEvent *event =
+ [self nextEventMatchingMask:NSAnyEventMask
+ untilDate:[NSDate distantFuture]
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES];
+ [self sendEvent:event];
+ [self updateWindows];
+ } while (shouldKeepRunning);
+
+ [pool release];
+}
+
+- (void)stop: (id)sender
+{
+ shouldKeepRunning = NO;
+}
+#endif
+
- (void)logNotification: (NSNotification *)notification
{
const char *name = [[notification name] UTF8String];
[self windowDidBecomeKey:notification];
[nonfs_window orderOut:self];
}
- else if (! FRAME_EXTERNAL_TOOL_BAR (emacsframe))
- [toolbar setVisible:NO];
+ else
+ {
+ BOOL tbar_visible = FRAME_EXTERNAL_TOOL_BAR (emacsframe) ? YES : NO;
+#ifdef NS_IMPL_COCOA
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+ unsigned val = (unsigned)[NSApp presentationOptions];
+
+ // OSX 10.7 bug fix, the menu won't appear without this.
+ // val is non-zero on other OSX versions.
+ if (val == 0)
+ {
+ NSApplicationPresentationOptions options
+ = NSApplicationPresentationAutoHideDock
+ | NSApplicationPresentationAutoHideMenuBar
+ | NSApplicationPresentationFullScreen
+ | NSApplicationPresentationAutoHideToolbar;
+
+ [NSApp setPresentationOptions: options];
+ }
+#endif
+#endif
+ [toolbar setVisible:tbar_visible];
+ }
}
- (void)windowWillExitFullScreen:(NSNotification *)notification
{
[self setFSValue: fs_before_fs];
fs_before_fs = -1;
-#ifdef NS_IMPL_COCOA
+#ifdef HAVE_NATIVE_FS
[self updateCollectionBehaviour];
#endif
if (FRAME_EXTERNAL_TOOL_BAR (emacsframe))
if (fs_is_native)
{
-#ifdef NS_IMPL_COCOA
+#ifdef HAVE_NATIVE_FS
[[self window] toggleFullScreen:sender];
#endif
return;
"Whether to confirm application quit using dialog.");
ns_confirm_quit = Qnil;
- staticpro (&ns_display_name_list);
- ns_display_name_list = Qnil;
-
DEFVAR_LISP ("ns-auto-hide-menu-bar", ns_auto_hide_menu_bar,
doc: /* Non-nil means that the menu bar is hidden, but appears when the mouse is near.
Only works on OSX 10.6 or later. */);
/* Tell Emacs about this window system. */
Fprovide (Qns, Qnil);
+ DEFSYM (Qcocoa, "cocoa");
+ DEFSYM (Qgnustep, "gnustep");
+
syms_of_nsfont ();
#ifdef NS_IMPL_COCOA
+ Fprovide (Qcocoa, Qnil);
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
syms_of_macfont ();
#endif
+#else
+ Fprovide (Qgnustep, Qnil);
#endif
}