Skip to content

Commit 330804d

Browse files
committed
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 <[email protected]>
1 parent 532e172 commit 330804d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/backends/x11.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -882,13 +882,15 @@ fn is_shm_available(c: &impl Connection) -> bool {
882882
/// Collect all visuals that use softbuffer's pixel format
883883
fn supported_visuals(c: &impl Connection) -> HashSet<Visualid> {
884884
// Check that depth 24 uses 32 bits per pixels
885+
// HACK(notgull): Also support depth 32 for transparent visuals.
886+
// Otherwise winit users get weird errors.
885887
if !c
886888
.setup()
887889
.pixmap_formats
888890
.iter()
889-
.any(|f| f.depth == 24 && f.bits_per_pixel == 32)
891+
.any(|f| (f.depth == 24 || f.depth == 32) && f.bits_per_pixel == 32)
890892
{
891-
log::warn!("X11 server does not have a depth 24 format with 32 bits per pixel");
893+
log::warn!("X11 server does not have a depth 24/32 format with 32 bits per pixel");
892894
return HashSet::new();
893895
}
894896

@@ -911,7 +913,7 @@ fn supported_visuals(c: &impl Connection) -> HashSet<Visualid> {
911913
screen
912914
.allowed_depths
913915
.iter()
914-
.filter(|depth| depth.depth == 24)
916+
.filter(|depth| depth.depth == 24 || depth.depth == 32)
915917
.flat_map(|depth| {
916918
depth
917919
.visuals

0 commit comments

Comments
 (0)