diff --git a/Cargo.toml b/Cargo.toml index 1aac5ba..39e2194 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,8 @@ winit = { version = "0.22.0", optional = true } drm = { version = "^0.4.0", git = "https://github.com/drakulix/drm-rs", branch = "develop", optional = true } gbm = { version = "^0.6.0", git = "https://github.com/drakulix/gbm.rs", branch = "develop", optional = true, default-features = false, features = ["drm-support"] } glium = { version = "0.23.0", optional = true, default-features = false } -input = { version = "0.4.1", optional = true } -udev = { version = "0.2.0", optional = true } +input = { version = "0.5", default-features = false, optional = true } +udev = { version = "0.4", optional = true } dbus = { version = "0.8", optional = true } systemd = { version = "0.4.0", optional = true } wayland-protocols = { version = "0.25.0", features = ["unstable_protocols", "server"], optional = true } @@ -37,7 +37,7 @@ image = { version = "0.21.0", optional = true } lazy_static = "1.0.0" thiserror = "1" # TODO: remove as soon as drm-rs provides an error implementing Error -failure = "0.1" +failure = { version = "0.1", optional = true } [dev-dependencies] slog-term = "2.3" @@ -47,8 +47,8 @@ gl_generator = { version = "0.10", optional = true } [features] default = ["backend_winit", "backend_drm_legacy", "backend_drm_gbm", "backend_drm_egl", "backend_libinput", "backend_udev", "backend_session_logind", "renderer_glium", "xwayland", "wayland_frontend"] -backend_winit = ["winit", "wayland-server/dlopen", "wayland-client/dlopen", "wayland-egl", "backend_egl", "renderer_gl", "use_system_lib"] -backend_drm = ["drm"] +backend_winit = ["winit", "wayland-server/dlopen", "wayland-client/dlopen", "backend_egl", "wayland-egl", "renderer_gl", "use_system_lib"] +backend_drm = ["drm", "failure"] backend_drm_legacy = ["backend_drm"] backend_drm_gbm = ["backend_drm", "gbm", "image"] backend_drm_egl = ["backend_drm", "backend_egl"] diff --git a/anvil/Cargo.toml b/anvil/Cargo.toml index a90fed6..8cbd009 100644 --- a/anvil/Cargo.toml +++ b/anvil/Cargo.toml @@ -15,6 +15,7 @@ glium = { version = "0.23.0", default-features = false } wayland-server = "0.25.0" xkbcommon = "0.4.0" bitflags = "1.2.1" +input = { version = "0.5.0", features = ["udev"], optional = true } [dependencies.smithay] path = ".." @@ -28,5 +29,5 @@ gl_generator = "0.10" default = [ "winit", "egl", "udev", "logind" ] egl = [ "smithay/use_system_lib" ] winit = [ "smithay/backend_winit" ] -udev = [ "smithay/backend_libinput", "smithay/backend_drm_legacy", "smithay/backend_drm_gbm", "smithay/backend_drm_egl", "smithay/backend_udev", "smithay/backend_session" ] +udev = [ "smithay/backend_libinput", "smithay/backend_udev", "smithay/backend_drm_legacy", "smithay/backend_drm_gbm", "smithay/backend_drm_egl", "smithay/backend_session", "input" ] logind = [ "smithay/backend_session_logind" ] diff --git a/anvil/src/udev.rs b/anvil/src/udev.rs index 1c5dbcd..418ab01 100644 --- a/anvil/src/udev.rs +++ b/anvil/src/udev.rs @@ -118,14 +118,12 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop, log /* * Initialize the udev backend */ - let context = ::smithay::reexports::udev::Context::new().map_err(|_| ())?; let seat = session.seat(); - let primary_gpu = primary_gpu(&context, &seat).unwrap_or_default(); + let primary_gpu = primary_gpu(&seat).unwrap_or_default(); let bytes = include_bytes!("../resources/cursor2.rgba"); let udev_backend = UdevBackend::new( - &context, UdevHandlerImpl { compositor_token, #[cfg(feature = "egl")] @@ -223,7 +221,7 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop, log * Initialize libinput backend */ let mut libinput_context = - Libinput::new_from_udev::>(session.clone().into(), &context); + Libinput::new_with_udev::>(session.clone().into()); let libinput_session_id = notifier.register(libinput_context.observer()); libinput_context.udev_assign_seat(&seat).unwrap(); let mut libinput_backend = LibinputInputBackend::new(libinput_context, log.clone()); diff --git a/src/backend/session/direct.rs b/src/backend/session/direct.rs index 2bb6057..1188178 100644 --- a/src/backend/session/direct.rs +++ b/src/backend/session/direct.rs @@ -66,7 +66,7 @@ use std::{ }, }; #[cfg(feature = "backend_udev")] -use udev::Context; +use udev::Device as UdevDevice; #[allow(dead_code)] mod tty { @@ -126,12 +126,7 @@ fn is_tty_device(dev: dev_t, _path: Option<&Path>) -> bool { fn is_tty_device(dev: dev_t, path: Option<&Path>) -> bool { match path { Some(path) => { - let udev = match Context::new() { - Ok(context) => context, - Err(_) => return major(dev) == TTY_MAJOR || minor(dev) != 0, - }; - - let device = match udev.device_from_syspath(path) { + let device = match UdevDevice::from_syspath(path) { Ok(device) => device, Err(_) => return major(dev) == TTY_MAJOR || minor(dev) != 0, }; diff --git a/src/backend/udev.rs b/src/backend/udev.rs index 7319729..5001af6 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -13,10 +13,11 @@ use nix::sys::stat::{dev_t, stat}; use std::{ collections::HashSet, ffi::OsString, + io::Result as IoResult, os::unix::io::{AsRawFd, RawFd}, path::{Path, PathBuf}, }; -use udev::{Context, Enumerator, EventType, MonitorBuilder, MonitorSocket, Result as UdevResult}; +use udev::{Enumerator, EventType, MonitorBuilder, MonitorSocket}; use calloop::{ generic::{Generic, SourceFd}, @@ -46,22 +47,16 @@ impl UdevBackend { /// Creates a new [`UdevBackend`] /// /// ## Arguments - /// `context` - An initialized udev context /// `handler` - User-provided handler to respond to any detected changes /// `seat` - /// `logger` - slog Logger to be used by the backend and its `DrmDevices`. - pub fn new>( - context: &Context, - mut handler: T, - seat: S, - logger: L, - ) -> UdevResult> + pub fn new>(mut handler: T, seat: S, logger: L) -> IoResult> where L: Into>, { let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_udev")); - let devices = all_gpus(context, seat)? + let devices = all_gpus(seat)? .into_iter() // Create devices .flat_map(|path| match stat(&path) { @@ -76,9 +71,7 @@ impl UdevBackend { }) .collect(); - let mut builder = MonitorBuilder::new(context)?; - builder.match_subsystem("drm")?; - let monitor = builder.listen()?; + let monitor = MonitorBuilder::new()?.match_subsystem("drm")?.listen()?; Ok(UdevBackend { devices, @@ -173,8 +166,8 @@ pub trait UdevHandler { /// /// Might be used for filtering in [`UdevHandler::device_added`] or for manual /// [`LegacyDrmDevice`](::backend::drm::legacy::LegacyDrmDevice) initialization. -pub fn primary_gpu>(context: &Context, seat: S) -> UdevResult> { - let mut enumerator = Enumerator::new(context)?; +pub fn primary_gpu>(seat: S) -> IoResult> { + let mut enumerator = Enumerator::new()?; enumerator.match_subsystem("drm")?; enumerator.match_sysname("card[0-9]*")?; @@ -204,8 +197,8 @@ pub fn primary_gpu>(context: &Context, seat: S) -> UdevResult>(context: &Context, seat: S) -> UdevResult> { - let mut enumerator = Enumerator::new(context)?; +pub fn all_gpus>(seat: S) -> IoResult> { + let mut enumerator = Enumerator::new()?; enumerator.match_subsystem("drm")?; enumerator.match_sysname("card[0-9]*")?; Ok(enumerator