From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround Date: Tue, 07 Aug 2012 20:13:14 +0300 Message-ID: <83txwefwwl.fsf@gnu.org> References: <69c9ec930ef1d48655624d437aa66d0fce275d3e.1325166766.git.dancol@dancol.org> <4EFC9416.6090005@dancol.org> <4EFC987D.2020901@dancol.org> <4EFCF0BF.1020907@dancol.org> <4EFD2D75.3030603@dancol.org> <8339c2v3h7.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1344359651 6579 80.91.229.3 (7 Aug 2012 17:14:11 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 7 Aug 2012 17:14:11 +0000 (UTC) Cc: Juanma Barranquero , 10397@debbugs.gnu.org To: Daniel Colascione Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 07 19:14:09 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SynM8-0006ZJ-QI for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Aug 2012 19:14:09 +0200 Original-Received: from localhost ([::1]:51087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SynM8-0002NN-0S for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Aug 2012 13:14:08 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SynM4-0002MF-BD for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2012 13:14:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SynM3-0002qW-8p for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2012 13:14:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58812) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SynM3-0002qR-5B for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2012 13:14:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SynTm-0001f0-C2 for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2012 13:22:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Aug 2012 17:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10397 X-GNU-PR-Package: emacs,w32 X-GNU-PR-Keywords: patch Original-Received: via spool by 10397-submit@debbugs.gnu.org id=B10397.13443600966333 (code B ref 10397); Tue, 07 Aug 2012 17:22:02 +0000 Original-Received: (at 10397) by debbugs.gnu.org; 7 Aug 2012 17:21:36 +0000 Original-Received: from localhost ([127.0.0.1]:40114 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SynTM-0001e5-8l for submit@debbugs.gnu.org; Tue, 07 Aug 2012 13:21:36 -0400 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:62078) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SynTJ-0001dx-JW for 10397@debbugs.gnu.org; Tue, 07 Aug 2012 13:21:34 -0400 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0M8E00500A0XC200@a-mtaout21.012.net.il> for 10397@debbugs.gnu.org; Tue, 07 Aug 2012 20:13:14 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M8E005LLAI1AD40@a-mtaout21.012.net.il>; Tue, 07 Aug 2012 20:13:14 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list 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:62919 Archived-At: > Date: Tue, 07 Aug 2012 01:19:27 -0700 > From: Daniel Colascione > > 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 | 9 ++++++++- > 1 files changed, 8 insertions(+), 1 deletions(-) > > diff --git a/src/w32fns.c b/src/w32fns.c > index b82d4bc..7fc5cf5 100644 > --- a/src/w32fns.c > +++ b/src/w32fns.c > @@ -4513,8 +4513,15 @@ If omitted or nil, that stands for the selected frame's display. */) > hdc = GetDC (dpyinfo->root_window); > if (dpyinfo->has_palette) > cap = GetDeviceCaps (hdc, SIZEPALETTE); > - else > + else if (dpyinfo->n_cbits <= 8) > + /* According to the MSDN, GetDeviceCaps (NUMCOLORS) is valid only > + for devices with at most eight bits per pixel. It's supposed > + to return -1 for other displays, but because it actually > + returns other, incorrect values under some conditions (e.g., > + remote desktop), only use it when we know it's valid. */ > cap = GetDeviceCaps (hdc, NUMCOLORS); > + else > + cap = -1; > > /* We force 24+ bit depths to 24-bit, both to prevent an overflow > and because probably is more meaningful on Windows anyway */ Last time we spoke, the conclusion (at least mine ;-) was that it might be better not to call GetDeviceCaps at all, and instead reuse the code below this, which uses the number of planes and bits per plane. If you agree with that reasoning, could you please see if that change solves your problem? In any case, let's separate between this patch and the rest of "w32 GUI with Cygwin" patches, as they are really unrelated. In particular, as soon as we agree on this one, you cam go ahead and commit it regardless of the rest. Thanks.