Move attach_buffer_and_commit
This commit is contained in:
parent
6f1b391b00
commit
43e9ef390a
2 changed files with 28 additions and 23 deletions
|
|
@ -35,7 +35,7 @@ pub struct Capture {
|
|||
pub buffer: Mutex<Option<Buffer>>,
|
||||
pub source: CaptureSource,
|
||||
first_frame: AtomicBool,
|
||||
session: Mutex<Option<zcosmic_screencopy_session_v1::ZcosmicScreencopySessionV1>>,
|
||||
pub session: Mutex<Option<zcosmic_screencopy_session_v1::ZcosmicScreencopySessionV1>>,
|
||||
}
|
||||
|
||||
impl Capture {
|
||||
|
|
@ -64,6 +64,10 @@ impl Capture {
|
|||
self.session.lock().unwrap().is_some()
|
||||
}
|
||||
|
||||
pub fn unset_first_frame(&self) {
|
||||
self.first_frame.store(false, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
pub fn first_frame(&self) -> bool {
|
||||
self.first_frame.load(Ordering::SeqCst)
|
||||
}
|
||||
|
|
@ -108,26 +112,6 @@ impl Capture {
|
|||
}
|
||||
*self.buffer.lock().unwrap() = None;
|
||||
}
|
||||
|
||||
pub fn attach_buffer_and_commit(&self, conn: &Connection) {
|
||||
let session = self.session.lock().unwrap();
|
||||
let buffer = self.buffer.lock().unwrap();
|
||||
let (Some(session), Some(buffer)) = (session.as_ref(), buffer.as_ref()) else {
|
||||
return;
|
||||
};
|
||||
|
||||
let node = buffer
|
||||
.node()
|
||||
.and_then(|x| x.to_str().map(|x| x.to_string()));
|
||||
|
||||
session.attach_buffer(&buffer.buffer, node, 0); // XXX age?
|
||||
if self.first_frame() {
|
||||
session.commit(zcosmic_screencopy_session_v1::Options::empty());
|
||||
} else {
|
||||
session.commit(zcosmic_screencopy_session_v1::Options::OnDamage);
|
||||
}
|
||||
conn.flush().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Capture {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue