Skip to content

Commit

Permalink
Fix initial configure reset logic
Browse files Browse the repository at this point in the history
  • Loading branch information
PolyMeilex committed Oct 28, 2024
1 parent 6dce628 commit 5a1edd2
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/wayland/shell/xdg/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ macro_rules! xdg_role {
pub last_acked: Option<$state>,
/// Holds the current state after a successful commit.
pub current: $state,
/// Does the surface have a buffer (updated on every commit)
is_mapped: bool,

$(
$(#[$attributes_field_meta])*
Expand Down Expand Up @@ -293,6 +295,7 @@ macro_rules! xdg_role {
server_pending: None,
last_acked: None,
current: Default::default(),
is_mapped: false,

$(
$attributes_field_name: Default::default(),
Expand Down Expand Up @@ -1572,7 +1575,7 @@ impl ToplevelSurface {
_dh: &DisplayHandle,
surface: &wl_surface::WlSurface,
) {
let is_mapped = crate::backend::renderer::utils::with_renderer_surface_state(surface, |state| {
let has_buffer = crate::backend::renderer::utils::with_renderer_surface_state(surface, |state| {
state.buffer().is_some()
});

Expand All @@ -1585,12 +1588,15 @@ impl ToplevelSurface {
.unwrap();

// This can be None if rendering utils are not used by the user
if let Some(is_mapped) = is_mapped {
// After xdg surface unmaps it has to perform the initial commit-configure sequence again
if !is_mapped {
if let Some(has_buffer) = has_buffer {
// The surface was mapped in the past, and now got unmapped
if guard.is_mapped && !has_buffer {
// After xdg surface unmaps it has to perform the initial commit-configure sequence again
guard.initial_configure_sent = false;
guard.initial_decoration_configure_sent = false;
}

guard.is_mapped = has_buffer;
}

if let Some(state) = guard.last_acked.clone() {
Expand Down Expand Up @@ -1977,7 +1983,7 @@ impl PopupSurface {
_dh: &DisplayHandle,
surface: &wl_surface::WlSurface,
) {
let is_mapped = crate::backend::renderer::utils::with_renderer_surface_state(surface, |state| {
let has_buffer = crate::backend::renderer::utils::with_renderer_surface_state(surface, |state| {
state.buffer().is_some()
});

Expand All @@ -1991,11 +1997,14 @@ impl PopupSurface {
attributes.committed = true;

// This can be None if rendering utils are not used by the user
if let Some(is_mapped) = is_mapped {
// After xdg surface unmaps it has to perform the initial commit-configure sequence again
if !is_mapped {
if let Some(has_buffer) = has_buffer {
// The surface was mapped in the past, and now got unmapped
if attributes.is_mapped && !has_buffer {
// After xdg surface unmaps it has to perform the initial commit-configure sequence again
attributes.initial_configure_sent = false;
}

attributes.is_mapped = has_buffer;
}

if attributes.initial_configure_sent {
Expand Down

0 comments on commit 5a1edd2

Please sign in to comment.