all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* list-colors-display shows only one color
@ 2002-02-11 18:12 Juanma Barranquero
  2002-02-11 19:48 ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Juanma Barranquero @ 2002-02-11 18:12 UTC (permalink / raw)


As a result of 

2002-01-25  Eli Zaretskii  <eliz@is.elta.co.il>

        * facemenu.el (list-colors-display): If the argument is nil, don't
        show more colors that the number returned by display-color-cells.

and

2001-01-02  Andrew Innes  <andrewi@gnu.org>

        * w32fns.c (Fx_display_color_cells): Determine correct value, when
        system doesn't tell us directly.

M-x list-colors-display shows only one color ("snow") in my system, a
Windows XP in 32-bit color mode. Previously it showed the full list.

(x-display-color-cells) returns 1, BTW.



                                                           /L/e/k/t/u


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-11 18:12 list-colors-display shows only one color Juanma Barranquero
@ 2002-02-11 19:48 ` Eli Zaretskii
  2002-02-11 20:44   ` Andreas Schwab
  2002-02-12  9:00   ` Juanma Barranquero
  0 siblings, 2 replies; 15+ messages in thread
From: Eli Zaretskii @ 2002-02-11 19:48 UTC (permalink / raw)
  Cc: emacs-devel

> From: Juanma Barranquero <lektu@terra.es>
> Date: Mon, 11 Feb 2002 19:12:33 +0100
> 
> M-x list-colors-display shows only one color ("snow") in my system, a
> Windows XP in 32-bit color mode. Previously it showed the full list.
> 
> (x-display-color-cells) returns 1, BTW.

That's the bug, right there: x-display-color-cells should report the
true number of colors supported by the display.  If it reports 1, many
features in color support will start to break down, list-colors-display
being the least of them.

The change I made simply makes a point of not displaying more colors
than the terminal supports.  That is The Right Thing, IMHO, since
otherwise someone could set internal variables and lists of colors to
preposterous values, and get strange results in list-colors-display.
It is also needed for extended color support on tty's, where the
number of colors in tty-color-alist can be much larger than the
actual number of distinct colors a tty can display.

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-11 19:48 ` Eli Zaretskii
@ 2002-02-11 20:44   ` Andreas Schwab
  2002-02-12  5:41     ` Eli Zaretskii
  2002-02-13 15:37     ` Richard Stallman
  2002-02-12  9:00   ` Juanma Barranquero
  1 sibling, 2 replies; 15+ messages in thread
From: Andreas Schwab @ 2002-02-11 20:44 UTC (permalink / raw)
  Cc: lektu, emacs-devel

"Eli Zaretskii" <eliz@is.elta.co.il> writes:

|> > From: Juanma Barranquero <lektu@terra.es>
|> > Date: Mon, 11 Feb 2002 19:12:33 +0100
|> > 
|> > M-x list-colors-display shows only one color ("snow") in my system, a
|> > Windows XP in 32-bit color mode. Previously it showed the full list.
|> > 
|> > (x-display-color-cells) returns 1, BTW.
|> 
|> That's the bug, right there: x-display-color-cells should report the
|> true number of colors supported by the display.  If it reports 1, many
|> features in color support will start to break down, list-colors-display
|> being the least of them.

Hmm, (x-display-color-cells) returns 256 for me, although I'm working on
a TrueColor 24-bit display.  man DisplayCells says:

       The DisplayCells macro returns the number of entries in
       the default colormap.

xcolors can display all colors from rgb.txt simultanously, as it seems.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-11 20:44   ` Andreas Schwab
@ 2002-02-12  5:41     ` Eli Zaretskii
  2002-02-12 11:01       ` Andreas Schwab
  2002-02-13 15:37     ` Richard Stallman
  1 sibling, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2002-02-12  5:41 UTC (permalink / raw)
  Cc: lektu, emacs-devel


On Mon, 11 Feb 2002, Andreas Schwab wrote:

> |> That's the bug, right there: x-display-color-cells should report the
> |> true number of colors supported by the display.  If it reports 1, many
> |> features in color support will start to break down, list-colors-display
> |> being the least of them.
> 
> Hmm, (x-display-color-cells) returns 256 for me, although I'm working on
> a TrueColor 24-bit display.  man DisplayCells says:
> 
>        The DisplayCells macro returns the number of entries in
>        the default colormap.

I'm not sure I understand what are you saying.  Are you saying that 256 
is an incorrect value?  On X, x-display-color-cells returns what 
DisplayCells returns, so Emacs isn't ``guilty'' ;-)

> xcolors can display all colors from rgb.txt simultanously, as it seems.

The number of colors you have on a 24-bit display is much larger than 
what rgb.txt shows, but the number of colors that are available in the 
colormap is typically smaller, so 256 doesn't sound very wrong to me.

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-11 19:48 ` Eli Zaretskii
  2002-02-11 20:44   ` Andreas Schwab
@ 2002-02-12  9:00   ` Juanma Barranquero
  2002-02-12 12:18     ` Juanma Barranquero
  1 sibling, 1 reply; 15+ messages in thread
From: Juanma Barranquero @ 2002-02-12  9:00 UTC (permalink / raw)


On Mon, 11 Feb 2002 21:48:25 +0200, "Eli Zaretskii" <eliz@is.elta.co.il> wrote:

> That's the bug, right there: x-display-color-cells should report the
> true number of colors supported by the display.

Yes, I supposed as much. I imagine x-display-color-cells should return
256 (or 240 or something like that) on my display. I'll try to debug
what's happening, because I bet it isn't very reproducible on other
people's machines.



                                                           /L/e/k/t/u


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-12  5:41     ` Eli Zaretskii
@ 2002-02-12 11:01       ` Andreas Schwab
  2002-02-12 11:05         ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Andreas Schwab @ 2002-02-12 11:01 UTC (permalink / raw)
  Cc: lektu, emacs-devel

Eli Zaretskii <eliz@is.elta.co.il> writes:

|> On Mon, 11 Feb 2002, Andreas Schwab wrote:
|> 
|> > |> That's the bug, right there: x-display-color-cells should report the
|> > |> true number of colors supported by the display.  If it reports 1, many
|> > |> features in color support will start to break down, list-colors-display
|> > |> being the least of them.
|> > 
|> > Hmm, (x-display-color-cells) returns 256 for me, although I'm working on
|> > a TrueColor 24-bit display.  man DisplayCells says:
|> > 
|> >        The DisplayCells macro returns the number of entries in
|> >        the default colormap.
|> 
|> I'm not sure I understand what are you saying.  Are you saying that 256 
|> is an incorrect value?  On X, x-display-color-cells returns what 
|> DisplayCells returns, so Emacs isn't ``guilty'' ;-)

What I want to say is that DisplayCells might not be the right function
in this context.  But then, I don't know what "default colormap" is
supposed to mean.

|> > xcolors can display all colors from rgb.txt simultanously, as it seems.
|> 
|> The number of colors you have on a 24-bit display is much larger than 
|> what rgb.txt shows, but the number of colors that are available in the 
|> colormap is typically smaller, so 256 doesn't sound very wrong to me.

Why shouldn't Emacs be able to display all colors as well?

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-12 11:01       ` Andreas Schwab
@ 2002-02-12 11:05         ` Eli Zaretskii
  0 siblings, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2002-02-12 11:05 UTC (permalink / raw)
  Cc: lektu, emacs-devel


On Tue, 12 Feb 2002, Andreas Schwab wrote:

> |> I'm not sure I understand what are you saying.  Are you saying that 256 
> |> is an incorrect value?  On X, x-display-color-cells returns what 
> |> DisplayCells returns, so Emacs isn't ``guilty'' ;-)
> 
> What I want to say is that DisplayCells might not be the right function
> in this context.  But then, I don't know what "default colormap" is
> supposed to mean.

I'm not a great expert on X, but AFAIK a colormap is where X looks up 
the color given its RGB values.  The default colormap is a colormap used 
for an X application unless it sets up its own colormap.

If my interpretation is correct, you cannot have more distinct colors 
than the number of cells in a colormap.

> |> The number of colors you have on a 24-bit display is much larger than 
> |> what rgb.txt shows, but the number of colors that are available in the 
> |> colormap is typically smaller, so 256 doesn't sound very wrong to me.
> 
> Why shouldn't Emacs be able to display all colors as well?

Because some of them will be identical.

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-12  9:00   ` Juanma Barranquero
@ 2002-02-12 12:18     ` Juanma Barranquero
  2002-02-13 13:31       ` Andreas Schwab
  2002-02-13 15:39       ` Richard Stallman
  0 siblings, 2 replies; 15+ messages in thread
From: Juanma Barranquero @ 2002-02-12 12:18 UTC (permalink / raw)



> I'll try to debug what's happening

On x-display-color-cells:

>   if (cap < 0)
>      cap = 1 << (dpyinfo->n_planes * dpyinfo->n_cbits);
  

At this moment dpyinfo->n_planes == 1 and dpyinfo->n_cbits == 32.

(Aside: Interestingly,

  cap = 1 << 32;

is statically determined by MSVC to be 0, but

  x = 32;
  cap = 1 << x;

is 1.)

Anway, 1 << 32 is an error because it's obviously going to overflow cap.

Something like

  if (cap < 0)
    {
      int depth = dpyinfo->n_planes * dpyinfo->n_cbits;
      if (depth > SOME_VALUE) {
        cap = 1 << SOME_VALUE;
      else
        cap = 1 << depth;
    }
  
is posible, but:

1.- Is not pretty.

2.- There's no obvious SOME_VALUE; probably it would vary between 16-bit
and 32-bit Windows, the graphics card and driver, etc.

3.- Something's wrong here, I think. Even before Eli's change on
list-colors-display, that function listed more colors that my driver was
able to display simultaneously (because some of them appeared as equal).
OTOH, the driver is saying that it is not palette-based... :(

As expected, setting my Windows in 24-bit color mode works fine.

                                                           /L/e/k/t/u


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-12 12:18     ` Juanma Barranquero
@ 2002-02-13 13:31       ` Andreas Schwab
  2002-02-13 14:13         ` Juanma Barranquero
  2002-02-13 15:39       ` Richard Stallman
  1 sibling, 1 reply; 15+ messages in thread
From: Andreas Schwab @ 2002-02-13 13:31 UTC (permalink / raw)
  Cc: emacs-devel

Juanma Barranquero <lektu@terra.es> writes:

|> Anway, 1 << 32 is an error because it's obviously going to overflow cap.

The C standard makes this undefined:

    6.5.7 Bitwise shift operators

    [#3] The integer promotions are performed on each of the operands. The
    type of the result is that of the promoted left operand. If the value
    of the right operand is negative or is greater than or equal to the
    width of the promoted left operand, the behavior is undefined.

Even (1 << 31) is undefined, since that is not representable in a 32-bit
signed int.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-13 13:31       ` Andreas Schwab
@ 2002-02-13 14:13         ` Juanma Barranquero
  2002-02-13 14:39           ` Andreas Schwab
  0 siblings, 1 reply; 15+ messages in thread
From: Juanma Barranquero @ 2002-02-13 14:13 UTC (permalink / raw)



On Wed, 13 Feb 2002 14:31:34 +0100, Andreas Schwab <schwab@suse.de> wrote:

> The C standard makes this undefined:
<snip>
> Even (1 << 31) is undefined, since that is not representable in a 32-bit
> signed int.

You're right, it is not a C error, but still it is an error in the Emacs
sources, as it is not going to give a sensible answer :)


                                                           /L/e/k/t/u


_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-13 14:13         ` Juanma Barranquero
@ 2002-02-13 14:39           ` Andreas Schwab
  0 siblings, 0 replies; 15+ messages in thread
From: Andreas Schwab @ 2002-02-13 14:39 UTC (permalink / raw)
  Cc: emacs-devel

Juanma Barranquero <lektu@terra.es> writes:

|> On Wed, 13 Feb 2002 14:31:34 +0100, Andreas Schwab <schwab@suse.de> wrote:
|> 
|> > The C standard makes this undefined:
|> <snip>
|> > Even (1 << 31) is undefined, since that is not representable in a 32-bit
|> > signed int.
|> 
|> You're right, it is not a C error, but still it is an error in the Emacs
|> sources, as it is not going to give a sensible answer :)

Being undefined it is an error to write that in any way.  I actually
agreed with you.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-11 20:44   ` Andreas Schwab
  2002-02-12  5:41     ` Eli Zaretskii
@ 2002-02-13 15:37     ` Richard Stallman
  2002-02-13 16:25       ` Andreas Schwab
  1 sibling, 1 reply; 15+ messages in thread
From: Richard Stallman @ 2002-02-13 15:37 UTC (permalink / raw)
  Cc: eliz, lektu, emacs-devel

    Hmm, (x-display-color-cells) returns 256 for me, although I'm working on
    a TrueColor 24-bit display.  man DisplayCells says:

	   The DisplayCells macro returns the number of entries in
	   the default colormap.


Is this a bug in x-display-color-cells, or a bug in DisplayCells,
or a bug in the doc of x-display-color-cells?

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-12 12:18     ` Juanma Barranquero
  2002-02-13 13:31       ` Andreas Schwab
@ 2002-02-13 15:39       ` Richard Stallman
  2002-02-13 17:07         ` Juanma Barranquero
  1 sibling, 1 reply; 15+ messages in thread
From: Richard Stallman @ 2002-02-13 15:39 UTC (permalink / raw)
  Cc: emacs-devel

    On x-display-color-cells:

    >   if (cap < 0)
    >      cap = 1 << (dpyinfo->n_planes * dpyinfo->n_cbits);


    At this moment dpyinfo->n_planes == 1 and dpyinfo->n_cbits == 32.

It is an error to use the C shift operator with those arguments.
So this code clearly is one bug, and needs to be fixed.
Maybe that fix will solve the problem you are encountering.

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-13 15:37     ` Richard Stallman
@ 2002-02-13 16:25       ` Andreas Schwab
  0 siblings, 0 replies; 15+ messages in thread
From: Andreas Schwab @ 2002-02-13 16:25 UTC (permalink / raw)
  Cc: eliz, lektu, emacs-devel

Richard Stallman <rms@gnu.org> writes:

|>     Hmm, (x-display-color-cells) returns 256 for me, although I'm working on
|>     a TrueColor 24-bit display.  man DisplayCells says:
|> 
|> 	   The DisplayCells macro returns the number of entries in
|> 	   the default colormap.
|> 
|> 
|> Is this a bug in x-display-color-cells, or a bug in DisplayCells,
|> or a bug in the doc of x-display-color-cells?

I'm not really sure.  As it seems, I do not really understand how a
TrueColor visual acually manages the colors.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: list-colors-display shows only one color
  2002-02-13 15:39       ` Richard Stallman
@ 2002-02-13 17:07         ` Juanma Barranquero
  0 siblings, 0 replies; 15+ messages in thread
From: Juanma Barranquero @ 2002-02-13 17:07 UTC (permalink / raw)



On Wed, 13 Feb 2002 08:39:00 -0700 (MST), Richard Stallman <rms@gnu.org> wrote:

> It is an error to use the C shift operator with those arguments.
> So this code clearly is one bug, and needs to be fixed.
> Maybe that fix will solve the problem you are encountering.

cap is make_number'd, so this is a posible fix.


                                                           /L/e/k/t/u



2002-02-13  Juanma Barranquero  <lektu@terra.es>

	* w32fns.c (Fx_display_color_cells): Don't allow number of color
	cells to overflow EMACS_INT size.


Index: w32fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32fns.c,v
retrieving revision 1.154
diff -u -c -r1.154 w32fns.c
*** w32fns.c	9 Feb 2002 01:31:07 -0000	1.154
--- w32fns.c	13 Feb 2002 17:01:13 -0000
***************
*** 7654,7660 ****
      cap = GetDeviceCaps (hdc,NUMCOLORS);
  
    if (cap < 0)
!     cap = 1 << (dpyinfo->n_planes * dpyinfo->n_cbits);
    
    ReleaseDC (dpyinfo->root_window, hdc);
    
--- 7654,7660 ----
      cap = GetDeviceCaps (hdc,NUMCOLORS);
  
    if (cap < 0)
!     cap = 1 << min(dpyinfo->n_planes * dpyinfo->n_cbits, VALBITS - 2);
    
    ReleaseDC (dpyinfo->root_window, hdc);
    



_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/emacs-devel


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2002-02-13 17:07 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-02-11 18:12 list-colors-display shows only one color Juanma Barranquero
2002-02-11 19:48 ` Eli Zaretskii
2002-02-11 20:44   ` Andreas Schwab
2002-02-12  5:41     ` Eli Zaretskii
2002-02-12 11:01       ` Andreas Schwab
2002-02-12 11:05         ` Eli Zaretskii
2002-02-13 15:37     ` Richard Stallman
2002-02-13 16:25       ` Andreas Schwab
2002-02-12  9:00   ` Juanma Barranquero
2002-02-12 12:18     ` Juanma Barranquero
2002-02-13 13:31       ` Andreas Schwab
2002-02-13 14:13         ` Juanma Barranquero
2002-02-13 14:39           ` Andreas Schwab
2002-02-13 15:39       ` Richard Stallman
2002-02-13 17:07         ` Juanma Barranquero

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.