clippy fixes
This commit is contained in:
parent
d69d15630e
commit
a5f3c5c5d2
|
@ -5,10 +5,7 @@ use std::ffi::CStr;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::{
|
use std::sync::mpsc::{channel, Receiver, Sender};
|
||||||
atomic::{AtomicUsize, Ordering},
|
|
||||||
mpsc::{channel, Receiver, Sender},
|
|
||||||
};
|
|
||||||
use std::{collections::HashSet, os::raw::c_char};
|
use std::{collections::HashSet, os::raw::c_char};
|
||||||
|
|
||||||
use cgmath::{prelude::*, Matrix3, Vector2, Vector3};
|
use cgmath::{prelude::*, Matrix3, Vector2, Vector3};
|
||||||
|
|
|
@ -178,6 +178,7 @@ pub trait Frame {
|
||||||
/// Render a texture to the current target as a flat 2d-plane at a given
|
/// Render a texture to the current target as a flat 2d-plane at a given
|
||||||
/// position and applying the given transformation with the given alpha value.
|
/// position and applying the given transformation with the given alpha value.
|
||||||
/// (Meaning `src_transform` should match the orientation of surface being rendered).
|
/// (Meaning `src_transform` should match the orientation of surface being rendered).
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn render_texture_at(
|
fn render_texture_at(
|
||||||
&mut self,
|
&mut self,
|
||||||
texture: &Self::TextureId,
|
texture: &Self::TextureId,
|
||||||
|
|
|
@ -141,7 +141,7 @@ where
|
||||||
TraversalAction::SkipChildren
|
TraversalAction::SkipChildren
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|surface, states, location| {
|
|_surface, states, location| {
|
||||||
let mut location = *location;
|
let mut location = *location;
|
||||||
if let Some(data) = states.data_map.get::<RefCell<SurfaceState>>() {
|
if let Some(data) = states.data_map.get::<RefCell<SurfaceState>>() {
|
||||||
let mut data = data.borrow_mut();
|
let mut data = data.borrow_mut();
|
||||||
|
|
|
@ -313,7 +313,8 @@ impl WinitGraphicsBackend {
|
||||||
damage: Option<&[Rectangle<i32, Logical>]>,
|
damage: Option<&[Rectangle<i32, Logical>]>,
|
||||||
scale: f64,
|
scale: f64,
|
||||||
) -> Result<(), crate::backend::SwapBuffersError> {
|
) -> Result<(), crate::backend::SwapBuffersError> {
|
||||||
let mut damage = if self.damage_tracking && damage.is_some() && !damage.unwrap().is_empty() {
|
let mut damage = match damage {
|
||||||
|
Some(damage) if self.damage_tracking && !damage.is_empty() => {
|
||||||
let size = self
|
let size = self
|
||||||
.size
|
.size
|
||||||
.borrow()
|
.borrow()
|
||||||
|
@ -322,20 +323,22 @@ impl WinitGraphicsBackend {
|
||||||
.to_logical(scale)
|
.to_logical(scale)
|
||||||
.to_i32_round::<i32>();
|
.to_i32_round::<i32>();
|
||||||
let damage = damage
|
let damage = damage
|
||||||
.unwrap()
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|rect| {
|
.map(|rect| {
|
||||||
Rectangle::from_loc_and_size((rect.loc.x, size.h - rect.loc.y - rect.size.h), rect.size)
|
Rectangle::from_loc_and_size(
|
||||||
|
(rect.loc.x, size.h - rect.loc.y - rect.size.h),
|
||||||
|
rect.size,
|
||||||
|
)
|
||||||
.to_f64()
|
.to_f64()
|
||||||
.to_physical(scale)
|
.to_physical(scale)
|
||||||
.to_i32_round::<i32>()
|
.to_i32_round::<i32>()
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
Some(damage)
|
Some(damage)
|
||||||
} else {
|
}
|
||||||
None
|
_ => None,
|
||||||
};
|
};
|
||||||
self.egl.swap_buffers(damage.as_mut().map(|x| &mut **x))?;
|
self.egl.swap_buffers(damage.as_deref_mut())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub fn layer_map_for_output(o: &Output) -> RefMut<'_, LayerMap> {
|
||||||
(0, 0),
|
(0, 0),
|
||||||
o.current_mode()
|
o.current_mode()
|
||||||
.map(|mode| mode.size.to_logical(o.current_scale()))
|
.map(|mode| mode.size.to_logical(o.current_scale()))
|
||||||
.unwrap_or((0, 0).into()),
|
.unwrap_or_else(|| (0, 0).into()),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
@ -130,9 +130,9 @@ impl LayerMap {
|
||||||
output
|
output
|
||||||
.current_mode()
|
.current_mode()
|
||||||
.map(|mode| mode.size.to_logical(output.current_scale()))
|
.map(|mode| mode.size.to_logical(output.current_scale()))
|
||||||
.unwrap_or((0, 0).into()),
|
.unwrap_or_else(|| (0, 0).into()),
|
||||||
);
|
);
|
||||||
let mut zone = output_rect.clone();
|
let mut zone = output_rect;
|
||||||
slog::debug!(
|
slog::debug!(
|
||||||
crate::slog_or_fallback(None),
|
crate::slog_or_fallback(None),
|
||||||
"Arranging layers into {:?}",
|
"Arranging layers into {:?}",
|
||||||
|
@ -212,18 +212,18 @@ impl LayerMap {
|
||||||
location,
|
location,
|
||||||
size
|
size
|
||||||
);
|
);
|
||||||
if layer
|
let size_changed = layer
|
||||||
.0
|
.0
|
||||||
.surface
|
.surface
|
||||||
.with_pending_state(|state| {
|
.with_pending_state(|state| {
|
||||||
state.size.replace(size).map(|old| old != size).unwrap_or(true)
|
state.size.replace(size).map(|old| old != size).unwrap_or(true)
|
||||||
})
|
})
|
||||||
.unwrap()
|
.unwrap();
|
||||||
{
|
if size_changed {
|
||||||
layer.0.surface.send_configure();
|
layer.0.surface.send_configure();
|
||||||
}
|
}
|
||||||
|
|
||||||
layer_state(&layer).location = location;
|
layer_state(layer).location = location;
|
||||||
}
|
}
|
||||||
|
|
||||||
slog::debug!(crate::slog_or_fallback(None), "Remaining zone {:?}", zone);
|
slog::debug!(crate::slog_or_fallback(None), "Remaining zone {:?}", zone);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// TODO: Remove - but for now, this makes sure these files are not completely highlighted with warnings
|
// TODO: Remove - but for now, this makes sure these files are not completely highlighted with warnings
|
||||||
#![allow(missing_docs, clippy::all)]
|
#![allow(missing_docs)]
|
||||||
pub(crate) mod layer;
|
pub(crate) mod layer;
|
||||||
mod popup;
|
mod popup;
|
||||||
pub mod space;
|
pub mod space;
|
||||||
|
|
|
@ -47,6 +47,7 @@ where
|
||||||
}
|
}
|
||||||
fn geometry(&self, space_id: usize) -> Rectangle<i32, Logical>;
|
fn geometry(&self, space_id: usize) -> Rectangle<i32, Logical>;
|
||||||
fn accumulated_damage(&self, for_values: Option<(&Space, &Output)>) -> Vec<Rectangle<i32, Logical>>;
|
fn accumulated_damage(&self, for_values: Option<(&Space, &Output)>) -> Vec<Rectangle<i32, Logical>>;
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn draw(
|
fn draw(
|
||||||
&self,
|
&self,
|
||||||
space_id: usize,
|
space_id: usize,
|
||||||
|
|
|
@ -30,7 +30,6 @@ use self::window::*;
|
||||||
|
|
||||||
crate::utils::ids::id_gen!(next_space_id, SPACE_ID, SPACE_IDS);
|
crate::utils::ids::id_gen!(next_space_id, SPACE_ID, SPACE_IDS);
|
||||||
|
|
||||||
// TODO: Maybe replace UnmanagedResource if nothing else comes up?
|
|
||||||
#[derive(Debug, thiserror::Error)]
|
#[derive(Debug, thiserror::Error)]
|
||||||
pub enum SpaceError {
|
pub enum SpaceError {
|
||||||
#[error("Window is not mapped to this space")]
|
#[error("Window is not mapped to this space")]
|
||||||
|
@ -43,11 +42,12 @@ pub struct Space {
|
||||||
// in z-order, back to front
|
// in z-order, back to front
|
||||||
windows: IndexSet<Window>,
|
windows: IndexSet<Window>,
|
||||||
outputs: Vec<Output>,
|
outputs: Vec<Output>,
|
||||||
// TODO:
|
|
||||||
//layers: Vec<Layer>,
|
|
||||||
logger: ::slog::Logger,
|
logger: ::slog::Logger,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type DynamicRenderElements<R> =
|
||||||
|
Box<dyn RenderElement<R, <R as Renderer>::Frame, <R as Renderer>::Error, <R as Renderer>::TextureId>>;
|
||||||
|
|
||||||
impl Drop for Space {
|
impl Drop for Space {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
SPACE_IDS.lock().unwrap().remove(&self.id);
|
SPACE_IDS.lock().unwrap().remove(&self.id);
|
||||||
|
@ -382,9 +382,7 @@ impl Space {
|
||||||
output: &Output,
|
output: &Output,
|
||||||
age: usize,
|
age: usize,
|
||||||
clear_color: [f32; 4],
|
clear_color: [f32; 4],
|
||||||
custom_elements: &[Box<
|
custom_elements: &[DynamicRenderElements<R>],
|
||||||
dyn RenderElement<R, <R as Renderer>::Frame, <R as Renderer>::Error, <R as Renderer>::TextureId>,
|
|
||||||
>],
|
|
||||||
) -> Result<Option<Vec<Rectangle<i32, Logical>>>, RenderError<R>>
|
) -> Result<Option<Vec<Rectangle<i32, Logical>>>, RenderError<R>>
|
||||||
where
|
where
|
||||||
R: Renderer + ImportAll + 'static,
|
R: Renderer + ImportAll + 'static,
|
||||||
|
|
|
@ -97,7 +97,7 @@ where
|
||||||
damage: &[Rectangle<i32, Logical>],
|
damage: &[Rectangle<i32, Logical>],
|
||||||
log: &slog::Logger,
|
log: &slog::Logger,
|
||||||
) -> Result<(), R::Error> {
|
) -> Result<(), R::Error> {
|
||||||
let res = draw_window(renderer, frame, &self, scale, location, damage, log);
|
let res = draw_window(renderer, frame, self, scale, location, damage, log);
|
||||||
if res.is_ok() {
|
if res.is_ok() {
|
||||||
window_state(space_id, self).drawn = true;
|
window_state(space_id, self).drawn = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,13 +109,12 @@ where
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|key| !data.damage_seen.contains(key))
|
.map(|key| !data.damage_seen.contains(key))
|
||||||
.unwrap_or(true)
|
.unwrap_or(true)
|
||||||
|
&& states.role == Some("subsurface")
|
||||||
{
|
{
|
||||||
if states.role == Some("subsurface") {
|
|
||||||
let current = states.cached_state.current::<SubsurfaceCachedState>();
|
let current = states.cached_state.current::<SubsurfaceCachedState>();
|
||||||
location += current.location;
|
location += current.location;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
TraversalAction::DoChildren(location)
|
TraversalAction::DoChildren(location)
|
||||||
},
|
},
|
||||||
|_surface, states, location| {
|
|_surface, states, location| {
|
||||||
|
|
|
@ -105,9 +105,6 @@ impl Window {
|
||||||
pub fn new(toplevel: Kind) -> Window {
|
pub fn new(toplevel: Kind) -> Window {
|
||||||
let id = next_window_id();
|
let id = next_window_id();
|
||||||
|
|
||||||
// TODO: Do we want this? For new lets add Window::commit
|
|
||||||
//add_commit_hook(toplevel.get_surface().unwrap(), surface_commit);
|
|
||||||
|
|
||||||
Window(Rc::new(WindowInner {
|
Window(Rc::new(WindowInner {
|
||||||
id,
|
id,
|
||||||
toplevel,
|
toplevel,
|
||||||
|
@ -127,7 +124,6 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A bounding box over this window and its children.
|
/// A bounding box over this window and its children.
|
||||||
// TODO: Cache and document when to trigger updates. If possible let space do it
|
|
||||||
pub fn bbox(&self) -> Rectangle<i32, Logical> {
|
pub fn bbox(&self) -> Rectangle<i32, Logical> {
|
||||||
if self.0.toplevel.get_surface().is_some() {
|
if self.0.toplevel.get_surface().is_some() {
|
||||||
self.0.bbox.get()
|
self.0.bbox.get()
|
||||||
|
@ -154,7 +150,6 @@ impl Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Activate/Deactivate this window
|
/// Activate/Deactivate this window
|
||||||
// TODO: Add more helpers for Maximize? Minimize? Fullscreen? I dunno
|
|
||||||
pub fn set_activated(&self, active: bool) -> bool {
|
pub fn set_activated(&self, active: bool) -> bool {
|
||||||
match self.0.toplevel {
|
match self.0.toplevel {
|
||||||
Kind::Xdg(ref t) => t
|
Kind::Xdg(ref t) => t
|
||||||
|
|
|
@ -449,7 +449,7 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn region_attributes_empty() {
|
fn region_attributes_empty() {
|
||||||
let region = RegionAttributes { rects: vec![] };
|
let region = RegionAttributes { rects: vec![] };
|
||||||
assert_eq!(region.contains((0, 0)), false);
|
assert!(!region.contains((0, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -458,7 +458,7 @@ mod tests {
|
||||||
rects: vec![(RectangleKind::Add, Rectangle::from_loc_and_size((0, 0), (10, 10)))],
|
rects: vec![(RectangleKind::Add, Rectangle::from_loc_and_size((0, 0), (10, 10)))],
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(region.contains((0, 0)), true);
|
assert!(region.contains((0, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -473,8 +473,8 @@ mod tests {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(region.contains((0, 0)), false);
|
assert!(!region.contains((0, 0)));
|
||||||
assert_eq!(region.contains((5, 5)), true);
|
assert!(region.contains((5, 5)));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -490,8 +490,8 @@ mod tests {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(region.contains((0, 0)), false);
|
assert!(!region.contains((0, 0)));
|
||||||
assert_eq!(region.contains((5, 5)), true);
|
assert!(region.contains((5, 5)));
|
||||||
assert_eq!(region.contains((2, 2)), true);
|
assert!(region.contains((2, 2)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue