Update smithay

Updates for `last_acked`, etc. API changes in
https://github.com/Smithay/smithay/pull/1817.

Includes layer shell fixes
from https://github.com/Smithay/smithay/pull/1819.
This commit is contained in:
Ian Douglas Scott 2025-10-09 18:18:29 -07:00 committed by Victoria Brekenfeld
parent 9816b18259
commit e129094bfb
4 changed files with 45 additions and 40 deletions

2
Cargo.lock generated
View file

@ -4961,7 +4961,7 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]] [[package]]
name = "smithay" name = "smithay"
version = "0.7.0" version = "0.7.0"
source = "git+https://github.com/smithay/smithay.git?rev=eb45814#eb45814725597a7f0db07eccf4bd473d87c730bc" source = "git+https://github.com/smithay/smithay.git?rev=d743e1a#d743e1a317fa0f01d1c4cadd96d277a1ec7b59d9"
dependencies = [ dependencies = [
"aliasable", "aliasable",
"appendlist", "appendlist",

View file

@ -145,4 +145,4 @@ cosmic-protocols = { git = "https://github.com/pop-os//cosmic-protocols", branch
cosmic-client-toolkit = { git = "https://github.com/pop-os//cosmic-protocols", branch = "main" } cosmic-client-toolkit = { git = "https://github.com/pop-os//cosmic-protocols", branch = "main" }
[patch.crates-io] [patch.crates-io]
smithay = { git = "https://github.com/smithay/smithay.git", rev = "eb45814" } smithay = { git = "https://github.com/smithay/smithay.git", rev = "d743e1a" }

View file

@ -43,7 +43,9 @@ use smithay::{
wayland::{ wayland::{
compositor::{SurfaceData, TraversalAction, with_states, with_surface_tree_downward}, compositor::{SurfaceData, TraversalAction, with_states, with_surface_tree_downward},
seat::WaylandFocus, seat::WaylandFocus,
shell::xdg::{SurfaceCachedState, ToplevelSurface, XdgToplevelSurfaceData}, shell::xdg::{
SurfaceCachedState, ToplevelCachedState, ToplevelSurface, XdgToplevelSurfaceData,
},
}, },
xwayland::{X11Surface, xwm::X11Relatable}, xwayland::{X11Surface, xwm::X11Relatable},
}; };
@ -215,7 +217,7 @@ impl CosmicSurface {
pub fn is_activated(&self, pending: bool) -> bool { pub fn is_activated(&self, pending: bool) -> bool {
match self.0.underlying_surface() { match self.0.underlying_surface() {
WindowSurface::Wayland(toplevel) => with_toplevel_state(toplevel, pending, |state| { WindowSurface::Wayland(toplevel) => with_toplevel_state(toplevel, pending, |state| {
state.states.contains(ToplevelState::Activated) state.is_some_and(|state| state.states.contains(ToplevelState::Activated))
}), }),
WindowSurface::X11(surface) => surface.is_activated(), WindowSurface::X11(surface) => surface.is_activated(),
} }
@ -247,9 +249,11 @@ impl CosmicSurface {
}); });
let xdg_state = with_toplevel_state(toplevel, pending, |state| { let xdg_state = with_toplevel_state(toplevel, pending, |state| {
state.and_then(|state| {
state state
.decoration_mode .decoration_mode
.map(|mode| mode == DecorationMode::ClientSide) .map(|mode| mode == DecorationMode::ClientSide)
})
}); });
kde_state.or(xdg_state).unwrap_or(true) kde_state.or(xdg_state).unwrap_or(true)
@ -262,7 +266,9 @@ impl CosmicSurface {
match self.0.underlying_surface() { match self.0.underlying_surface() {
WindowSurface::Wayland(toplevel) => { WindowSurface::Wayland(toplevel) => {
if enable { if enable {
let previous_decoration_state = toplevel.current_state().decoration_mode; let previous_decoration_state = toplevel.with_committed_state(|state| {
state.map_or_else(Default::default, |state| state.decoration_mode)
});
if PreferredDecorationMode::is_unset(&self.0) { if PreferredDecorationMode::is_unset(&self.0) {
PreferredDecorationMode::update(&self.0, previous_decoration_state); PreferredDecorationMode::update(&self.0, previous_decoration_state);
} }
@ -298,7 +304,7 @@ impl CosmicSurface {
match self.0.underlying_surface() { match self.0.underlying_surface() {
WindowSurface::Wayland(toplevel) => { WindowSurface::Wayland(toplevel) => {
Some(with_toplevel_state(toplevel, pending, |state| { Some(with_toplevel_state(toplevel, pending, |state| {
state.states.contains(ToplevelState::Resizing) state.is_some_and(|state| state.states.contains(ToplevelState::Resizing))
})) }))
} }
WindowSurface::X11(_surface) => None, WindowSurface::X11(_surface) => None,
@ -322,7 +328,7 @@ impl CosmicSurface {
match self.0.underlying_surface() { match self.0.underlying_surface() {
WindowSurface::Wayland(toplevel) => { WindowSurface::Wayland(toplevel) => {
Some(with_toplevel_state(toplevel, pending, |state| { Some(with_toplevel_state(toplevel, pending, |state| {
state.states.contains(ToplevelState::TiledLeft) state.is_some_and(|state| state.states.contains(ToplevelState::TiledLeft))
})) }))
} }
WindowSurface::X11(_surface) => None, WindowSurface::X11(_surface) => None,
@ -351,7 +357,7 @@ impl CosmicSurface {
pub fn is_fullscreen(&self, pending: bool) -> bool { pub fn is_fullscreen(&self, pending: bool) -> bool {
match self.0.underlying_surface() { match self.0.underlying_surface() {
WindowSurface::Wayland(toplevel) => with_toplevel_state(toplevel, pending, |state| { WindowSurface::Wayland(toplevel) => with_toplevel_state(toplevel, pending, |state| {
state.states.contains(ToplevelState::Fullscreen) state.is_some_and(|state| state.states.contains(ToplevelState::Fullscreen))
}), }),
WindowSurface::X11(surface) => surface.is_fullscreen(), WindowSurface::X11(surface) => surface.is_fullscreen(),
} }
@ -375,7 +381,7 @@ impl CosmicSurface {
pub fn is_maximized(&self, pending: bool) -> bool { pub fn is_maximized(&self, pending: bool) -> bool {
match self.0.underlying_surface() { match self.0.underlying_surface() {
WindowSurface::Wayland(toplevel) => with_toplevel_state(toplevel, pending, |state| { WindowSurface::Wayland(toplevel) => with_toplevel_state(toplevel, pending, |state| {
state.states.contains(ToplevelState::Maximized) state.is_some_and(|state| state.states.contains(ToplevelState::Maximized))
}), }),
WindowSurface::X11(surface) => surface.is_maximized(), WindowSurface::X11(surface) => surface.is_maximized(),
} }
@ -491,10 +497,9 @@ impl CosmicSurface {
.lock() .lock()
.unwrap(); .unwrap();
attrs attrs
.configure_serial .last_acked
.as_ref() .as_ref()
.map(|s| s >= serial) .is_some_and(|configure| configure.serial >= *serial)
.unwrap_or(false)
}), }),
WindowSurface::X11(_surface) => true, WindowSurface::X11(_surface) => true,
} }
@ -503,17 +508,12 @@ impl CosmicSurface {
pub fn serial_past(&self, serial: &Serial) -> bool { pub fn serial_past(&self, serial: &Serial) -> bool {
match self.0.underlying_surface() { match self.0.underlying_surface() {
WindowSurface::Wayland(toplevel) => with_states(toplevel.wl_surface(), |states| { WindowSurface::Wayland(toplevel) => with_states(toplevel.wl_surface(), |states| {
let attrs = states let mut guard = states.cached_state.get::<ToplevelCachedState>();
.data_map guard
.get::<XdgToplevelSurfaceData>() .current()
.unwrap() .last_acked
.lock()
.unwrap();
attrs
.current_serial
.as_ref() .as_ref()
.map(|s| s >= serial) .is_some_and(|configure| configure.serial >= *serial)
.unwrap_or(false)
}), }),
WindowSurface::X11(_surface) => true, WindowSurface::X11(_surface) => true,
} }
@ -531,12 +531,18 @@ impl CosmicSurface {
.unwrap(); .unwrap();
let current_server = attributes.current_server_state(); let current_server = attributes.current_server_state();
if attributes.current.size == current_server.size { let mut guard = states.cached_state.get::<ToplevelCachedState>();
if guard
.current()
.last_acked
.as_ref()
.is_some_and(|configure| configure.state.size == current_server.size)
{
// The window had committed for our previous size change, so we can // The window had committed for our previous size change, so we can
// change the size again. // change the size again.
trace!( trace!(
"current size matches server size: {:?}", "current size matches server size: {:?}",
attributes.current.size guard.current().last_acked.as_ref().unwrap().state.size
); );
true true
} else { } else {
@ -927,15 +933,14 @@ where
} }
} }
fn with_toplevel_state<T, F: FnOnce(&smithay::wayland::shell::xdg::ToplevelState) -> T>( fn with_toplevel_state<T, F: FnOnce(Option<&smithay::wayland::shell::xdg::ToplevelState>) -> T>(
toplevel: &ToplevelSurface, toplevel: &ToplevelSurface,
pending: bool, pending: bool,
cb: F, cb: F,
) -> T { ) -> T {
if pending { if pending {
toplevel.with_pending_state(|pending| cb(pending)) toplevel.with_pending_state(|pending| cb(Some(pending)))
} else { } else {
let current = toplevel.current_state(); toplevel.with_committed_state(|committed| cb(committed))
cb(&current)
} }
} }

View file

@ -15,7 +15,9 @@ use smithay::{
wayland::{ wayland::{
compositor::{get_role, with_states}, compositor::{get_role, with_states},
seat::WaylandFocus, seat::WaylandFocus,
shell::xdg::{PopupSurface, ToplevelSurface, XDG_POPUP_ROLE, XdgPopupSurfaceData}, shell::xdg::{
PopupCachedState, PopupSurface, ToplevelSurface, XDG_POPUP_ROLE, XdgPopupSurfaceData,
},
}, },
}; };
use tracing::warn; use tracing::warn;
@ -87,14 +89,12 @@ pub fn update_reactive_popups<'a>(
for (popup, _) in PopupManager::popups_for_surface(toplevel.wl_surface()) { for (popup, _) in PopupManager::popups_for_surface(toplevel.wl_surface()) {
match popup { match popup {
PopupKind::Xdg(surface) => { PopupKind::Xdg(surface) => {
let positioner = with_states(surface.wl_surface(), |states| { let positioner = with_states(&surface.wl_surface(), |states| {
let attributes = states let mut guard = states.cached_state.get::<PopupCachedState>();
.data_map guard
.get::<XdgPopupSurfaceData>() .current()
.unwrap() .last_acked
.lock() .map_or_else(Default::default, |configure| configure.state.positioner)
.unwrap();
attributes.current.positioner
}); });
if positioner.reactive { if positioner.reactive {
let anchor_point = loc + positioner.get_anchor_point().as_global(); let anchor_point = loc + positioner.get_anchor_point().as_global();