chore: Rust 2024 edition

Set the formatting style to 2021 edition to avoid disrupting existing work.
Remove when possible.
This commit is contained in:
Vukašin Vojinović 2025-07-21 14:56:53 +02:00 committed by Victoria Brekenfeld
parent 35d781dc1e
commit 7f7ab8bcbe
19 changed files with 494 additions and 506 deletions

View file

@ -3,7 +3,7 @@ name: Continuous Integration
on: on:
push: push:
branches: branches:
- master - master
pull_request: pull_request:
jobs: jobs:
@ -67,6 +67,7 @@ jobs:
meson -Dbuiltin=enabled -Dserver=disabled -Dexamples=disabled -Dman-pages=disabled build . meson -Dbuiltin=enabled -Dserver=disabled -Dexamples=disabled -Dman-pages=disabled build .
ninja -C build ninja -C build
sudo meson install -C build sudo meson install -C build
sudo ldconfig
- name: Test features - name: Test features
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
env: env:

865
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[package] [package]
authors = ["Victoria Brekenfeld"] authors = ["Victoria Brekenfeld"]
edition = "2021" edition = "2024"
license = "GPL-3.0-only" license = "GPL-3.0-only"
name = "cosmic-comp" name = "cosmic-comp"
version = "0.1.0" version = "0.1.0"
@ -25,7 +25,7 @@ cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", rev = "
"server", "server",
] } ] }
cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon" } cosmic-settings-config = { git = "https://github.com/pop-os/cosmic-settings-daemon" }
cosmic-settings-daemon-config = { git = "https://github.com/pop-os/cosmic-settings-daemon", branch = "greeter", features = [ cosmic-settings-daemon-config = { git = "https://github.com/pop-os/cosmic-settings-daemon", features = [
"greeter", "greeter",
] } ] }
cosmic-text = { git = "https://github.com/pop-os/cosmic-text.git", features = [ cosmic-text = { git = "https://github.com/pop-os/cosmic-text.git", features = [

View file

@ -0,0 +1 @@
style_edition = "2021"

View file

@ -163,7 +163,7 @@ fn init_libinput(
let libinput_backend = LibinputInputBackend::new(libinput_context.clone()); let libinput_backend = LibinputInputBackend::new(libinput_context.clone());
evlh.insert_source(libinput_backend, move |mut event, _, state| { evlh.insert_source(libinput_backend, move |mut event, _, state| {
if let InputEvent::DeviceAdded { ref mut device } = &mut event { if let InputEvent::DeviceAdded { device } = &mut event {
state.common.config.read_device(device); state.common.config.read_device(device);
state state
.backend .backend

View file

@ -1379,7 +1379,7 @@ where
elements.truncate(old_len); elements.truncate(old_len);
} }
if let (Some(ref damage), _) = &res { if let (Some(damage), _) = &res {
let blit_to_buffer = let blit_to_buffer =
|renderer: &mut R, blit_from: &mut R::Framebuffer<'_>| { |renderer: &mut R, blit_from: &mut R::Framebuffer<'_>| {
if let Ok(dmabuf) = get_dmabuf(buffer) { if let Ok(dmabuf) = get_dmabuf(buffer) {

View file

@ -10,13 +10,13 @@ use crate::{
}; };
use cosmic_config::{ConfigGet, CosmicConfigEntry}; use cosmic_config::{ConfigGet, CosmicConfigEntry};
use cosmic_settings_config::window_rules::ApplicationException; use cosmic_settings_config::window_rules::ApplicationException;
use cosmic_settings_config::{Shortcuts, shortcuts, window_rules}; use cosmic_settings_config::{shortcuts, window_rules, Shortcuts};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use smithay::utils::{Clock, Monotonic}; use smithay::utils::{Clock, Monotonic};
use smithay::wayland::xdg_activation::XdgActivationState; use smithay::wayland::xdg_activation::XdgActivationState;
pub use smithay::{ pub use smithay::{
backend::input::{self as smithay_input, KeyState}, backend::input::{self as smithay_input, KeyState},
input::keyboard::{Keysym, ModifiersState, keysyms as KeySyms}, input::keyboard::{keysyms as KeySyms, Keysym, ModifiersState},
output::{Mode, Output}, output::{Mode, Output},
reexports::{ reexports::{
calloop::LoopHandle, calloop::LoopHandle,
@ -25,7 +25,7 @@ pub use smithay::{
TapButtonMap, TapButtonMap,
}, },
}, },
utils::{Logical, Physical, Point, SERIAL_COUNTER, Size, Transform}, utils::{Logical, Physical, Point, Size, Transform, SERIAL_COUNTER},
}; };
use std::{ use std::{
cell::RefCell, cell::RefCell,
@ -33,7 +33,7 @@ use std::{
fs::OpenOptions, fs::OpenOptions,
io::Write, io::Write,
path::PathBuf, path::PathBuf,
sync::{Arc, atomic::AtomicBool}, sync::{atomic::AtomicBool, Arc},
}; };
use tracing::{error, warn}; use tracing::{error, warn};
@ -45,8 +45,8 @@ pub use self::types::*;
use cosmic::config::CosmicTk; use cosmic::config::CosmicTk;
pub use cosmic_comp_config::output::EdidProduct; pub use cosmic_comp_config::output::EdidProduct;
use cosmic_comp_config::{ use cosmic_comp_config::{
CosmicCompConfig, KeyboardConfig, TileBehavior, XkbConfig, XwaylandDescaling, input::InputConfig, workspace::WorkspaceConfig, CosmicCompConfig, KeyboardConfig, TileBehavior,
XwaylandEavesdropping, ZoomConfig, input::InputConfig, workspace::WorkspaceConfig, XkbConfig, XwaylandDescaling, XwaylandEavesdropping, ZoomConfig,
}; };
#[derive(Debug)] #[derive(Debug)]

View file

@ -2030,7 +2030,7 @@ impl State {
Stage::SessionLock(lock_surface) => { Stage::SessionLock(lock_surface) => {
return ControlFlow::Break(Ok(lock_surface return ControlFlow::Break(Ok(lock_surface
.cloned() .cloned()
.map(KeyboardFocusTarget::LockSurface))) .map(KeyboardFocusTarget::LockSurface)));
} }
Stage::LayerPopup { Stage::LayerPopup {
layer, layer,

View file

@ -54,7 +54,7 @@ unsafe fn set_cloexec(fd: RawFd) -> rustix::io::Result<()> {
if fd == -1 { if fd == -1 {
return Err(rustix::io::Errno::BADF); return Err(rustix::io::Errno::BADF);
} }
let fd = BorrowedFd::borrow_raw(fd); let fd = unsafe { BorrowedFd::borrow_raw(fd) };
let flags = rustix::io::fcntl_getfd(fd)?; let flags = rustix::io::fcntl_getfd(fd)?;
rustix::io::fcntl_setfd(fd, flags | rustix::io::FdFlags::CLOEXEC) rustix::io::fcntl_setfd(fd, flags | rustix::io::FdFlags::CLOEXEC)
} }

View file

@ -667,8 +667,7 @@ impl CosmicMapped {
WindowSurface::Wayland(_) => "Protocol: Wayland", WindowSurface::Wayland(_) => "Protocol: Wayland",
WindowSurface::X11(_) => "Protocol: X11", WindowSurface::X11(_) => "Protocol: X11",
}); });
if let WindowSurface::X11(ref surf) = if let WindowSurface::X11(surf) = window.0.underlying_surface()
window.0.underlying_surface()
{ {
let geo = surf.geometry(); let geo = surf.geometry();
ui.label(format!( ui.label(format!(

View file

@ -1,6 +1,6 @@
use super::{ use super::{
CosmicSurface,
window::{Focus, RESIZE_BORDER}, window::{Focus, RESIZE_BORDER},
CosmicSurface,
}; };
use crate::{ use crate::{
backend::render::cursor::CursorState, backend::render::cursor::CursorState,
@ -17,12 +17,11 @@ use crate::{
}; };
use calloop::LoopHandle; use calloop::LoopHandle;
use cosmic::{ use cosmic::{
Apply, Element as CosmicElement, Theme, iced::{id::Id, widget as iced_widget, Alignment},
iced::{Alignment, id::Id, widget as iced_widget}, iced_core::{border::Radius, Background, Border, Color, Length},
iced_core::{Background, Border, Color, Length, border::Radius},
iced_runtime::Task, iced_runtime::Task,
iced_widget::scrollable::AbsoluteOffset, iced_widget::scrollable::AbsoluteOffset,
theme, widget as cosmic_widget, theme, widget as cosmic_widget, Apply, Element as CosmicElement, Theme,
}; };
use cosmic_settings_config::shortcuts; use cosmic_settings_config::shortcuts;
use shortcuts::action::{Direction, FocusDirection}; use shortcuts::action::{Direction, FocusDirection};
@ -30,16 +29,15 @@ use smithay::{
backend::{ backend::{
input::KeyState, input::KeyState,
renderer::{ renderer::{
ImportAll, ImportMem, Renderer,
element::{ element::{
AsRenderElements, memory::MemoryRenderBufferRenderElement, memory::MemoryRenderBufferRenderElement, surface::WaylandSurfaceRenderElement,
surface::WaylandSurfaceRenderElement, AsRenderElements,
}, },
ImportAll, ImportMem, Renderer,
}, },
}, },
desktop::{WindowSurfaceType, space::SpaceElement}, desktop::{space::SpaceElement, WindowSurfaceType},
input::{ input::{
Seat,
keyboard::{KeyboardTarget, KeysymHandle, ModifiersState}, keyboard::{KeyboardTarget, KeysymHandle, ModifiersState},
pointer::{ pointer::{
AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent, AxisFrame, ButtonEvent, CursorImageStatus, GestureHoldBeginEvent, GestureHoldEndEvent,
@ -51,6 +49,7 @@ use smithay::{
DownEvent, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchTarget, DownEvent, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchTarget,
UpEvent, UpEvent,
}, },
Seat,
}, },
output::Output, output::Output,
reexports::wayland_server::protocol::wl_surface::WlSurface, reexports::wayland_server::protocol::wl_surface::WlSurface,
@ -63,8 +62,8 @@ use std::{
fmt, fmt,
hash::Hash, hash::Hash,
sync::{ sync::{
Arc, LazyLock, Mutex,
atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering}, atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering},
Arc, LazyLock, Mutex,
}, },
}; };
@ -314,7 +313,11 @@ impl CosmicStack {
if let Ok(old) = if let Ok(old) =
p.active p.active
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |val| { .fetch_update(Ordering::SeqCst, Ordering::SeqCst, |val| {
if val < max - 1 { Some(val + 1) } else { None } if val < max - 1 {
Some(val + 1)
} else {
None
}
}) })
{ {
p.previous_keyboard.store(old, Ordering::SeqCst); p.previous_keyboard.store(old, Ordering::SeqCst);

View file

@ -744,7 +744,7 @@ impl TilingLayout {
} }
}; };
for (ref mut parent_id, _) in children.iter_mut() { for (parent_id, _) in children.iter_mut() {
*parent_id = id.clone(); *parent_id = id.clone();
} }
if let Data::Mapped { mapped, .. } = other_tree.get_mut(&id).unwrap().data_mut() { if let Data::Mapped { mapped, .. } = other_tree.get_mut(&id).unwrap().data_mut() {

View file

@ -3267,22 +3267,29 @@ impl Shell {
let is_stacked = mapped.is_stack(); let is_stacked = mapped.is_stack();
if target_stack || !is_stacked { if target_stack || !is_stacked {
Box::new(window_items( Box::new(
&mapped, window_items(
is_tiled, &mapped,
is_stacked, is_tiled,
is_sticky, is_stacked,
tiling_enabled, is_sticky,
edge, tiling_enabled,
config, edge,
)) as Box<dyn Iterator<Item = Item>> config,
)
.collect::<Vec<Item>>()
.into_iter(),
) as Box<dyn Iterator<Item = Item>>
} else { } else {
let (tab, _) = mapped let (tab, _) = mapped
.windows() .windows()
.find(|(s, _)| s.wl_surface().as_deref() == Some(surface)) .find(|(s, _)| s.wl_surface().as_deref() == Some(surface))
.unwrap(); .unwrap();
Box::new(tab_items(&mapped, &tab, is_tiled, config)) Box::new(
as Box<dyn Iterator<Item = Item>> tab_items(&mapped, &tab, is_tiled, config)
.collect::<Vec<Item>>()
.into_iter(),
) as Box<dyn Iterator<Item = Item>>
} }
}; };
@ -3292,7 +3299,7 @@ impl Shell {
.mapped() .mapped()
.find_map(|m| { .find_map(|m| {
m.windows() m.windows()
.find(|(ref w, _)| w == surface) .find(|(w, _)| w == surface)
.map(|(_, loc)| (m, loc)) .map(|(_, loc)| (m, loc))
}) })
.map(|(mapped, relative_loc)| (set, mapped, relative_loc)) .map(|(mapped, relative_loc)| (set, mapped, relative_loc))

View file

@ -391,9 +391,9 @@ impl BackendData {
pub fn lock(&mut self) -> LockedBackend<'_> { pub fn lock(&mut self) -> LockedBackend<'_> {
match self { match self {
BackendData::Kms(ref mut state) => LockedBackend::Kms(state.lock_devices()), BackendData::Kms(state) => LockedBackend::Kms(state.lock_devices()),
BackendData::X11(ref mut state) => LockedBackend::X11(state), BackendData::X11(state) => LockedBackend::X11(state),
BackendData::Winit(ref mut state) => LockedBackend::Winit(state), BackendData::Winit(state) => LockedBackend::Winit(state),
_ => unreachable!("Tried to lock unset backend"), _ => unreachable!("Tried to lock unset backend"),
} }
} }
@ -535,8 +535,8 @@ impl<'a> LockedBackend<'a> {
LockedBackend::Winit(_) => {} // We cannot do this on the winit backend. LockedBackend::Winit(_) => {} // We cannot do this on the winit backend.
// Winit has a very strict render-loop and skipping frames breaks atleast the wayland winit-backend. // Winit has a very strict render-loop and skipping frames breaks atleast the wayland winit-backend.
// Swapping with damage (which should be empty on these frames) is likely good enough anyway. // Swapping with damage (which should be empty on these frames) is likely good enough anyway.
LockedBackend::X11(ref mut state) => state.schedule_render(&output), LockedBackend::X11(state) => state.schedule_render(&output),
LockedBackend::Kms(ref mut state) => state.schedule_render(&output), LockedBackend::Kms(state) => state.schedule_render(&output),
} }
} }

View file

@ -2,13 +2,11 @@ use std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
fmt, fmt,
hash::{Hash, Hasher}, hash::{Hash, Hasher},
sync::{Arc, LazyLock, Mutex, mpsc::Receiver}, sync::{mpsc::Receiver, Arc, LazyLock, Mutex},
}; };
use cosmic::{ use cosmic::{
Theme,
iced::{ iced::{
Limits, Point as IcedPoint, Size as IcedSize, Task,
advanced::{graphics::text::font_system, widget::Tree}, advanced::{graphics::text::font_system, widget::Tree},
event::Event, event::Event,
futures::{FutureExt, StreamExt}, futures::{FutureExt, StreamExt},
@ -16,17 +14,19 @@ use cosmic::{
mouse::{Button as MouseButton, Cursor, Event as MouseEvent, ScrollDelta}, mouse::{Button as MouseButton, Cursor, Event as MouseEvent, ScrollDelta},
touch::{Event as TouchEvent, Finger}, touch::{Event as TouchEvent, Finger},
window::Event as WindowEvent, window::Event as WindowEvent,
Limits, Point as IcedPoint, Size as IcedSize, Task,
}, },
iced_core::{Color, Length, Pixels, clipboard::Null as NullClipboard, id::Id, renderer::Style}, iced_core::{clipboard::Null as NullClipboard, id::Id, renderer::Style, Color, Length, Pixels},
iced_runtime::{ iced_runtime::{
Action, Debug,
program::{Program as IcedProgram, State}, program::{Program as IcedProgram, State},
task::into_stream, task::into_stream,
Action, Debug,
}, },
Theme,
}; };
use iced_tiny_skia::{ use iced_tiny_skia::{
graphics::{damage, Viewport},
Layer, Layer,
graphics::{Viewport, damage},
}; };
use ordered_float::OrderedFloat; use ordered_float::OrderedFloat;
@ -35,16 +35,15 @@ use smithay::{
allocator::Fourcc, allocator::Fourcc,
input::{ButtonState, KeyState}, input::{ButtonState, KeyState},
renderer::{ renderer::{
ImportMem, Renderer,
element::{ element::{
AsRenderElements, Kind,
memory::{MemoryRenderBuffer, MemoryRenderBufferRenderElement}, memory::{MemoryRenderBuffer, MemoryRenderBufferRenderElement},
AsRenderElements, Kind,
}, },
ImportMem, Renderer,
}, },
}, },
desktop::space::{RenderZindex, SpaceElement}, desktop::space::{RenderZindex, SpaceElement},
input::{ input::{
Seat,
keyboard::{KeyboardTarget, KeysymHandle, ModifiersState}, keyboard::{KeyboardTarget, KeysymHandle, ModifiersState},
pointer::{ pointer::{
AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent, AxisFrame, ButtonEvent, GestureHoldBeginEvent, GestureHoldEndEvent,
@ -56,10 +55,11 @@ use smithay::{
DownEvent, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchTarget, DownEvent, MotionEvent as TouchMotionEvent, OrientationEvent, ShapeEvent, TouchTarget,
UpEvent, UpEvent,
}, },
Seat,
}, },
output::Output, output::Output,
reexports::calloop::RegistrationToken, reexports::calloop::RegistrationToken,
reexports::calloop::{self, LoopHandle, futures::Scheduler}, reexports::calloop::{self, futures::Scheduler, LoopHandle},
utils::{ utils::{
Buffer as BufferCoords, IsAlive, Logical, Physical, Point, Rectangle, Scale, Serial, Size, Buffer as BufferCoords, IsAlive, Logical, Physical, Point, Rectangle, Scale, Serial, Size,
Transform, Transform,

View file

@ -53,7 +53,7 @@ fn toplevel_ensure_initial_configure(
} }
fn xdg_popup_ensure_initial_configure(popup: &PopupKind) { fn xdg_popup_ensure_initial_configure(popup: &PopupKind) {
if let PopupKind::Xdg(ref popup) = popup { if let PopupKind::Xdg(popup) = popup {
let initial_configure_sent = with_states(popup.wl_surface(), |states| { let initial_configure_sent = with_states(popup.wl_surface(), |states| {
states states
.data_map .data_map

View file

@ -72,10 +72,7 @@ impl State {
if offset_x > 0 || offset_y > 0 { if offset_x > 0 || offset_y > 0 {
for (output, conf) in conf.iter_mut() { for (output, conf) in conf.iter_mut() {
if let OutputConfiguration::Enabled { if let OutputConfiguration::Enabled { position, .. } = conf {
ref mut position, ..
} = conf
{
let current_config = output let current_config = output
.user_data() .user_data()
.get::<RefCell<OutputConfig>>() .get::<RefCell<OutputConfig>>()

View file

@ -26,7 +26,7 @@ pub fn set_all_surfaces_dpms_on(state: &mut State) {
} }
fn kms_surfaces(state: &mut State) -> impl Iterator<Item = &mut Surface> { fn kms_surfaces(state: &mut State) -> impl Iterator<Item = &mut Surface> {
if let BackendData::Kms(ref mut kms_state) = &mut state.backend { if let BackendData::Kms(kms_state) = &mut state.backend {
Some( Some(
kms_state kms_state
.drm_devices .drm_devices

View file

@ -209,7 +209,10 @@ where
.push((obj.downgrade(), instance)); .push((obj.downgrade(), instance));
} else { } else {
let _ = data_init.init(cosmic_toplevel, ToplevelHandleStateInner::empty()); let _ = data_init.init(cosmic_toplevel, ToplevelHandleStateInner::empty());
error!(?foreign_toplevel, "Toplevel for foreign-toplevel-list not registered for cosmic-toplevel-info."); error!(
?foreign_toplevel,
"Toplevel for foreign-toplevel-list not registered for cosmic-toplevel-info."
);
} }
} }
zcosmic_toplevel_info_v1::Request::Stop => { zcosmic_toplevel_info_v1::Request::Stop => {