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::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use wayland_server::{Display, EventLoopHandle};
|
use wayland_server::{Display, EventLoopHandle};
|
||||||
use wayland_server::sources::EventSource;
|
|
||||||
use wayland_server::protocol::{wl_output, wl_pointer};
|
use wayland_server::protocol::{wl_output, wl_pointer};
|
||||||
|
use wayland_server::sources::EventSource;
|
||||||
use xkbcommon::xkb::keysyms as xkb;
|
use xkbcommon::xkb::keysyms as xkb;
|
||||||
|
|
||||||
struct LibinputInputHandler {
|
struct LibinputInputHandler {
|
||||||
|
@ -475,17 +475,13 @@ impl UdevHandler<DrmHandlerImpl> for UdevHandlerImpl {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_changed(
|
fn device_changed(&mut self, _evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>) {
|
||||||
&mut self, _evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>
|
|
||||||
) {
|
|
||||||
//quick and dirt, just re-init all backends
|
//quick and dirt, just re-init all backends
|
||||||
let backends = self.backends.get(&device.device_id()).unwrap();
|
let backends = self.backends.get(&device.device_id()).unwrap();
|
||||||
*backends.borrow_mut() = self.scan_connectors(device);
|
*backends.borrow_mut() = self.scan_connectors(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn device_removed(
|
fn device_removed(&mut self, _evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>) {
|
||||||
&mut self, _evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>
|
|
||||||
) {
|
|
||||||
// drop the backends on this side
|
// drop the backends on this side
|
||||||
self.backends.remove(&device.device_id());
|
self.backends.remove(&device.device_id());
|
||||||
|
|
||||||
|
|
|
@ -529,12 +529,15 @@ impl<A: ControlDevice + 'static> Drop for DrmDevice<A> {
|
||||||
pub trait DrmHandler<A: ControlDevice + 'static> {
|
pub trait DrmHandler<A: ControlDevice + 'static> {
|
||||||
/// The `DrmBackend` of crtc has finished swapping buffers and new frame can now
|
/// The `DrmBackend` of crtc has finished swapping buffers and new frame can now
|
||||||
/// (and should be immediately) be rendered.
|
/// (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 `DrmDevice` has thrown an error.
|
||||||
///
|
///
|
||||||
/// The related backends are most likely *not* usable anymore and
|
/// The related backends are most likely *not* usable anymore and
|
||||||
/// the whole stack has to be recreated..
|
/// 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`,
|
/// 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> {
|
impl<A: ControlDevice + 'static> SessionObserver for DrmDeviceObserver<A> {
|
||||||
fn pause(&mut self, _evlh: &mut EventLoopHandle, devnum: Option<(u32, u32)>) {
|
fn pause(&mut self, _evlh: &mut EventLoopHandle, devnum: Option<(u32, u32)>) {
|
||||||
if let Some((major, minor)) = devnum {
|
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;
|
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>)>) {
|
fn activate(&mut self, _evlh: &mut EventLoopHandle, devnum: Option<(u32, u32, Option<RawFd>)>) {
|
||||||
if let Some((major, minor, fd)) = devnum {
|
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;
|
return;
|
||||||
} else if let Some(fd) = fd {
|
} else if let Some(fd) = fd {
|
||||||
info!(self.logger, "Replacing fd");
|
info!(self.logger, "Replacing fd");
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
//! automatically by the `UdevBackend`, if not done manually).
|
//! 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};
|
use super::direct::{self, direct_session_bind, DirectSession, DirectSessionNotifier};
|
||||||
#[cfg(feature = "backend_session_logind")]
|
#[cfg(feature = "backend_session_logind")]
|
||||||
use super::logind::{self, logind_session_bind, BoundLogindSession, LogindSession, LogindSessionNotifier};
|
use super::logind::{self, logind_session_bind, BoundLogindSession, LogindSession, LogindSessionNotifier};
|
||||||
|
@ -207,9 +207,9 @@ impl Session for AutoSession {
|
||||||
impl SessionNotifier for AutoSessionNotifier {
|
impl SessionNotifier for AutoSessionNotifier {
|
||||||
type Id = AutoId;
|
type Id = AutoId;
|
||||||
|
|
||||||
fn register<S: SessionObserver + 'static, A: AsSessionObserver<S>>(&mut self, signal: &mut A)
|
fn register<S: SessionObserver + 'static, A: AsSessionObserver<S>>(
|
||||||
-> Self::Id
|
&mut self, signal: &mut A
|
||||||
{
|
) -> Self::Id {
|
||||||
match self {
|
match self {
|
||||||
#[cfg(feature = "backend_session_logind")]
|
#[cfg(feature = "backend_session_logind")]
|
||||||
&mut AutoSessionNotifier::Logind(ref mut logind) => {
|
&mut AutoSessionNotifier::Logind(ref mut logind) => {
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
//! automatically by the `UdevBackend`, if not done manually).
|
//! 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,
|
use dbus::{BusName, BusType, Connection, ConnectionItem, ConnectionItems, Interface, Member, Message,
|
||||||
MessageItem, OwnedFd, Path as DbusPath, Watch, WatchEvent};
|
MessageItem, OwnedFd, Path as DbusPath, Watch, WatchEvent};
|
||||||
use nix::fcntl::OFlag;
|
use nix::fcntl::OFlag;
|
||||||
|
@ -392,9 +392,9 @@ pub struct Id(usize);
|
||||||
impl SessionNotifier for LogindSessionNotifier {
|
impl SessionNotifier for LogindSessionNotifier {
|
||||||
type Id = Id;
|
type Id = Id;
|
||||||
|
|
||||||
fn register<S: SessionObserver + 'static, A: AsSessionObserver<S>>(&mut self, signal: &mut A)
|
fn register<S: SessionObserver + 'static, A: AsSessionObserver<S>>(
|
||||||
-> Self::Id
|
&mut self, signal: &mut A
|
||||||
{
|
) -> Self::Id {
|
||||||
self.internal
|
self.internal
|
||||||
.signals
|
.signals
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
//! for notifications are the `Libinput` context, the `UdevBackend` or a `DrmDevice` (handled
|
//! for notifications are the `Libinput` context, the `UdevBackend` or a `DrmDevice` (handled
|
||||||
//! automatically by the `UdevBackend`, if not done manually).
|
//! 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::{Error as NixError, Result as NixResult};
|
||||||
use nix::fcntl::{self, open, OFlag};
|
use nix::fcntl::{self, open, OFlag};
|
||||||
use nix::libc::c_int;
|
use nix::libc::c_int;
|
||||||
|
@ -344,9 +344,9 @@ pub struct Id(usize);
|
||||||
impl SessionNotifier for DirectSessionNotifier {
|
impl SessionNotifier for DirectSessionNotifier {
|
||||||
type Id = Id;
|
type Id = Id;
|
||||||
|
|
||||||
fn register<S: SessionObserver + 'static, A: AsSessionObserver<S>>(&mut self, signal: &mut A)
|
fn register<S: SessionObserver + 'static, A: AsSessionObserver<S>>(
|
||||||
-> Self::Id
|
&mut self, signal: &mut A
|
||||||
{
|
) -> Self::Id {
|
||||||
self.signals.push(Some(Box::new(signal.observer())));
|
self.signals.push(Some(Box::new(signal.observer())));
|
||||||
Id(self.signals.len() - 1)
|
Id(self.signals.len() - 1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,8 @@ pub trait SessionNotifier {
|
||||||
/// Registers a given `SessionObserver`.
|
/// Registers a given `SessionObserver`.
|
||||||
///
|
///
|
||||||
/// Returns an id of the inserted observer, can be used to remove it again.
|
/// 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`.
|
/// Removes an observer by its given id from `SessionNotifier::register`.
|
||||||
fn unregister(&mut self, signal: Self::Id);
|
fn unregister(&mut self, signal: Self::Id);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
//! backend.
|
//! backend.
|
||||||
|
|
||||||
use backend::drm::{drm_device_bind, DrmDevice, DrmHandler};
|
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::Device as BasicDevice;
|
||||||
use drm::control::Device as ControlDevice;
|
use drm::control::Device as ControlDevice;
|
||||||
use nix::fcntl;
|
use nix::fcntl;
|
||||||
|
@ -171,7 +171,8 @@ impl<
|
||||||
H: DrmHandler<SessionFdDrmDevice> + 'static,
|
H: DrmHandler<SessionFdDrmDevice> + 'static,
|
||||||
S: Session + 'static,
|
S: Session + 'static,
|
||||||
T: UdevHandler<H> + '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> {
|
fn observer(&mut self) -> UdevBackendObserver<H> {
|
||||||
UdevBackendObserver {
|
UdevBackendObserver {
|
||||||
devices: Rc::downgrade(&self.devices),
|
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)>) {
|
fn pause<'a>(&mut self, evlh: &mut EventLoopHandle, devnum: Option<(u32, u32)>) {
|
||||||
if let Some(devices) = self.devices.upgrade() {
|
if let Some(devices) = self.devices.upgrade() {
|
||||||
for fd_event_source in devices.borrow_mut().values_mut() {
|
for fd_event_source in devices.borrow_mut().values_mut() {
|
||||||
|
@ -285,8 +285,7 @@ where
|
||||||
if let Err(err) = udev.session.close(fd) {
|
if let Err(err) = udev.session.close(fd) {
|
||||||
warn!(
|
warn!(
|
||||||
udev.logger,
|
udev.logger,
|
||||||
"Failed to close dropped device. Error: {:?}. Ignoring",
|
"Failed to close dropped device. Error: {:?}. Ignoring", err
|
||||||
err
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -322,7 +321,7 @@ where
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
// New connector
|
// New connector
|
||||||
EventType::Change => {
|
EventType::Change => {
|
||||||
info!(udev.logger, "Device Changed");
|
info!(udev.logger, "Device Changed");
|
||||||
|
@ -341,14 +340,12 @@ where
|
||||||
} else {
|
} else {
|
||||||
info!(udev.logger, "changed, but no devnum");
|
info!(udev.logger, "changed, but no devnum");
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: |evlh, udev, _, err| {
|
error: |evlh, udev, _, err| udev.handler.error(evlh, err),
|
||||||
udev.handler.error(evlh, err)
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,9 +367,7 @@ pub trait UdevHandler<H: DrmHandler<SessionFdDrmDevice> + 'static> {
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
/// Panics if you try to borrow the token of the belonging `UdevBackend` using this `StateProxy`.
|
/// Panics if you try to borrow the token of the belonging `UdevBackend` using this `StateProxy`.
|
||||||
fn device_changed(
|
fn device_changed(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>);
|
||||||
&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>
|
|
||||||
);
|
|
||||||
/// Called when a device was removed.
|
/// Called when a device was removed.
|
||||||
///
|
///
|
||||||
/// The device will not accept any operations anymore and its file descriptor will be closed once
|
/// 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
|
||||||
/// Panics if you try to borrow the token of the belonging `UdevBackend` using this `StateProxy`.
|
/// Panics if you try to borrow the token of the belonging `UdevBackend` using this `StateProxy`.
|
||||||
fn device_removed(
|
fn device_removed(&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>);
|
||||||
&mut self, evlh: &mut EventLoopHandle, device: &mut DrmDevice<SessionFdDrmDevice>
|
|
||||||
);
|
|
||||||
/// Called when the udev context has encountered and error.
|
/// Called when the udev context has encountered and error.
|
||||||
///
|
///
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
|
|
Loading…
Reference in New Issue