Call attach_buffer_and_commit before reading front buffer

This way double buffering is somewhat useful; we can start another
capture before reading out the buffer.
This commit is contained in:
Ian Douglas Scott 2024-01-25 16:00:37 -08:00
parent 89910b8e75
commit 6e422b740c

View file

@ -150,6 +150,10 @@ impl ScreencopyHandler for AppData {
let (front, back) = session.buffers.as_mut().unwrap();
mem::swap(front, back);
// Capture again on damage
session.attach_buffer_and_commit(&capture, conn);
let (front, _) = session.buffers.as_mut().unwrap();
let img = unsafe { front.to_image() };
let image = CaptureImage { img };
match &capture.source {
@ -164,9 +168,6 @@ impl ScreencopyHandler for AppData {
));
}
};
// Capture again on damage
session.attach_buffer_and_commit(&capture, conn);
}
fn failed(