From c8c0568b66ad9dc2ab997a30ec9e98ec89625b43 Mon Sep 17 00:00:00 2001 From: Mikayla Maki Date: Fri, 16 May 2025 12:20:28 +0200 Subject: [PATCH] Add object safe APIs to the macOS adapter --- platforms/macos/src/adapter.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/platforms/macos/src/adapter.rs b/platforms/macos/src/adapter.rs index 2de5dbafc..2be7cc239 100644 --- a/platforms/macos/src/adapter.rs +++ b/platforms/macos/src/adapter.rs @@ -103,6 +103,25 @@ impl Adapter { Self { state } } + /// Check if the adapter is currently active. + pub fn active(&self) -> bool { + match self.state { + State::Inactive { .. } => false, + _ => true, + } + } + + /// If the tree has been initialized, apply the given TreeUpdate. Note: If + /// the caller's implementation of [`ActivationHandler::request_initial_tree`] + /// initially returned `None`, the [`TreeUpdate`] returned by the provided function + /// must contain a full tree. + /// + /// If a [`QueuedEvents`] instance is returned, the caller must call + /// [`QueuedEvents::raise`] on it. + pub fn update(&mut self, update: TreeUpdate) -> Option { + self.update_if_active(|| update) + } + /// If and only if the tree has been initialized, call the provided function /// and apply the resulting update. Note: If the caller's implementation of /// [`ActivationHandler::request_initial_tree`] initially returned `None`,