From 7fb43ac250c5b68a61de6aad5704aed6bf0ce983 Mon Sep 17 00:00:00 2001 From: Daemonratte Date: Thu, 15 Oct 2026 11:30:51 +0200 Subject: [PATCH] gdkrgb: choose visuals by their color bits, 30-bit ones included --- gdk/gdkrgb.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/gdk/gdkrgb.c b/gdk/gdkrgb.c index a7146bdbb..86413ef21 100644 --- a/gdk/gdkrgb.c +++ b/gdk/gdkrgb.c @@ -390,17 +390,25 @@ gdk_rgb_score_visual (GdkVisual *visual) if (visual->type == GDK_VISUAL_TRUE_COLOR || visual->type == GDK_VISUAL_DIRECT_COLOR) { - if (visual->depth == 24) - { - quality = 9; - /* Should test for MSB visual here, and set speed if so. */ - } - else if (visual->depth == 16) + /* Visuals with alpha (depth 32 with 24 color bits) are skipped */ + gint bits = visual->red_prec + visual->green_prec + visual->blue_prec; + + if (bits != visual->depth) + quality = 0; + else if (bits > 24) + quality = 10; + else if (bits == 24) + quality = 9; + else if (bits == 16) quality = 8; - else if (visual->depth == 15) + else if (bits == 15) quality = 7; - else if (visual->depth == 8) + else if (bits > 8) + quality = 5; + else if (bits == 8) quality = 4; + else if (bits >= 3) + quality = 2; } else if (visual->type == GDK_VISUAL_PSEUDO_COLOR || visual->type == GDK_VISUAL_STATIC_COLOR)