diff options
| author | Po Lu | 2022-03-08 14:15:01 +0800 |
|---|---|---|
| committer | Po Lu | 2022-03-08 14:16:56 +0800 |
| commit | 39a2eb04f3f2e2b91192e3553e5366ca4d676370 (patch) | |
| tree | be93d25f9917fc13fc539753a17d21eb1124292c | |
| parent | 5f87550f533ba051fc366627a39aacab3c5629db (diff) | |
| download | emacs-39a2eb04f3f2e2b91192e3553e5366ca4d676370.tar.gz emacs-39a2eb04f3f2e2b91192e3553e5366ca4d676370.zip | |
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.
| -rw-r--r-- | src/xfns.c | 15 |
1 files 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. | |||
| 5131 | { | 5131 | { |
| 5132 | struct x_display_info *dpyinfo = check_x_display_info (terminal); | 5132 | struct x_display_info *dpyinfo = check_x_display_info (terminal); |
| 5133 | 5133 | ||
| 5134 | int nr_planes = DisplayPlanes (dpyinfo->display, | 5134 | if (dpyinfo->visual_info.class != TrueColor |
| 5135 | XScreenNumberOfScreen (dpyinfo->screen)); | 5135 | && dpyinfo->visual_info.class != DirectColor) |
| 5136 | return make_fixnum (dpyinfo->visual_info.colormap_size); | ||
| 5136 | 5137 | ||
| 5137 | /* Truncate nr_planes to 24 to avoid integer overflow. | 5138 | int nr_planes = dpyinfo->n_planes; |
| 5138 | Some displays says 32, but only 24 bits are actually significant. | 5139 | |
| 5140 | /* Truncate nr_planes to 24 to avoid integer overflow. Some | ||
| 5141 | displays says 32, but only 24 bits are actually significant. | ||
| 5139 | There are only very few and rare video cards that have more than | 5142 | There are only very few and rare video cards that have more than |
| 5140 | 24 significant bits. Also 24 bits is more than 16 million colors, | 5143 | 24 significant bits. Also 24 bits is more than 16 million |
| 5141 | it "should be enough for everyone". */ | 5144 | colors, it "should be enough for everyone". */ |
| 5142 | if (nr_planes > 24) nr_planes = 24; | 5145 | if (nr_planes > 24) nr_planes = 24; |
| 5143 | 5146 | ||
| 5144 | return make_fixnum (1 << nr_planes); | 5147 | return make_fixnum (1 << nr_planes); |