| ... | @@ -4,6 +4,7 @@ | ... | @@ -4,6 +4,7 @@ |
| 4 | | 4 | |
| 5 | use canvas::date::DateField; | 5 | use canvas::date::DateField; |
| 6 | use std::{ | 6 | use std::{ |
| | 7 | error::Error, |
| 7 | ffi::CStr, | 8 | ffi::CStr, |
| 8 | path::PathBuf, | 9 | path::PathBuf, |
| 9 | process::Command, | 10 | process::Command, |
| ... | @@ -15,7 +16,6 @@ use std::{ | ... | @@ -15,7 +16,6 @@ use std::{ |
| 15 | }; | 16 | }; |
| 16 | use ui::{Flags, Spec, Ui, px}; | 17 | use ui::{Flags, Spec, Ui, px}; |
| 17 | use winit::{ | 18 | use winit::{ |
| 18 | error::EventLoopError, | | |
| 19 | event_loop::{EventLoop, EventLoopProxy}, | 19 | event_loop::{EventLoop, EventLoopProxy}, |
| 20 | platform::{ | 20 | platform::{ |
| 21 | wayland::{EventLoopExtWayland, WindowAttributesExtWayland}, | 21 | wayland::{EventLoopExtWayland, WindowAttributesExtWayland}, |
| ... | @@ -41,17 +41,31 @@ static QUIT: OnceLock<EventLoopProxy<crate::UserEvent>> = OnceLock::new(); | ... | @@ -41,17 +41,31 @@ static QUIT: OnceLock<EventLoopProxy<crate::UserEvent>> = OnceLock::new(); |
| 41 | /// KWin leaves windows square. | 41 | /// KWin leaves windows square. |
| 42 | static BREEZE_RADIUS: AtomicU32 = AtomicU32::new(0); | 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 | // Month and day names and date orders follow the user's locale; other categories stay C. | 45 | // Month and day names and date orders follow the user's locale; other categories stay C. |
| 46 | unsafe { libc::setlocale(libc::LC_TIME, c"".as_ptr()) }; | 46 | unsafe { libc::setlocale(libc::LC_TIME, c"".as_ptr()) }; |
| 47 | let mut builder = EventLoop::with_user_event(); | 47 | let mut builder = EventLoop::with_user_event(); |
| 48 | // winit takes Wayland wherever a compositor is named, even without libwayland-client. | 48 | // winit takes Wayland wherever a compositor is named, even without libwayland-client. |
| 49 | let named = |names: &[&str]| names.iter().any(|name| std::env::var_os(name).is_some()); | 49 | let named = |names: &[&str]| names.iter().any(|name| std::env::var_os(name).is_some()); |
| 50 | if named(&["WAYLAND_DISPLAY", "WAYLAND_SOCKET"]) | 50 | let mut x11 = !named(&["WAYLAND_DISPLAY", "WAYLAND_SOCKET"]); |
| 51 | && named(&["DISPLAY"]) | 51 | if !x11 && named(&["DISPLAY"]) && !crate::loader::loads(c"libwayland-client.so.0") { |
| 52 | && !crate::loader::loads(c"libwayland-client.so.0") | | |
| 53 | { | | |
| 54 | builder.with_x11(); | 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 | let event_loop = builder.build()?; | 70 | let event_loop = builder.build()?; |
| 57 | if !headless { | 71 | if !headless { |