| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | |
| 5 | 5 | use canvas::date::DateField; |
| 6 | 6 | use std::{ |
| 7 | error::Error, |
| 7 | 8 | ffi::CStr, |
| 8 | 9 | path::PathBuf, |
| 9 | 10 | process::Command, |
| ... | ... | @@ -15,7 +16,6 @@ use std::{ |
| 15 | 16 | }; |
| 16 | 17 | use ui::{Flags, Spec, Ui, px}; |
| 17 | 18 | use winit::{ |
| 18 | | error::EventLoopError, |
| 19 | 19 | event_loop::{EventLoop, EventLoopProxy}, |
| 20 | 20 | platform::{ |
| 21 | 21 | wayland::{EventLoopExtWayland, WindowAttributesExtWayland}, |
| ... | ... | @@ -41,17 +41,31 @@ static QUIT: OnceLock<EventLoopProxy<crate::UserEvent>> = OnceLock::new(); |
| 41 | 41 | /// KWin leaves windows square. |
| 42 | 42 | static BREEZE_RADIUS: AtomicU32 = AtomicU32::new(0); |
| 43 | 43 | |
| 44 | | pub fn event_loop(headless: bool) -> Result<EventLoop<crate::UserEvent>, EventLoopError> { |
| 44 | pub fn event_loop(headless: bool) -> Result<EventLoop<crate::UserEvent>, Box<dyn Error>> { |
| 45 | 45 | // Month and day names and date orders follow the user's locale; other categories stay C. |
| 46 | 46 | unsafe { libc::setlocale(libc::LC_TIME, c"".as_ptr()) }; |
| 47 | 47 | let mut builder = EventLoop::with_user_event(); |
| 48 | 48 | // winit takes Wayland wherever a compositor is named, even without libwayland-client. |
| 49 | 49 | let named = |names: &[&str]| names.iter().any(|name| std::env::var_os(name).is_some()); |
| 50 | | if named(&["WAYLAND_DISPLAY", "WAYLAND_SOCKET"]) |
| 51 | | && named(&["DISPLAY"]) |
| 52 | | && !crate::loader::loads(c"libwayland-client.so.0") |
| 53 | | { |
| 50 | let mut x11 = !named(&["WAYLAND_DISPLAY", "WAYLAND_SOCKET"]); |
| 51 | if !x11 && named(&["DISPLAY"]) && !crate::loader::loads(c"libwayland-client.so.0") { |
| 54 | 52 | builder.with_x11(); |
| 53 | x11 = true; |
| 54 | } |
| 55 | // winit panics on the keyboard without them. |
| 56 | let keyboard: &[(&CStr, &str)] = if x11 { |
| 57 | &[ |
| 58 | (c"libxkbcommon.so.0", "libxkbcommon"), |
| 59 | (c"libxkbcommon-x11.so.0", "libxkbcommon-x11"), |
| 60 | ] |
| 61 | } else { |
| 62 | &[(c"libxkbcommon.so.0", "libxkbcommon")] |
| 63 | }; |
| 64 | if let Some((_, package)) = keyboard |
| 65 | .iter() |
| 66 | .find(|(library, _)| !crate::loader::loads(library)) |
| 67 | { |
| 68 | return Err(format!("Install {package} to start Snowbound.").into()); |
| 55 | 69 | } |
| 56 | 70 | let event_loop = builder.build()?; |
| 57 | 71 | if !headless { |