desktop: api cleanups
This commit is contained in:
parent
d7350d18ee
commit
d84a66e053
|
@ -117,7 +117,12 @@ impl LayerMap {
|
|||
bbox
|
||||
}
|
||||
|
||||
pub fn layer_under(&self, layer: WlrLayer, point: Point<f64, Logical>) -> Option<&LayerSurface> {
|
||||
pub fn layer_under<P: Into<Point<f64, Logical>>>(
|
||||
&self,
|
||||
layer: WlrLayer,
|
||||
point: P,
|
||||
) -> Option<&LayerSurface> {
|
||||
let point = point.into();
|
||||
self.layers_on(layer).rev().find(|l| {
|
||||
let bbox = self.layer_geometry(l);
|
||||
bbox.to_f64().contains(point)
|
||||
|
@ -401,7 +406,11 @@ impl LayerSurface {
|
|||
|
||||
/// Finds the topmost surface under this point if any and returns it together with the location of this
|
||||
/// surface.
|
||||
pub fn surface_under(&self, point: Point<f64, Logical>) -> Option<(WlSurface, Point<i32, Logical>)> {
|
||||
pub fn surface_under<P: Into<Point<f64, Logical>>>(
|
||||
&self,
|
||||
point: P,
|
||||
) -> Option<(WlSurface, Point<i32, Logical>)> {
|
||||
let point = point.into();
|
||||
if let Some(surface) = self.get_surface() {
|
||||
for (popup, location) in PopupManager::popups_for_surface(surface)
|
||||
.ok()
|
||||
|
@ -457,12 +466,12 @@ impl LayerSurface {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn draw_layer<R, E, F, T>(
|
||||
pub fn draw_layer<R, E, F, T, P>(
|
||||
renderer: &mut R,
|
||||
frame: &mut F,
|
||||
layer: &LayerSurface,
|
||||
scale: f64,
|
||||
location: Point<i32, Logical>,
|
||||
location: P,
|
||||
damage: &[Rectangle<i32, Logical>],
|
||||
log: &slog::Logger,
|
||||
) -> Result<(), R::Error>
|
||||
|
@ -471,7 +480,9 @@ where
|
|||
F: Frame<Error = E, TextureId = T>,
|
||||
E: std::error::Error,
|
||||
T: Texture + 'static,
|
||||
P: Into<Point<i32, Logical>>,
|
||||
{
|
||||
let location = location.into();
|
||||
if let Some(surface) = layer.get_surface() {
|
||||
draw_surface_tree(renderer, frame, surface, scale, location, damage, log)?;
|
||||
for (popup, p_location) in PopupManager::popups_for_surface(surface)
|
||||
|
|
|
@ -98,22 +98,22 @@ impl Drop for Space {
|
|||
impl Space {
|
||||
pub fn new<L>(log: L) -> Space
|
||||
where
|
||||
L: Into<slog::Logger>,
|
||||
L: Into<Option<slog::Logger>>,
|
||||
{
|
||||
Space {
|
||||
id: next_space_id(),
|
||||
windows: IndexSet::new(),
|
||||
outputs: Vec::new(),
|
||||
logger: log.into(),
|
||||
logger: crate::slog_or_fallback(log),
|
||||
}
|
||||
}
|
||||
|
||||
/// Map window and moves it to top of the stack
|
||||
///
|
||||
/// This can safely be called on an already mapped window
|
||||
pub fn map_window(&mut self, window: &Window, location: Point<i32, Logical>) {
|
||||
pub fn map_window<P: Into<Point<i32, Logical>>>(&mut self, window: &Window, location: P) {
|
||||
self.insert_window(window);
|
||||
window_state(self.id, window).location = location;
|
||||
window_state(self.id, window).location = location.into();
|
||||
}
|
||||
|
||||
pub fn raise_window(&mut self, window: &Window) {
|
||||
|
@ -148,7 +148,8 @@ impl Space {
|
|||
}
|
||||
|
||||
/// Get a reference to the window under a given point, if any
|
||||
pub fn window_under(&self, point: Point<f64, Logical>) -> Option<&Window> {
|
||||
pub fn window_under<P: Into<Point<f64, Logical>>>(&self, point: P) -> Option<&Window> {
|
||||
let point = point.into();
|
||||
self.windows.iter().rev().find(|w| {
|
||||
let bbox = window_rect(w, &self.id);
|
||||
bbox.to_f64().contains(point)
|
||||
|
@ -156,7 +157,8 @@ impl Space {
|
|||
}
|
||||
|
||||
/// Get a reference to the output under a given point, if any
|
||||
pub fn output_under(&self, point: Point<f64, Logical>) -> Option<&Output> {
|
||||
pub fn output_under<P: Into<Point<f64, Logical>>>(&self, point: P) -> Option<&Output> {
|
||||
let point = point.into();
|
||||
self.outputs.iter().rev().find(|o| {
|
||||
let bbox = self.output_geometry(o);
|
||||
bbox.map(|bbox| bbox.to_f64().contains(point)).unwrap_or(false)
|
||||
|
@ -199,10 +201,10 @@ impl Space {
|
|||
Some(window_rect(w, &self.id))
|
||||
}
|
||||
|
||||
pub fn map_output(&mut self, output: &Output, scale: f64, location: Point<i32, Logical>) {
|
||||
pub fn map_output<P: Into<Point<i32, Logical>>>(&mut self, output: &Output, scale: f64, location: P) {
|
||||
let mut state = output_state(self.id, output);
|
||||
*state = OutputState {
|
||||
location,
|
||||
location: location.into(),
|
||||
render_scale: scale,
|
||||
..Default::default()
|
||||
};
|
||||
|
|
|
@ -21,7 +21,8 @@ impl SurfaceState {
|
|||
.map(|dims| dims.to_logical(self.buffer_scale))
|
||||
}
|
||||
|
||||
fn contains_point(&self, attrs: &SurfaceAttributes, point: Point<f64, Logical>) -> bool {
|
||||
fn contains_point<P: Into<Point<f64, Logical>>>(&self, attrs: &SurfaceAttributes, point: P) -> bool {
|
||||
let point = point.into();
|
||||
let size = match self.size() {
|
||||
None => return false, // If the surface has no size, it can't have an input region.
|
||||
Some(size) => size,
|
||||
|
|
|
@ -221,10 +221,11 @@ impl Window {
|
|||
|
||||
/// Finds the topmost surface under this point if any and returns it together with the location of this
|
||||
/// surface.
|
||||
pub fn surface_under(
|
||||
pub fn surface_under<P: Into<Point<f64, Logical>>>(
|
||||
&self,
|
||||
point: Point<f64, Logical>,
|
||||
point: P,
|
||||
) -> Option<(wl_surface::WlSurface, Point<i32, Logical>)> {
|
||||
let point = point.into();
|
||||
if let Some(surface) = self.0.toplevel.get_surface() {
|
||||
for (popup, location) in PopupManager::popups_for_surface(surface)
|
||||
.ok()
|
||||
|
@ -276,12 +277,12 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn draw_window<R, E, F, T>(
|
||||
pub fn draw_window<R, E, F, T, P>(
|
||||
renderer: &mut R,
|
||||
frame: &mut F,
|
||||
window: &Window,
|
||||
scale: f64,
|
||||
location: Point<i32, Logical>,
|
||||
location: P,
|
||||
damage: &[Rectangle<i32, Logical>],
|
||||
log: &slog::Logger,
|
||||
) -> Result<(), R::Error>
|
||||
|
@ -290,7 +291,9 @@ where
|
|||
F: Frame<Error = E, TextureId = T>,
|
||||
E: std::error::Error,
|
||||
T: Texture + 'static,
|
||||
P: Into<Point<i32, Logical>>,
|
||||
{
|
||||
let location = location.into();
|
||||
if let Some(surface) = window.toplevel().get_surface() {
|
||||
draw_surface_tree(renderer, frame, surface, scale, location, damage, log)?;
|
||||
for (popup, p_location) in PopupManager::popups_for_surface(surface)
|
||||
|
|
Loading…
Reference in New Issue