From aaa6e625e912af742cef006a42bfe3e9fe91bca8 Mon Sep 17 00:00:00 2001 From: Victor Berger Date: Sun, 30 May 2021 22:01:36 +0200 Subject: [PATCH] Update to calloop 0.8, DrmDevice as an EventSource --- Cargo.toml | 4 +- anvil/src/input_handler.rs | 2 +- anvil/src/main.rs | 7 +- anvil/src/state.rs | 25 ++--- anvil/src/udev.rs | 104 ++++++++++-------- anvil/src/winit.rs | 10 +- anvil/src/xwayland/mod.rs | 10 +- anvil/src/xwayland/x11rb_event_source.rs | 2 +- examples/raw_drm.rs | 28 +++-- src/backend/drm/device/mod.rs | 134 ++++++++++------------- src/backend/drm/mod.rs | 2 +- src/backend/libinput/mod.rs | 4 +- src/backend/session/dbus/mod.rs | 6 +- src/backend/udev.rs | 6 +- src/xwayland/xserver.rs | 12 +- 15 files changed, 175 insertions(+), 181 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b885012..da14c56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ members = [ "anvil" ] [dependencies] bitflags = "1" -calloop = "0.6.2" +calloop = {version = "0.8.0" } cgmath = "0.18.0" dbus = { version = "0.9.0", optional = true } drm-fourcc = "^2.1.1" @@ -35,7 +35,7 @@ wayland-egl = { version = "0.28", optional = true } wayland-protocols = { version = "0.28", features = ["unstable_protocols", "server"], optional = true } wayland-server = { version = "0.28.3", optional = true } wayland-sys = { version = "0.28", optional = true } -winit = { version = "0.24.0", optional = true } +winit = { version = "0.25.0", optional = true } xkbcommon = "0.4.0" scan_fmt = { version = "0.2", default-features = false } diff --git a/anvil/src/input_handler.rs b/anvil/src/input_handler.rs index 46940bd..e05fcb6 100644 --- a/anvil/src/input_handler.rs +++ b/anvil/src/input_handler.rs @@ -16,7 +16,7 @@ use smithay::{ }, }; -impl AnvilState { +impl AnvilState { pub fn process_input_event(&mut self, event: InputEvent) { match event { InputEvent::Keyboard { event, .. } => self.on_keyboard_key::(event), diff --git a/anvil/src/main.rs b/anvil/src/main.rs index e1e72cb..4de14bc 100644 --- a/anvil/src/main.rs +++ b/anvil/src/main.rs @@ -39,14 +39,13 @@ fn main() { o!(), ); - let mut event_loop = EventLoop::::new().unwrap(); - let display = Rc::new(RefCell::new(Display::new())); - let arg = ::std::env::args().nth(1); match arg.as_ref().map(|s| &s[..]) { #[cfg(feature = "winit")] Some("--winit") => { info!(log, "Starting anvil with winit backend"); + let mut event_loop = EventLoop::try_new().unwrap(); + let display = Rc::new(RefCell::new(Display::new())); if let Err(()) = winit::run_winit(display, &mut event_loop, log.clone()) { crit!(log, "Failed to initialize winit backend."); } @@ -54,6 +53,8 @@ fn main() { #[cfg(feature = "udev")] Some("--tty-udev") => { info!(log, "Starting anvil on a tty using udev"); + let mut event_loop = EventLoop::try_new().unwrap(); + let display = Rc::new(RefCell::new(Display::new())); if let Err(()) = udev::run_udev(display, &mut event_loop, log.clone()) { crit!(log, "Failed to initialize tty backend."); } diff --git a/anvil/src/state.rs b/anvil/src/state.rs index 2d377f2..24d358d 100644 --- a/anvil/src/state.rs +++ b/anvil/src/state.rs @@ -9,10 +9,7 @@ use std::{ use smithay::{ reexports::{ - calloop::{ - generic::{Fd, Generic}, - Interest, LoopHandle, Mode, Source, - }, + calloop::{generic::Generic, Interest, LoopHandle, Mode, RegistrationToken}, wayland_server::{protocol::wl_surface::WlSurface, Display}, }, wayland::{ @@ -36,11 +33,12 @@ use crate::udev::MyOutput; #[cfg(feature = "xwayland")] use crate::xwayland::XWm; -pub struct AnvilState { +pub struct AnvilState { + pub backend: Backend, pub socket_name: String, pub running: Arc, pub display: Rc>, - pub handle: LoopHandle, + pub handle: LoopHandle<'static, AnvilState>, pub ctoken: CompositorToken, pub window_map: Rc>>, pub dnd_icon: Arc>>, @@ -56,30 +54,30 @@ pub struct AnvilState { #[cfg(feature = "udev")] pub session: Option, // things we must keep alive - _wayland_event_source: Source>, + _wayland_event_source: RegistrationToken, #[cfg(feature = "xwayland")] - _xwayland: XWayland, + _xwayland: XWayland>, } -impl AnvilState { +impl AnvilState { pub fn init( display: Rc>, - handle: LoopHandle, + handle: LoopHandle<'static, AnvilState>, #[cfg(feature = "egl")] egl_reader: Rc>>, #[cfg(feature = "udev")] session: Option, #[cfg(not(feature = "udev"))] _session: Option<()>, #[cfg(feature = "udev")] output_map: Option>>>, #[cfg(not(feature = "udev"))] _output_map: Option<()>, log: slog::Logger, - ) -> AnvilState { + ) -> AnvilState { // init the wayland connection let _wayland_event_source = handle .insert_source( - Generic::from_fd(display.borrow().get_poll_fd(), Interest::Readable, Mode::Level), + Generic::from_fd(display.borrow().get_poll_fd(), Interest::READ, Mode::Level), { let display = display.clone(); let log = log.clone(); - move |_, _, state: &mut AnvilState| { + move |_, _, state: &mut AnvilState| { let mut display = display.borrow_mut(); match display.dispatch(std::time::Duration::from_millis(0), state) { Ok(_) => Ok(()), @@ -176,6 +174,7 @@ impl AnvilState { }; AnvilState { + backend: Default::default(), running: Arc::new(AtomicBool::new(true)), display, handle, diff --git a/anvil/src/udev.rs b/anvil/src/udev.rs index 1adeadd..34cfcdf 100644 --- a/anvil/src/udev.rs +++ b/anvil/src/udev.rs @@ -16,7 +16,7 @@ use slog::Logger; use smithay::backend::{drm::DevPath, egl::display::EGLBufferReader, udev::primary_gpu}; use smithay::{ backend::{ - drm::{device_bind, DeviceHandler, DrmDevice, DrmError, DrmRenderSurface}, + drm::{DrmDevice, DrmError, DrmEvent, DrmRenderSurface}, egl::{EGLContext, EGLDisplay}, libinput::{LibinputInputBackend, LibinputSessionInterface}, renderer::{ @@ -29,9 +29,8 @@ use smithay::{ }, reexports::{ calloop::{ - generic::Generic, timer::{Timer, TimerHandle}, - EventLoop, LoopHandle, Source, + Dispatcher, EventLoop, LoopHandle, RegistrationToken, }, drm::{ self, @@ -71,9 +70,17 @@ impl AsRawFd for SessionFd { } } +pub struct UdevData {} + +impl Default for UdevData { + fn default() -> UdevData { + UdevData {} + } +} + pub fn run_udev( display: Rc>, - event_loop: &mut EventLoop, + event_loop: &mut EventLoop<'static, AnvilState>, log: Logger, ) -> Result<(), ()> { let name = display @@ -272,10 +279,11 @@ struct BackendData { context: EGLContext, egl: EGLDisplay, gbm: GbmDevice, - event_source: Source>>, + registration_token: RegistrationToken, + event_dispatcher: Dispatcher<'static, DrmDevice, AnvilState>, } -struct UdevHandlerImpl { +struct UdevHandlerImpl { compositor_token: CompositorToken, #[cfg(feature = "egl")] egl_buffer_reader: Rc>>, @@ -290,12 +298,12 @@ struct UdevHandlerImpl { pointer_image: ImageBuffer, Vec>, cursor_status: Arc>, dnd_icon: Arc>>, - loop_handle: LoopHandle, + loop_handle: LoopHandle<'static, AnvilState>, signaler: Signaler, logger: ::slog::Logger, } -impl UdevHandlerImpl { +impl UdevHandlerImpl { pub fn scan_connectors( device: &mut DrmDevice, gbm: &GbmDevice, @@ -392,7 +400,7 @@ impl UdevHandlerImpl { } } -impl UdevHandlerImpl { +impl UdevHandlerImpl { fn device_added(&mut self, device_id: dev_t, path: PathBuf) { // Try to open the device if let Some((mut device, gbm)) = self @@ -465,7 +473,7 @@ impl UdevHandlerImpl { } }; - let backends = Rc::new(RefCell::new(UdevHandlerImpl::::scan_connectors( + let backends = Rc::new(RefCell::new(UdevHandlerImpl::scan_connectors( &mut device, &gbm, &egl, @@ -516,15 +524,22 @@ impl UdevHandlerImpl { SessionSignal::ActivateSession | SessionSignal::ActivateDevice { .. } => listener.activate(), _ => {} }); - device.set_handler(DrmHandlerImpl { + let mut drm_handler = DrmHandlerImpl { renderer, loop_handle: self.loop_handle.clone(), - }); + }; device.link(self.signaler.clone()); let dev_id = device.device_id(); - let event_source = device_bind(&self.loop_handle, device) - .map_err(|e| -> IoError { e.into() }) + let event_dispatcher = Dispatcher::new(device, move |event, _, _| match event { + DrmEvent::VBlank(crtc) => drm_handler.vblank(crtc), + DrmEvent::Error(error) => { + error!(drm_handler.renderer.logger, "{:?}", error); + } + }); + let registration_token = self + .loop_handle + .register_dispatcher(event_dispatcher.clone()) .unwrap(); trace!(self.logger, "Backends: {:?}", backends.borrow().keys()); @@ -538,7 +553,8 @@ impl UdevHandlerImpl { dev_id, BackendData { _restart_token: restart_token, - event_source, + registration_token, + event_dispatcher, surfaces: backends, egl, context, @@ -557,26 +573,25 @@ impl UdevHandlerImpl { let mut output_map = self.output_map.borrow_mut(); let signaler = self.signaler.clone(); output_map.retain(|output| output.device_id != device); - self.loop_handle - .with_source(&backend_data.event_source, |source| { - let mut backends = backend_data.surfaces.borrow_mut(); - *backends = UdevHandlerImpl::::scan_connectors( - &mut source.file, - &backend_data.gbm, - &backend_data.egl, - &backend_data.context, - &mut *display, - &mut *output_map, - &signaler, - &logger, - ); - for renderer in backends.values() { - let logger = logger.clone(); - // render first frame - schedule_initial_render(renderer.clone(), &loop_handle, logger); - } - }); + let mut source = backend_data.event_dispatcher.as_source_mut(); + let mut backends = backend_data.surfaces.borrow_mut(); + *backends = UdevHandlerImpl::scan_connectors( + &mut *source, + &backend_data.gbm, + &backend_data.egl, + &backend_data.context, + &mut *display, + &mut *output_map, + &signaler, + &logger, + ); + + for renderer in backends.values() { + let logger = logger.clone(); + // render first frame + schedule_initial_render(renderer.clone(), &loop_handle, logger); + } } } @@ -591,7 +606,8 @@ impl UdevHandlerImpl { .borrow_mut() .retain(|output| output.device_id != device); - let _device = self.loop_handle.remove(backend_data.event_source).unwrap(); + let _device = self.loop_handle.remove(backend_data.registration_token); + let _device = backend_data.event_dispatcher.into_source_inner(); // don't use hardware acceleration anymore, if this was the primary gpu #[cfg(feature = "egl")] @@ -607,22 +623,18 @@ impl UdevHandlerImpl { pub struct DrmHandlerImpl { renderer: Rc, - loop_handle: LoopHandle, + loop_handle: LoopHandle<'static, Data>, } -impl DeviceHandler for DrmHandlerImpl { +impl DrmHandlerImpl { fn vblank(&mut self, crtc: crtc::Handle) { self.renderer.clone().render(crtc, None, Some(&self.loop_handle)) } - - fn error(&mut self, error: DrmError) { - error!(self.renderer.logger, "{:?}", error); - } } pub struct DrmRendererSessionListener { renderer: Rc, - loop_handle: LoopHandle, + loop_handle: LoopHandle<'static, Data>, } impl DrmRendererSessionListener { @@ -652,7 +664,7 @@ pub struct DrmRenderer { } impl DrmRenderer { - fn render_all(self: Rc, evt_handle: Option<&LoopHandle>) { + fn render_all(self: Rc, evt_handle: Option<&LoopHandle<'static, Data>>) { for crtc in self.backends.borrow().keys() { self.clone().render(*crtc, None, evt_handle); } @@ -661,7 +673,7 @@ impl DrmRenderer { self: Rc, crtc: crtc::Handle, timer: Option, crtc::Handle)>>, - evt_handle: Option<&LoopHandle>, + evt_handle: Option<&LoopHandle<'static, Data>>, ) { if let Some(surface) = self.backends.borrow().get(&crtc) { let result = DrmRenderer::render_surface( @@ -716,7 +728,7 @@ impl DrmRenderer { renderer.render( crtc, Some(handle.clone()), - Option::<&LoopHandle>::None, + Option::<&LoopHandle<'static, Data>>::None, ); } }) @@ -846,7 +858,7 @@ impl DrmRenderer { fn schedule_initial_render( renderer: Rc>, - evt_handle: &LoopHandle, + evt_handle: &LoopHandle<'static, Data>, logger: ::slog::Logger, ) { let result = { diff --git a/anvil/src/winit.rs b/anvil/src/winit.rs index e0dcdc4..c795a72 100644 --- a/anvil/src/winit.rs +++ b/anvil/src/winit.rs @@ -17,9 +17,17 @@ use slog::Logger; use crate::drawing::*; use crate::state::AnvilState; +pub struct WinitData; + +impl Default for WinitData { + fn default() -> WinitData { + WinitData + } +} + pub fn run_winit( display: Rc>, - event_loop: &mut EventLoop, + event_loop: &mut EventLoop<'static, AnvilState>, log: Logger, ) -> Result<(), ()> { let (renderer, mut input) = winit::init(log.clone()).map_err(|err| { diff --git a/anvil/src/xwayland/mod.rs b/anvil/src/xwayland/mod.rs index 322972e..d16f45b 100644 --- a/anvil/src/xwayland/mod.rs +++ b/anvil/src/xwayland/mod.rs @@ -35,16 +35,16 @@ mod x11rb_event_source; /// Implementation of [`smithay::xwayland::XWindowManager`] that is used for starting XWayland. /// After XWayland was started, the actual state is kept in `X11State`. -pub struct XWm { - handle: LoopHandle, +pub struct XWm { + handle: LoopHandle<'static, AnvilState>, token: CompositorToken, window_map: Rc>, log: slog::Logger, } -impl XWm { +impl XWm { pub fn new( - handle: LoopHandle, + handle: LoopHandle<'static, AnvilState>, token: CompositorToken, window_map: Rc>, log: slog::Logger, @@ -58,7 +58,7 @@ impl XWm { } } -impl XWindowManager for XWm { +impl XWindowManager for XWm { fn xwayland_ready(&mut self, connection: UnixStream, client: Client) { let (wm, source) = X11State::start_wm(connection, self.token, self.window_map.clone(), self.log.clone()).unwrap(); diff --git a/anvil/src/xwayland/x11rb_event_source.rs b/anvil/src/xwayland/x11rb_event_source.rs index aefaa7f..bf907ba 100644 --- a/anvil/src/xwayland/x11rb_event_source.rs +++ b/anvil/src/xwayland/x11rb_event_source.rs @@ -21,7 +21,7 @@ pub struct X11Source { impl X11Source { pub fn new(connection: Rc) -> Self { let fd = Fd(connection.stream().as_raw_fd()); - let generic = Generic::new(fd, Interest::Readable, Mode::Level); + let generic = Generic::new(fd, Interest::READ, Mode::Level); Self { connection, generic } } } diff --git a/examples/raw_drm.rs b/examples/raw_drm.rs index 7038a94..e217b58 100644 --- a/examples/raw_drm.rs +++ b/examples/raw_drm.rs @@ -7,7 +7,7 @@ use slog::Drain; use smithay::{ backend::{ allocator::{dumb::DumbBuffer, Fourcc, Slot, Swapchain}, - drm::{device_bind, DeviceHandler, DrmDevice, DrmError, DrmSurface}, + drm::{DrmDevice, DrmEvent, DrmSurface}, }, reexports::{ calloop::EventLoop, @@ -16,7 +16,6 @@ use smithay::{ }; use std::{ fs::{File, OpenOptions}, - io::Error as IoError, os::unix::io::{AsRawFd, RawFd}, rc::Rc, sync::Mutex, @@ -48,7 +47,7 @@ fn main() { file: Rc::new(options.open("/dev/dri/card0").unwrap()), }; - let mut device = DrmDevice::new(fd.clone(), true, log.clone()).unwrap(); + let device = DrmDevice::new(fd.clone(), true, log.clone()).unwrap(); // Get a set of all modesetting resource handles (excluding planes): let res_handles = ControlDevice::resource_handles(&device).unwrap(); @@ -111,20 +110,23 @@ fn main() { *first_buffer.userdata() = Some(framebuffer); // Get the device as an allocator into the - device.set_handler(DrmHandlerImpl { + let mut vblank_handler = VBlankHandler { swapchain, current: first_buffer, surface: surface.clone(), - }); + }; /* * Register the DrmDevice on the EventLoop */ - let mut event_loop = EventLoop::<()>::new().unwrap(); - let _source = device_bind(&event_loop.handle(), device) - .map_err(|err| -> IoError { err.into() }) + let mut event_loop = EventLoop::<()>::try_new().unwrap(); + event_loop + .handle() + .insert_source(device, move |event, _: &mut (), _: &mut ()| match event { + DrmEvent::VBlank(crtc) => vblank_handler.vblank(crtc), + DrmEvent::Error(e) => panic!("{}", e), + }) .unwrap(); - // Start rendering surface .commit([(framebuffer, surface.plane())].iter(), true) @@ -134,13 +136,13 @@ fn main() { event_loop.run(None, &mut (), |_| {}).unwrap(); } -pub struct DrmHandlerImpl { +pub struct VBlankHandler { swapchain: Swapchain, DumbBuffer, framebuffer::Handle>, current: Slot, framebuffer::Handle>, surface: Rc>, } -impl DeviceHandler for DrmHandlerImpl { +impl VBlankHandler { fn vblank(&mut self, _crtc: crtc::Handle) { { // Next buffer @@ -168,8 +170,4 @@ impl DeviceHandler for DrmHandlerImpl { .page_flip([(fb, self.surface.plane())].iter(), true) .unwrap(); } - - fn error(&mut self, error: DrmError) { - panic!("{:?}", error); - } } diff --git a/src/backend/drm/device/mod.rs b/src/backend/drm/device/mod.rs index d091271..f1e5c6a 100644 --- a/src/backend/drm/device/mod.rs +++ b/src/backend/drm/device/mod.rs @@ -1,10 +1,9 @@ use std::cell::RefCell; use std::os::unix::io::{AsRawFd, RawFd}; use std::path::PathBuf; -use std::rc::Rc; use std::sync::{atomic::AtomicBool, Arc}; -use calloop::{generic::Generic, InsertError, LoopHandle, Source}; +use calloop::{EventSource, Interest, Poll, Readiness, Token}; use drm::control::{connector, crtc, Device as ControlDevice, Event, Mode, ResourceHandles}; use drm::{ClientCapability, Device as BasicDevice}; use nix::libc::dev_t; @@ -21,7 +20,6 @@ use legacy::LegacyDrmDevice; pub struct DrmDevice { pub(super) dev_id: dev_t, pub(crate) internal: Arc>, - handler: Rc>>>, #[cfg(feature = "backend_session")] pub(super) links: RefCell>, has_universal_planes: bool, @@ -145,7 +143,6 @@ impl DrmDevice { Ok(DrmDevice { dev_id, internal, - handler: Rc::new(RefCell::new(None)), #[cfg(feature = "backend_session")] links: RefCell::new(Vec::new()), has_universal_planes, @@ -180,43 +177,6 @@ impl DrmDevice { ) } - /// Processes any open events of the underlying file descriptor. - /// - /// You should not call this function manually, but rather use - /// [`device_bind`] to register the device - /// to an [`EventLoop`](calloop::EventLoop) - /// and call this function when the device becomes readable - /// to synchronize your rendering to the vblank events of the open crtc's - pub fn process_events(&mut self) { - match self.receive_events() { - Ok(events) => { - for event in events { - if let Event::PageFlip(event) = event { - trace!(self.logger, "Got a page-flip event for crtc ({:?})", event.crtc); - if let Some(handler) = self.handler.borrow_mut().as_mut() { - handler.vblank(event.crtc); - } - } else { - trace!( - self.logger, - "Got a non-page-flip event of device '{:?}'.", - self.dev_path() - ); - } - } - } - Err(source) => { - if let Some(handler) = self.handler.borrow_mut().as_mut() { - handler.error(Error::Access { - errmsg: "Error processing drm events", - dev: self.dev_path(), - source, - }); - } - } - } - } - /// Returns if the underlying implementation uses atomic-modesetting or not. pub fn is_atomic(&self) -> bool { match *self.internal { @@ -225,19 +185,6 @@ impl DrmDevice { } } - /// Assigns a [`DeviceHandler`] called during event processing. - /// - /// See [`device_bind`] and [`DeviceHandler`] - pub fn set_handler(&mut self, handler: impl DeviceHandler + 'static) { - let handler = Some(Box::new(handler) as Box); - *self.handler.borrow_mut() = handler; - } - - /// Clear a set [`DeviceHandler`](trait.DeviceHandler.html), if any - pub fn clear_handler(&mut self) { - self.handler.borrow_mut().take(); - } - /// Returns a list of crtcs for this device pub fn crtcs(&self) -> &[crtc::Handle] { self.resources.crtcs() @@ -334,16 +281,6 @@ impl DrmDevice { } } -/// Trait to receive events of a bound [`DrmDevice`] -/// -/// See [`device_bind`] -pub trait DeviceHandler { - /// A vblank blank event on the provided crtc has happend - fn vblank(&mut self, crtc: crtc::Handle); - /// An error happend while processing events - fn error(&mut self, error: Error); -} - /// Trait representing open devices that *may* return a `Path` pub trait DevPath { /// Returns the path of the open device if possible @@ -358,25 +295,64 @@ impl DevPath for A { } } -/// calloop source associated with a Device -pub type DrmSource = Generic>; +/// Events that can be generated by a DrmDevice +pub enum DrmEvent { + /// A vblank blank event on the provided crtc has happend + VBlank(crtc::Handle), + /// An error happend while processing events + Error(Error), +} -/// Bind a `Device` to an [`EventLoop`](calloop::EventLoop), -/// -/// This will cause it to recieve events and feed them into a previously -/// set [`DeviceHandler`](DeviceHandler). -pub fn device_bind( - handle: &LoopHandle, - device: DrmDevice, -) -> ::std::result::Result>, InsertError>> +impl EventSource for DrmDevice where A: AsRawFd + 'static, - Data: 'static, { - let source = Generic::new(device, calloop::Interest::Readable, calloop::Mode::Level); + type Event = DrmEvent; + type Metadata = (); + type Ret = (); - handle.insert_source(source, |_, source, _| { - source.process_events(); + fn process_events(&mut self, _: Readiness, _: Token, mut callback: F) -> std::io::Result<()> + where + F: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret, + { + match self.receive_events() { + Ok(events) => { + for event in events { + if let Event::PageFlip(event) = event { + trace!(self.logger, "Got a page-flip event for crtc ({:?})", event.crtc); + callback(DrmEvent::VBlank(event.crtc), &mut ()); + } else { + trace!( + self.logger, + "Got a non-page-flip event of device '{:?}'.", + self.dev_path() + ); + } + } + } + Err(source) => { + callback( + DrmEvent::Error(Error::Access { + errmsg: "Error processing drm events", + dev: self.dev_path(), + source, + }), + &mut (), + ); + } + } Ok(()) - }) + } + + fn register(&mut self, poll: &mut Poll, token: Token) -> std::io::Result<()> { + poll.register(self.as_raw_fd(), Interest::READ, calloop::Mode::Level, token) + } + + fn reregister(&mut self, poll: &mut Poll, token: Token) -> std::io::Result<()> { + poll.reregister(self.as_raw_fd(), Interest::READ, calloop::Mode::Level, token) + } + + fn unregister(&mut self, poll: &mut Poll) -> std::io::Result<()> { + poll.unregister(self.as_raw_fd()) + } } diff --git a/src/backend/drm/mod.rs b/src/backend/drm/mod.rs index 4ac3784..5cae32c 100644 --- a/src/backend/drm/mod.rs +++ b/src/backend/drm/mod.rs @@ -68,7 +68,7 @@ mod render; pub(self) mod session; pub(self) mod surface; -pub use device::{device_bind, DevPath, DeviceHandler, DrmDevice, DrmSource}; +pub use device::{DevPath, DrmDevice, DrmEvent}; pub use error::Error as DrmError; #[cfg(feature = "backend_gbm")] pub use render::{DrmRenderSurface, Error as DrmRenderError}; diff --git a/src/backend/libinput/mod.rs b/src/backend/libinput/mod.rs index 090dc84..82d16d0 100644 --- a/src/backend/libinput/mod.rs +++ b/src/backend/libinput/mod.rs @@ -469,11 +469,11 @@ impl EventSource for LibinputInputBackend { } fn register(&mut self, poll: &mut Poll, token: Token) -> std::io::Result<()> { - poll.register(self.as_raw_fd(), Interest::Readable, Mode::Level, token) + poll.register(self.as_raw_fd(), Interest::READ, Mode::Level, token) } fn reregister(&mut self, poll: &mut Poll, token: Token) -> std::io::Result<()> { - poll.reregister(self.as_raw_fd(), Interest::Readable, Mode::Level, token) + poll.reregister(self.as_raw_fd(), Interest::READ, Mode::Level, token) } fn unregister(&mut self, poll: &mut Poll) -> std::io::Result<()> { diff --git a/src/backend/session/dbus/mod.rs b/src/backend/session/dbus/mod.rs index 02a3ff9..2b50d95 100644 --- a/src/backend/session/dbus/mod.rs +++ b/src/backend/session/dbus/mod.rs @@ -76,9 +76,9 @@ impl EventSource for DBusConnection { fn reregister(&mut self, poll: &mut Poll, token: Token) -> io::Result<()> { let new_watch = self.cx.channel().watch(); let new_interest = match (new_watch.read, new_watch.write) { - (true, true) => Some(Interest::Both), - (true, false) => Some(Interest::Readable), - (false, true) => Some(Interest::Writable), + (true, true) => Some(Interest::BOTH), + (true, false) => Some(Interest::READ), + (false, true) => Some(Interest::WRITE), (false, false) => None, }; if new_watch.fd != self.current_watch.fd { diff --git a/src/backend/udev.rs b/src/backend/udev.rs index 4ab81d7..d049557 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -18,7 +18,7 @@ //! // process the initial list of devices //! } //! -//! # let event_loop = smithay::reexports::calloop::EventLoop::<()>::new().unwrap(); +//! # let event_loop = smithay::reexports::calloop::EventLoop::<()>::try_new().unwrap(); //! # let loop_handle = event_loop.handle(); //! // setup the event source for long-term monitoring //! loop_handle.insert_source(udev, |event, _, _dispatch_data| match event { @@ -182,11 +182,11 @@ impl EventSource for UdevBackend { } fn register(&mut self, poll: &mut Poll, token: Token) -> std::io::Result<()> { - poll.register(self.as_raw_fd(), Interest::Readable, Mode::Level, token) + poll.register(self.as_raw_fd(), Interest::READ, Mode::Level, token) } fn reregister(&mut self, poll: &mut Poll, token: Token) -> std::io::Result<()> { - poll.reregister(self.as_raw_fd(), Interest::Readable, Mode::Level, token) + poll.reregister(self.as_raw_fd(), Interest::READ, Mode::Level, token) } fn unregister(&mut self, poll: &mut Poll) -> std::io::Result<()> { diff --git a/src/xwayland/xserver.rs b/src/xwayland/xserver.rs index 4fd8d90..ce052f1 100644 --- a/src/xwayland/xserver.rs +++ b/src/xwayland/xserver.rs @@ -55,7 +55,7 @@ use std::{ use calloop::{ generic::{Fd, Generic}, - Interest, LoopHandle, Mode, Source, + Interest, LoopHandle, Mode, RegistrationToken, }; use nix::Error as NixError; @@ -91,7 +91,7 @@ impl XWayland { /// Start the XWayland server pub fn init( wm: WM, - handle: LoopHandle, + handle: LoopHandle<'static, Data>, display: Rc>, data: &mut T, logger: L, @@ -109,7 +109,7 @@ impl XWayland { source_maker: Box::new(move |inner, fd| { handle .insert_source( - Generic::new(Fd(fd), Interest::Readable, Mode::Level), + Generic::new(Fd(fd), Interest::READ, Mode::Level), move |evt, _, _| { debug_assert!(evt.readable); xwayland_ready(&inner); @@ -136,13 +136,13 @@ impl Drop for XWayland { struct XWaylandInstance { display_lock: X11Lock, wayland_client: Client, - startup_handler: Option>>, + startup_handler: Option, wm_fd: Option, started_at: ::std::time::Instant, child_stdout: Option, } -type SourceMaker = dyn FnMut(Rc>>, RawFd) -> Result>, ()>; +type SourceMaker = dyn FnMut(Rc>>, RawFd) -> Result; // Inner implementation of the XWayland manager struct Inner { @@ -150,7 +150,7 @@ struct Inner { source_maker: Box>, wayland_display: Rc>, instance: Option, - kill_source: Box>)>, + kill_source: Box, log: ::slog::Logger, }