diff options
| author | Anders Lindgren | 2016-03-17 21:07:04 +0100 |
|---|---|---|
| committer | Anders Lindgren | 2016-03-17 21:07:04 +0100 |
| commit | 1df7173eb23510ef5faabede04a487955aec2917 (patch) | |
| tree | 836f4a39f614abe3fefcd735f047153c9ebbd364 | |
| parent | 7a2edd3427b8006805c8fd293c2e481114776e4d (diff) | |
| download | emacs-1df7173eb23510ef5faabede04a487955aec2917.tar.gz emacs-1df7173eb23510ef5faabede04a487955aec2917.zip | |
Avoid screen artifacts with new OS X visible bell after scrolling
* src/nsterm.m (EmacsBell): Save NSView when displaying the
visible bell and set `needsDisplay' when removed.
(hide_bell): Trace.
(ns_copy_bits): Trace.
| -rw-r--r-- | src/nsterm.m | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/nsterm.m b/src/nsterm.m index 38aa4a3a413..b796193af77 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -1172,10 +1172,31 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, | |||
| 1172 | ========================================================================== */ | 1172 | ========================================================================== */ |
| 1173 | 1173 | ||
| 1174 | 1174 | ||
| 1175 | // This bell implementation shows the visual bell image asynchronously | ||
| 1176 | // from the rest of Emacs. This is done by adding a NSView to the | ||
| 1177 | // superview of the Emacs window and removing it using a timer. | ||
| 1178 | // | ||
| 1179 | // Unfortunately, some Emacs operations, like scrolling, is done using | ||
| 1180 | // low-level primitives that copy the content of the window, including | ||
| 1181 | // the bell image. To some extent, this is handled by removing the | ||
| 1182 | // image prior to scrolling and marking that the window is in need for | ||
| 1183 | // redisplay. | ||
| 1184 | // | ||
| 1185 | // To test this code, make sure that there is no artifacts of the bell | ||
| 1186 | // image in the following situations. Use a non-empty buffer (like the | ||
| 1187 | // tutorial) to ensure that a scroll is performed: | ||
| 1188 | // | ||
| 1189 | // * Single-window: C-g C-v | ||
| 1190 | // | ||
| 1191 | // * Side-by-windows: C-x 3 C-g C-v | ||
| 1192 | // | ||
| 1193 | // * Windows above each other: C-x 2 C-g C-v | ||
| 1194 | |||
| 1175 | @interface EmacsBell : NSImageView | 1195 | @interface EmacsBell : NSImageView |
| 1176 | { | 1196 | { |
| 1177 | // Number of currently active bell:s. | 1197 | // Number of currently active bell:s. |
| 1178 | unsigned int nestCount; | 1198 | unsigned int nestCount; |
| 1199 | NSView * mView; | ||
| 1179 | bool isAttached; | 1200 | bool isAttached; |
| 1180 | } | 1201 | } |
| 1181 | - (void)show:(NSView *)view; | 1202 | - (void)show:(NSView *)view; |
| @@ -1204,7 +1225,6 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, | |||
| 1204 | [self.image unlockFocus]; | 1225 | [self.image unlockFocus]; |
| 1205 | #else | 1226 | #else |
| 1206 | self.image = [NSImage imageNamed:NSImageNameCaution]; | 1227 | self.image = [NSImage imageNamed:NSImageNameCaution]; |
| 1207 | [self.image setScalesWhenResized:YES]; | ||
| 1208 | [self.image setSize:NSMakeSize(self.image.size.width * 5, | 1228 | [self.image setSize:NSMakeSize(self.image.size.width * 5, |
| 1209 | self.image.size.height * 5)]; | 1229 | self.image.size.height * 5)]; |
| 1210 | #endif | 1230 | #endif |
| @@ -1229,6 +1249,7 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, | |||
| 1229 | [self setFrameSize:self.image.size]; | 1249 | [self setFrameSize:self.image.size]; |
| 1230 | 1250 | ||
| 1231 | isAttached = true; | 1251 | isAttached = true; |
| 1252 | mView = view; | ||
| 1232 | [[[view window] contentView] addSubview:self | 1253 | [[[view window] contentView] addSubview:self |
| 1233 | positioned:NSWindowAbove | 1254 | positioned:NSWindowAbove |
| 1234 | relativeTo:nil]; | 1255 | relativeTo:nil]; |
| @@ -1258,9 +1279,12 @@ ns_clip_to_row (struct window *w, struct glyph_row *row, | |||
| 1258 | 1279 | ||
| 1259 | -(void)remove | 1280 | -(void)remove |
| 1260 | { | 1281 | { |
| 1282 | NSTRACE ("[EmacsBell remove]"); | ||
| 1261 | if (isAttached) | 1283 | if (isAttached) |
| 1262 | { | 1284 | { |
| 1285 | NSTRACE_MSG ("removeFromSuperview"); | ||
| 1263 | [self removeFromSuperview]; | 1286 | [self removeFromSuperview]; |
| 1287 | mView.needsDisplay = YES; | ||
| 1264 | isAttached = false; | 1288 | isAttached = false; |
| 1265 | } | 1289 | } |
| 1266 | } | 1290 | } |
| @@ -1310,6 +1334,8 @@ static void hide_bell () | |||
| 1310 | Ensure the bell is hidden. | 1334 | Ensure the bell is hidden. |
| 1311 | -------------------------------------------------------------------------- */ | 1335 | -------------------------------------------------------------------------- */ |
| 1312 | { | 1336 | { |
| 1337 | NSTRACE ("hide_bell"); | ||
| 1338 | |||
| 1313 | if (bell_view != nil) | 1339 | if (bell_view != nil) |
| 1314 | { | 1340 | { |
| 1315 | [bell_view remove]; | 1341 | [bell_view remove]; |
| @@ -2392,6 +2418,8 @@ ns_clear_frame_area (struct frame *f, int x, int y, int width, int height) | |||
| 2392 | static void | 2418 | static void |
| 2393 | ns_copy_bits (struct frame *f, NSRect src, NSRect dest) | 2419 | ns_copy_bits (struct frame *f, NSRect src, NSRect dest) |
| 2394 | { | 2420 | { |
| 2421 | NSTRACE ("ns_copy_bits"); | ||
| 2422 | |||
| 2395 | if (FRAME_NS_VIEW (f)) | 2423 | if (FRAME_NS_VIEW (f)) |
| 2396 | { | 2424 | { |
| 2397 | hide_bell(); // Ensure the bell image isn't scrolled. | 2425 | hide_bell(); // Ensure the bell image isn't scrolled. |