Mercurial > emacs
changeset 107058:f151a3ed653f
* nsterm.m (ns_ring_bell): Handle visible bell like X.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 30 Jan 2010 22:36:06 -0500 |
parents | c71f0d2188b2 |
children | 4ab5994c2846 |
files | src/ChangeLog src/nsterm.m |
diffstat | 2 files changed, 54 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Sat Jan 30 13:58:56 2010 -0800 +++ b/src/ChangeLog Sat Jan 30 22:36:06 2010 -0500 @@ -1,3 +1,7 @@ +2010-01-31 Filipe Cabecinhas <filcab@gmail.com> (tiny change) + + * nsterm.m (ns_ring_bell): Handle visible bell like X. + 2010-01-30 Andreas Schwab <schwab@linux-m68k.org> * character.h (CHAR_PRINTABLE_P): Reparenthesize to avoid warning.
--- a/src/nsterm.m Sat Jan 30 13:58:56 2010 -0800 +++ b/src/nsterm.m Sat Jan 30 22:36:06 2010 -0500 @@ -808,23 +808,58 @@ 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); }