#include "process.h"
#endif
+#ifdef NS_IMPL_COCOA
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+#include "macfont.h"
+#endif
+#endif
+
/* call tracing */
#if 0
int term_trace_num = 0;
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;
-/* Last window where we saw the mouse. Used by mouse-autoselect-window. */
-static Lisp_Object last_window;
-
/* display update */
-NSPoint last_mouse_motion_position;
-static NSRect last_mouse_glyph;
-static Time last_mouse_movement_time = 0;
-static Lisp_Object last_mouse_motion_frame;
-static EmacsScroller *last_mouse_scroll_bar = nil;
static struct frame *ns_updating_frame;
static NSView *focus_view = NULL;
static int ns_window_num = 0;
#endif
static BOOL gsaved = NO;
static BOOL ns_fake_keydown = NO;
-int ns_tmp_flags; /* FIXME */
-struct nsfont_info *ns_tmp_font; /* FIXME */
#ifdef NS_IMPL_COCOA
static BOOL ns_menu_bar_is_hidden = NO;
#endif
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];
NSTRACE (ns_update_end);
}
-
-static void
-ns_flush (struct frame *f)
-/* --------------------------------------------------------------------------
- external (RIF) call
- NS impl is no-op since currently we flush in ns_update_end and elsewhere
- -------------------------------------------------------------------------- */
-{
- NSTRACE (ns_flush);
-}
-
-
static void
ns_focus (struct frame *f, NSRect *r, int n)
/* --------------------------------------------------------------------------
}
}
-
-static void
-ns_reset_terminal_modes (struct terminal *terminal)
-/* Externally called as hook */
-{
- NSTRACE (ns_reset_terminal_modes);
-}
-
-
-static void
-ns_set_terminal_modes (struct terminal *terminal)
-/* Externally called as hook */
-{
- NSTRACE (ns_set_terminal_modes);
-}
-
-
-
/* ==========================================================================
Frame / window manager related functions
External (hook): called on things like window switching within frame
-------------------------------------------------------------------------- */
{
- struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (frame);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
struct frame *old_highlight = dpyinfo->x_highlight_frame;
NSTRACE (ns_frame_rehighlight);
NSTRACE (x_iconify_frame);
check_window_system (f);
view = FRAME_NS_VIEW (f);
- dpyinfo = FRAME_NS_DISPLAY_INFO (f);
+ dpyinfo = FRAME_DISPLAY_INFO (f);
if (dpyinfo->x_highlight_frame == f)
dpyinfo->x_highlight_frame = 0;
NSTRACE (x_free_frame_resources);
check_window_system (f);
view = FRAME_NS_VIEW (f);
- dpyinfo = FRAME_NS_DISPLAY_INFO (f);
+ dpyinfo = FRAME_DISPLAY_INFO (f);
hlinfo = MOUSE_HL_INFO (f);
[(EmacsView *)view setWindowClosing: YES]; /* may not have been informed */
NSColor *
ns_lookup_indexed_color (unsigned long idx, struct frame *f)
{
- struct ns_color_table *color_table = FRAME_NS_DISPLAY_INFO (f)->color_table;
+ struct ns_color_table *color_table = FRAME_DISPLAY_INFO (f)->color_table;
if (idx < 1 || idx >= color_table->avail)
return nil;
return color_table->colors[idx];
unsigned long
ns_index_color (NSColor *color, struct frame *f)
{
- struct ns_color_table *color_table = FRAME_NS_DISPLAY_INFO (f)->color_table;
+ struct ns_color_table *color_table = FRAME_DISPLAY_INFO (f)->color_table;
ptrdiff_t idx;
ptrdiff_t i;
if (!f)
return;
- color_table = FRAME_NS_DISPLAY_INFO (f)->color_table;
+ color_table = FRAME_DISPLAY_INFO (f)->color_table;
if (idx <= 0 || idx >= color_table->size) {
message1 ("ns_free_indexed_color: Color index out of range.\n");
/*fprintf (stderr, "ns_get_color: '%s'\n", name); */
block_input ();
- if ([nsname isEqualToString: @"ns_selection_color"])
+ if ([nsname isEqualToString: @"ns_selection_bg_color"])
{
- nsname = ns_selection_color;
- name = [ns_selection_color UTF8String];
+#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"])
+ {
+ /* 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. */
change the entire-frame transparency
-------------------------------------------------------------------------- */
{
- struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (f);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
double alpha = 1.0;
double alpha_min = 1.0;
known as last_mouse_glyph.
------------------------------------------------------------------------ */
{
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (frame);
+ NSRect *r;
+
// NSTRACE (note_mouse_movement);
- XSETFRAME (last_mouse_motion_frame, frame);
+ dpyinfo->last_mouse_motion_frame = frame;
+ r = &dpyinfo->last_mouse_glyph;
/* Note, this doesn't get called for enter/leave, since we don't have a
position. Those are taken care of in the corresponding NSView methods. */
/* has movement gone beyond last rect we were tracking? */
- if (x < last_mouse_glyph.origin.x ||
- x >= (last_mouse_glyph.origin.x + last_mouse_glyph.size.width) ||
- y < last_mouse_glyph.origin.y ||
- y >= (last_mouse_glyph.origin.y + last_mouse_glyph.size.height))
+ if (x < r->origin.x || x >= r->origin.x + r->size.width
+ || y < r->origin.y || y >= r->origin.y + r->size.height)
{
- ns_update_begin(frame);
+ ns_update_begin (frame);
frame->mouse_moved = 1;
note_mouse_highlight (frame, x, y);
- remember_mouse_glyph (frame, x, y, &last_mouse_glyph);
- ns_update_end(frame);
+ remember_mouse_glyph (frame, x, y, r);
+ ns_update_end (frame);
return 1;
}
return;
}
- dpyinfo = FRAME_NS_DISPLAY_INFO (*fp);
+ dpyinfo = FRAME_DISPLAY_INFO (*fp);
block_input ();
- if (last_mouse_scroll_bar != nil && insist == 0)
+ if (dpyinfo->last_mouse_scroll_bar != nil && insist == 0)
{
/* TODO: we do not use this path at the moment because drag events will
go directly to the EmacsScroller. Leaving code in for now. */
- [last_mouse_scroll_bar getMouseMotionPart: (int *)part window: bar_window
- x: x y: y];
- if (time) *time = last_mouse_movement_time;
- last_mouse_scroll_bar = nil;
+ [dpyinfo->last_mouse_scroll_bar
+ getMouseMotionPart: (int *)part window: bar_window x: x y: y];
+ if (time)
+ *time = dpyinfo->last_mouse_movement_time;
+ dpyinfo->last_mouse_scroll_bar = nil;
}
else
{
&& FRAME_NS_DISPLAY (XFRAME (frame)) == FRAME_NS_DISPLAY (*fp))
XFRAME (frame)->mouse_moved = 0;
- last_mouse_scroll_bar = nil;
- if (last_mouse_frame && FRAME_LIVE_P (last_mouse_frame))
- f = last_mouse_frame;
+ dpyinfo->last_mouse_scroll_bar = nil;
+ if (dpyinfo->last_mouse_frame
+ && FRAME_LIVE_P (dpyinfo->last_mouse_frame))
+ f = dpyinfo->last_mouse_frame;
else
f = dpyinfo->x_focus_frame ? dpyinfo->x_focus_frame
: SELECTED_FRAME ();
position = [[view window] mouseLocationOutsideOfEventStream];
position = [view convertPoint: position fromView: nil];
- remember_mouse_glyph (f, position.x, position.y, &last_mouse_glyph);
+ remember_mouse_glyph (f, position.x, position.y,
+ &dpyinfo->last_mouse_glyph);
/*fprintf (stderr, "ns_mouse_position: %.0f, %.0f\n", position.x, position.y); */
if (bar_window) *bar_window = Qnil;
if (x) XSETINT (*x, lrint (position.x));
if (y) XSETINT (*y, lrint (position.y));
- if (time) *time = last_mouse_movement_time;
+ if (time)
+ *time = dpyinfo->last_mouse_movement_time;
*fp = f;
}
}
else
{
s->left_overhang = 0;
- s->right_overhang = ((struct nsfont_info *)font)->ital ?
- FONT_HEIGHT (font) * 0.2 : 0;
+ if (EQ (font->driver->type, Qns))
+ s->right_overhang = ((struct nsfont_info *)font)->ital ?
+ FONT_HEIGHT (font) * 0.2 : 0;
+ else
+ s->right_overhang = 0;
}
}
: FRAME_BACKGROUND_COLOR (s->f)) set];
else
{
- struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (s->f);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (s->f);
[[dpyinfo->bitmaps[face->stipple-1].img stippleMask] set];
}
{
/* TODO (optimize): focus for box and contents draw */
NSRect r[2];
- int n;
+ int n, flags;
char box_drawn_p = 0;
+ struct font *font = s->face->font;
+ if (! font) font = FRAME_FONT (s->f);
NSTRACE (ns_draw_glyph_string);
ns_maybe_dumpglyphs_background
(s, s->first_glyph->type == COMPOSITE_GLYPH);
- ns_tmp_flags = s->hl == DRAW_CURSOR ? NS_DUMPGLYPH_CURSOR :
- (s->hl == DRAW_MOUSE_FACE ? NS_DUMPGLYPH_MOUSEFACE :
- (s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND :
- NS_DUMPGLYPH_NORMAL));
- ns_tmp_font = (struct nsfont_info *)s->face->font;
- if (ns_tmp_font == NULL)
- ns_tmp_font = (struct nsfont_info *)FRAME_FONT (s->f);
+ flags = s->hl == DRAW_CURSOR ? NS_DUMPGLYPH_CURSOR :
+ (s->hl == DRAW_MOUSE_FACE ? NS_DUMPGLYPH_MOUSEFACE :
+ (s->for_overlaps ? NS_DUMPGLYPH_FOREGROUND :
+ NS_DUMPGLYPH_NORMAL));
if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR)
{
NS_FACE_FOREGROUND (s->face) = tmp;
}
- ns_tmp_font->font.driver->draw
+ font->driver->draw
(s, 0, s->nchars, s->x, s->y,
- (ns_tmp_flags == NS_DUMPGLYPH_NORMAL && !s->background_filled_p)
- || ns_tmp_flags == NS_DUMPGLYPH_MOUSEFACE);
+ (flags == NS_DUMPGLYPH_NORMAL && !s->background_filled_p)
+ || flags == NS_DUMPGLYPH_MOUSEFACE);
+
+ {
+ NSColor *col = (NS_FACE_FOREGROUND (s->face) != 0
+ ? ns_lookup_indexed_color (NS_FACE_FOREGROUND (s->face),
+ s->f)
+ : FRAME_FOREGROUND_COLOR (s->f));
+ [col set];
+
+ /* Draw underline, overline, strike-through. */
+ ns_draw_text_decoration (s, s->face, col, s->width, s->x);
+ }
if (s->hl == DRAW_CURSOR && s->w->phys_cursor_type == FILLED_BOX_CURSOR)
{
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.. */
ns_after_update_window_line,
ns_update_window_begin,
ns_update_window_end,
- ns_flush,
- 0, /* flush_display_optional */
+ 0, /* flush_display */
x_clear_window_mouse_face,
x_get_glyph_overhangs,
x_fix_overlapping_area,
0, /* define_fringe_bitmap */ /* FIXME: simplify ns_draw_fringe_bitmap */
0, /* destroy_fringe_bitmap */
ns_compute_glyph_string_overhangs,
- ns_draw_glyph_string, /* interface to nsfont.m */
+ ns_draw_glyph_string,
ns_define_frame_cursor,
ns_clear_frame_area,
ns_draw_window_cursor,
terminal->ins_del_lines_hook = 0; /* XXX vestigial? */
terminal->delete_glyphs_hook = 0; /* XXX vestigial? */
terminal->ring_bell_hook = ns_ring_bell;
- terminal->reset_terminal_modes_hook = ns_reset_terminal_modes;
- terminal->set_terminal_modes_hook = ns_set_terminal_modes;
+ terminal->reset_terminal_modes_hook = NULL;
+ terminal->set_terminal_modes_hook = NULL;
terminal->update_begin_hook = ns_update_begin;
terminal->update_end_hook = ns_update_end;
terminal->set_terminal_window_hook = NULL; /* XXX vestigial? */
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];
/* called on font panel selection */
- (void)changeFont: (id)sender
{
- NSEvent *e =[[self window] currentEvent];
- struct face *face =FRAME_DEFAULT_FACE (emacsframe);
+ NSEvent *e = [[self window] currentEvent];
+ struct face *face = FRAME_DEFAULT_FACE (emacsframe);
+ struct font *font = face->font;
id newFont;
CGFloat size;
+ NSFont *nsfont;
NSTRACE (changeFont);
+
if (!emacs_event)
return;
- if ((newFont = [sender convertFont:
- ((struct nsfont_info *)face->font)->nsfont]))
+ if (EQ (font->driver->type, Qns))
+ nsfont = ((struct nsfont_info *)font)->nsfont;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+ else
+ nsfont = (NSFont *) macfont_get_nsctfont (font);
+#endif
+
+ if ((newFont = [sender convertFont: nsfont]))
{
SET_FRAME_GARBAGED (emacsframe); /* now needed as of 2008/10 */
NSString *str = [aString respondsToSelector: @selector (string)] ?
[aString string] : aString;
if (NS_KEYLOG)
- NSLog (@"setMarkedText '%@' len =%d range %d from %d", str, [str length],
- selRange.length, selRange.location);
+ NSLog (@"setMarkedText '%@' len =%lu range %lu from %lu",
+ str, (unsigned long)[str length],
+ (unsigned long)selRange.length,
+ (unsigned long)selRange.location);
if (workingText != nil)
[self deleteWorkingText];
if (workingText == nil)
return;
if (NS_KEYLOG)
- NSLog(@"deleteWorkingText len =%d\n", [workingText length]);
+ NSLog(@"deleteWorkingText len =%lu\n", (unsigned long)[workingText length]);
[workingText release];
workingText = nil;
processingCompose = NO;
/* This is what happens when the user presses a mouse button. */
- (void)mouseDown: (NSEvent *)theEvent
{
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
NSPoint p = [self convertPoint: [theEvent locationInWindow] fromView: nil];
NSTRACE (mouseDown);
if (!emacs_event)
return;
- last_mouse_frame = emacsframe;
+ dpyinfo->last_mouse_frame = emacsframe;
/* appears to be needed to prevent spurious movement events generated on
button clicks */
- last_mouse_frame->mouse_moved = 0;
+ emacsframe->mouse_moved = 0;
if ([theEvent type] == NSScrollWheel)
{
- (void)mouseMoved: (NSEvent *)e
{
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (emacsframe);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
Lisp_Object frame;
+ NSPoint pt;
// NSTRACE (mouseMoved);
- last_mouse_movement_time = EV_TIMESTAMP (e);
- last_mouse_motion_position
- = [self convertPoint: [e locationInWindow] fromView: nil];
+ dpyinfo->last_mouse_movement_time = EV_TIMESTAMP (e);
+ pt = [self convertPoint: [e locationInWindow] fromView: nil];
+ dpyinfo->last_mouse_motion_x = pt.x;
+ dpyinfo->last_mouse_motion_y = pt.y;
/* update any mouse face */
if (hlinfo->mouse_face_hidden)
if (!NILP (Vmouse_autoselect_window))
{
NSTRACE (mouse_autoselect_window);
- Lisp_Object window;
- window = window_from_coordinates(emacsframe, last_mouse_motion_position.x,
- last_mouse_motion_position.y, 0, 0);
+ static Lisp_Object last_mouse_window;
+ Lisp_Object window
+ = window_from_coordinates (emacsframe, pt.x, pt.y, 0, 0);
+
if (WINDOWP (window)
- && !EQ (window, last_window)
+ && !EQ (window, last_mouse_window)
&& !EQ (window, selected_window)
&& (focus_follows_mouse
|| (EQ (XWINDOW (window)->frame,
emacs_event->frame_or_window = window;
EV_TRAILER2 (e);
}
- last_window = window;
+ /* Remember the last window where we saw the mouse. */
+ last_mouse_window = window;
}
- if (!note_mouse_movement (emacsframe, last_mouse_motion_position.x,
- last_mouse_motion_position.y))
+ if (!note_mouse_movement (emacsframe, pt.x, pt.y))
help_echo_string = previous_help_echo_string;
XSETFRAME (frame, emacsframe);
- (void)windowDidBecomeKey: (NSNotification *)notification
/* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */
{
- struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
struct frame *old_focus = dpyinfo->x_focus_frame;
NSTRACE (windowDidBecomeKey);
- (void)windowDidResignKey: (NSNotification *)notification
/* cf. x_detect_focus_change(), x_focus_changed(), x_new_focus_frame() */
{
- struct ns_display_info *dpyinfo = FRAME_NS_DISPLAY_INFO (emacsframe);
+ struct ns_display_info *dpyinfo = FRAME_DISPLAY_INFO (emacsframe);
BOOL is_focus_frame = dpyinfo->x_focus_frame == emacsframe;
NSTRACE (windowDidResignKey);
[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;
- (void)mouseEntered: (NSEvent *)theEvent
{
NSTRACE (mouseEntered);
- last_mouse_movement_time = EV_TIMESTAMP (theEvent);
+ if (emacsframe)
+ FRAME_DISPLAY_INFO (emacsframe)->last_mouse_movement_time
+ = EV_TIMESTAMP (theEvent);
}
if (!hlinfo)
return;
- last_mouse_movement_time = EV_TIMESTAMP (theEvent);
+ FRAME_DISPLAY_INFO (emacsframe)->last_mouse_movement_time
+ = EV_TIMESTAMP (theEvent);
if (emacsframe == hlinfo->mouse_face_mouse_frame)
{
"Whether to confirm application quit using dialog.");
ns_confirm_quit = Qnil;
- staticpro (&ns_display_name_list);
- ns_display_name_list = Qnil;
-
- staticpro (&last_mouse_motion_frame);
- last_mouse_motion_frame = 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. */);
baseline level. The default value is nil. */);
x_underline_at_descent_line = 0;
- /* Tell emacs about this window system. */
- Fprovide (intern ("ns"), Qnil);
+ /* 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
+
}