aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mod.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/utils/mod.rs b/src/utils/mod.rs
index d5201532..959a804e 100644
--- a/src/utils/mod.rs
+++ b/src/utils/mod.rs
@@ -17,8 +17,11 @@ use smithay::reexports::rustix::time::{clock_gettime, ClockId};
use smithay::reexports::wayland_protocols::xdg::shell::server::xdg_toplevel;
use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface;
use smithay::utils::{Coordinate, Logical, Point, Rectangle, Size, Transform};
-use smithay::wayland::compositor::{send_surface_state, SurfaceData};
+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,
+};
pub mod id;
pub mod scale;
@@ -221,6 +224,22 @@ pub fn output_matches_name(output: &Output, target: &str) -> bool {
name.matches(target)
}
+pub fn with_toplevel_role<T>(
+ toplevel: &ToplevelSurface,
+ f: impl FnOnce(&mut XdgToplevelSurfaceRoleAttributes) -> T,
+) -> T {
+ with_states(toplevel.wl_surface(), |states| {
+ let mut role = states
+ .data_map
+ .get::<XdgToplevelSurfaceData>()
+ .unwrap()
+ .lock()
+ .unwrap();
+
+ f(&mut role)
+ })
+}
+
#[cfg(feature = "dbus")]
pub fn show_screenshot_notification(image_path: Option<PathBuf>) {
let mut notification = notify_rust::Notification::new();