Mercurial > emacs
comparison src/nsterm.m @ 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 | 36dd02b00382 |
children | bb5cb7ece094 |
comparison
equal
deleted
inserted
replaced
107057:c71f0d2188b2 | 107058:f151a3ed653f |
---|---|
806 pool = [[NSAutoreleasePool alloc] init]; | 806 pool = [[NSAutoreleasePool alloc] init]; |
807 | 807 |
808 view = FRAME_NS_VIEW (frame); | 808 view = FRAME_NS_VIEW (frame); |
809 if (view != nil) | 809 if (view != nil) |
810 { | 810 { |
811 NSRect r, surr; | 811 /* Get the bounds of our NSView */ |
812 NSPoint dim = NSMakePoint (128, 128); | 812 NSRect viewBounds = [view bounds]; |
813 | 813 |
814 r = [view bounds]; | 814 /* Height of each line to flash. */ |
815 r.origin.x += (r.size.width - dim.x) / 2; | 815 int flash_height = FRAME_LINE_HEIGHT (frame); |
816 r.origin.y += (r.size.height - dim.y) / 2; | 816 int width = FRAME_PIXEL_WIDTH (frame) |
817 r.size.width = dim.x; | 817 - NS_SCROLL_BAR_WIDTH (frame); |
818 r.size.height = dim.y; | 818 |
819 surr = NSInsetRect (r, -2, -2); | 819 /* Get the GraphicsContext */ |
820 ns_focus (frame, &surr, 1); | 820 CGContextRef ctxt = [[NSGraphicsContext currentContext] graphicsPort]; |
821 [[view window] cacheImageInRect: [view convertRect: surr toView:nil]]; | 821 CGRect lowerLine, upperLine; |
822 [ns_lookup_indexed_color (NS_FACE_FOREGROUND | 822 lowerLine = |
823 (FRAME_DEFAULT_FACE (frame)), frame) set]; | 823 CGRectMake(viewBounds.origin.x, viewBounds.origin.y, |
824 NSRectFill (r); | 824 width + NS_SCROLL_BAR_WIDTH(frame), |
825 flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame)); | |
826 upperLine = | |
827 CGRectMake(viewBounds.origin.x, | |
828 viewBounds.origin.y + viewBounds.size.height | |
829 - (flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame)), | |
830 width, | |
831 flash_height + FRAME_INTERNAL_BORDER_WIDTH (frame)); | |
832 | |
833 /* Invert the colors using a difference blend. */ | |
834 CGContextSetBlendMode(ctxt, kCGBlendModeDifference); | |
835 CGContextSetGrayFillColor(ctxt, 1, 1); | |
836 | |
837 /* If window is tall, flash top and bottom line. */ | |
838 if (viewBounds.size.height > 3 * FRAME_LINE_HEIGHT (frame)) | |
839 { | |
840 CGContextFillRect(ctxt, upperLine); | |
841 CGContextFillRect(ctxt, lowerLine); | |
842 } | |
843 else | |
844 /* If it is short, flash it all. */ | |
845 CGContextFillRect(ctxt, NSRectToCGRect([view bounds])); | |
846 | |
847 /* Bounce Dock icon. Maybe we can allow some configuration here. */ | |
848 [NSApp requestUserAttention: NSInformationalRequest]; | |
849 | |
825 [[view window] flushWindow]; | 850 [[view window] flushWindow]; |
826 ns_timeout (150000); | 851 ns_timeout (150000); |
827 [[view window] restoreCachedImage]; | 852 |
853 /* If window is tall, flash top and bottom line. */ | |
854 if (viewBounds.size.height > 3 * FRAME_LINE_HEIGHT (frame)) | |
855 { | |
856 CGContextFillRect(ctxt, upperLine); | |
857 CGContextFillRect(ctxt, lowerLine); | |
858 } | |
859 else | |
860 /* If it is short, flash it all. */ | |
861 CGContextFillRect(ctxt, NSRectToCGRect([view bounds])); | |
862 | |
828 [[view window] flushWindow]; | 863 [[view window] flushWindow]; |
829 ns_unfocus (frame); | 864 ns_unfocus (frame); |
830 } | 865 } |
831 [pool release]; | 866 [pool release]; |
832 UNBLOCK_INPUT; | 867 UNBLOCK_INPUT; |