pub fn update_if_active(&mut self, update_factory: impl FnOnce() -> TreeUpdate) {
        let mut state = self.state.lock().unwrap();
        match &mut *state {
            AdapterState::Inactive { .. } => (),
            AdapterState::Pending {
                is_window_focused,
                root_window_bounds,
                action_handler,
            } => {
                let initial_state = update_factory();
                let r#impl = AdapterImpl::with_wrapped_action_handler(
                    self.id,
                    get_or_init_app_context(),
                    Callback::new(),
                    initial_state,
                    *is_window_focused,
                    *root_window_bounds,
                    Arc::clone(action_handler),
                );
                *state = AdapterState::Active(r#impl);
            }
            AdapterState::Active(r#impl) => r#impl.update(update_factory()),
        }
    }
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`,
the [`TreeUpdate`] returned by the provided function must contain
a full tree.
platforms/unix/src/adapter.rs