fix(wayland): frame callbacks in order
This commit is contained in:
@@ -48,7 +48,7 @@ pub struct SurfaceState {
|
|||||||
pub geometry: Option<Geometry>,
|
pub geometry: Option<Geometry>,
|
||||||
pub min_size: Option<Vector2<u32>>,
|
pub min_size: Option<Vector2<u32>>,
|
||||||
pub max_size: Option<Vector2<u32>>,
|
pub max_size: Option<Vector2<u32>>,
|
||||||
frame_callbacks: Registry<Callback>,
|
frame_callbacks: Vec<Arc<Callback>>,
|
||||||
}
|
}
|
||||||
impl Default for SurfaceState {
|
impl Default for SurfaceState {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
@@ -58,7 +58,7 @@ impl Default for SurfaceState {
|
|||||||
geometry: None,
|
geometry: None,
|
||||||
min_size: None,
|
min_size: None,
|
||||||
max_size: None,
|
max_size: None,
|
||||||
frame_callbacks: Registry::new(),
|
frame_callbacks: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ impl Surface {
|
|||||||
}
|
}
|
||||||
#[tracing::instrument(level = "debug", skip_all)]
|
#[tracing::instrument(level = "debug", skip_all)]
|
||||||
pub fn frame_event(&self) {
|
pub fn frame_event(&self) {
|
||||||
for callback in self.current_state().frame_callbacks.take_valid_contents() {
|
for callback in self.state.lock().current.frame_callbacks.drain(..) {
|
||||||
let _ = self.message_sink.send(Message::Frame(callback));
|
let _ = self.message_sink.send(Message::Frame(callback));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -258,7 +258,7 @@ impl WlSurface for Surface {
|
|||||||
callback_id: ObjectId,
|
callback_id: ObjectId,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let callback = client.insert(callback_id, Callback(callback_id));
|
let callback = client.insert(callback_id, Callback(callback_id));
|
||||||
self.state.lock().pending.frame_callbacks.add_raw(&callback);
|
self.state.lock().pending.frame_callbacks.push(callback);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ impl ClientExt for Client {
|
|||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct DoubleBuffer<State: Debug + Clone> {
|
pub struct DoubleBuffer<State: Debug + Clone> {
|
||||||
current: State,
|
pub current: State,
|
||||||
pub pending: State,
|
pub pending: State,
|
||||||
}
|
}
|
||||||
impl<State: Debug + Clone> DoubleBuffer<State> {
|
impl<State: Debug + Clone> DoubleBuffer<State> {
|
||||||
|
|||||||
Reference in New Issue
Block a user