diff --git a/examples/udev.rs b/examples/udev.rs index 53deb7b..c6c227f 100644 --- a/examples/udev.rs +++ b/examples/udev.rs @@ -105,7 +105,9 @@ impl InputHandler for LibinputInputHandler { self.keyboard .input(keycode, state, serial, move |modifiers, keysym| { debug!(log, "keysym"; "state" => format!("{:?}", state), "mods" => format!("{:?}", modifiers), "keysym" => xkbcommon::xkb::keysym_get_name(keysym)); - if modifiers.ctrl && modifiers.alt && keysym == xkb::KEY_BackSpace && state == KeyState::Pressed { + if modifiers.ctrl && modifiers.alt && keysym == xkb::KEY_BackSpace + && state == KeyState::Pressed + { info!(log, "Stopping example using Ctrl+Alt+Backspace"); running.store(false, Ordering::SeqCst); false @@ -113,7 +115,9 @@ impl InputHandler for LibinputInputHandler { info!(log, "Stopping example using Logo+Q"); running.store(false, Ordering::SeqCst); false - } else if modifiers.ctrl && modifiers.alt && keysym == xkb::KEY_XF86Switch_VT_1 && state == KeyState::Pressed { + } else if modifiers.ctrl && modifiers.alt && keysym == xkb::KEY_XF86Switch_VT_1 + && state == KeyState::Pressed + { info!(log, "Trying to switch to vt 1"); if let Err(err) = session.change_vt(1) { error!(log, "Error switching to vt 1: {}", err); @@ -337,9 +341,8 @@ fn main() { /* * Initialize libinput backend */ - let mut libinput_context = Libinput::new_from_udev::< - LibinputSessionInterface, - >(session.clone().into(), &context); + let mut libinput_context = + Libinput::new_from_udev::>(session.clone().into(), &context); let libinput_session_id = notifier.register(libinput_context.clone()); libinput_context.udev_assign_seat(&seat).unwrap(); let mut libinput_backend = LibinputInputBackend::new(libinput_context, log.clone()); diff --git a/src/backend/drm/backend.rs b/src/backend/drm/backend.rs index 95f5223..72b537c 100644 --- a/src/backend/drm/backend.rs +++ b/src/backend/drm/backend.rs @@ -96,14 +96,17 @@ impl DrmBackend { })?; front_bo.set_userdata(fb).unwrap(); - let cursor = Cell::new((context - .create_buffer_object( - 1, - 1, - GbmFormat::ARGB8888, - BufferObjectFlags::CURSOR | BufferObjectFlags::WRITE, - ) - .chain_err(|| ErrorKind::GbmInitFailed)?, (0,0))); + let cursor = Cell::new(( + context + .create_buffer_object( + 1, + 1, + GbmFormat::ARGB8888, + BufferObjectFlags::CURSOR | BufferObjectFlags::WRITE, + ) + .chain_err(|| ErrorKind::GbmInitFailed)?, + (0, 0), + )); Ok(DrmBackend { backend: Rc::new(DrmBackendInternal { diff --git a/src/backend/drm/mod.rs b/src/backend/drm/mod.rs index 3a3d590..9a76cea 100644 --- a/src/backend/drm/mod.rs +++ b/src/backend/drm/mod.rs @@ -219,7 +219,7 @@ use drm::control::{connector, crtc, encoder, Mode, ResourceInfo}; use drm::control::Device as ControlDevice; use drm::control::framebuffer; use drm::result::Error as DrmError; -use gbm::{Device as GbmDevice, BufferObject}; +use gbm::{BufferObject, Device as GbmDevice}; use nix; use nix::sys::stat::{self, dev_t, fstat}; use std::collections::HashMap; @@ -328,7 +328,10 @@ impl DrmDevice { // we want to mode-set, so we better be the master, if we run via a tty session if let Err(_) = drm.set_master() { - warn!(log, "Unable to become drm master, assuming unpriviledged mode"); + warn!( + log, + "Unable to become drm master, assuming unpriviledged mode" + ); drm.priviledged = false; }; @@ -607,10 +610,10 @@ impl SessionObserver for StateToken> { fn pause<'a>(&mut self, state: &mut StateProxy<'a>, devnum: Option<(u32, u32)>) { let device = state.get_mut(self); if let Some((major, minor)) = devnum { - if major as u64 != stat::major(device.device_id) || - minor as u64 != stat::minor(device.device_id) { - return; - } + if major as u64 != stat::major(device.device_id) || minor as u64 != stat::minor(device.device_id) + { + return; + } } device.active = false; if device.priviledged { @@ -626,14 +629,14 @@ impl SessionObserver for StateToken> { fn activate<'a>(&mut self, state: &mut StateProxy<'a>, devnum: Option<(u32, u32, Option)>) { let device = state.get_mut(self); if let Some((major, minor, fd)) = devnum { - if major as u64 != stat::major(device.device_id) || - minor as u64 != stat::minor(device.device_id) + if major as u64 != stat::major(device.device_id) || minor as u64 != stat::minor(device.device_id) { - return; - } else if let Some(fd) = fd { - info!(device.logger, "Replacing fd"); - nix::unistd::dup2(device.as_raw_fd(), fd).expect("Failed to replace file descriptor of drm device"); - } + return; + } else if let Some(fd) = fd { + info!(device.logger, "Replacing fd"); + nix::unistd::dup2(device.as_raw_fd(), fd) + .expect("Failed to replace file descriptor of drm device"); + } } device.active = true; if device.priviledged { @@ -657,8 +660,8 @@ impl SessionObserver for StateToken> { } // reset cursor { - let &(ref cursor, ref hotspot) : &(BufferObject<()>, (u32, u32)) - = unsafe { &*backend.cursor.as_ptr() }; + let &(ref cursor, ref hotspot): &(BufferObject<()>, (u32, u32)) = + unsafe { &*backend.cursor.as_ptr() }; if crtc::set_cursor2( &*backend.context, *crtc, @@ -667,10 +670,7 @@ impl SessionObserver for StateToken> { ).is_err() { if let Err(err) = crtc::set_cursor(&*backend.context, *crtc, cursor) { - error!( - device.logger, - "Failed to reset cursor. Error: {}", err - ); + error!(device.logger, "Failed to reset cursor. Error: {}", err); } } } diff --git a/src/backend/session/auto.rs b/src/backend/session/auto.rs index b9bac5b..56c4e64 100644 --- a/src/backend/session/auto.rs +++ b/src/backend/session/auto.rs @@ -29,20 +29,19 @@ //! automatically by the `UdevBackend`, if not done manually). //! ``` -use std::io::{Result as IoResult}; -use std::rc::Rc; +use super::{AsErrno, 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}; +use nix::fcntl::OFlag; use std::cell::RefCell; +use std::io::Result as IoResult; use std::os::unix::io::RawFd; use std::path::Path; -use nix::fcntl::OFlag; -use wayland_server::{EventLoopHandle}; +use std::rc::Rc; +use wayland_server::EventLoopHandle; use wayland_server::sources::SignalEventSource; -use super::{Session, SessionNotifier, SessionObserver, AsErrno}; -#[cfg(feature = "backend_session_logind")] -use super::logind::{self, LogindSession, LogindSessionNotifier, BoundLogindSession, logind_session_bind}; -use super::direct::{self, DirectSession, DirectSessionNotifier, direct_session_bind}; - /// `Session` using the best available inteface #[derive(Clone)] pub enum AutoSession { @@ -80,8 +79,7 @@ pub enum BoundAutoSession { pub struct AutoId(AutoIdInternal); #[derive(PartialEq, Eq)] enum AutoIdInternal { - #[cfg(feature = "backend_session_logind")] - Logind(logind::Id), + #[cfg(feature = "backend_session_logind")] Logind(logind::Id), Direct(direct::Id), } @@ -89,22 +87,32 @@ impl AutoSession { /// Tries to create a new session via the best available interface. #[cfg(feature = "backend_session_logind")] pub fn new(logger: L) -> Option<(AutoSession, AutoSessionNotifier)> - where L: Into> + where + L: Into>, { let logger = ::slog_or_stdlog(logger) .new(o!("smithay_module" => "backend_session_auto", "session_type" => "auto")); info!(logger, "Trying to create logind session"); match LogindSession::new(logger.clone()) { - Ok((session, notifier)) => Some((AutoSession::Logind(session), AutoSessionNotifier::Logind(notifier))), + Ok((session, notifier)) => Some(( + AutoSession::Logind(session), + AutoSessionNotifier::Logind(notifier), + )), Err(err) => { warn!(logger, "Failed to create logind session: {}", err); info!(logger, "Falling back to create tty session"); match DirectSession::new(None, logger.clone()) { - Ok((session, notifier)) => Some((AutoSession::Direct(Rc::new(RefCell::new(session))), AutoSessionNotifier::Direct(notifier))), + Ok((session, notifier)) => Some(( + AutoSession::Direct(Rc::new(RefCell::new(session))), + AutoSessionNotifier::Direct(notifier), + )), Err(err) => { warn!(logger, "Failed to create direct session: {}", err); - error!(logger, "Could not create any session, possibilities exhausted"); + error!( + logger, + "Could not create any session, possibilities exhausted" + ); None } } @@ -114,17 +122,24 @@ impl AutoSession { #[cfg(not(feature = "backend_session_logind"))] pub fn new(logger: L) -> Option<(AutoSession, AutoSessionNotifier)> - where L: Into> + where + L: Into>, { let logger = ::slog_or_stdlog(logger) .new(o!("smithay_module" => "backend_session_auto", "session_type" => "auto")); info!(logger, "Trying to create tty session"); match DirectSession::new(None, logger.clone()) { - Ok((session, notifier)) => Some((AutoSession::Direct(Rc::new(RefCell::new(session))), AutoSessionNotifier::Direct(notifier))), + Ok((session, notifier)) => Some(( + AutoSession::Direct(Rc::new(RefCell::new(session))), + AutoSessionNotifier::Direct(notifier), + )), Err(err) => { warn!(logger, "Failed to create direct session: {}", err); - error!(logger, "Could not create any session, possibilities exhausted"); + error!( + logger, + "Could not create any session, possibilities exhausted" + ); None } } @@ -136,7 +151,9 @@ impl AutoSession { /// Allows the `AutoSessionNotifier` to listen for incoming signals signalling the session state. /// If you don't use this function `AutoSessionNotifier` will not correctly tell you the /// session state and call it's `SessionObservers`. -pub fn auto_session_bind(notifier: AutoSessionNotifier, evlh: &mut EventLoopHandle) -> IoResult { +pub fn auto_session_bind( + notifier: AutoSessionNotifier, evlh: &mut EventLoopHandle +) -> IoResult { Ok(match notifier { #[cfg(feature = "backend_session_logind")] AutoSessionNotifier::Logind(logind) => BoundAutoSession::Logind(logind_session_bind(logind, evlh)?), @@ -192,15 +209,23 @@ impl SessionNotifier for AutoSessionNotifier { fn register(&mut self, signal: S) -> Self::Id { match self { #[cfg(feature = "backend_session_logind")] - &mut AutoSessionNotifier::Logind(ref mut logind) => AutoId(AutoIdInternal::Logind(logind.register(signal))), - &mut AutoSessionNotifier::Direct(ref mut direct) => AutoId(AutoIdInternal::Direct(direct.register(signal))), + &mut AutoSessionNotifier::Logind(ref mut logind) => { + AutoId(AutoIdInternal::Logind(logind.register(signal))) + } + &mut AutoSessionNotifier::Direct(ref mut direct) => { + AutoId(AutoIdInternal::Direct(direct.register(signal))) + } } } fn unregister(&mut self, signal: Self::Id) { match (self, signal) { #[cfg(feature = "backend_session_logind")] - (&mut AutoSessionNotifier::Logind(ref mut logind), AutoId(AutoIdInternal::Logind(signal))) => logind.unregister(signal), - (&mut AutoSessionNotifier::Direct(ref mut direct), AutoId(AutoIdInternal::Direct(signal))) => direct.unregister(signal), + (&mut AutoSessionNotifier::Logind(ref mut logind), AutoId(AutoIdInternal::Logind(signal))) => { + logind.unregister(signal) + } + (&mut AutoSessionNotifier::Direct(ref mut direct), AutoId(AutoIdInternal::Direct(signal))) => { + direct.unregister(signal) + } _ => unreachable!(), } } diff --git a/src/backend/session/dbus/logind.rs b/src/backend/session/dbus/logind.rs index 4aa415f..84918a3 100644 --- a/src/backend/session/dbus/logind.rs +++ b/src/backend/session/dbus/logind.rs @@ -30,17 +30,18 @@ //! automatically by the `UdevBackend`, if not done manually). //! ``` -use ::backend::session::{AsErrno, Session, SessionNotifier, SessionObserver}; +use backend::session::{AsErrno, Session, SessionNotifier, SessionObserver}; +use dbus::{BusName, BusType, Connection, ConnectionItem, ConnectionItems, Interface, Member, Message, + MessageItem, OwnedFd, Path as DbusPath, Watch, WatchEvent}; use nix::fcntl::OFlag; -use nix::sys::stat::{stat, fstat, major, minor}; +use nix::sys::stat::{fstat, major, minor, stat}; use std::cell::RefCell; use std::io::Result as IoResult; use std::os::unix::io::RawFd; -use std::rc::{Rc, Weak}; use std::path::Path; +use std::rc::{Rc, Weak}; use std::sync::atomic::{AtomicBool, Ordering}; use systemd::login; -use dbus::{BusType, Connection, ConnectionItems, ConnectionItem, Message, BusName, Interface, Member, Path as DbusPath, OwnedFd, MessageItem, Watch, WatchEvent}; use wayland_server::EventLoopHandle; use wayland_server::sources::{FdEventSource, FdEventSourceImpl, FdInterest}; @@ -62,14 +63,14 @@ pub struct LogindSession { /// `SessionNotifier` via the logind dbus interface pub struct LogindSessionNotifier { - internal: Rc + internal: Rc, } impl LogindSession { /// Tries to create a new session via the logind dbus interface. pub fn new(logger: L) -> Result<(LogindSession, LogindSessionNotifier)> where - L: Into> + L: Into>, { let logger = ::slog_or_stdlog(logger) .new(o!("smithay_module" => "backend_session", "session_type" => "logind")); @@ -88,35 +89,50 @@ impl LogindSession { "/org/freedesktop/login1", "org.freedesktop.login1.Manager", "GetSession", - Some(vec![session_id.clone().into()]) + Some(vec![session_id.clone().into()]), )?.get1::>() - .chain_err(|| ErrorKind::UnexpectedMethodReturn)?; + .chain_err(|| ErrorKind::UnexpectedMethodReturn)?; // Match all signals that we want to receive and handle - let match1 = String::from("type='signal',\ - sender='org.freedesktop.login1',\ - interface='org.freedesktop.login1.Manager',\ - member='SessionRemoved',\ - path='/org/freedesktop/login1'"); - conn.add_match(&match1).chain_err(|| ErrorKind::DbusMatchFailed(match1))?; - let match2 = format!("type='signal',\ - sender='org.freedesktop.login1',\ - interface='org.freedesktop.login1.Session',\ - member='PauseDevice',\ - path='{}'", &session_path); - conn.add_match(&match2).chain_err(|| ErrorKind::DbusMatchFailed(match2))?; - let match3 = format!("type='signal',\ - sender='org.freedesktop.login1',\ - interface='org.freedesktop.login1.Session',\ - member='ResumeDevice',\ - path='{}'", &session_path); - conn.add_match(&match3).chain_err(|| ErrorKind::DbusMatchFailed(match3))?; - let match4 = format!("type='signal',\ - sender='org.freedesktop.login1',\ - interface='org.freedesktop.DBus.Properties',\ - member='PropertiesChanged',\ - path='{}'", &session_path); - conn.add_match(&match4).chain_err(|| ErrorKind::DbusMatchFailed(match4))?; + let match1 = String::from( + "type='signal',\ + sender='org.freedesktop.login1',\ + interface='org.freedesktop.login1.Manager',\ + member='SessionRemoved',\ + path='/org/freedesktop/login1'", + ); + conn.add_match(&match1) + .chain_err(|| ErrorKind::DbusMatchFailed(match1))?; + let match2 = format!( + "type='signal',\ + sender='org.freedesktop.login1',\ + interface='org.freedesktop.login1.Session',\ + member='PauseDevice',\ + path='{}'", + &session_path + ); + conn.add_match(&match2) + .chain_err(|| ErrorKind::DbusMatchFailed(match2))?; + let match3 = format!( + "type='signal',\ + sender='org.freedesktop.login1',\ + interface='org.freedesktop.login1.Session',\ + member='ResumeDevice',\ + path='{}'", + &session_path + ); + conn.add_match(&match3) + .chain_err(|| ErrorKind::DbusMatchFailed(match3))?; + let match4 = format!( + "type='signal',\ + sender='org.freedesktop.login1',\ + interface='org.freedesktop.DBus.Properties',\ + member='PropertiesChanged',\ + path='{}'", + &session_path + ); + conn.add_match(&match4) + .chain_err(|| ErrorKind::DbusMatchFailed(match4))?; // Activate (switch to) the session and take control LogindSessionImpl::blocking_call( @@ -153,9 +169,7 @@ impl LogindSession { internal: Rc::downgrade(&internal), seat, }, - LogindSessionNotifier { - internal, - } + LogindSessionNotifier { internal }, )) } } @@ -171,14 +185,9 @@ impl LogindSessionNotifier { } impl LogindSessionImpl { - fn blocking_call<'d, 'p, 'i, 'm, D, P, I, M> - ( - conn: &Connection, - destination: D, - path: P, - interface: I, - method: M, - arguments: Option> + fn blocking_call<'d, 'p, 'i, 'm, D, P, I, M>( + conn: &Connection, destination: D, path: P, interface: I, method: M, + arguments: Option>, ) -> Result where D: Into>, @@ -198,21 +207,26 @@ impl LogindSessionImpl { }; let mut message = conn.send_with_reply_and_block(message, 1000) - .chain_err(|| ErrorKind::FailedToSendDbusCall( - destination.clone(), - path.clone(), - interface.clone(), - method.clone() - ))?; + .chain_err(|| { + ErrorKind::FailedToSendDbusCall( + destination.clone(), + path.clone(), + interface.clone(), + method.clone(), + ) + })?; match message.as_result() { Ok(_) => Ok(message), - Err(err) => Err(Error::with_chain(err, ErrorKind::DbusCallFailed( - destination.clone(), - path.clone(), - interface.clone(), - method.clone() - ))) + Err(err) => Err(Error::with_chain( + err, + ErrorKind::DbusCallFailed( + destination.clone(), + path.clone(), + interface.clone(), + method.clone(), + ), + )), } } @@ -221,7 +235,7 @@ impl LogindSessionImpl { let message = if let ConnectionItem::Signal(ref s) = item { s } else { - continue + continue; }; if &*message.interface().unwrap() == "org.freedesktop.login1.Manager" && &*message.member().unwrap() == "SessionRemoved" @@ -243,7 +257,10 @@ impl LogindSessionImpl { let major = major.chain_err(|| ErrorKind::UnexpectedMethodReturn)?; let minor = minor.chain_err(|| ErrorKind::UnexpectedMethodReturn)?; let pause_type = pause_type.chain_err(|| ErrorKind::UnexpectedMethodReturn)?; - debug!(self.logger, "Request of type \"{}\" to close device ({},{})", pause_type, major, minor); + debug!( + self.logger, + "Request of type \"{}\" to close device ({},{})", pause_type, major, minor + ); for signal in &mut *self.signals.borrow_mut() { if let &mut Some(ref mut signal) = signal { signal.pause(&mut evlh.state().as_proxy(), Some((major, minor))); @@ -260,14 +277,15 @@ impl LogindSessionImpl { self.session_path.clone(), "org.freedesktop.login1.Session", "PauseDeviceComplete", - Some(vec![major.into(), minor.into()]) + Some(vec![major.into(), minor.into()]), )?; } } else if &*message.member().unwrap() == "ResumeDevice" { let (major, minor, fd) = message.get3::(); let major = major.chain_err(|| ErrorKind::UnexpectedMethodReturn)?; let minor = minor.chain_err(|| ErrorKind::UnexpectedMethodReturn)?; - let fd = fd.chain_err(|| ErrorKind::UnexpectedMethodReturn)?.into_fd(); + let fd = fd.chain_err(|| ErrorKind::UnexpectedMethodReturn)? + .into_fd(); debug!(self.logger, "Reactivating device ({},{})", major, minor); for signal in &mut *self.signals.borrow_mut() { if let &mut Some(ref mut signal) = signal { @@ -278,9 +296,10 @@ impl LogindSessionImpl { } else if &*message.interface().unwrap() == "org.freedesktop.DBus.Properties" && &*message.member().unwrap() == "PropertiesChanged" { - use dbus::arg::{Array, Dict, Iter, Variant, Get}; + use dbus::arg::{Array, Dict, Get, Iter, Variant}; - let (_, changed, _) = message.get3::, Iter>, Array>(); + let (_, changed, _) = + message.get3::, Iter>, Array>(); let mut changed = changed.chain_err(|| ErrorKind::UnexpectedMethodReturn)?; if let Some((_, mut value)) = changed.find(|&(ref key, _)| &*key == "Active") { if let Some(active) = Get::get(&mut value.0) { @@ -303,15 +322,16 @@ impl Session for LogindSession { let (fd, _paused) = LogindSessionImpl::blocking_call( &*session.conn.borrow(), "org.freedesktop.login1", - session.session_path.clone(), + session.session_path.clone(), "org.freedesktop.login1.Session", "TakeDevice", Some(vec![ (major(stat.st_rdev) as u32).into(), (minor(stat.st_rdev) as u32).into(), - ]) + ]), )?.get2::(); - let fd = fd.chain_err(|| ErrorKind::UnexpectedMethodReturn)?.into_fd(); + let fd = fd.chain_err(|| ErrorKind::UnexpectedMethodReturn)? + .into_fd(); Ok(fd) } else { bail!(ErrorKind::SessionLost) @@ -324,13 +344,13 @@ impl Session for LogindSession { LogindSessionImpl::blocking_call( &*session.conn.borrow(), "org.freedesktop.login1", - session.session_path.clone(), + session.session_path.clone(), "org.freedesktop.login1.Session", "ReleaseDevice", Some(vec![ (major(stat.st_rdev) as u32).into(), (minor(stat.st_rdev) as u32).into(), - ]) + ]), ).map(|_| ()) } else { bail!(ErrorKind::SessionLost) @@ -354,12 +374,10 @@ impl Session for LogindSession { LogindSessionImpl::blocking_call( &*session.conn.borrow_mut(), "org.freedesktop.login1", - "/org/freedesktop/login1/seat/self", + "/org/freedesktop/login1/seat/self", "org.freedesktop.login1.Seat", "SwitchTo", - Some(vec![ - (vt_num as u32).into(), - ]) + Some(vec![(vt_num as u32).into()]), ).map(|_| ()) } else { bail!(ErrorKind::SessionLost) @@ -375,7 +393,10 @@ impl SessionNotifier for LogindSessionNotifier { type Id = Id; fn register(&mut self, signal: S) -> Id { - self.internal.signals.borrow_mut().push(Some(Box::new(signal))); + self.internal + .signals + .borrow_mut() + .push(Some(Box::new(signal))); Id(self.internal.signals.borrow().len() - 1) } fn unregister(&mut self, signal: Id) { @@ -409,20 +430,23 @@ pub struct BoundLogindSession { /// session state and call it's `SessionObservers`. pub fn logind_session_bind( notifier: LogindSessionNotifier, evlh: &mut EventLoopHandle -) -> IoResult -{ +) -> IoResult { let watches = notifier.internal.conn.borrow().watch_fds(); - let sources = watches.clone().into_iter().map(|watch| { - let mut interest = FdInterest::empty(); - interest.set(FdInterest::READ, watch.readable()); - interest.set(FdInterest::WRITE, watch.writable()); - evlh.add_fd_event_source( - watch.fd(), - fd_event_source_implementation(), - notifier.internal.clone(), - interest - ) - }).collect::>>>>()?; + let sources = watches + .clone() + .into_iter() + .map(|watch| { + let mut interest = FdInterest::empty(); + interest.set(FdInterest::READ, watch.readable()); + interest.set(FdInterest::WRITE, watch.writable()); + evlh.add_fd_event_source( + watch.fd(), + fd_event_source_implementation(), + notifier.internal.clone(), + interest, + ) + }) + .collect::>>>>()?; Ok(BoundLogindSession { notifier, @@ -460,13 +484,17 @@ fn fd_event_source_implementation() -> FdEventSourceImpl> FdEventSourceImpl { ready: |evlh, session, fd, interest| { let conn = session.conn.borrow(); - let items = conn.watch_handle(fd, match interest { - x if x.contains(FdInterest::READ) && x.contains(FdInterest::WRITE) => - WatchEvent::Readable as u32 | WatchEvent::Writable as u32, - x if x.contains(FdInterest::READ) => WatchEvent::Readable as u32, - x if x.contains(FdInterest::WRITE) => WatchEvent::Writable as u32, - _ => return, - }); + let items = conn.watch_handle( + fd, + match interest { + x if x.contains(FdInterest::READ) && x.contains(FdInterest::WRITE) => { + WatchEvent::Readable as u32 | WatchEvent::Writable as u32 + } + x if x.contains(FdInterest::READ) => WatchEvent::Readable as u32, + x if x.contains(FdInterest::WRITE) => WatchEvent::Writable as u32, + _ => return, + }, + ); if let Err(err) = session.handle_signals(evlh, items) { error!(session.logger, "Error handling dbus signals: {}", err); } diff --git a/src/backend/udev.rs b/src/backend/udev.rs index c90936f..aad9472 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -178,7 +178,8 @@ impl< H: DrmHandler + 'static, S: Session + 'static, T: UdevHandler + 'static, -> SessionObserver for StateToken> { +> SessionObserver for StateToken> +{ fn pause<'a>(&mut self, state: &mut StateProxy<'a>, devnum: Option<(u32, u32)>) { state.with_value(self, |state, udev| { for &mut (ref mut device, _) in udev.devices.values_mut() { diff --git a/src/lib.rs b/src/lib.rs index b5f4b4d..ec1d923 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,18 +16,18 @@ extern crate wayland_server; extern crate wayland_sys; extern crate xkbcommon; +#[cfg(feature = "dbus")] +extern crate dbus; #[cfg(feature = "backend_drm")] extern crate drm; #[cfg(feature = "backend_drm")] extern crate gbm; #[cfg(feature = "backend_libinput")] extern crate input; -#[cfg(feature = "udev")] -extern crate udev; -#[cfg(feature = "dbus")] -extern crate dbus; #[cfg(feature = "backend_session_logind")] extern crate systemd; +#[cfg(feature = "udev")] +extern crate udev; #[cfg(feature = "backend_winit")] extern crate wayland_client; #[cfg(feature = "backend_winit")]