Skip to content

Commit 60509a6

Browse files
committed
Update smithay
Updates for `last_acked`, etc. API changes in Smithay/smithay#1817. Includes layer shell fixes from Smithay/smithay#1819.
1 parent 5561fbc commit 60509a6

File tree

4 files changed

+45
-40
lines changed

4 files changed

+45
-40
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,4 @@ cosmic-protocols = { git = "https://github.com/pop-os//cosmic-protocols", branch
145145
cosmic-client-toolkit = { git = "https://github.com/pop-os//cosmic-protocols", branch = "main" }
146146

147147
[patch.crates-io]
148-
smithay = { git = "https://github.com/smithay/smithay.git", rev = "eb45814" }
148+
smithay = { git = "https://github.com/smithay/smithay.git", rev = "8dd5d55" }

src/shell/element/surface.rs

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ use smithay::{
4343
wayland::{
4444
compositor::{SurfaceData, TraversalAction, with_states, with_surface_tree_downward},
4545
seat::WaylandFocus,
46-
shell::xdg::{SurfaceCachedState, ToplevelSurface, XdgToplevelSurfaceData},
46+
shell::xdg::{
47+
SurfaceCachedState, ToplevelCachedState, ToplevelSurface, XdgToplevelSurfaceData,
48+
},
4749
},
4850
xwayland::{X11Surface, xwm::X11Relatable},
4951
};
@@ -215,7 +217,7 @@ impl CosmicSurface {
215217
pub fn is_activated(&self, pending: bool) -> bool {
216218
match self.0.underlying_surface() {
217219
WindowSurface::Wayland(toplevel) => with_toplevel_state(toplevel, pending, |state| {
218-
state.states.contains(ToplevelState::Activated)
220+
state.is_some_and(|state| state.states.contains(ToplevelState::Activated))
219221
}),
220222
WindowSurface::X11(surface) => surface.is_activated(),
221223
}
@@ -247,9 +249,11 @@ impl CosmicSurface {
247249
});
248250

249251
let xdg_state = with_toplevel_state(toplevel, pending, |state| {
250-
state
251-
.decoration_mode
252-
.map(|mode| mode == DecorationMode::ClientSide)
252+
state.and_then(|state| {
253+
state
254+
.decoration_mode
255+
.map(|mode| mode == DecorationMode::ClientSide)
256+
})
253257
});
254258

255259
kde_state.or(xdg_state).unwrap_or(true)
@@ -262,7 +266,9 @@ impl CosmicSurface {
262266
match self.0.underlying_surface() {
263267
WindowSurface::Wayland(toplevel) => {
264268
if enable {
265-
let previous_decoration_state = toplevel.current_state().decoration_mode;
269+
let previous_decoration_state = toplevel.with_committed_state(|state| {
270+
state.map_or_else(Default::default, |state| state.decoration_mode)
271+
});
266272
if PreferredDecorationMode::is_unset(&self.0) {
267273
PreferredDecorationMode::update(&self.0, previous_decoration_state);
268274
}
@@ -298,7 +304,7 @@ impl CosmicSurface {
298304
match self.0.underlying_surface() {
299305
WindowSurface::Wayland(toplevel) => {
300306
Some(with_toplevel_state(toplevel, pending, |state| {
301-
state.states.contains(ToplevelState::Resizing)
307+
state.is_some_and(|state| state.states.contains(ToplevelState::Resizing))
302308
}))
303309
}
304310
WindowSurface::X11(_surface) => None,
@@ -322,7 +328,7 @@ impl CosmicSurface {
322328
match self.0.underlying_surface() {
323329
WindowSurface::Wayland(toplevel) => {
324330
Some(with_toplevel_state(toplevel, pending, |state| {
325-
state.states.contains(ToplevelState::TiledLeft)
331+
state.is_some_and(|state| state.states.contains(ToplevelState::TiledLeft))
326332
}))
327333
}
328334
WindowSurface::X11(_surface) => None,
@@ -351,7 +357,7 @@ impl CosmicSurface {
351357
pub fn is_fullscreen(&self, pending: bool) -> bool {
352358
match self.0.underlying_surface() {
353359
WindowSurface::Wayland(toplevel) => with_toplevel_state(toplevel, pending, |state| {
354-
state.states.contains(ToplevelState::Fullscreen)
360+
state.is_some_and(|state| state.states.contains(ToplevelState::Fullscreen))
355361
}),
356362
WindowSurface::X11(surface) => surface.is_fullscreen(),
357363
}
@@ -375,7 +381,7 @@ impl CosmicSurface {
375381
pub fn is_maximized(&self, pending: bool) -> bool {
376382
match self.0.underlying_surface() {
377383
WindowSurface::Wayland(toplevel) => with_toplevel_state(toplevel, pending, |state| {
378-
state.states.contains(ToplevelState::Maximized)
384+
state.is_some_and(|state| state.states.contains(ToplevelState::Maximized))
379385
}),
380386
WindowSurface::X11(surface) => surface.is_maximized(),
381387
}
@@ -491,10 +497,9 @@ impl CosmicSurface {
491497
.lock()
492498
.unwrap();
493499
attrs
494-
.configure_serial
500+
.last_acked
495501
.as_ref()
496-
.map(|s| s >= serial)
497-
.unwrap_or(false)
502+
.is_some_and(|configure| configure.serial >= *serial)
498503
}),
499504
WindowSurface::X11(_surface) => true,
500505
}
@@ -503,17 +508,12 @@ impl CosmicSurface {
503508
pub fn serial_past(&self, serial: &Serial) -> bool {
504509
match self.0.underlying_surface() {
505510
WindowSurface::Wayland(toplevel) => with_states(toplevel.wl_surface(), |states| {
506-
let attrs = states
507-
.data_map
508-
.get::<XdgToplevelSurfaceData>()
509-
.unwrap()
510-
.lock()
511-
.unwrap();
512-
attrs
513-
.current_serial
511+
let mut guard = states.cached_state.get::<ToplevelCachedState>();
512+
guard
513+
.current()
514+
.last_acked
514515
.as_ref()
515-
.map(|s| s >= serial)
516-
.unwrap_or(false)
516+
.is_some_and(|configure| configure.serial >= *serial)
517517
}),
518518
WindowSurface::X11(_surface) => true,
519519
}
@@ -531,12 +531,18 @@ impl CosmicSurface {
531531
.unwrap();
532532

533533
let current_server = attributes.current_server_state();
534-
if attributes.current.size == current_server.size {
534+
let mut guard = states.cached_state.get::<ToplevelCachedState>();
535+
if guard
536+
.current()
537+
.last_acked
538+
.as_ref()
539+
.is_some_and(|configure| configure.state.size == current_server.size)
540+
{
535541
// The window had committed for our previous size change, so we can
536542
// change the size again.
537543
trace!(
538544
"current size matches server size: {:?}",
539-
attributes.current.size
545+
guard.current().last_acked.as_ref().unwrap().state.size
540546
);
541547
true
542548
} else {
@@ -927,15 +933,14 @@ where
927933
}
928934
}
929935

930-
fn with_toplevel_state<T, F: FnOnce(&smithay::wayland::shell::xdg::ToplevelState) -> T>(
936+
fn with_toplevel_state<T, F: FnOnce(Option<&smithay::wayland::shell::xdg::ToplevelState>) -> T>(
931937
toplevel: &ToplevelSurface,
932938
pending: bool,
933939
cb: F,
934940
) -> T {
935941
if pending {
936-
toplevel.with_pending_state(|pending| cb(pending))
942+
toplevel.with_pending_state(|pending| cb(Some(pending)))
937943
} else {
938-
let current = toplevel.current_state();
939-
cb(&current)
944+
toplevel.with_committed_state(|committed| cb(committed))
940945
}
941946
}

src/wayland/handlers/xdg_shell/popup.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ use smithay::{
1515
wayland::{
1616
compositor::{get_role, with_states},
1717
seat::WaylandFocus,
18-
shell::xdg::{PopupSurface, ToplevelSurface, XDG_POPUP_ROLE, XdgPopupSurfaceData},
18+
shell::xdg::{
19+
PopupCachedState, PopupSurface, ToplevelSurface, XDG_POPUP_ROLE, XdgPopupSurfaceData,
20+
},
1921
},
2022
};
2123
use tracing::warn;
@@ -87,14 +89,12 @@ pub fn update_reactive_popups<'a>(
8789
for (popup, _) in PopupManager::popups_for_surface(toplevel.wl_surface()) {
8890
match popup {
8991
PopupKind::Xdg(surface) => {
90-
let positioner = with_states(surface.wl_surface(), |states| {
91-
let attributes = states
92-
.data_map
93-
.get::<XdgPopupSurfaceData>()
94-
.unwrap()
95-
.lock()
96-
.unwrap();
97-
attributes.current.positioner
92+
let positioner = with_states(&surface.wl_surface(), |states| {
93+
let mut guard = states.cached_state.get::<PopupCachedState>();
94+
guard
95+
.current()
96+
.last_acked
97+
.map_or_else(Default::default, |configure| configure.state.positioner)
9898
});
9999
if positioner.reactive {
100100
let anchor_point = loc + positioner.get_anchor_point().as_global();

0 commit comments

Comments
 (0)