From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.bugs Subject: bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround Date: Thu, 29 Dec 2011 06:05:53 -0800 Message-ID: <69c9ec930ef1d48655624d437aa66d0fce275d3e.1325166766.git.dancol@dancol.org> NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1325167645 6388 80.91.229.12 (29 Dec 2011 14:07:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 29 Dec 2011 14:07:25 +0000 (UTC) To: 10397@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 29 15:07:21 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RgGda-0000HR-7m for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 Dec 2011 15:07:18 +0100 Original-Received: from localhost ([::1]:42067 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgGdZ-0003zI-Mr for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 Dec 2011 09:07:17 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:57795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgGdV-0003vv-Em for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 09:07:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RgGdU-0008Pe-FF for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 09:07:13 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgGdU-0008PY-Dl for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 09:07:12 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RgGgE-0002I0-9E for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 09:10:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Colascione Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 29 Dec 2011 14:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 10397 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13251677428699 (code B ref -1); Thu, 29 Dec 2011 14:10:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Dec 2011 14:09:02 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RgGfE-0002Fw-4t for submit@debbugs.gnu.org; Thu, 29 Dec 2011 09:09:01 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RgGfB-0002Fo-Dp for submit@debbugs.gnu.org; Thu, 29 Dec 2011 09:08:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RgGcN-0008Fd-Do for submit@debbugs.gnu.org; Thu, 29 Dec 2011 09:06:07 -0500 Original-Received: from lists.gnu.org ([140.186.70.17]:56475) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgGcN-0008FZ-C9 for submit@debbugs.gnu.org; Thu, 29 Dec 2011 09:06:03 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:57554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgGcH-0003Op-SM for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 09:06:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RgGcE-0008EE-0i for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 09:05:57 -0500 Original-Received: from dancol.org ([96.126.100.184]:33789) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgGcD-0008EA-J8 for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 09:05:53 -0500 Original-Received: from dancol by dancol.org with local (Exim 4.72) (envelope-from ) id 1RgGcD-0007na-7d for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 06:05:53 -0800 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 29 Dec 2011 09:10:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:55270 Archived-At: Under remote desktop, Windows returns the wrong number of colors from GetDeviceCaps (hdc, NUMCOLORS). I hit this bug myself, and MSDN comments seem to indicate that others hit it as well. The workaround seems harmless: on non-palettized displays, calculating the number of display colors based on display bitness should produce good results. --- src/w32fns.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/src/w32fns.c b/src/w32fns.c index 822e353..4b94f16 100644 --- a/src/w32fns.c +++ b/src/w32fns.c @@ -4510,7 +4510,10 @@ If omitted or nil, that stands for the selected frame's display. */) if (dpyinfo->has_palette) cap = GetDeviceCaps (hdc, SIZEPALETTE); else - cap = GetDeviceCaps (hdc, NUMCOLORS); + // GetDeviceCaps (NUMCOLORS) is buggy under remote desktop and sometimes + // returns the number of system reserved colors (20) instead of + // the actual number of available colors. + cap = -1; /* We force 24+ bit depths to 24-bit, both to prevent an overflow and because probably is more meaningful on Windows anyway */ -- 1.7.5.1