Skip to content

Commit c2b2c19

Browse files
authored
Merge pull request #2 from willnode/cosmic-orbital
Pass damage area to orbital window sync
2 parents a3f77e2 + ae0f2e3 commit c2b2c19

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

‎src/orbital.rs‎

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> OrbitalImpl<D, W> {
163163

164164
// Window buffer map is dropped here
165165
}
166-
167-
// Tell orbital to show the latest window data
168-
syscall::fsync(self.window_fd()).expect("failed to sync orbital window");
169166
}
170167

171168
/// Fetch the buffer from the window.
@@ -209,10 +206,13 @@ impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferImpl<'a, D, W> {
209206
}
210207

211208
pub fn present(self) -> Result<(), SoftBufferError> {
209+
self.present_with_damage(&[])
210+
}
211+
212+
pub fn present_with_damage(self, damage: &[Rect]) -> Result<(), SoftBufferError> {
212213
match self.pixels {
213214
Pixels::Mapping(mapping) => {
214215
drop(mapping);
215-
syscall::fsync(self.imp.window_fd()).expect("failed to sync orbital window");
216216
self.imp.presented = true;
217217
}
218218
Pixels::Buffer(buffer) => {
@@ -221,10 +221,19 @@ impl<'a, D: HasDisplayHandle, W: HasWindowHandle> BufferImpl<'a, D, W> {
221221
}
222222
}
223223

224-
Ok(())
225-
}
224+
// Tell orbital to show the latest window data
225+
if damage.is_empty() {
226+
syscall::fsync(self.imp.window_fd()).expect("failed to sync orbital window");
227+
} else {
228+
use std::fmt::Write;
229+
let mut damage_buf = "Y".to_string();
230+
for m in damage {
231+
let _ = write!(damage_buf, ",{},{},{},{}", m.x, m.y, m.width, m.height);
232+
}
233+
syscall::write(self.imp.window_fd(), damage_buf.as_bytes())
234+
.expect("failed to sync orbital window");
235+
}
226236

227-
pub fn present_with_damage(self, _damage: &[Rect]) -> Result<(), SoftBufferError> {
228-
self.present()
237+
Ok(())
229238
}
230239
}

0 commit comments

Comments
 (0)