refactor(corner-radius): corner_radius method for CosmicSurface
This commit is contained in:
parent
4e30513673
commit
f01ebf2f6f
4 changed files with 33 additions and 113 deletions
|
|
@ -1,3 +1,5 @@
|
|||
use crate::wayland::protocols::corner_radius::CornerRadiusData;
|
||||
use smithay::reexports::wayland_server::Resource;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
sync::{
|
||||
|
|
@ -7,6 +9,7 @@ use std::{
|
|||
time::Duration,
|
||||
};
|
||||
|
||||
use cosmic_protocols::corner_radius::v1::server::cosmic_corner_radius_toplevel_v1::CosmicCornerRadiusToplevelV1;
|
||||
use smithay::{
|
||||
backend::renderer::{
|
||||
element::{
|
||||
|
|
@ -34,7 +37,7 @@ use smithay::{
|
|||
},
|
||||
},
|
||||
wayland_protocols_misc::server_decoration::server::org_kde_kwin_server_decoration::Mode as KdeMode,
|
||||
wayland_server::protocol::wl_surface::WlSurface,
|
||||
wayland_server::{protocol::wl_surface::WlSurface, Weak},
|
||||
},
|
||||
utils::{
|
||||
user_data::UserDataMap, IsAlive, Logical, Physical, Point, Rectangle, Scale, Serial, Size,
|
||||
|
|
@ -124,6 +127,30 @@ impl CosmicSurface {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn corner_radius(&self) -> Option<[u8; 4]> {
|
||||
self.wl_surface().and_then(|surface| {
|
||||
with_states(&surface, |s| {
|
||||
let d = s
|
||||
.data_map
|
||||
.get::<Mutex<Weak<CosmicCornerRadiusToplevelV1>>>()?;
|
||||
let guard = d.lock().unwrap();
|
||||
|
||||
let weak_data = guard.upgrade().ok()?;
|
||||
|
||||
let corners = weak_data.data::<CornerRadiusData>()?;
|
||||
|
||||
let guard = corners.lock().unwrap();
|
||||
|
||||
Some([
|
||||
guard.top_right,
|
||||
guard.bottom_right,
|
||||
guard.top_left,
|
||||
guard.bottom_left,
|
||||
])
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
pub fn app_id(&self) -> String {
|
||||
match self.0.underlying_surface() {
|
||||
WindowSurface::Wayland(toplevel) => with_states(toplevel.wl_surface(), |states| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue