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 19:18:13 -0800 Message-ID: <4EFD2D75.3030603@dancol.org> References: <69c9ec930ef1d48655624d437aa66d0fce275d3e.1325166766.git.dancol@dancol.org> <4EFC9416.6090005@dancol.org> <4EFC987D.2020901@dancol.org> <4EFCF0BF.1020907@dancol.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigA8334856D1EF176FF2F8474A" X-Trace: dough.gmane.org 1325215159 8699 80.91.229.12 (30 Dec 2011 03:19:19 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 30 Dec 2011 03:19:19 +0000 (UTC) Cc: 10397@debbugs.gnu.org To: Juanma Barranquero Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 30 04:19:14 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 1RgSzx-00007P-T6 for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Dec 2011 04:19:14 +0100 Original-Received: from localhost ([::1]:43389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgSzx-0001Md-Fa for geb-bug-gnu-emacs@m.gmane.org; Thu, 29 Dec 2011 22:19:13 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:40080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgSzt-0001MH-Sv for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 22:19:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RgSzt-0005Ut-0z for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 22:19:09 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RgSzs-0005Uo-UN for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 22:19:08 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RgT2f-0004cB-LW for bug-gnu-emacs@gnu.org; Thu, 29 Dec 2011 22:22:01 -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: Fri, 30 Dec 2011 03:22:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10397 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 10397-submit@debbugs.gnu.org id=B10397.132521528117683 (code B ref 10397); Fri, 30 Dec 2011 03:22:01 +0000 Original-Received: (at 10397) by debbugs.gnu.org; 30 Dec 2011 03:21:21 +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 1RgT21-0004bA-6I for submit@debbugs.gnu.org; Thu, 29 Dec 2011 22:21:21 -0500 Original-Received: from dancol.org ([96.126.100.184]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RgT1y-0004b0-Qs for 10397@debbugs.gnu.org; Thu, 29 Dec 2011 22:21:19 -0500 Original-Received: from c-24-18-179-193.hsd1.wa.comcast.net ([24.18.179.193] helo=edith.local) by dancol.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1RgSzA-0000Cz-5f; Thu, 29 Dec 2011 19:18:24 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 In-Reply-To: X-Enigmail-Version: 1.3.4 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 29 Dec 2011 22:22:01 -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:55295 Archived-At: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigA8334856D1EF176FF2F8474A Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12/29/11 7:07 PM, Juanma Barranquero wrote: > On Thu, Dec 29, 2011 at 23:59, Daniel Colascione wr= ote: >=20 >> What about this: we'll distrust any NUMCOLORS response less than 256. >> You'll never use direct color with a bit depth that small, so any answ= er >> in that range must be bogus. >=20 > Hmm. Shouldn't in fact GetDeviceCaps (hdc, NUMCOLORS) always be <=3D 25= 6? >=20 > According to http://msdn.microsoft.com/en-us/library/dd144877(v=3Dvs.85= ).aspx >=20 > NUMCOLORS > Number of entries in the device's color table, if the device has a > color depth of no more than 8 bits per pixel. For devices with greater > color depths, 1 is returned. >=20 > (It says "1", but it's a typo for "-1".) Good catch. What about this (untested) code? hdc =3D GetDC (dpyinfo->root_window); if (dpyinfo->has_palette) cap =3D GetDeviceCaps (hdc, SIZEPALETTE); 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; --------------enigA8334856D1EF176FF2F8474A 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 iEYEARECAAYFAk79LXcACgkQ17c2LVA10VvKxQCfZDp9vKb01FeYhP1bKSQ7wdQc +N4AnRuoGZgqwr6OeuYM+xhdXWdWexIq =7Jjc -----END PGP SIGNATURE----- --------------enigA8334856D1EF176FF2F8474A--