make attributes state functions public in xdg shell

This commit is contained in:
Christian Meissl 2021-11-22 20:58:33 +01:00 committed by Victor Berger
parent 4f36e03266
commit 2123760c9e
1 changed files with 15 additions and 11 deletions

View File

@ -212,14 +212,17 @@ macro_rules! xdg_role {
} }
/// Gets the latest state that has been configured /// Gets the latest state that has been configured
/// on the server. The state can include changes /// on the server and sent to the client.
/// that have been made on the server but not yet ///
/// acked or committed by the client. It does not /// The state includes all changes that have been
/// include the current pending state. /// made on the server, including all not yet
/// acked or committed changes, but excludes the
/// current [`server_pending`](#structfield.server_pending) state.
/// ///
/// This can be used for example to check if the /// This can be used for example to check if the
/// pending state is different from the last configured. /// [`server_pending`](#structfield.server_pending) state
fn current_server_state(&self) -> &$state { /// is different from the last configured.
pub fn current_server_state(&self) -> &$state {
// We check if there is already a non-acked pending // We check if there is already a non-acked pending
// configure and use its state or otherwise we could // configure and use its state or otherwise we could
// loose some state that was previously configured // loose some state that was previously configured
@ -240,12 +243,13 @@ macro_rules! xdg_role {
.unwrap_or(&self.current) .unwrap_or(&self.current)
} }
/// Check if the state has pending changes. /// Check if the state has pending changes that have
/// not been sent to the client.
/// ///
/// This differs to just checking if the server pending /// This differs from just checking if the [`server_pending`](#structfield.server_pending)
/// state is some in that it also check if a pending /// state is [`Some`] in that it also checks if a current pending
/// state is different from the current server state. /// state is different from the [`current_server_state`](#method.current_server_state).
fn has_pending_changes(&self) -> bool { pub fn has_pending_changes(&self) -> bool {
self.server_pending.as_ref().map(|s| s != self.current_server_state()).unwrap_or(false) self.server_pending.as_ref().map(|s| s != self.current_server_state()).unwrap_or(false)
} }
} }