diff --git a/src/desktop/layer.rs b/src/desktop/layer.rs index c3176b4..427f96d 100644 --- a/src/desktop/layer.rs +++ b/src/desktop/layer.rs @@ -117,7 +117,12 @@ impl LayerMap { bbox } - pub fn layer_under(&self, layer: WlrLayer, point: Point) -> Option<&LayerSurface> { + pub fn layer_under>>( + &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) -> Option<(WlSurface, Point)> { + pub fn surface_under>>( + &self, + point: P, + ) -> Option<(WlSurface, Point)> { + 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( +pub fn draw_layer( renderer: &mut R, frame: &mut F, layer: &LayerSurface, scale: f64, - location: Point, + location: P, damage: &[Rectangle], log: &slog::Logger, ) -> Result<(), R::Error> @@ -471,7 +480,9 @@ where F: Frame, E: std::error::Error, T: Texture + 'static, + P: Into>, { + 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) diff --git a/src/desktop/space.rs b/src/desktop/space.rs index e47ad96..d2fd8b2 100644 --- a/src/desktop/space.rs +++ b/src/desktop/space.rs @@ -98,22 +98,22 @@ impl Drop for Space { impl Space { pub fn new(log: L) -> Space where - L: Into, + L: Into>, { 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) { + pub fn map_window>>(&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) -> Option<&Window> { + pub fn window_under>>(&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) -> Option<&Output> { + pub fn output_under>>(&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) { + pub fn map_output>>(&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() }; diff --git a/src/desktop/utils.rs b/src/desktop/utils.rs index 67c6433..eb2cbf7 100644 --- a/src/desktop/utils.rs +++ b/src/desktop/utils.rs @@ -21,7 +21,8 @@ impl SurfaceState { .map(|dims| dims.to_logical(self.buffer_scale)) } - fn contains_point(&self, attrs: &SurfaceAttributes, point: Point) -> bool { + fn contains_point>>(&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, diff --git a/src/desktop/window.rs b/src/desktop/window.rs index 02be9f7..e8ced19 100644 --- a/src/desktop/window.rs +++ b/src/desktop/window.rs @@ -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>>( &self, - point: Point, + point: P, ) -> Option<(wl_surface::WlSurface, Point)> { + 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( +pub fn draw_window( renderer: &mut R, frame: &mut F, window: &Window, scale: f64, - location: Point, + location: P, damage: &[Rectangle], log: &slog::Logger, ) -> Result<(), R::Error> @@ -290,7 +291,9 @@ where F: Frame, E: std::error::Error, T: Texture + 'static, + P: Into>, { + 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)