diff options
| author | Anders Lindgren | 2016-01-02 15:54:01 +0100 |
|---|---|---|
| committer | Anders Lindgren | 2016-01-02 15:54:01 +0100 |
| commit | 55a28d8a1b1981d8469b39c68488f1848e8601b2 (patch) | |
| tree | 9921dea24f46d146164cb053ed42eef59a1f987b /src | |
| parent | d064034c1c805ba263de26efe7ca42acecbe8899 (diff) | |
| download | emacs-55a28d8a1b1981d8469b39c68488f1848e8601b2.tar.gz emacs-55a28d8a1b1981d8469b39c68488f1848e8601b2.zip | |
; Fixed visual bell artifact problem on NextStep.
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nsterm.m | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index 0510f8e0e91..b270e0e58b5 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1150,9 +1150,11 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, | |||
| 1150 | { | 1150 | { |
| 1151 | // Number of currently active bell:s. | 1151 | // Number of currently active bell:s. |
| 1152 | unsigned int nestCount; | 1152 | unsigned int nestCount; |
| 1153 | bool isAttached; | ||
| 1153 | } | 1154 | } |
| 1154 | - (void)show:(NSView *)view; | 1155 | - (void)show:(NSView *)view; |
| 1155 | - (void)hide; | 1156 | - (void)hide; |
| 1157 | - (void)remove; | ||
| 1156 | @end | 1158 | @end |
| 1157 | 1159 | ||
| 1158 | @implementation EmacsBell | 1160 | @implementation EmacsBell |
| @@ -1162,6 +1164,7 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, | |||
| 1162 | if ((self = [super init])) | 1164 | if ((self = [super init])) |
| 1163 | { | 1165 | { |
| 1164 | nestCount = 0; | 1166 | nestCount = 0; |
| 1167 | isAttached = false; | ||
| 1165 | self.image = [NSImage imageNamed:NSImageNameCaution]; | 1168 | self.image = [NSImage imageNamed:NSImageNameCaution]; |
| 1166 | } | 1169 | } |
| 1167 | return self; | 1170 | return self; |
| @@ -1183,6 +1186,7 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, | |||
| 1183 | [self setFrameOrigin:pos]; | 1186 | [self setFrameOrigin:pos]; |
| 1184 | [self setFrameSize:self.image.size]; | 1187 | [self setFrameSize:self.image.size]; |
| 1185 | 1188 | ||
| 1189 | isAttached = true; | ||
| 1186 | [[[view window] contentView] addSubview:self | 1190 | [[[view window] contentView] addSubview:self |
| 1187 | positioned:NSWindowAbove | 1191 | positioned:NSWindowAbove |
| 1188 | relativeTo:nil]; | 1192 | relativeTo:nil]; |
| @@ -1199,17 +1203,31 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, | |||
| 1199 | // Note: Trace output from this method isn't shown, reason unknown. | 1203 | // Note: Trace output from this method isn't shown, reason unknown. |
| 1200 | // NSTRACE ("[EmacsBell hide]"); | 1204 | // NSTRACE ("[EmacsBell hide]"); |
| 1201 | 1205 | ||
| 1202 | --nestCount; | 1206 | if (nestCount > 0) |
| 1207 | --nestCount; | ||
| 1203 | 1208 | ||
| 1204 | // Remove the image once the last bell became inactive. | 1209 | // Remove the image once the last bell became inactive. |
| 1205 | if (nestCount == 0) | 1210 | if (nestCount == 0) |
| 1206 | { | 1211 | { |
| 1212 | [self remove]; | ||
| 1213 | } | ||
| 1214 | } | ||
| 1215 | |||
| 1216 | |||
| 1217 | -(void)remove | ||
| 1218 | { | ||
| 1219 | if (isAttached) | ||
| 1220 | { | ||
| 1207 | [self removeFromSuperview]; | 1221 | [self removeFromSuperview]; |
| 1222 | isAttached = false; | ||
| 1208 | } | 1223 | } |
| 1209 | } | 1224 | } |
| 1210 | 1225 | ||
| 1211 | @end | 1226 | @end |
| 1212 | 1227 | ||
| 1228 | |||
| 1229 | static EmacsBell * bell_view = nil; | ||
| 1230 | |||
| 1213 | static void | 1231 | static void |
| 1214 | ns_ring_bell (struct frame *f) | 1232 | ns_ring_bell (struct frame *f) |
| 1215 | /* -------------------------------------------------------------------------- | 1233 | /* -------------------------------------------------------------------------- |
| @@ -1222,7 +1240,6 @@ ns_ring_bell (struct frame *f) | |||
| 1222 | struct frame *frame = SELECTED_FRAME (); | 1240 | struct frame *frame = SELECTED_FRAME (); |
| 1223 | NSView *view; | 1241 | NSView *view; |
| 1224 | 1242 | ||
| 1225 | static EmacsBell * bell_view = nil; | ||
| 1226 | if (bell_view == nil) | 1243 | if (bell_view == nil) |
| 1227 | { | 1244 | { |
| 1228 | bell_view = [[EmacsBell alloc] init]; | 1245 | bell_view = [[EmacsBell alloc] init]; |
| @@ -1246,6 +1263,18 @@ ns_ring_bell (struct frame *f) | |||
| 1246 | } | 1263 | } |
| 1247 | 1264 | ||
| 1248 | 1265 | ||
| 1266 | static void hide_bell () | ||
| 1267 | /* -------------------------------------------------------------------------- | ||
| 1268 | Ensure the bell is hidden. | ||
| 1269 | -------------------------------------------------------------------------- */ | ||
| 1270 | { | ||
| 1271 | if (bell_view != nil) | ||
| 1272 | { | ||
| 1273 | [bell_view remove]; | ||
| 1274 | } | ||
| 1275 | } | ||
| 1276 | |||
| 1277 | |||
| 1249 | /* ========================================================================== | 1278 | /* ========================================================================== |
| 1250 | 1279 | ||
| 1251 | Frame / window manager related functions | 1280 | Frame / window manager related functions |
| @@ -2328,6 +2357,8 @@ ns_copy_bits (struct frame *f, NSRect src, NSRect dest) | |||
| 2328 | { | 2357 | { |
| 2329 | if (FRAME_NS_VIEW (f)) | 2358 | if (FRAME_NS_VIEW (f)) |
| 2330 | { | 2359 | { |
| 2360 | hide_bell(); // Ensure the bell image isn't scrolled. | ||
| 2361 | |||
| 2331 | ns_focus (f, &dest, 1); | 2362 | ns_focus (f, &dest, 1); |
| 2332 | [FRAME_NS_VIEW (f) scrollRect: src | 2363 | [FRAME_NS_VIEW (f) scrollRect: src |
| 2333 | by: NSMakeSize (dest.origin.x - src.origin.x, | 2364 | by: NSMakeSize (dest.origin.x - src.origin.x, |