12
12
use nix:: sys:: stat:: { dev_t, stat} ;
13
13
use std:: {
14
14
collections:: HashSet ,
15
+ io:: Result as IoResult ,
15
16
ffi:: OsString ,
16
17
os:: unix:: io:: { AsRawFd , RawFd } ,
17
18
path:: { Path , PathBuf } ,
18
19
} ;
19
- use udev:: { Context , Enumerator , EventType , MonitorBuilder , MonitorSocket , Result as UdevResult } ;
20
+ use udev:: { Enumerator , EventType , MonitorBuilder , MonitorSocket } ;
20
21
21
22
use calloop:: {
22
23
generic:: { Generic , SourceFd } ,
@@ -46,22 +47,20 @@ impl<T: UdevHandler + 'static> UdevBackend<T> {
46
47
/// Creates a new [`UdevBackend`]
47
48
///
48
49
/// ## Arguments
49
- /// `context` - An initialized udev context
50
50
/// `handler` - User-provided handler to respond to any detected changes
51
51
/// `seat` -
52
52
/// `logger` - slog Logger to be used by the backend and its `DrmDevices`.
53
53
pub fn new < L , S : AsRef < str > > (
54
- context : & Context ,
55
54
mut handler : T ,
56
55
seat : S ,
57
56
logger : L ,
58
- ) -> UdevResult < UdevBackend < T > >
57
+ ) -> IoResult < UdevBackend < T > >
59
58
where
60
59
L : Into < Option < :: slog:: Logger > > ,
61
60
{
62
61
let log = crate :: slog_or_stdlog ( logger) . new ( o ! ( "smithay_module" => "backend_udev" ) ) ;
63
62
64
- let devices = all_gpus ( context , seat) ?
63
+ let devices = all_gpus ( seat) ?
65
64
. into_iter ( )
66
65
// Create devices
67
66
. flat_map ( |path| match stat ( & path) {
@@ -76,9 +75,9 @@ impl<T: UdevHandler + 'static> UdevBackend<T> {
76
75
} )
77
76
. collect ( ) ;
78
77
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 ( ) ?;
82
81
83
82
Ok ( UdevBackend {
84
83
devices,
@@ -173,8 +172,8 @@ pub trait UdevHandler {
173
172
///
174
173
/// Might be used for filtering in [`UdevHandler::device_added`] or for manual
175
174
/// [`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 ( ) ?;
178
177
enumerator. match_subsystem ( "drm" ) ?;
179
178
enumerator. match_sysname ( "card[0-9]*" ) ?;
180
179
@@ -204,8 +203,8 @@ pub fn primary_gpu<S: AsRef<str>>(context: &Context, seat: S) -> UdevResult<Opti
204
203
///
205
204
/// Might be used for manual [`LegacyDrmDevice`](::backend::drm::legacy::LegacyDrmDevice)
206
205
/// 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 ( ) ?;
209
208
enumerator. match_subsystem ( "drm" ) ?;
210
209
enumerator. match_sysname ( "card[0-9]*" ) ?;
211
210
Ok ( enumerator
0 commit comments