changeset 54218:6f75b2135827

* xfns.c (Fx_display_color_cells): Use number of planes to calculate how many colors can be displayed.
author Jan Djärv <jan.h.d@swipnet.se>
date Mon, 01 Mar 2004 12:51:33 +0000
parents 0cbe097fca37
children e7d4fe5d5a35
files src/ChangeLog src/xfns.c
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Mon Mar 01 07:09:38 2004 +0000
+++ b/src/ChangeLog	Mon Mar 01 12:51:33 2004 +0000
@@ -1,3 +1,8 @@
+2004-03-01  Jan Dj,Ad(Brv  <jan.h.d@swipnet.se>
+
+	* xfns.c (Fx_display_color_cells): Use number of planes to calculate
+	how many colors can be displayed.
+
 2004-03-01  Kenichi Handa  <handa@m17n.org>
 
 	* editfns.c (Ftranslate_region): Handle multibyte chars in TABLE
--- a/src/xfns.c	Mon Mar 01 07:09:38 2004 +0000
+++ b/src/xfns.c	Mon Mar 01 12:51:33 2004 +0000
@@ -3758,8 +3758,17 @@
 {
   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,