anvil.window_map: add WindowMap::geometry
This commit is contained in:
parent
9fd9db82ae
commit
546ff48af5
|
@ -144,6 +144,16 @@ where
|
||||||
height: max_y - min_y,
|
height: max_y - min_y,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the geometry of this window.
|
||||||
|
pub fn geometry(&self, ctoken: CompositorToken<R>) -> Rectangle {
|
||||||
|
// It's the set geometry with the full bounding box as the fallback.
|
||||||
|
ctoken
|
||||||
|
.with_surface_data(self.toplevel.get_surface().unwrap(), |attributes| {
|
||||||
|
attributes.user_data.get::<SurfaceData>().unwrap().geometry
|
||||||
|
})
|
||||||
|
.unwrap_or(self.bbox)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WindowMap<R> {
|
pub struct WindowMap<R> {
|
||||||
|
@ -236,4 +246,12 @@ where
|
||||||
w.self_update(self.ctoken);
|
w.self_update(self.ctoken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the geometry of the toplevel, if it exists.
|
||||||
|
pub fn geometry(&self, toplevel: &Kind<R>) -> Option<Rectangle> {
|
||||||
|
self.windows
|
||||||
|
.iter()
|
||||||
|
.find(|w| w.toplevel.equals(toplevel))
|
||||||
|
.map(|w| w.geometry(self.ctoken))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue