Commit bda6cfe 1 parent 9a34e7f commit bda6cfe Copy full SHA for bda6cfe
File tree 2 files changed +14
-20
lines changed
2 files changed +14
-20
lines changed Original file line number Diff line number Diff line change @@ -12,26 +12,23 @@ use WindowBuilder;
12
12
use platform:: x11:: XConnection ;
13
13
use platform:: x11:: ffi:: XVisualInfo ;
14
14
15
- pub use platform:: x11 ;
15
+ pub use platform:: XNotSupported ;
16
16
17
17
/// Additional methods on `EventsLoop` that are specific to Linux.
18
18
pub trait EventsLoopExt {
19
19
/// Builds a new `EventsLoop` that is forced to use X11.
20
- fn new_x11 ( ) -> Self ;
20
+ fn new_x11 ( ) -> Result < Self , XNotSupported >
21
+ where Self : Sized ;
21
22
22
23
/// Builds a new `EventsLoop` that is forced to use Wayland.
23
- fn new_wayland ( ) -> Self ;
24
+ fn new_wayland ( ) -> Self
25
+ where Self : Sized ;
24
26
}
25
27
26
28
impl EventsLoopExt for EventsLoop {
27
29
#[ inline]
28
- fn new_x11 ( ) -> Self {
29
- EventsLoop {
30
- events_loop : match LinuxEventsLoop :: new_x11 ( ) {
31
- Ok ( e) => e,
32
- Err ( _) => panic ! ( ) // TODO: propagate
33
- }
34
- }
30
+ fn new_x11 ( ) -> Result < Self , XNotSupported > {
31
+ LinuxEventsLoop :: new_x11 ( ) . map ( |ev| EventsLoop { events_loop : ev } )
35
32
}
36
33
37
34
#[ inline]
Original file line number Diff line number Diff line change @@ -9,9 +9,10 @@ use libc;
9
9
10
10
use self :: x11:: XConnection ;
11
11
use self :: x11:: XError ;
12
- use self :: x11:: XNotSupported ;
13
12
use self :: x11:: ffi:: XVisualInfo ;
14
13
14
+ pub use self :: x11:: XNotSupported ;
15
+
15
16
mod dlopen;
16
17
pub mod wayland;
17
18
pub mod x11;
@@ -285,10 +286,7 @@ impl EventsLoop {
285
286
if let Ok ( env_var) = env:: var ( BACKEND_PREFERENCE_ENV_VAR ) {
286
287
match env_var. as_str ( ) {
287
288
"x11" => {
288
- match EventsLoop :: new_x11 ( ) {
289
- Ok ( e) => return e,
290
- Err ( _) => panic ! ( ) // TODO: propagate
291
- }
289
+ return EventsLoop :: new_x11 ( ) . unwrap ( ) ; // TODO: propagate
292
290
} ,
293
291
"wayland" => {
294
292
match EventsLoop :: new_wayland ( ) {
@@ -318,12 +316,11 @@ impl EventsLoop {
318
316
. ok_or ( ( ) )
319
317
}
320
318
321
- pub fn new_x11 ( ) -> Result < EventsLoop , ( ) > {
322
- if let Ok ( ref x) = * X11_BACKEND {
323
- return Ok ( EventsLoop :: X ( x11:: EventsLoop :: new ( x. clone ( ) ) ) ) ;
319
+ pub fn new_x11 ( ) -> Result < EventsLoop , XNotSupported > {
320
+ match * X11_BACKEND {
321
+ Ok ( ref x) => Ok ( EventsLoop :: X ( x11:: EventsLoop :: new ( x. clone ( ) ) ) ) ,
322
+ Err ( ref err) => Err ( err. clone ( ) ) ,
324
323
}
325
-
326
- Err ( ( ) )
327
324
}
328
325
329
326
#[ inline]
You can’t perform that action at this time.
0 commit comments