From 330804de4c853fa59bfce8bef0f9d69d305fc0f2 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sat, 22 Jun 2024 09:23:54 -0700 Subject: [PATCH] x11: Support visuals with depth 32 This can lead to weird results in some cases, but it's better than crashing. Once we have a better format API we can work around this. ref rust-windowing/winit#3646 Signed-off-by: John Nunley --- src/backends/x11.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/backends/x11.rs b/src/backends/x11.rs index d3b6080..b01fb5f 100644 --- a/src/backends/x11.rs +++ b/src/backends/x11.rs @@ -882,13 +882,15 @@ fn is_shm_available(c: &impl Connection) -> bool { /// Collect all visuals that use softbuffer's pixel format fn supported_visuals(c: &impl Connection) -> HashSet { // Check that depth 24 uses 32 bits per pixels + // HACK(notgull): Also support depth 32 for transparent visuals. + // Otherwise winit users get weird errors. if !c .setup() .pixmap_formats .iter() - .any(|f| f.depth == 24 && f.bits_per_pixel == 32) + .any(|f| (f.depth == 24 || f.depth == 32) && f.bits_per_pixel == 32) { - log::warn!("X11 server does not have a depth 24 format with 32 bits per pixel"); + log::warn!("X11 server does not have a depth 24/32 format with 32 bits per pixel"); return HashSet::new(); } @@ -911,7 +913,7 @@ fn supported_visuals(c: &impl Connection) -> HashSet { screen .allowed_depths .iter() - .filter(|depth| depth.depth == 24) + .filter(|depth| depth.depth == 24 || depth.depth == 32) .flat_map(|depth| { depth .visuals