From 4a2658090b459ff27354a899e1b3201b81888206 Mon Sep 17 00:00:00 2001 From: Drakulix Date: Wed, 21 Feb 2018 14:24:37 +0100 Subject: [PATCH] Code formatting --- examples/udev.rs | 10 +++------- src/backend/drm/mod.rs | 13 +++++++------ src/backend/session/auto.rs | 8 ++++---- src/backend/session/dbus/logind.rs | 8 ++++---- src/backend/session/direct.rs | 8 ++++---- src/backend/session/mod.rs | 3 ++- src/backend/udev.rs | 27 ++++++++++----------------- 7 files changed, 34 insertions(+), 43 deletions(-) diff --git a/examples/udev.rs b/examples/udev.rs index 595eadb..15accb2 100644 --- a/examples/udev.rs +++ b/examples/udev.rs @@ -55,8 +55,8 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use std::time::Duration; use wayland_server::{Display, EventLoopHandle}; -use wayland_server::sources::EventSource; use wayland_server::protocol::{wl_output, wl_pointer}; +use wayland_server::sources::EventSource; use xkbcommon::xkb::keysyms as xkb; struct LibinputInputHandler { @@ -475,17 +475,13 @@ impl UdevHandler for UdevHandlerImpl { }) } - fn device_changed( - &mut self, _evlh: &mut EventLoopHandle, device: &mut DrmDevice - ) { + fn device_changed(&mut self, _evlh: &mut EventLoopHandle, device: &mut DrmDevice) { //quick and dirt, just re-init all backends let backends = self.backends.get(&device.device_id()).unwrap(); *backends.borrow_mut() = self.scan_connectors(device); } - fn device_removed( - &mut self, _evlh: &mut EventLoopHandle, device: &mut DrmDevice - ) { + fn device_removed(&mut self, _evlh: &mut EventLoopHandle, device: &mut DrmDevice) { // drop the backends on this side self.backends.remove(&device.device_id()); diff --git a/src/backend/drm/mod.rs b/src/backend/drm/mod.rs index 76567d1..6aebfce 100644 --- a/src/backend/drm/mod.rs +++ b/src/backend/drm/mod.rs @@ -529,12 +529,15 @@ impl Drop for DrmDevice { pub trait DrmHandler { /// The `DrmBackend` of crtc has finished swapping buffers and new frame can now /// (and should be immediately) be rendered. - fn ready(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice, crtc: crtc::Handle, frame: u32, duration: Duration); + fn ready( + &mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice, crtc: crtc::Handle, frame: u32, + duration: Duration, + ); /// The `DrmDevice` has thrown an error. /// /// The related backends are most likely *not* usable anymore and /// the whole stack has to be recreated.. - fn error(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice, error: DrmError); + fn error(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice, error: DrmError); } /// Bind a `DrmDevice` to an `EventLoop`, @@ -622,8 +625,7 @@ impl AsSessionObserver> for Drm impl SessionObserver for DrmDeviceObserver { fn pause(&mut self, _evlh: &mut EventLoopHandle, devnum: Option<(u32, u32)>) { if let Some((major, minor)) = devnum { - if major as u64 != stat::major(self.device_id) || minor as u64 != stat::minor(self.device_id) - { + if major as u64 != stat::major(self.device_id) || minor as u64 != stat::minor(self.device_id) { return; } } @@ -657,8 +659,7 @@ impl SessionObserver for DrmDeviceObserver { fn activate(&mut self, _evlh: &mut EventLoopHandle, devnum: Option<(u32, u32, Option)>) { if let Some((major, minor, fd)) = devnum { - if major as u64 != stat::major(self.device_id) || minor as u64 != stat::minor(self.device_id) - { + if major as u64 != stat::major(self.device_id) || minor as u64 != stat::minor(self.device_id) { return; } else if let Some(fd) = fd { info!(self.logger, "Replacing fd"); diff --git a/src/backend/session/auto.rs b/src/backend/session/auto.rs index beadf3f..a32ed03 100644 --- a/src/backend/session/auto.rs +++ b/src/backend/session/auto.rs @@ -29,7 +29,7 @@ //! automatically by the `UdevBackend`, if not done manually). //! ``` -use super::{AsErrno, Session, SessionNotifier, SessionObserver, AsSessionObserver}; +use super::{AsErrno, AsSessionObserver, Session, SessionNotifier, SessionObserver}; use super::direct::{self, direct_session_bind, DirectSession, DirectSessionNotifier}; #[cfg(feature = "backend_session_logind")] use super::logind::{self, logind_session_bind, BoundLogindSession, LogindSession, LogindSessionNotifier}; @@ -207,9 +207,9 @@ impl Session for AutoSession { impl SessionNotifier for AutoSessionNotifier { type Id = AutoId; - fn register>(&mut self, signal: &mut A) - -> Self::Id - { + fn register>( + &mut self, signal: &mut A + ) -> Self::Id { match self { #[cfg(feature = "backend_session_logind")] &mut AutoSessionNotifier::Logind(ref mut logind) => { diff --git a/src/backend/session/dbus/logind.rs b/src/backend/session/dbus/logind.rs index 73ee191..38ce38d 100644 --- a/src/backend/session/dbus/logind.rs +++ b/src/backend/session/dbus/logind.rs @@ -30,7 +30,7 @@ //! automatically by the `UdevBackend`, if not done manually). //! ``` -use backend::session::{AsErrno, Session, SessionNotifier, SessionObserver, AsSessionObserver}; +use backend::session::{AsErrno, AsSessionObserver, Session, SessionNotifier, SessionObserver}; use dbus::{BusName, BusType, Connection, ConnectionItem, ConnectionItems, Interface, Member, Message, MessageItem, OwnedFd, Path as DbusPath, Watch, WatchEvent}; use nix::fcntl::OFlag; @@ -392,9 +392,9 @@ pub struct Id(usize); impl SessionNotifier for LogindSessionNotifier { type Id = Id; - fn register>(&mut self, signal: &mut A) - -> Self::Id - { + fn register>( + &mut self, signal: &mut A + ) -> Self::Id { self.internal .signals .borrow_mut() diff --git a/src/backend/session/direct.rs b/src/backend/session/direct.rs index 018ac46..d5567aa 100644 --- a/src/backend/session/direct.rs +++ b/src/backend/session/direct.rs @@ -45,7 +45,7 @@ //! for notifications are the `Libinput` context, the `UdevBackend` or a `DrmDevice` (handled //! automatically by the `UdevBackend`, if not done manually). -use super::{AsErrno, Session, SessionNotifier, SessionObserver, AsSessionObserver}; +use super::{AsErrno, AsSessionObserver, Session, SessionNotifier, SessionObserver}; use nix::{Error as NixError, Result as NixResult}; use nix::fcntl::{self, open, OFlag}; use nix::libc::c_int; @@ -344,9 +344,9 @@ pub struct Id(usize); impl SessionNotifier for DirectSessionNotifier { type Id = Id; - fn register>(&mut self, signal: &mut A) - -> Self::Id - { + fn register>( + &mut self, signal: &mut A + ) -> Self::Id { self.signals.push(Some(Box::new(signal.observer()))); Id(self.signals.len() - 1) } diff --git a/src/backend/session/mod.rs b/src/backend/session/mod.rs index 3a9b77e..a11c6d3 100644 --- a/src/backend/session/mod.rs +++ b/src/backend/session/mod.rs @@ -53,7 +53,8 @@ pub trait SessionNotifier { /// Registers a given `SessionObserver`. /// /// Returns an id of the inserted observer, can be used to remove it again. - fn register>(&mut self, signal: &mut A) -> Self::Id; + fn register>(&mut self, signal: &mut A) + -> Self::Id; /// Removes an observer by its given id from `SessionNotifier::register`. fn unregister(&mut self, signal: Self::Id); diff --git a/src/backend/udev.rs b/src/backend/udev.rs index 2f2804d..49a3dd2 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -10,7 +10,7 @@ //! backend. use backend::drm::{drm_device_bind, DrmDevice, DrmHandler}; -use backend::session::{Session, SessionObserver, AsSessionObserver}; +use backend::session::{AsSessionObserver, Session, SessionObserver}; use drm::Device as BasicDevice; use drm::control::Device as ControlDevice; use nix::fcntl; @@ -171,7 +171,8 @@ impl< H: DrmHandler + 'static, S: Session + 'static, T: UdevHandler + 'static, -> AsSessionObserver> for UdevBackend { +> AsSessionObserver> for UdevBackend +{ fn observer(&mut self) -> UdevBackendObserver { UdevBackendObserver { devices: Rc::downgrade(&self.devices), @@ -180,8 +181,7 @@ impl< } } -impl + 'static> SessionObserver for UdevBackendObserver -{ +impl + 'static> SessionObserver for UdevBackendObserver { fn pause<'a>(&mut self, evlh: &mut EventLoopHandle, devnum: Option<(u32, u32)>) { if let Some(devices) = self.devices.upgrade() { for fd_event_source in devices.borrow_mut().values_mut() { @@ -285,8 +285,7 @@ where if let Err(err) = udev.session.close(fd) { warn!( udev.logger, - "Failed to close dropped device. Error: {:?}. Ignoring", - err + "Failed to close dropped device. Error: {:?}. Ignoring", err ); }; } @@ -322,7 +321,7 @@ where }; } } - }, + } // New connector EventType::Change => { info!(udev.logger, "Device Changed"); @@ -341,14 +340,12 @@ where } else { info!(udev.logger, "changed, but no devnum"); } - }, + } _ => {} } } }, - error: |evlh, udev, _, err| { - udev.handler.error(evlh, err) - }, + error: |evlh, udev, _, err| udev.handler.error(evlh, err), } } @@ -370,9 +367,7 @@ pub trait UdevHandler + 'static> { /// /// ## Panics /// Panics if you try to borrow the token of the belonging `UdevBackend` using this `StateProxy`. - fn device_changed( - &mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice - ); + fn device_changed(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice); /// Called when a device was removed. /// /// The device will not accept any operations anymore and its file descriptor will be closed once @@ -380,9 +375,7 @@ pub trait UdevHandler + 'static> { /// /// ## Panics /// Panics if you try to borrow the token of the belonging `UdevBackend` using this `StateProxy`. - fn device_removed( - &mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice - ); + fn device_removed(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice); /// Called when the udev context has encountered and error. /// /// ## Panics