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: Tue, 07 Aug 2012 10:33:23 -0700 Message-ID: <50215163.1000206@dancol.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> <83txwefwwl.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig93354792DF11C1866B077EE3" X-Trace: dough.gmane.org 1344360857 17070 80.91.229.3 (7 Aug 2012 17:34:17 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 7 Aug 2012 17:34:17 +0000 (UTC) Cc: Juanma Barranquero , 10397@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Aug 07 19:34:17 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 1SynfZ-0007RT-7r for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Aug 2012 19:34:13 +0200 Original-Received: from localhost ([::1]:60554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SynfY-0000YU-HE for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Aug 2012 13:34:12 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:52578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SynfR-0000Xz-Sa for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2012 13:34:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SynfP-0001rO-5d for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2012 13:34:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SynfP-0001rJ-26 for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2012 13:34:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1Synn8-00027w-9r for bug-gnu-emacs@gnu.org; Tue, 07 Aug 2012 13:42:02 -0400 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: Tue, 07 Aug 2012 17:42: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.13443612908134 (code B ref 10397); Tue, 07 Aug 2012 17:42:02 +0000 Original-Received: (at 10397) by debbugs.gnu.org; 7 Aug 2012 17:41:30 +0000 Original-Received: from localhost ([127.0.0.1]:40142 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Synmb-000277-Iw for submit@debbugs.gnu.org; Tue, 07 Aug 2012 13:41:29 -0400 Original-Received: from dancol.org ([96.126.100.184]:39499) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SynmZ-00026z-1Y for 10397@debbugs.gnu.org; Tue, 07 Aug 2012 13:41:28 -0400 Original-Received: from c-76-22-66-162.hsd1.wa.comcast.net ([76.22.66.162] helo=[192.168.1.2]) by dancol.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1Synen-0007cq-8H; Tue, 07 Aug 2012 10:33:25 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: <83txwefwwl.fsf@gnu.org> X-Enigmail-Version: 1.4.3 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:62920 Archived-At: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig93354792DF11C1866B077EE3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 8/7/12 10:13 AM, Eli Zaretskii wrote: >> 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 =3D GetDC (dpyinfo->root_window); >> if (dpyinfo->has_palette) >> cap =3D GetDeviceCaps (hdc, SIZEPALETTE); >> - else >> + else if (dpyinfo->n_cbits <=3D 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 =3D GetDeviceCaps (hdc, NUMCOLORS); >> + else >> + cap =3D -1; >> =20 >> /* We force 24+ bit depths to 24-bit, both to prevent an overflow >> and because probably is more meaningful on Windows anyway */ >=20 > 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? Sorry about that --- I'm bringing a lot of this up form very cold mental storage. It's been a little while since I've had a chance to do any Emacs hacking. I'm perfectly happy using the planes-and-bits code instead of calling GetDeviceCaps. I'll remove this patch from the cygw32 changeset and check the (now, much simpler) fix for the colors issue into the trunk, if that's all right. --------------enig93354792DF11C1866B077EE3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (Darwin) Comment: GPGTools - http://gpgtools.org iEYEARECAAYFAlAhUWMACgkQ17c2LVA10VtdwgCgo25ck6VoPpm+ZRQNo2t8q55n PAQAoLcPEvLzRVErDHvJ3xomOzSdbh1+ =bY37 -----END PGP SIGNATURE----- --------------enig93354792DF11C1866B077EE3--