Skip to content

Commit 19260e8

Browse files
committed
Update to udev 0.4
1 parent cd25b1d commit 19260e8

File tree

4 files changed

+17
-25
lines changed

4 files changed

+17
-25
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ winit = { version = "0.22.0", optional = true }
2727
drm = { version = "^0.4.0", git = "https://github.com/drakulix/drm-rs", branch = "develop", optional = true }
2828
gbm = { version = "^0.6.0", git = "https://github.com/drakulix/gbm.rs", branch = "develop", optional = true, default-features = false, features = ["drm-support"] }
2929
glium = { version = "0.23.0", optional = true, default-features = false }
30-
input = { version = "0.4.1", optional = true }
31-
udev = { version = "0.2.0", optional = true }
30+
input = { version = "0.5", default-features = false, optional = true }
31+
udev = { version = "0.4", optional = true }
3232
dbus = { version = "0.8", optional = true }
3333
systemd = { version = "0.4.0", optional = true }
3434
wayland-protocols = { version = "0.25.0", features = ["unstable_protocols", "server"], optional = true }

anvil/src/udev.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,12 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop<AnvilState>, log
118118
/*
119119
* Initialize the udev backend
120120
*/
121-
let context = ::smithay::reexports::udev::Context::new().map_err(|_| ())?;
122121
let seat = session.seat();
123122

124-
let primary_gpu = primary_gpu(&context, &seat).unwrap_or_default();
123+
let primary_gpu = primary_gpu(&seat).unwrap_or_default();
125124

126125
let bytes = include_bytes!("../resources/cursor2.rgba");
127126
let udev_backend = UdevBackend::new(
128-
&context,
129127
UdevHandlerImpl {
130128
compositor_token,
131129
#[cfg(feature = "egl")]
@@ -223,7 +221,7 @@ pub fn run_udev(mut display: Display, mut event_loop: EventLoop<AnvilState>, log
223221
* Initialize libinput backend
224222
*/
225223
let mut libinput_context =
226-
Libinput::new_from_udev::<LibinputSessionInterface<AutoSession>>(session.clone().into(), &context);
224+
Libinput::new_with_udev::<LibinputSessionInterface<AutoSession>>(session.clone().into());
227225
let libinput_session_id = notifier.register(libinput_context.observer());
228226
libinput_context.udev_assign_seat(&seat).unwrap();
229227
let mut libinput_backend = LibinputInputBackend::new(libinput_context, log.clone());

src/backend/session/direct.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use std::{
6666
},
6767
};
6868
#[cfg(feature = "backend_udev")]
69-
use udev::Context;
69+
use udev::Device as UdevDevice;
7070

7171
#[allow(dead_code)]
7272
mod tty {
@@ -126,12 +126,7 @@ fn is_tty_device(dev: dev_t, _path: Option<&Path>) -> bool {
126126
fn is_tty_device(dev: dev_t, path: Option<&Path>) -> bool {
127127
match path {
128128
Some(path) => {
129-
let udev = match Context::new() {
130-
Ok(context) => context,
131-
Err(_) => return major(dev) == TTY_MAJOR || minor(dev) != 0,
132-
};
133-
134-
let device = match udev.device_from_syspath(path) {
129+
let device = match UdevDevice::from_syspath(path) {
135130
Ok(device) => device,
136131
Err(_) => return major(dev) == TTY_MAJOR || minor(dev) != 0,
137132
};

src/backend/udev.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
use nix::sys::stat::{dev_t, stat};
1313
use std::{
1414
collections::HashSet,
15+
io::Result as IoResult,
1516
ffi::OsString,
1617
os::unix::io::{AsRawFd, RawFd},
1718
path::{Path, PathBuf},
1819
};
19-
use udev::{Context, Enumerator, EventType, MonitorBuilder, MonitorSocket, Result as UdevResult};
20+
use udev::{Enumerator, EventType, MonitorBuilder, MonitorSocket};
2021

2122
use calloop::{
2223
generic::{Generic, SourceFd},
@@ -46,22 +47,20 @@ impl<T: UdevHandler + 'static> UdevBackend<T> {
4647
/// Creates a new [`UdevBackend`]
4748
///
4849
/// ## Arguments
49-
/// `context` - An initialized udev context
5050
/// `handler` - User-provided handler to respond to any detected changes
5151
/// `seat` -
5252
/// `logger` - slog Logger to be used by the backend and its `DrmDevices`.
5353
pub fn new<L, S: AsRef<str>>(
54-
context: &Context,
5554
mut handler: T,
5655
seat: S,
5756
logger: L,
58-
) -> UdevResult<UdevBackend<T>>
57+
) -> IoResult<UdevBackend<T>>
5958
where
6059
L: Into<Option<::slog::Logger>>,
6160
{
6261
let log = crate::slog_or_stdlog(logger).new(o!("smithay_module" => "backend_udev"));
6362

64-
let devices = all_gpus(context, seat)?
63+
let devices = all_gpus(seat)?
6564
.into_iter()
6665
// Create devices
6766
.flat_map(|path| match stat(&path) {
@@ -76,9 +75,9 @@ impl<T: UdevHandler + 'static> UdevBackend<T> {
7675
})
7776
.collect();
7877

79-
let mut builder = MonitorBuilder::new(context)?;
80-
builder.match_subsystem("drm")?;
81-
let monitor = builder.listen()?;
78+
let monitor = MonitorBuilder::new()?
79+
.match_subsystem("drm")?
80+
.listen()?;
8281

8382
Ok(UdevBackend {
8483
devices,
@@ -173,8 +172,8 @@ pub trait UdevHandler {
173172
///
174173
/// Might be used for filtering in [`UdevHandler::device_added`] or for manual
175174
/// [`LegacyDrmDevice`](::backend::drm::legacy::LegacyDrmDevice) initialization.
176-
pub fn primary_gpu<S: AsRef<str>>(context: &Context, seat: S) -> UdevResult<Option<PathBuf>> {
177-
let mut enumerator = Enumerator::new(context)?;
175+
pub fn primary_gpu<S: AsRef<str>>(seat: S) -> IoResult<Option<PathBuf>> {
176+
let mut enumerator = Enumerator::new()?;
178177
enumerator.match_subsystem("drm")?;
179178
enumerator.match_sysname("card[0-9]*")?;
180179

@@ -204,8 +203,8 @@ pub fn primary_gpu<S: AsRef<str>>(context: &Context, seat: S) -> UdevResult<Opti
204203
///
205204
/// Might be used for manual [`LegacyDrmDevice`](::backend::drm::legacy::LegacyDrmDevice)
206205
/// initialization.
207-
pub fn all_gpus<S: AsRef<str>>(context: &Context, seat: S) -> UdevResult<Vec<PathBuf>> {
208-
let mut enumerator = Enumerator::new(context)?;
206+
pub fn all_gpus<S: AsRef<str>>(seat: S) -> IoResult<Vec<PathBuf>> {
207+
let mut enumerator = Enumerator::new()?;
209208
enumerator.match_subsystem("drm")?;
210209
enumerator.match_sysname("card[0-9]*")?;
211210
Ok(enumerator

0 commit comments

Comments
 (0)