Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xdg: Add getters for pending configures and current state serial #1617

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/wayland/shell/xdg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ macro_rules! xdg_role {
pub last_acked: Option<$state>,
/// Holds the current state after a successful commit.
pub current: $state,
/// Holds the last acked configure serial at the time of the last successful
/// commit. This serial corresponds to the current state.
pub current_serial: Option<Serial>,
/// Does the surface have a buffer (updated on every commit)
has_buffer: bool,

Expand Down Expand Up @@ -282,6 +285,14 @@ macro_rules! xdg_role {
pub fn has_pending_changes(&self) -> bool {
self.server_pending.as_ref().map(|s| s != self.current_server_state()).unwrap_or(false)
}

/// Returns a list of configures sent to, but not yet acknowledged by the client.
///
/// The list is ordered by age, so the last configure in the list is the last one sent
/// to the client.
pub fn pending_configures(&self) -> &[$configure_name] {
&self.pending_configures
}
}

impl Default for $attributes_name {
Expand All @@ -294,6 +305,7 @@ macro_rules! xdg_role {
server_pending: None,
last_acked: None,
current: Default::default(),
current_serial: None,
has_buffer: false,

$(
Expand Down Expand Up @@ -1603,6 +1615,7 @@ impl ToplevelSurface {

if let Some(state) = guard.last_acked.clone() {
guard.current = state;
guard.current_serial = guard.configure_serial;
}
});
}
Expand Down Expand Up @@ -1993,9 +2006,8 @@ impl PopupSurface {

if attributes.initial_configure_sent {
if let Some(state) = attributes.last_acked {
if state != attributes.current {
attributes.current = state;
}
attributes.current = state;
attributes.current_serial = attributes.configure_serial;
}
}
});
Expand Down
Loading