From 334faa08fc2b292e3ef5d2237a71834561b20c5a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Dj=C3=A4rv?= Date: Mon, 1 Mar 2004 12:51:33 +0000 Subject: [PATCH] * xfns.c (Fx_display_color_cells): Use number of planes to calculate how many colors can be displayed. --- src/ChangeLog | 5 +++++ src/xfns.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 742e2c3dabc..bd641e8f6fb 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2004-03-01 Jan Dj,Ad(Brv + + * xfns.c (Fx_display_color_cells): Use number of planes to calculate + how many colors can be displayed. + 2004-03-01 Kenichi Handa * editfns.c (Ftranslate_region): Handle multibyte chars in TABLE diff --git a/src/xfns.c b/src/xfns.c index a3e885bac74..3028a61018c 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -3758,8 +3758,17 @@ If omitted or nil, that stands for the selected frame's display. */) { struct x_display_info *dpyinfo = check_x_display_info (display); - return make_number (DisplayCells (dpyinfo->display, - XScreenNumberOfScreen (dpyinfo->screen))); + int nr_planes = DisplayPlanes (dpyinfo->display, + XScreenNumberOfScreen (dpyinfo->screen)); + + /* 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". */ + if (nr_planes > 24) nr_planes = 24; + + return make_number (1 << nr_planes); } DEFUN ("x-server-max-request-size", Fx_server_max_request_size, -- 2.39.2