Functional parity with linux
This commit is contained in:
@@ -4,8 +4,8 @@ use std::cell::RefCell;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicU64, Ordering};
|
||||
use std::sync::{Arc, Mutex, OnceLock};
|
||||
|
||||
use ruin_runtime::channel::mpsc;
|
||||
use ruin_runtime::{WorkerHandle, queue_future, queue_microtask, spawn_worker};
|
||||
@@ -18,6 +18,13 @@ use crate::trace_targets;
|
||||
use crate::tree::CursorIcon;
|
||||
use crate::window::{WindowConfigured, WindowId, WindowLifecycle, WindowSpec, WindowUpdate};
|
||||
|
||||
type CommandWakeHook = Arc<dyn Fn() + Send + Sync + 'static>;
|
||||
|
||||
fn command_wake_hook() -> &'static Mutex<Option<CommandWakeHook>> {
|
||||
static HOOK: OnceLock<Mutex<Option<CommandWakeHook>>> = OnceLock::new();
|
||||
HOOK.get_or_init(|| Mutex::new(None))
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct PlatformProxy {
|
||||
command_tx: mpsc::UnboundedSender<PlatformRequest>,
|
||||
@@ -346,7 +353,20 @@ impl PlatformProxy {
|
||||
}
|
||||
|
||||
fn send(&self, command: PlatformRequest) -> Result<(), PlatformClosed> {
|
||||
self.command_tx.send(command).map_err(|_| PlatformClosed)
|
||||
self.command_tx.send(command).map_err(|_| PlatformClosed)?;
|
||||
if let Ok(hook) = command_wake_hook().lock()
|
||||
&& let Some(hook) = hook.as_ref().cloned()
|
||||
{
|
||||
hook();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub fn set_command_wake_hook(hook: Option<CommandWakeHook>) {
|
||||
if let Ok(mut slot) = command_wake_hook().lock() {
|
||||
*slot = hook;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user