Merge pull request #2 from willnode/cosmic-orbital

Pass damage area to orbital window sync
This commit is contained in:
Jeremy Soller 2026-04-18 12:05:04 -06:00 committed by GitHub
commit c2b2c19ddb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -163,9 +163,6 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> OrbitalImpl<D, W> {
// Window buffer map is dropped here // 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. /// 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> { pub fn present(self) -> Result<(), SoftBufferError> {
self.present_with_damage(&[])
}
pub fn present_with_damage(self, damage: &[Rect]) -> Result<(), SoftBufferError> {
match self.pixels { match self.pixels {
Pixels::Mapping(mapping) => { Pixels::Mapping(mapping) => {
drop(mapping); drop(mapping);
syscall::fsync(self.imp.window_fd()).expect("failed to sync orbital window");
self.imp.presented = true; self.imp.presented = true;
} }
Pixels::Buffer(buffer) => { 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(()) Ok(())
} }
pub fn present_with_damage(self, _damage: &[Rect]) -> Result<(), SoftBufferError> {
self.present()
}
} }