aboutsummaryrefslogtreecommitdiff
path: root/src/utils/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/mod.rs')
-rw-r--r--src/utils/mod.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index 26bfe582..a96c1bfc 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -25,7 +25,8 @@ use smithay::utils::{Coordinate, Logical, Point, Rectangle, Size, Transform};
use smithay::wayland::compositor::{send_surface_state, with_states, SurfaceData};
use smithay::wayland::fractional_scale::with_fractional_scale;
use smithay::wayland::shell::xdg::{
- ToplevelSurface, XdgToplevelSurfaceData, XdgToplevelSurfaceRoleAttributes,
+ ToplevelCachedState, ToplevelState, ToplevelSurface, XdgToplevelSurfaceData,
+ XdgToplevelSurfaceRoleAttributes,
};
use wayland_backend::server::Credentials;
@@ -279,6 +280,25 @@ pub fn with_toplevel_role<T>(
})
}
+pub fn with_toplevel_role_and_current<T>(
+ toplevel: &ToplevelSurface,
+ f: impl FnOnce(&mut XdgToplevelSurfaceRoleAttributes, Option<&ToplevelState>) -> T,
+) -> T {
+ with_states(toplevel.wl_surface(), |states| {
+ let mut role = states
+ .data_map
+ .get::<XdgToplevelSurfaceData>()
+ .unwrap()
+ .lock()
+ .unwrap();
+
+ let mut guard = states.cached_state.get::<ToplevelCachedState>();
+ let current = guard.current().last_acked.as_ref().map(|c| &c.state);
+
+ f(&mut role, current)
+ })
+}
+
pub fn update_tiled_state(
toplevel: &ToplevelSurface,
prefer_no_csd: bool,