Repository: alacritty/alacritty (language: rust)

Issue:
Messages are not updated on sway if the dialog has the same size as the previous one
### System
OS: ArchLinux
Version: 0.12.2, but also happens in the current master branch, and at least since 0.10.0 
DE: Sway

### Steps to reproduce

1. Edit the alacritty config, such that two messages with same length are emitted on startup:
   On the current master branch this can be done, by adding attributes x and y to window section top generate 2 warnings.
   On version 0.12.2, the window padding x and y value can be set to `a` to generate 2 errors.
2. Click on the cross to close the first message.

### Expected result
The second message is now shown.
Clicking again on the cross, closes the dialog.

### Actual result
The first message is still shown.
Clicking again on the cross, closes the dialog, so the first click was processed.

### First analysis
If messages result in dialog boxes of different size, the size and the text is updated. Only if the dialog box size is unchanged, the text isn't changed either. I couldn't reproduce the error on GNOME/Wayland or KDE/X11. If more the 2 messages with same dialog size are shown, the text of the first messages stays until the dialog gets closed the correct number of times. Some other actions trigger a text update (f.e. focusing another window, pressing enter) while others don't (f.e. pressing a non-enter key). If the first message is a warning and the second message an error, the color isn't updated either.

### Debugging results
Clicks correctly result in a call to `Display::draw`, which sees the new message. However, there seems to be no damage rect for the dialog box, which might be the reason, why the box text and color isn't updated. If `Display::swap_buffers` uses  `surface.swap_buffers` instead of `surface.swap_buffers_with_damage`, the error does not occur. However, I am a bit confused, whether this is really the underlying cause, because there isn't a damage rect on GNOME or KDE either, and the error doesn't occur there.



Discussion / hints:
Could you test with the `alacritty -o debug.highlight_damage=true`? It should draw the purple rectangles over the things being damaged.
It doesn't draw a purple rect over the dialog box, except for the last message, when the dialog box is closed, then the purple rect extend over the message box, that is no longer shown.
But they wouldn't be visible anyway, because `Display::draw` calls `self.highlight_damage` before drawing the message box.
Ah, but it works correctly, right? Since it should disable all the damage tracking if you use it.
If this debug option makes a difference than it's a damage tracking bug, otherwise some redraw/dirty logic.
It does work correctly, yes.
Adding
```rust
self.damage_rects.push(Rect { x: 0, y: 0, width: size_info.width().ceil() as i32, height: (size_info.height() - y).ceil() as i32 });
```

after

https://github.com/alacritty/alacritty/blob/e35e5ad14fce8456afdd89f2b392b9924bb27471/alacritty/src/display/mod.rs#L942-L943

fixes the issue.
Yeah, it's a damage tracking issue then. Thx for testing.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8467cb8bf0c..48a65132043 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -69,6 +69,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - `window.startup_mode` applied to window again when creating new tab
 - Crash when leaving search after resize
 - Cursor being hidden after reaching cursor blinking timeout
+- Message bar content getting stuck after closing with multiple messages on Wayland
 
 ### Removed
 
diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs
index 1d993af8c01..878f03e164b 100644
--- a/alacritty/src/display/mod.rs
+++ b/alacritty/src/display/mod.rs
@@ -941,12 +941,18 @@ impl Display {
                 MessageType::Warning => config.colors.normal.yellow,
             };
 
+            let x = 0;
+            let width = size_info.width() as i32;
+            let height = (size_info.height() - y) as i32;
             let message_bar_rect =
-                RenderRect::new(0., y, size_info.width(), size_info.height() - y, bg, 1.);
+                RenderRect::new(x as f32, y, width as f32, height as f32, bg, 1.);
 
             // Push message_bar in the end, so it'll be above all other content.
             rects.push(message_bar_rect);
 
+            // Always damage message bar, since it could have messages of the same size in it.
+            self.damage_rects.push(DamageRect { x, y: y as i32, width, height });
+
             // Draw rectangles.
             self.renderer.draw_rects(&size_info, &metrics, rects);
 


Test patch: