Skip to content

Commit 638c16b

Browse files
committed
Add object safe APIs to the macOS adapter
1 parent daf5faf commit 638c16b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

platforms/macos/src/adapter.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,25 @@ impl Adapter {
103103
Self { state }
104104
}
105105

106+
/// Check if the adapter is currently active.
107+
pub fn active(&mut self) -> bool {
108+
match self.state {
109+
State::Inactive { .. } => false,
110+
_ => true,
111+
}
112+
}
113+
114+
/// If the tree has been initialized, apply the given TreeUpdate. Note: If
115+
/// the caller's implementation of [`ActivationHandler::request_initial_tree`]
116+
/// initially returned `None`, the [`TreeUpdate`] returned by the provided function
117+
/// must contain a full tree.
118+
///
119+
/// If a [`QueuedEvents`] instance is returned, the caller must call
120+
/// [`QueuedEvents::raise`] on it.
121+
pub fn update(&mut self, update: TreeUpdate) -> Option<QueuedEvents> {
122+
self.update_if_active(|| update)
123+
}
124+
106125
/// If and only if the tree has been initialized, call the provided function
107126
/// and apply the resulting update. Note: If the caller's implementation of
108127
/// [`ActivationHandler::request_initial_tree`] initially returned `None`,

0 commit comments

Comments
 (0)