/* NeXT/Open/GNUstep / MacOSX communication module.
- Copyright (C) 1989, 1993, 1994, 2005, 2006, 2008, 2009
+ Copyright (C) 1989, 1993, 1994, 2005, 2006, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of GNU Emacs.
Lisp_Object ns_input_spi_name, ns_input_spi_arg;
Lisp_Object Vx_toolkit_scroll_bars;
static Lisp_Object Qmodifier_value;
-/* TODO: unsure why these defined in term files, anyway we need in keymap.c */
-Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper;
+Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper, Qnone;
extern Lisp_Object Qcursor_color, Qcursor_type, Qns;
/* Specifies which emacs modifier should be generated when NS receives
view = FRAME_NS_VIEW (frame);
if (view != nil)
{
- NSRect r, surr;
- NSPoint dim = NSMakePoint (128, 128);
-
- r = [view bounds];
- r.origin.x += (r.size.width - dim.x) / 2;
- r.origin.y += (r.size.height - dim.y) / 2;
- r.size.width = dim.x;
- r.size.height = dim.y;
- surr = NSInsetRect (r, -2, -2);
- ns_focus (frame, &surr, 1);
- [[view window] cacheImageInRect: [view convertRect: surr toView:nil]];
- [ns_lookup_indexed_color (NS_FACE_FOREGROUND
- (FRAME_DEFAULT_FACE (frame)), frame) set];
- NSRectFill (r);
+ /* Get the bounds of our NSView */
+ NSRect viewBounds = [view bounds];
+
+ /* Height of each line to flash. */
+ int flash_height = FRAME_LINE_HEIGHT (frame);
+ int width = FRAME_PIXEL_WIDTH (frame)
+ - NS_SCROLL_BAR_WIDTH (frame);
+
+ /* Get the GraphicsContext */
+ CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicsPort];
+ CGRect lowerLine, upperLine;
+ lowerLine =
+ CGRectMake(viewBounds.origin.x, viewBounds.origin.y,
+ width + NS_SCROLL_BAR_WIDTH(frame),
+ flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame));
+ upperLine =
+ CGRectMake(viewBounds.origin.x,
+ viewBounds.origin.y + viewBounds.size.height
+ - (flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame)),
+ width,
+ flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame));
+
+ /* Invert the colors using a difference blend. */
+ CGContextSetBlendMode(ctxt, kCGBlendModeDifference);
+ CGContextSetGrayFillColor(ctxt, 1, 1);
+
+ /* If window is tall, flash top and bottom line. */
+ if (viewBounds.size.height > 3 * FRAME_LINE_HEIGHT (frame))
+ {
+ CGContextFillRect(ctxt, upperLine);
+ CGContextFillRect(ctxt, lowerLine);
+ }
+ else
+ /* If it is short, flash it all. */
+ CGContextFillRect(ctxt, NSRectToCGRect([view bounds]));
+
+ /* Bounce Dock icon. Maybe we can allow some configuration here. */
+ [NSApp requestUserAttention: NSInformationalRequest];
+
[[view window] flushWindow];
ns_timeout (150000);
- [[view window] restoreCachedImage];
+
+ /* If window is tall, flash top and bottom line. */
+ if (viewBounds.size.height > 3 * FRAME_LINE_HEIGHT (frame))
+ {
+ CGContextFillRect(ctxt, upperLine);
+ CGContextFillRect(ctxt, lowerLine);
+ }
+ else
+ /* If it is short, flash it all. */
+ CGContextFillRect(ctxt, NSRectToCGRect([view bounds]));
+
[[view window] flushWindow];
ns_unfocus (frame);
}
Return 0 if not found
-------------------------------------------------------------------------- */
{
- NSColor *temp;
- int notFound = ns_get_color (name, &temp);
-
+ NSColor *col;
NSTRACE (ns_defined_color);
- if (notFound)
- return 0;
-
+ BLOCK_INPUT;
+ if (ns_get_color (name, &col) != 0) /* Color not found */
+ {
+ UNBLOCK_INPUT;
+ return 0;
+ }
if (makeIndex && alloc)
- color_def->pixel = ns_index_color(temp, f); /* [temp retain]; */
-
- ns_query_color (temp, color_def, !makeIndex);
-
+ color_def->pixel = ns_index_color (col, f);
+ ns_query_color (col, color_def, !makeIndex);
+ UNBLOCK_INPUT;
return 1;
}
}
-static void
-ns_set_default_prefs ()
-/* --------------------------------------------------------------------------
- Initialize preference variables to defaults
- -------------------------------------------------------------------------- */
-{
- ns_alternate_modifier = Qmeta;
- ns_command_modifier = Qsuper;
- ns_control_modifier = Qcontrol;
- ns_function_modifier = Qnone;
- ns_antialias_text = Qt;
- ns_antialias_threshold = 10.0; /* not exposed to lisp side */
- ns_confirm_quit = Qnil;
-}
-
-
static void
ns_default (const char *parameter, Lisp_Object *result,
Lisp_Object yesval, Lisp_Object noval,
UNBLOCK_INPUT;
- /* Read various user defaults. */
- ns_set_default_prefs ();
if (!inhibit_x_resources)
{
ns_default ("GSFontAntiAlias", &ns_antialias_text,
syms_of_nsterm ()
{
NSTRACE (syms_of_nsterm);
+
+ ns_antialias_threshold = 10.0;
+
+ /* from 23+ we need to tell emacs what modifiers there are.. */
+ DEFSYM (Qmodifier_value, "modifier-value");
+ DEFSYM (Qalt, "alt");
+ DEFSYM (Qhyper, "hyper");
+ DEFSYM (Qmeta, "meta");
+ DEFSYM (Qsuper, "super");
+ DEFSYM (Qcontrol, "control");
+ DEFSYM (Qnone, "none");
+ Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
+ Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier));
+ Fput (Qmeta, Qmodifier_value, make_number (meta_modifier));
+ Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
+ Fput (Qcontrol, Qmodifier_value, make_number (ctrl_modifier));
+
DEFVAR_LISP ("ns-input-file", &ns_input_file,
"The file specified in the last NS event.");
ns_input_file =Qnil;
Set to control, meta, alt, super, or hyper means it is taken to be that key.\n\
Set to none means that the alternate / option key is not interpreted by Emacs\n\
at all, allowing it to be used at a lower level for accented character entry.");
+ ns_alternate_modifier = Qmeta;
DEFVAR_LISP ("ns-command-modifier", &ns_command_modifier,
"This variable describes the behavior of the command key.\n\
Set to control, meta, alt, super, or hyper means it is taken to be that key.");
+ ns_command_modifier = Qsuper;
DEFVAR_LISP ("ns-control-modifier", &ns_control_modifier,
"This variable describes the behavior of the control key.\n\
Set to control, meta, alt, super, or hyper means it is taken to be that key.");
+ ns_control_modifier = Qcontrol;
DEFVAR_LISP ("ns-function-modifier", &ns_function_modifier,
"This variable describes the behavior of the function key (on laptops).\n\
Set to control, meta, alt, super, or hyper means it is taken to be that key.\n\
Set to none means that the function key is not interpreted by Emacs at all,\n\
allowing it to be used at a lower level for accented character entry.");
+ ns_function_modifier = Qnone;
DEFVAR_LISP ("ns-antialias-text", &ns_antialias_text,
"Non-nil (the default) means to render text antialiased. Only has an effect on OS X Panther and above.");
+ ns_antialias_text = Qt;
DEFVAR_LISP ("ns-confirm-quit", &ns_confirm_quit,
"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;
- /* from 23+ we need to tell emacs what modifiers there are.. */
- Qmodifier_value = intern ("modifier-value");
- Qalt = intern ("alt");
- Fput (Qalt, Qmodifier_value, make_number (alt_modifier));
- Qhyper = intern ("hyper");
- Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier));
- Qmeta = intern ("meta");
- Fput (Qmeta, Qmodifier_value, make_number (meta_modifier));
- Qsuper = intern ("super");
- Fput (Qsuper, Qmodifier_value, make_number (super_modifier));
- Qcontrol = intern ("control");
- Fput (Qcontrol, Qmodifier_value, make_number (ctrl_modifier));
-
/* TODO: move to common code */
DEFVAR_LISP ("x-toolkit-scroll-bars", &Vx_toolkit_scroll_bars,
doc: /* If not nil, Emacs uses toolkit scroll bars. */);