Add version method to ToplevelSurface

Currently the `shell_surface` is not accessible to the outside, meaning
there is no way to query for the XDG shell protocol version supported by
the client.

Adding a `version` method fixes that problem, which allows compositors
to act differently based on the supported protocol version. As an
example this allows setting the state to `State::Maximized` if the
tiling states are not available.
This commit is contained in:
Christian Duerr 2021-11-09 22:42:15 +01:00 committed by Victor Berger
parent 4dec5f7fa2
commit 076f824431
1 changed files with 5 additions and 0 deletions

View File

@ -903,6 +903,11 @@ impl ToplevelSurface {
self.shell_surface.as_ref().is_alive() && self.wl_surface.as_ref().is_alive() self.shell_surface.as_ref().is_alive() && self.wl_surface.as_ref().is_alive()
} }
/// Supported XDG shell protocol version.
pub fn version(&self) -> u32 {
self.shell_surface.as_ref().version()
}
/// Retrieve the shell client owning this toplevel surface /// Retrieve the shell client owning this toplevel surface
/// ///
/// Returns `None` if the surface does actually no longer exist. /// Returns `None` if the surface does actually no longer exist.