diff options
| author | Chong Yidong | 2010-01-30 22:36:06 -0500 |
|---|---|---|
| committer | Chong Yidong | 2010-01-30 22:36:06 -0500 |
| commit | cb2a62f242e8c718982d034063136d375d5bbf80 (patch) | |
| tree | d8441ea6883b14ca385a03deb28fc2a7e8abbb5e /src | |
| parent | fe6902ed191454be16fff0e0a94fea28f455ed6b (diff) | |
| download | emacs-cb2a62f242e8c718982d034063136d375d5bbf80.tar.gz emacs-cb2a62f242e8c718982d034063136d375d5bbf80.zip | |
* nsterm.m (ns_ring_bell): Handle visible bell like X.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/nsterm.m | 65 |
2 files changed, 54 insertions, 15 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 795b6059a6f..85d5ca3f025 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2010-01-31 Filipe Cabecinhas <filcab@gmail.com> (tiny change) | ||
| 2 | |||
| 3 | * nsterm.m (ns_ring_bell): Handle visible bell like X. | ||
| 4 | |||
| 1 | 2010-01-30 Andreas Schwab <schwab@linux-m68k.org> | 5 | 2010-01-30 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 6 | ||
| 3 | * character.h (CHAR_PRINTABLE_P): Reparenthesize to avoid warning. | 7 | * character.h (CHAR_PRINTABLE_P): Reparenthesize to avoid warning. |
diff --git a/src/nsterm.m b/src/nsterm.m index a102267920c..3951fdc2e58 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -808,23 +808,58 @@ ns_ring_bell () | |||
| 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 | } |