From 821812e2477f45ac5f2572dd7d469b8408e351aa Mon Sep 17 00:00:00 2001 From: Daniel Colascione Date: Mon, 8 Oct 2012 10:44:42 -0800 Subject: [PATCH] * w32fns.c (Fx_display_color_cells): Instead of using NCOLORS, which is broke under remote desktop, calculating the number of colors available for a display based on the display's number of planes and number of bits per pixel per plane. (bug#10397). --- src/ChangeLog | 7 +++++++ src/w32fns.c | 18 +++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 122e0d19655..1d90b7bb9e1 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2012-10-08 Daniel Colascione + + * w32fns.c (Fx_display_color_cells): Instead of using NCOLORS, + which is broke under remote desktop, calculating the number of + colors available for a display based on the display's number of + planes and number of bits per pixel per plane. (bug#10397). + 2012-10-08 Juanma Barranquero * makefile.w32-in (LOCAL_FLAGS): Don't define HAVE_NTGUI, it's now diff --git a/src/w32fns.c b/src/w32fns.c index e728d19a9b3..ff8e5fef439 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -4642,22 +4642,14 @@ If omitted or nil, that stands for the selected frame's display. */) (Lisp_Object display) { struct w32_display_info *dpyinfo = check_x_display_info (display); - HDC hdc; int cap; - hdc = GetDC (dpyinfo->root_window); - if (dpyinfo->has_palette) - cap = GetDeviceCaps (hdc, SIZEPALETTE); - else - cap = GetDeviceCaps (hdc, NUMCOLORS); - - /* We force 24+ bit depths to 24-bit, both to prevent an overflow - and because probably is more meaningful on Windows anyway */ - if (cap < 0) - cap = 1 << min (dpyinfo->n_planes * dpyinfo->n_cbits, 24); - - ReleaseDC (dpyinfo->root_window, hdc); + /* Don't use NCOLORS: it returns incorrect results under remote + * desktop. We force 24+ bit depths to 24-bit, both to prevent an + * overflow and because probably is more meaningful on Windows + * anyway. */ + cap = 1 << min (dpyinfo->n_planes * dpyinfo->n_cbits, 24); return make_number (cap); } -- 2.39.2