* src/nsterm.m (EmacsBell): Add feature to remove visual bell
unconditionally.
(hide_bell): New function.
(ns_copy_bits): Hide visible bell before scrolling the frame content.
{
// Number of currently active bell:s.
unsigned int nestCount;
{
// Number of currently active bell:s.
unsigned int nestCount;
}
- (void)show:(NSView *)view;
- (void)hide;
}
- (void)show:(NSView *)view;
- (void)hide;
@end
@implementation EmacsBell
@end
@implementation EmacsBell
if ((self = [super init]))
{
nestCount = 0;
if ((self = [super init]))
{
nestCount = 0;
self.image = [NSImage imageNamed:NSImageNameCaution];
}
return self;
self.image = [NSImage imageNamed:NSImageNameCaution];
}
return self;
[self setFrameOrigin:pos];
[self setFrameSize:self.image.size];
[self setFrameOrigin:pos];
[self setFrameSize:self.image.size];
[[[view window] contentView] addSubview:self
positioned:NSWindowAbove
relativeTo:nil];
[[[view window] contentView] addSubview:self
positioned:NSWindowAbove
relativeTo:nil];
// Note: Trace output from this method isn't shown, reason unknown.
// NSTRACE ("[EmacsBell hide]");
// Note: Trace output from this method isn't shown, reason unknown.
// NSTRACE ("[EmacsBell hide]");
+ if (nestCount > 0)
+ --nestCount;
// Remove the image once the last bell became inactive.
if (nestCount == 0)
// Remove the image once the last bell became inactive.
if (nestCount == 0)
+ {
+ [self remove];
+ }
+}
+
+
+-(void)remove
+{
+ if (isAttached)
{
[self removeFromSuperview];
{
[self removeFromSuperview];
+
+static EmacsBell * bell_view = nil;
+
static void
ns_ring_bell (struct frame *f)
/* --------------------------------------------------------------------------
static void
ns_ring_bell (struct frame *f)
/* --------------------------------------------------------------------------
struct frame *frame = SELECTED_FRAME ();
NSView *view;
struct frame *frame = SELECTED_FRAME ();
NSView *view;
- static EmacsBell * bell_view = nil;
if (bell_view == nil)
{
bell_view = [[EmacsBell alloc] init];
if (bell_view == nil)
{
bell_view = [[EmacsBell alloc] init];
+static void hide_bell ()
+/* --------------------------------------------------------------------------
+ Ensure the bell is hidden.
+ -------------------------------------------------------------------------- */
+{
+ if (bell_view != nil)
+ {
+ [bell_view remove];
+ }
+}
+
+
/* ==========================================================================
Frame / window manager related functions
/* ==========================================================================
Frame / window manager related functions
{
if (FRAME_NS_VIEW (f))
{
{
if (FRAME_NS_VIEW (f))
{
+ hide_bell(); // Ensure the bell image isn't scrolled.
+
ns_focus (f, &dest, 1);
[FRAME_NS_VIEW (f) scrollRect: src
by: NSMakeSize (dest.origin.x - src.origin.x,
ns_focus (f, &dest, 1);
[FRAME_NS_VIEW (f) scrollRect: src
by: NSMakeSize (dest.origin.x - src.origin.x,