Files
Graphite/desktop/ui/src/events.rs
Timon ba0a97aefe Desktop: Isolate CEF-rendered UI into separate crate and process (#4321)
* Extract CEF rendered UI into a separate process and crate

* Review

* Review

* Review

* Review

* Remove necessary workarounds

* Block on frame copy ack

* Crop and resample frames correctly

* Skip blank frames

* Fix deps

* Fix fmt

* Fix clippy warning

* Review

* Fix todo
2026-07-14 14:51:20 -07:00

42 lines
879 B
Rust

use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::Receiver;
use crate::UiEvent;
#[derive(Clone)]
pub(crate) struct EventQueue {
sender: std::sync::mpsc::Sender<UiEvent>,
terminated: Arc<AtomicBool>,
}
impl EventQueue {
pub(crate) fn new() -> (Self, Receiver<UiEvent>) {
let (sender, receiver) = std::sync::mpsc::channel();
(
Self {
sender,
terminated: Arc::new(AtomicBool::new(false)),
},
receiver,
)
}
pub(crate) fn send(&self, event: UiEvent) {
let _ = self.sender.send(event);
}
pub(crate) fn terminate(&self, event: UiEvent) {
let _ = self.sender.send(event);
self.terminated.store(true, Ordering::SeqCst);
}
pub(crate) fn mark_terminated(&self) {
self.terminated.store(true, Ordering::SeqCst);
}
pub(crate) fn is_terminated(&self) -> bool {
self.terminated.load(Ordering::SeqCst)
}
}