Pass damage area to orbital window sync

This commit is contained in:
Wildan M 2026-04-16 02:44:45 +07:00
parent a3f77e251e
commit ae0f2e3e3f
No known key found for this signature in database
GPG key ID: 01AC53185C679C79

View file

@ -163,9 +163,6 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> OrbitalImpl<D, W> {
// Window buffer map is dropped here
}
// Tell orbital to show the latest window data
syscall::fsync(self.window_fd()).expect("failed to sync orbital window");
}
/// Fetch the buffer from the window.
@ -209,10 +206,13 @@ impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferImpl<'a, D, W> {
}
pub fn present(self) -> Result<(), SoftBufferError> {
self.present_with_damage(&[])
}
pub fn present_with_damage(self, damage: &[Rect]) -> Result<(), SoftBufferError> {
match self.pixels {
Pixels::Mapping(mapping) => {
drop(mapping);
syscall::fsync(self.imp.window_fd()).expect("failed to sync orbital window");
self.imp.presented = true;
}
Pixels::Buffer(buffer) => {
@ -221,10 +221,19 @@ impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferImpl<'a, D, W> {
}
}
// Tell orbital to show the latest window data
if damage.is_empty() {
syscall::fsync(self.imp.window_fd()).expect("failed to sync orbital window");
} else {
use std::fmt::Write;
let mut damage_buf = "Y".to_string();
for m in damage {
let _ = write!(damage_buf, ",{},{},{},{}", m.x, m.y, m.width, m.height);
}
syscall::write(self.imp.window_fd(), damage_buf.as_bytes())
.expect("failed to sync orbital window");
}
Ok(())
}
pub fn present_with_damage(self, _damage: &[Rect]) -> Result<(), SoftBufferError> {
self.present()
}
}