Code formatting
This commit is contained in:
parent
5d66f8fdb3
commit
4a2658090b
|
@ -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<DrmHandlerImpl> for UdevHandlerImpl {
|
|||
})
|
||||
}
|
||||
|
||||
fn device_changed(
|
||||
&mut self, _evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>
|
||||
) {
|
||||
fn device_changed(&mut self, _evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>) {
|
||||
//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<SessionFdDrmDevice>
|
||||
) {
|
||||
fn device_removed(&mut self, _evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>) {
|
||||
// drop the backends on this side
|
||||
self.backends.remove(&device.device_id());
|
||||
|
||||
|
|
|
@ -529,12 +529,15 @@ impl<A: ControlDevice + 'static> Drop for DrmDevice<A> {
|
|||
pub trait DrmHandler<A: ControlDevice + 'static> {
|
||||
/// 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<A>, crtc: crtc::Handle, frame: u32, duration: Duration);
|
||||
fn ready(
|
||||
&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice<A>, 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<A>, error: DrmError);
|
||||
fn error(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice<A>, error: DrmError);
|
||||
}
|
||||
|
||||
/// Bind a `DrmDevice` to an `EventLoop`,
|
||||
|
@ -622,8 +625,7 @@ impl<A: ControlDevice + 'static> AsSessionObserver<DrmDeviceObserver<A>> for Drm
|
|||
impl<A: ControlDevice + 'static> SessionObserver for DrmDeviceObserver<A> {
|
||||
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<A: ControlDevice + 'static> SessionObserver for DrmDeviceObserver<A> {
|
|||
|
||||
fn activate(&mut self, _evlh: &mut EventLoopHandle, devnum: Option<(u32, u32, Option<RawFd>)>) {
|
||||
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");
|
||||
|
|
|
@ -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<S: SessionObserver + 'static, A: AsSessionObserver<S>>(&mut self, signal: &mut A)
|
||||
-> Self::Id
|
||||
{
|
||||
fn register<S: SessionObserver + 'static, A: AsSessionObserver<S>>(
|
||||
&mut self, signal: &mut A
|
||||
) -> Self::Id {
|
||||
match self {
|
||||
#[cfg(feature = "backend_session_logind")]
|
||||
&mut AutoSessionNotifier::Logind(ref mut logind) => {
|
||||
|
|
|
@ -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<S: SessionObserver + 'static, A: AsSessionObserver<S>>(&mut self, signal: &mut A)
|
||||
-> Self::Id
|
||||
{
|
||||
fn register<S: SessionObserver + 'static, A: AsSessionObserver<S>>(
|
||||
&mut self, signal: &mut A
|
||||
) -> Self::Id {
|
||||
self.internal
|
||||
.signals
|
||||
.borrow_mut()
|
||||
|
|
|
@ -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<S: SessionObserver + 'static, A: AsSessionObserver<S>>(&mut self, signal: &mut A)
|
||||
-> Self::Id
|
||||
{
|
||||
fn register<S: SessionObserver + 'static, A: AsSessionObserver<S>>(
|
||||
&mut self, signal: &mut A
|
||||
) -> Self::Id {
|
||||
self.signals.push(Some(Box::new(signal.observer())));
|
||||
Id(self.signals.len() - 1)
|
||||
}
|
||||
|
|
|
@ -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<S: SessionObserver + 'static, A: AsSessionObserver<S>>(&mut self, signal: &mut A) -> Self::Id;
|
||||
fn register<S: SessionObserver + 'static, A: AsSessionObserver<S>>(&mut self, signal: &mut A)
|
||||
-> Self::Id;
|
||||
/// Removes an observer by its given id from `SessionNotifier::register`.
|
||||
fn unregister(&mut self, signal: Self::Id);
|
||||
|
||||
|
|
|
@ -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<SessionFdDrmDevice> + 'static,
|
||||
S: Session + 'static,
|
||||
T: UdevHandler<H> + 'static,
|
||||
> AsSessionObserver<UdevBackendObserver<H>> for UdevBackend<H, S, T> {
|
||||
> AsSessionObserver<UdevBackendObserver<H>> for UdevBackend<H, S, T>
|
||||
{
|
||||
fn observer(&mut self) -> UdevBackendObserver<H> {
|
||||
UdevBackendObserver {
|
||||
devices: Rc::downgrade(&self.devices),
|
||||
|
@ -180,8 +181,7 @@ impl<
|
|||
}
|
||||
}
|
||||
|
||||
impl<H: DrmHandler<SessionFdDrmDevice> + 'static> SessionObserver for UdevBackendObserver<H>
|
||||
{
|
||||
impl<H: DrmHandler<SessionFdDrmDevice> + 'static> SessionObserver for UdevBackendObserver<H> {
|
||||
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<H: DrmHandler<SessionFdDrmDevice> + '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<SessionFdDrmDevice>
|
||||
);
|
||||
fn device_changed(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>);
|
||||
/// 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<H: DrmHandler<SessionFdDrmDevice> + '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<SessionFdDrmDevice>
|
||||
);
|
||||
fn device_removed(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>);
|
||||
/// Called when the udev context has encountered and error.
|
||||
///
|
||||
/// ## Panics
|
||||
|
|
Loading…
Reference in New Issue