From 39a2eb04f3f2e2b91192e3553e5366ca4d676370 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 8 Mar 2022 14:15:01 +0800 Subject: [PATCH] Return actual color cell count in x-display-color-cells * src/xfns.c (Fx_display_color_cells): Return the actual amount of color cells, or the amount of individual combinations of components. --- src/xfns.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/xfns.c b/src/xfns.c index 3d1fa926096..9a445b26820 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5131,14 +5131,17 @@ If omitted or nil, that stands for the selected frame's display. { struct x_display_info *dpyinfo = check_x_display_info (terminal); - int nr_planes = DisplayPlanes (dpyinfo->display, - XScreenNumberOfScreen (dpyinfo->screen)); + if (dpyinfo->visual_info.class != TrueColor + && dpyinfo->visual_info.class != DirectColor) + return make_fixnum (dpyinfo->visual_info.colormap_size); - /* Truncate nr_planes to 24 to avoid integer overflow. - Some displays says 32, but only 24 bits are actually significant. + int nr_planes = dpyinfo->n_planes; + + /* Truncate nr_planes to 24 to avoid integer overflow. Some + displays says 32, but only 24 bits are actually significant. There are only very few and rare video cards that have more than - 24 significant bits. Also 24 bits is more than 16 million colors, - it "should be enough for everyone". */ + 24 significant bits. Also 24 bits is more than 16 million + colors, it "should be enough for everyone". */ if (nr_planes > 24) nr_planes = 24; return make_fixnum (1 << nr_planes); -- 2.39.2