@@ -3,6 +3,8 @@ use smithay::backend::input;
3
3
use smithay:: backend:: winit:: WinitVirtualDevice ;
4
4
use smithay:: output:: Output ;
5
5
6
+ use crate :: backend:: Backend ;
7
+ use crate :: niri:: State ;
6
8
use crate :: protocols:: virtual_pointer:: VirtualPointer ;
7
9
8
10
pub trait NiriInputBackend : input:: InputBackend < Device = Self :: NiriDevice > {
@@ -16,29 +18,33 @@ where
16
18
}
17
19
18
20
pub trait NiriInputDevice : input:: Device {
19
- // FIXME: should this be per-event? logically yes,
20
- // but right now we only use it for virtual pointers, which have static outputs.
21
- fn output ( & self ) -> Option < Output > ;
21
+ // FIXME: this should maybe be per-event, not per-device,
22
+ // but it's not clear that this matters in practice?
23
+ // it might be more obvious once we implement it for libinput
24
+ fn output ( & self , state : & State ) -> Option < Output > ;
22
25
}
23
26
24
27
impl NiriInputDevice for libinput:: Device {
25
- fn output ( & self ) -> Option < Output > {
28
+ fn output ( & self , _state : & State ) -> Option < Output > {
26
29
// FIXME: Allow specifying the output per-device?
27
- // In that case, change the method to take a reference to our state or config or something
28
- // (because we can't easily change the libinput Device struct)
29
30
None
30
31
}
31
32
}
32
33
33
34
impl NiriInputDevice for WinitVirtualDevice {
34
- fn output ( & self ) -> Option < Output > {
35
- // here it's actually *correct* to return None, because there is only one output.
36
- None
35
+ fn output ( & self , state : & State ) -> Option < Output > {
36
+ match state. backend {
37
+ Backend :: Winit ( ref winit) => Some ( winit. single_output ( ) . clone ( ) ) ,
38
+ // returning None over panicking here because it's not worth panicking over
39
+ // and also, foreseeably, someone might want to, at some point, use `WinitInputBackend`
40
+ // for dirty hacks or mocking or whatever, in which case this will be useful.
41
+ _ => None ,
42
+ }
37
43
}
38
44
}
39
45
40
46
impl NiriInputDevice for VirtualPointer {
41
- fn output ( & self ) -> Option < Output > {
47
+ fn output ( & self , _ : & State ) -> Option < Output > {
42
48
self . output ( ) . cloned ( )
43
49
}
44
50
}
0 commit comments