unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Daniel Colascione <dancol@dancol.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Juanma Barranquero <lekktu@gmail.com>, 10397@debbugs.gnu.org
Subject: bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround
Date: Tue, 07 Aug 2012 10:33:23 -0700	[thread overview]
Message-ID: <50215163.1000206@dancol.org> (raw)
In-Reply-To: <83txwefwwl.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2307 bytes --]

On 8/7/12 10:13 AM, Eli Zaretskii wrote:
>> Date: Tue, 07 Aug 2012 01:19:27 -0700
>> From: Daniel Colascione <dancol@dancol.org>
>>
>> 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?

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.



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 235 bytes --]

  reply	other threads:[~2012-08-07 17:33 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-29 14:05 bug#10397: [PATCH] Under Remote Desktop, NUMCOLORS is unreliable; workaround Daniel Colascione
2011-12-29 16:13 ` Juanma Barranquero
2011-12-29 16:23   ` Daniel Colascione
2011-12-29 16:27     ` Juanma Barranquero
2011-12-29 16:42       ` Daniel Colascione
2011-12-29 16:45         ` Juanma Barranquero
2011-12-29 22:59           ` Daniel Colascione
2011-12-29 23:10             ` Juanma Barranquero
2011-12-29 23:13               ` Daniel Colascione
2011-12-29 23:18                 ` Juanma Barranquero
2011-12-30  3:07             ` Juanma Barranquero
2011-12-30  3:18               ` Daniel Colascione
2011-12-30  8:51                 ` Eli Zaretskii
2011-12-30  9:00                 ` Eli Zaretskii
2011-12-30 12:24                   ` Juanma Barranquero
2012-08-07 17:13                     ` Eli Zaretskii
2012-08-07 17:33                       ` Daniel Colascione [this message]
2012-08-07 18:07                         ` Eli Zaretskii
2016-02-25  6:25                         ` Lars Ingebrigtsen
2016-12-13  0:04                           ` Glenn Morris
2011-12-30  1:04 ` Jason Rumney
2011-12-30  1:10   ` Daniel Colascione

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50215163.1000206@dancol.org \
    --to=dancol@dancol.org \
    --cc=10397@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=lekktu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).