chore: clippy
This commit is contained in:
parent
c13e52da04
commit
2ca99c670a
59 changed files with 1974 additions and 2137 deletions
|
|
@ -204,20 +204,20 @@ impl State {
|
|||
}
|
||||
}
|
||||
}
|
||||
if let Some(blocklist) = dev_list_var("COSMIC_DRM_BLOCK_DEVICES") {
|
||||
if let Ok(node) = DrmNode::from_dev_id(dev) {
|
||||
let node = node
|
||||
.node_with_type(NodeType::Render)
|
||||
.and_then(|res| res.ok())
|
||||
.unwrap_or(node);
|
||||
for ident in blocklist {
|
||||
if ident.matches(&node) {
|
||||
info!(
|
||||
"Skipping device {} due to COSMIC_DRM_BLOCK_DEVICE list.",
|
||||
path.display()
|
||||
);
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
if let Some(blocklist) = dev_list_var("COSMIC_DRM_BLOCK_DEVICES")
|
||||
&& let Ok(node) = DrmNode::from_dev_id(dev)
|
||||
{
|
||||
let node = node
|
||||
.node_with_type(NodeType::Render)
|
||||
.and_then(|res| res.ok())
|
||||
.unwrap_or(node);
|
||||
for ident in blocklist {
|
||||
if ident.matches(&node) {
|
||||
info!(
|
||||
"Skipping device {} due to COSMIC_DRM_BLOCK_DEVICE list.",
|
||||
path.display()
|
||||
);
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -271,10 +271,10 @@ impl State {
|
|||
notifier,
|
||||
move |event, metadata, state: &mut State| match event {
|
||||
DrmEvent::VBlank(crtc) => {
|
||||
if let Some(device) = state.backend.kms().drm_devices.get_mut(&drm_node) {
|
||||
if let Some(surface) = device.inner.surfaces.get_mut(&crtc) {
|
||||
surface.on_vblank(metadata.take());
|
||||
}
|
||||
if let Some(device) = state.backend.kms().drm_devices.get_mut(&drm_node)
|
||||
&& let Some(surface) = device.inner.surfaces.get_mut(&crtc)
|
||||
{
|
||||
surface.on_vblank(metadata.take());
|
||||
}
|
||||
}
|
||||
DrmEvent::Error(err) => {
|
||||
|
|
@ -676,10 +676,10 @@ impl LockedDevice<'_> {
|
|||
|
||||
let mut compositor = compositor.lock().unwrap();
|
||||
compositor.render_frame(renderer, &elements, CLEAR_COLOR, FrameFlags::empty())?;
|
||||
if let Err(err) = compositor.commit_frame() {
|
||||
if !matches!(err, FrameError::EmptyFrame) {
|
||||
return Err(err.into());
|
||||
}
|
||||
if let Err(err) = compositor.commit_frame()
|
||||
&& !matches!(err, FrameError::EmptyFrame)
|
||||
{
|
||||
return Err(err.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,17 +32,17 @@ pub fn display_configuration(
|
|||
.iter()
|
||||
.flat_map(|conn| device.get_connector(*conn, true).ok())
|
||||
{
|
||||
if let Some(enc) = conn.current_encoder() {
|
||||
if let Some(crtc) = device.get_encoder(enc)?.crtc() {
|
||||
// If is is connected we found a mapping
|
||||
if conn.state() == ConnectorState::Connected {
|
||||
map.insert(conn.handle(), Some(crtc));
|
||||
// If not, the user just unplugged something,
|
||||
// or the drm master did not cleanup?
|
||||
// Well, I guess we cleanup after them.
|
||||
} else {
|
||||
cleanup.push(crtc);
|
||||
}
|
||||
if let Some(enc) = conn.current_encoder()
|
||||
&& let Some(crtc) = device.get_encoder(enc)?.crtc()
|
||||
{
|
||||
// If is is connected we found a mapping
|
||||
if conn.state() == ConnectorState::Connected {
|
||||
map.insert(conn.handle(), Some(crtc));
|
||||
// If not, the user just unplugged something,
|
||||
// or the drm master did not cleanup?
|
||||
// Well, I guess we cleanup after them.
|
||||
} else {
|
||||
cleanup.push(crtc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -81,12 +81,11 @@ pub fn display_configuration(
|
|||
.iter()
|
||||
.flat_map(|conn| device.get_connector(*conn, false).ok())
|
||||
.filter(|conn| {
|
||||
if let Some(enc) = conn.current_encoder() {
|
||||
if let Ok(enc) = device.get_encoder(enc) {
|
||||
if let Some(crtc) = enc.crtc() {
|
||||
return cleanup.contains(&crtc);
|
||||
}
|
||||
}
|
||||
if let Some(enc) = conn.current_encoder()
|
||||
&& let Ok(enc) = device.get_encoder(enc)
|
||||
&& let Some(crtc) = enc.crtc()
|
||||
{
|
||||
return cleanup.contains(&crtc);
|
||||
}
|
||||
false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -230,14 +230,14 @@ fn determine_primary_gpu(
|
|||
drm_devices: &IndexMap<DrmNode, Device>,
|
||||
seat: String,
|
||||
) -> Result<Option<DrmNode>> {
|
||||
if let Some(device) = dev_var("COSMIC_RENDER_DEVICE") {
|
||||
if let Some(node) = drm_devices.values().find_map(|dev| {
|
||||
if let Some(device) = dev_var("COSMIC_RENDER_DEVICE")
|
||||
&& let Some(node) = drm_devices.values().find_map(|dev| {
|
||||
device
|
||||
.matches(&dev.inner.render_node)
|
||||
.then_some(dev.inner.render_node)
|
||||
}) {
|
||||
return Ok(Some(node));
|
||||
}
|
||||
})
|
||||
{
|
||||
return Ok(Some(node));
|
||||
}
|
||||
|
||||
// try to find builtin display
|
||||
|
|
@ -256,13 +256,12 @@ fn determine_primary_gpu(
|
|||
|
||||
// else try to find the boot gpu
|
||||
let boot = determine_boot_gpu(seat);
|
||||
if let Some(boot) = boot {
|
||||
if drm_devices
|
||||
if let Some(boot) = boot
|
||||
&& drm_devices
|
||||
.values()
|
||||
.any(|dev| dev.inner.render_node == boot)
|
||||
{
|
||||
return Ok(Some(boot));
|
||||
}
|
||||
{
|
||||
return Ok(Some(boot));
|
||||
}
|
||||
|
||||
// else just take the first
|
||||
|
|
@ -319,10 +318,9 @@ fn init_udev(
|
|||
let backend = state.backend.kms();
|
||||
if matches!(event, UdevEvent::Added { .. } | UdevEvent::Removed { .. })
|
||||
&& backend.primary_node.read().unwrap().is_none()
|
||||
&& let Err(err) = state.backend.kms().select_primary_gpu(&dh)
|
||||
{
|
||||
if let Err(err) = state.backend.kms().select_primary_gpu(&dh) {
|
||||
warn!("Failed to determine a new primary gpu: {}", err);
|
||||
}
|
||||
warn!("Failed to determine a new primary gpu: {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -462,18 +460,17 @@ impl KmsState {
|
|||
if let Some(primary_node) = primary_node
|
||||
.as_ref()
|
||||
.and_then(|node| node.node_with_type(NodeType::Primary).and_then(|x| x.ok()))
|
||||
&& let Some(device) = self.drm_devices.get(&primary_node)
|
||||
{
|
||||
if let Some(device) = self.drm_devices.get(&primary_node) {
|
||||
let import_device = device.drm.device().device_fd().clone();
|
||||
if supports_syncobj_eventfd(&import_device) {
|
||||
if let Some(state) = self.syncobj_state.as_mut() {
|
||||
state.update_device(import_device);
|
||||
} else {
|
||||
let syncobj_state = DrmSyncobjState::new::<State>(dh, import_device);
|
||||
self.syncobj_state = Some(syncobj_state);
|
||||
}
|
||||
return Ok(());
|
||||
let import_device = device.drm.device().device_fd().clone();
|
||||
if supports_syncobj_eventfd(&import_device) {
|
||||
if let Some(state) = self.syncobj_state.as_mut() {
|
||||
state.update_device(import_device);
|
||||
} else {
|
||||
let syncobj_state = DrmSyncobjState::new::<State>(dh, import_device);
|
||||
self.syncobj_state = Some(syncobj_state);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -939,15 +936,15 @@ impl KmsGuard<'_> {
|
|||
compositor
|
||||
};
|
||||
|
||||
if let Some(bpc) = output_config.0.max_bpc {
|
||||
if let Err(err) = drm_helpers::set_max_bpc(drm.device(), conn, bpc) {
|
||||
warn!(
|
||||
?bpc,
|
||||
?err,
|
||||
"Failed to set max_bpc on connector: {}",
|
||||
surface.output.name()
|
||||
);
|
||||
}
|
||||
if let Some(bpc) = output_config.0.max_bpc
|
||||
&& let Err(err) = drm_helpers::set_max_bpc(drm.device(), conn, bpc)
|
||||
{
|
||||
warn!(
|
||||
?bpc,
|
||||
?err,
|
||||
"Failed to set max_bpc on connector: {}",
|
||||
surface.output.name()
|
||||
);
|
||||
}
|
||||
|
||||
let vrr = output_config.0.vrr;
|
||||
|
|
|
|||
|
|
@ -782,91 +782,90 @@ impl SurfaceThreadState {
|
|||
// mark last frame completed
|
||||
if let Ok(Some(Some((mut feedback, frames, estimated_presentation_time)))) =
|
||||
compositor.frame_submitted()
|
||||
&& self.mirroring.is_none()
|
||||
{
|
||||
if self.mirroring.is_none() {
|
||||
let name = self.output.name();
|
||||
let message = if let Some(presentation_time) = presentation_time {
|
||||
let misprediction_s =
|
||||
presentation_time.as_secs_f64() - estimated_presentation_time.as_secs_f64();
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.presentation_misprediction_plot_name,
|
||||
misprediction_s * 1000.,
|
||||
);
|
||||
let name = self.output.name();
|
||||
let message = if let Some(presentation_time) = presentation_time {
|
||||
let misprediction_s =
|
||||
presentation_time.as_secs_f64() - estimated_presentation_time.as_secs_f64();
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.presentation_misprediction_plot_name,
|
||||
misprediction_s * 1000.,
|
||||
);
|
||||
|
||||
let now = Duration::from(now);
|
||||
if presentation_time > now {
|
||||
let diff = presentation_time - now;
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.time_since_presentation_plot_name,
|
||||
-diff.as_secs_f64() * 1000.,
|
||||
);
|
||||
format!("vblank on {name}, presentation is {diff:?} later")
|
||||
} else {
|
||||
let diff = now - presentation_time;
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.time_since_presentation_plot_name,
|
||||
diff.as_secs_f64() * 1000.,
|
||||
);
|
||||
format!("vblank on {name}, presentation was {diff:?} ago")
|
||||
}
|
||||
let now = Duration::from(now);
|
||||
if presentation_time > now {
|
||||
let diff = presentation_time - now;
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.time_since_presentation_plot_name,
|
||||
-diff.as_secs_f64() * 1000.,
|
||||
);
|
||||
format!("vblank on {name}, presentation is {diff:?} later")
|
||||
} else {
|
||||
format!("vblank on {name}, presentation time unknown")
|
||||
};
|
||||
let diff = now - presentation_time;
|
||||
tracy_client::Client::running().unwrap().plot(
|
||||
self.time_since_presentation_plot_name,
|
||||
diff.as_secs_f64() * 1000.,
|
||||
);
|
||||
format!("vblank on {name}, presentation was {diff:?} ago")
|
||||
}
|
||||
} else {
|
||||
format!("vblank on {name}, presentation time unknown")
|
||||
};
|
||||
tracy_client::Client::running()
|
||||
.unwrap()
|
||||
.message(&message, 0);
|
||||
|
||||
let (clock, flags) = if let Some(tp) = presentation_time {
|
||||
(
|
||||
tp.into(),
|
||||
wp_presentation_feedback::Kind::Vsync
|
||||
| wp_presentation_feedback::Kind::HwClock
|
||||
| wp_presentation_feedback::Kind::HwCompletion,
|
||||
)
|
||||
} else {
|
||||
(
|
||||
now,
|
||||
wp_presentation_feedback::Kind::Vsync
|
||||
| wp_presentation_feedback::Kind::HwCompletion,
|
||||
)
|
||||
};
|
||||
|
||||
let rate = self
|
||||
.output
|
||||
.current_mode()
|
||||
.map(|mode| Duration::from_secs_f64(1_000.0 / mode.refresh as f64));
|
||||
let refresh = match rate {
|
||||
Some(rate)
|
||||
if self
|
||||
.compositor
|
||||
.as_ref()
|
||||
.is_some_and(|comp| comp.with_compositor(|c| c.vrr_enabled())) =>
|
||||
{
|
||||
Refresh::Variable(rate)
|
||||
}
|
||||
Some(rate) => Refresh::Fixed(rate),
|
||||
None => Refresh::Unknown,
|
||||
};
|
||||
|
||||
if let Some(last_sequence) = self.last_sequence {
|
||||
let delta = sequence as f64 - last_sequence as f64;
|
||||
tracy_client::Client::running()
|
||||
.unwrap()
|
||||
.message(&message, 0);
|
||||
.plot(self.sequence_delta_plot_name, delta);
|
||||
}
|
||||
self.last_sequence = Some(sequence);
|
||||
|
||||
let (clock, flags) = if let Some(tp) = presentation_time {
|
||||
(
|
||||
tp.into(),
|
||||
wp_presentation_feedback::Kind::Vsync
|
||||
| wp_presentation_feedback::Kind::HwClock
|
||||
| wp_presentation_feedback::Kind::HwCompletion,
|
||||
)
|
||||
} else {
|
||||
(
|
||||
now,
|
||||
wp_presentation_feedback::Kind::Vsync
|
||||
| wp_presentation_feedback::Kind::HwCompletion,
|
||||
)
|
||||
};
|
||||
feedback.presented(clock, refresh, sequence as u64, flags);
|
||||
|
||||
let rate = self
|
||||
.output
|
||||
.current_mode()
|
||||
.map(|mode| Duration::from_secs_f64(1_000.0 / mode.refresh as f64));
|
||||
let refresh = match rate {
|
||||
Some(rate)
|
||||
if self
|
||||
.compositor
|
||||
.as_ref()
|
||||
.is_some_and(|comp| comp.with_compositor(|c| c.vrr_enabled())) =>
|
||||
{
|
||||
Refresh::Variable(rate)
|
||||
}
|
||||
Some(rate) => Refresh::Fixed(rate),
|
||||
None => Refresh::Unknown,
|
||||
};
|
||||
self.timings.presented(clock);
|
||||
|
||||
if let Some(last_sequence) = self.last_sequence {
|
||||
let delta = sequence as f64 - last_sequence as f64;
|
||||
tracy_client::Client::running()
|
||||
.unwrap()
|
||||
.plot(self.sequence_delta_plot_name, delta);
|
||||
}
|
||||
self.last_sequence = Some(sequence);
|
||||
|
||||
feedback.presented(clock, refresh, sequence as u64, flags);
|
||||
|
||||
self.timings.presented(clock);
|
||||
|
||||
while let Ok(pending_image_copy_data) = frames.recv() {
|
||||
pending_image_copy_data.send_success_when_ready(
|
||||
self.output.current_transform(),
|
||||
&self.loop_handle,
|
||||
clock,
|
||||
);
|
||||
}
|
||||
while let Ok(pending_image_copy_data) = frames.recv() {
|
||||
pending_image_copy_data.send_success_when_ready(
|
||||
self.output.current_transform(),
|
||||
&self.loop_handle,
|
||||
clock,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1077,11 +1076,11 @@ impl SurfaceThreadState {
|
|||
// we can't use the elements after `compositor.render_frame`,
|
||||
// so let's collect everything we need for screencopy now
|
||||
let mut has_cursor_mode_none = false;
|
||||
let frames = self
|
||||
.mirroring
|
||||
.is_none()
|
||||
.then(|| take_screencopy_frames(&self.output, &elements, &mut has_cursor_mode_none))
|
||||
.unwrap_or_default();
|
||||
let frames = if self.mirroring.is_none() {
|
||||
take_screencopy_frames(&self.output, &elements, &mut has_cursor_mode_none)
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
|
||||
// actual rendering
|
||||
let source_output = self
|
||||
|
|
@ -1312,10 +1311,10 @@ impl SurfaceThreadState {
|
|||
None
|
||||
};
|
||||
|
||||
if frame_result.needs_sync() {
|
||||
if let PrimaryPlaneElement::Swapchain(elem) = &frame_result.primary_element {
|
||||
elem.sync.wait()?;
|
||||
}
|
||||
if frame_result.needs_sync()
|
||||
&& let PrimaryPlaneElement::Swapchain(elem) = &frame_result.primary_element
|
||||
{
|
||||
elem.sync.wait()?;
|
||||
}
|
||||
|
||||
match compositor.queue_frame(feedback) {
|
||||
|
|
|
|||
|
|
@ -103,10 +103,10 @@ pub fn init_backend_auto(
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(inverted) = greeter_state.invert_colors {
|
||||
if inverted != state.a11y_state().screen_inverted() {
|
||||
state.request_screen_invert(inverted);
|
||||
}
|
||||
if let Some(inverted) = greeter_state.invert_colors
|
||||
&& inverted != state.a11y_state().screen_inverted()
|
||||
{
|
||||
state.request_screen_invert(inverted);
|
||||
}
|
||||
|
||||
if state
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ where
|
|||
};
|
||||
|
||||
let buf_translation = Matrix3::from_translation(Vector2::new(
|
||||
(view.src.loc.x as f64 / buf_size.w as f64) as f32,
|
||||
(view.src.loc.y as f64 / buf_size.h as f64) as f32,
|
||||
(view.src.loc.x / buf_size.w as f64) as f32,
|
||||
(view.src.loc.y / buf_size.h as f64) as f32,
|
||||
));
|
||||
|
||||
let input_to_geo =
|
||||
|
|
|
|||
|
|
@ -528,19 +528,17 @@ where
|
|||
);
|
||||
}
|
||||
|
||||
if !exclude_dnd_icon {
|
||||
if let Some(dnd_icon) = get_dnd_icon(seat) {
|
||||
elements.extend(
|
||||
cursor::draw_dnd_icon(
|
||||
renderer,
|
||||
&dnd_icon.surface,
|
||||
(location + dnd_icon.offset.to_f64()).to_i32_round(),
|
||||
scale,
|
||||
)
|
||||
.into_iter()
|
||||
.map(CosmicElement::Dnd),
|
||||
);
|
||||
}
|
||||
if !exclude_dnd_icon && let Some(dnd_icon) = get_dnd_icon(seat) {
|
||||
elements.extend(
|
||||
cursor::draw_dnd_icon(
|
||||
renderer,
|
||||
&dnd_icon.surface,
|
||||
(location + dnd_icon.offset.to_f64()).to_i32_round(),
|
||||
scale,
|
||||
)
|
||||
.into_iter()
|
||||
.map(CosmicElement::Dnd),
|
||||
);
|
||||
}
|
||||
|
||||
let theme = theme.cosmic();
|
||||
|
|
@ -1102,17 +1100,15 @@ impl PostprocessState {
|
|||
if let (Some(tex), Some(tracker)) = (
|
||||
self.cursor_texture.as_ref(),
|
||||
self.cursor_damage_tracker.as_ref(),
|
||||
) {
|
||||
if tex.format().is_some_and(|f| f == format)
|
||||
&& tracker.mode()
|
||||
== &(OutputModeSource::Static {
|
||||
size,
|
||||
scale,
|
||||
transform: Transform::Normal,
|
||||
})
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
) && tex.format().is_some_and(|f| f == format)
|
||||
&& tracker.mode()
|
||||
== &(OutputModeSource::Static {
|
||||
size,
|
||||
scale,
|
||||
transform: Transform::Normal,
|
||||
})
|
||||
{
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let texture = Offscreen::<GlesTexture>::create_buffer(renderer, format, buffer_size)?;
|
||||
|
|
|
|||
|
|
@ -61,10 +61,10 @@ impl ShadowShader {
|
|||
|
||||
let mut geo = geo.to_f64();
|
||||
let fractional_pixel = scale.ceil() / scale;
|
||||
geo.loc.x = geo.loc.x + fractional_pixel;
|
||||
geo.loc.y = geo.loc.y + fractional_pixel;
|
||||
geo.size.w = geo.size.w - fractional_pixel * 2.;
|
||||
geo.size.h = geo.size.h - fractional_pixel * 2.;
|
||||
geo.loc.x += fractional_pixel;
|
||||
geo.loc.y += fractional_pixel;
|
||||
geo.size.w -= fractional_pixel * 2.;
|
||||
geo.size.h -= fractional_pixel * 2.;
|
||||
|
||||
let user_data = Borrow::<GlesRenderer>::borrow(renderer.glow_renderer())
|
||||
.egl_context()
|
||||
|
|
@ -125,7 +125,7 @@ impl ShadowShader {
|
|||
.cast::<f32>()
|
||||
.unwrap();
|
||||
|
||||
let window_geo_loc = Vector2::new(window_geo.loc.x as f64, window_geo.loc.y as f64);
|
||||
let window_geo_loc = Vector2::new(window_geo.loc.x, window_geo.loc.y);
|
||||
let window_input_to_geo = (Matrix3::from_nonuniform_scale(area_size.x, area_size.y)
|
||||
* Matrix3::from_translation(Vector2::new(
|
||||
-window_geo_loc.x / area_size.x,
|
||||
|
|
|
|||
|
|
@ -517,24 +517,24 @@ where
|
|||
impl State {
|
||||
pub fn process_x11_event(&mut self, event: InputEvent<X11Input>) {
|
||||
// here we can handle special cases for x11 inputs, like mapping them to windows
|
||||
if let InputEvent::PointerMotionAbsolute { event } = &event {
|
||||
if let Some(window) = event.window() {
|
||||
let output = self
|
||||
.backend
|
||||
.x11()
|
||||
.surfaces
|
||||
.iter()
|
||||
.find(|surface| &surface.window == window.as_ref())
|
||||
.map(|surface| surface.output.clone())
|
||||
.unwrap();
|
||||
if let InputEvent::PointerMotionAbsolute { event } = &event
|
||||
&& let Some(window) = event.window()
|
||||
{
|
||||
let output = self
|
||||
.backend
|
||||
.x11()
|
||||
.surfaces
|
||||
.iter()
|
||||
.find(|surface| &surface.window == window.as_ref())
|
||||
.map(|surface| surface.output.clone())
|
||||
.unwrap();
|
||||
|
||||
let device = event.device();
|
||||
for seat in self.common.shell.read().seats.iter() {
|
||||
let devices = seat.user_data().get::<Devices>().unwrap();
|
||||
if devices.has_device(&device) {
|
||||
seat.set_active_output(&output);
|
||||
break;
|
||||
}
|
||||
let device = event.device();
|
||||
for seat in self.common.shell.read().seats.iter() {
|
||||
let devices = seat.user_data().get::<Devices>().unwrap();
|
||||
if devices.has_device(&device) {
|
||||
seat.set_active_output(&output);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue